OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
texture-handle.cpp File Reference
Include dependency graph for texture-handle.cpp:

Go to the source code of this file.

Macros

#define TEXTURE_MAP_TO_HANDLE(texture_map)   (reinterpret_cast<C4TextureMapHandle*>(texture_map))
 
#define HANDLE_TO_TEXTURE_MAP(handle)   (reinterpret_cast<C4TextureMap*>(handle))
 
#define GROUP_TO_HANDLE(group)   (reinterpret_cast<C4GroupHandle*>(group))
 
#define HANDLE_TO_GROUP(handle)   (reinterpret_cast<C4Group*>(handle))
 

Functions

C4TextureMapHandlec4_texture_map_handle_new (void)
 
void c4_texture_map_handle_free (C4TextureMapHandle *texture_map)
 
guint c4_texture_map_handle_load_map (C4TextureMapHandle *texture_map, C4GroupHandle *group, const char *entry_name, gboolean *overload_materials, gboolean *overload_textures)
 
gboolean c4_texture_map_handle_add_texture (C4TextureMapHandle *texture_map, const char *texture, guint32 avg_color)
 
const char * c4_texture_map_handle_get_texture (C4TextureMapHandle *texture_map, guint index)
 
guint32 c4_texture_handle_get_average_texture_color (C4TextureMapHandle *texture_map, const char *name)
 
const char * c4_texture_handle_get_entry_material_name (C4TextureMapHandle *texture_map, guint index)
 
const char * c4_texture_handle_get_entry_texture_name (C4TextureMapHandle *texture_map, guint index)
 

Macro Definition Documentation

#define GROUP_TO_HANDLE (   group)    (reinterpret_cast<C4GroupHandle*>(group))

Definition at line 23 of file texture-handle.cpp.

#define HANDLE_TO_GROUP (   handle)    (reinterpret_cast<C4Group*>(handle))

Definition at line 24 of file texture-handle.cpp.

Referenced by c4_texture_map_handle_load_map().

#define TEXTURE_MAP_TO_HANDLE (   texture_map)    (reinterpret_cast<C4TextureMapHandle*>(texture_map))

Definition at line 20 of file texture-handle.cpp.

Referenced by c4_texture_map_handle_new().

Function Documentation

guint32 c4_texture_handle_get_average_texture_color ( C4TextureMapHandle texture_map,
const char *  name 
)

Definition at line 68 of file texture-handle.cpp.

References HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_get_average_texture_color().

69 {
70  return HANDLE_TO_TEXTURE_MAP(texture_map)->GetTexture(name)->GetAverageColor();
71 }
#define HANDLE_TO_TEXTURE_MAP(handle)

Here is the caller graph for this function:

const char* c4_texture_handle_get_entry_material_name ( C4TextureMapHandle texture_map,
guint  index 
)

Definition at line 73 of file texture-handle.cpp.

References C4TexMapEntry::GetMaterialName(), and HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_get_material_name_from_mapping().

74 {
75  const C4TexMapEntry* entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(index);
76  if(!entry) return nullptr;
77  return entry->GetMaterialName();
78 }
#define HANDLE_TO_TEXTURE_MAP(handle)
Definition: C4Texture.h:48
const char * GetMaterialName() const
Definition: C4Texture.h:60

Here is the call graph for this function:

Here is the caller graph for this function:

const char* c4_texture_handle_get_entry_texture_name ( C4TextureMapHandle texture_map,
guint  index 
)

Definition at line 80 of file texture-handle.cpp.

References C4TexMapEntry::GetTextureName(), and HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_get_texture_name_from_mapping().

81 {
82  const C4TexMapEntry* entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(index);
83  if(!entry) return nullptr;
84  return entry->GetTextureName();
85 }
#define HANDLE_TO_TEXTURE_MAP(handle)
Definition: C4Texture.h:48
const char * GetTextureName() const
Definition: C4Texture.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean c4_texture_map_handle_add_texture ( C4TextureMapHandle texture_map,
const char *  texture,
guint32  avg_color 
)

Definition at line 55 of file texture-handle.cpp.

References HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_load_textures().

56 {
57  gboolean result = HANDLE_TO_TEXTURE_MAP(texture_map)->AddTexture(texture, nullptr);
58  if(!result) return FALSE;
59  HANDLE_TO_TEXTURE_MAP(texture_map)->GetTexture(texture)->SetAverageColor(avg_color);
60  return TRUE;
61 }
#define HANDLE_TO_TEXTURE_MAP(handle)

Here is the caller graph for this function:

void c4_texture_map_handle_free ( C4TextureMapHandle texture_map)

Definition at line 40 of file texture-handle.cpp.

41 {
42  //delete HANDLE_TO_TEXTURE_MAP(texture_map);
43 }
const char* c4_texture_map_handle_get_texture ( C4TextureMapHandle texture_map,
guint  index 
)

Definition at line 63 of file texture-handle.cpp.

References HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_get_texture_name().

64 {
65  return HANDLE_TO_TEXTURE_MAP(texture_map)->GetTexture(index);
66 }
#define HANDLE_TO_TEXTURE_MAP(handle)

Here is the caller graph for this function:

guint c4_texture_map_handle_load_map ( C4TextureMapHandle texture_map,
C4GroupHandle group,
const char *  entry_name,
gboolean *  overload_materials,
gboolean *  overload_textures 
)

Definition at line 45 of file texture-handle.cpp.

References HANDLE_TO_GROUP, and HANDLE_TO_TEXTURE_MAP.

Referenced by mape_texture_map_load_map().

46 {
47  bool fOverloadMaterials = false;
48  bool fOverloadTextures = false;
49  guint32 retval = HANDLE_TO_TEXTURE_MAP(texture_map)->LoadMap(*HANDLE_TO_GROUP(group), entry_name, &fOverloadMaterials, &fOverloadTextures);
50  if(overload_materials) *overload_materials = fOverloadMaterials;
51  if(overload_textures) *overload_textures = fOverloadTextures;
52  return retval;
53 }
#define HANDLE_TO_TEXTURE_MAP(handle)
#define HANDLE_TO_GROUP(handle)

Here is the caller graph for this function:

C4TextureMapHandle* c4_texture_map_handle_new ( void  )

Definition at line 28 of file texture-handle.cpp.

References C4TextureMap::Clear(), C4TextureMap::Init(), TEXTURE_MAP_TO_HANDLE, and TextureMap.

29 {
30  // Simply return a pointer to the global texture map. This is a bit stupid,
31  // but some functions in C4Landscape use the global texture map when looking
32  // up textures. This should be changed to get rid of the global variable,
33  //but yeah...
34  C4TextureMap* map = &::TextureMap;
35  map->Clear();
36  map->Init();
37  return TEXTURE_MAP_TO_HANDLE(map); //new C4TextureMap);
38 }
void Clear()
Definition: C4Texture.cpp:168
#define TEXTURE_MAP_TO_HANDLE(texture_map)
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
int32_t Init()
Definition: C4Texture.cpp:292

Here is the call graph for this function: