OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
material-handle.h File Reference
Include dependency graph for material-handle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef typedefG_BEGIN_DECLS
struct _C4MaterialHandle 
C4MaterialHandle
 
typedef struct _C4MaterialMapHandle C4MaterialMapHandle
 

Functions

C4MaterialMapHandlec4_material_map_handle_new (void)
 
void c4_material_map_handle_free (C4MaterialMapHandle *material_map)
 
guint c4_material_map_handle_load (C4MaterialMapHandle *material_map, C4GroupHandle *group)
 
void c4_material_map_crossmap_materials (C4MaterialMapHandle *material_map, C4TextureMapHandle *texture_map)
 
guint c4_material_map_handle_get_num (C4MaterialMapHandle *material_map)
 
C4MaterialHandlec4_material_map_handle_get_material (C4MaterialMapHandle *material_map, guint index)
 
const gchar * c4_material_handle_get_name (C4MaterialHandle *material)
 
const gchar * c4_material_handle_get_texture_overlay (C4MaterialHandle *material)
 

Typedef Documentation

typedef typedefG_BEGIN_DECLS struct _C4MaterialHandle C4MaterialHandle

Definition at line 26 of file material-handle.h.

typedef struct _C4MaterialMapHandle C4MaterialMapHandle

Definition at line 27 of file material-handle.h.

Function Documentation

const gchar* c4_material_handle_get_name ( C4MaterialHandle material)

Definition at line 85 of file material-handle.cpp.

References HANDLE_TO_MATERIAL.

Referenced by mape_material_get_name(), and mape_material_map_get_material_by_name().

86 {
87  return HANDLE_TO_MATERIAL(material)->Name;
88 }
#define HANDLE_TO_MATERIAL(handle)

Here is the caller graph for this function:

const gchar* c4_material_handle_get_texture_overlay ( C4MaterialHandle material)

Definition at line 89 of file material-handle.cpp.

References HANDLE_TO_MATERIAL.

Referenced by mape_material_get_texture_overlay().

90 {
91  return HANDLE_TO_MATERIAL(material)->sTextureOverlay.getData();
92 }
#define HANDLE_TO_MATERIAL(handle)

Here is the caller graph for this function:

void c4_material_map_crossmap_materials ( C4MaterialMapHandle material_map,
C4TextureMapHandle texture_map 
)

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

References C4Material::DefaultMatTex, StdStrBuf::getData(), HANDLE_TO_MATERIAL_MAP, HANDLE_TO_TEXTURE_MAP, C4MaterialCore::Name, and C4MaterialCore::sTextureOverlay.

Referenced by mape_material_map_set_default_textures().

56 {
57  // Don't call the official crossmap function since it tries to load some surfaces.
58  // All we need is the default texture.
59  for(int i = 0; i < HANDLE_TO_MATERIAL_MAP(material_map)->Num; ++i)
60  {
61  C4Material* mat = &HANDLE_TO_MATERIAL_MAP(material_map)->Map[i];
62  const char* overlay = mat->sTextureOverlay.getData();
63  if(!overlay || *overlay == '\0')
64  {
65  int first_tex_map_entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, nullptr, false);
66  overlay = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(first_tex_map_entry)->GetTextureName();
67  }
68 
69  if(overlay)
70  mat->DefaultMatTex = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, overlay, true);
71  }
72 }
const char * getData() const
Definition: StdBuf.h:442
int32_t DefaultMatTex
Definition: C4Material.h:155
StdCopyStrBuf sTextureOverlay
Definition: C4Material.h:114
#define HANDLE_TO_TEXTURE_MAP(handle)
#define HANDLE_TO_MATERIAL_MAP(handle)
char Name[C4M_MaxName+1]
Definition: C4Material.h:89

Here is the call graph for this function:

Here is the caller graph for this function:

void c4_material_map_handle_free ( C4MaterialMapHandle material_map)

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

46 {
47  //delete HANDLE_TO_MATERIAL_MAP(material_map);
48 }
C4MaterialHandle* c4_material_map_handle_get_material ( C4MaterialMapHandle material_map,
guint  index 
)

Definition at line 79 of file material-handle.cpp.

References HANDLE_TO_MATERIAL_MAP, and MATERIAL_TO_HANDLE.

Referenced by mape_material_map_get_material_by_name().

80 {
81  g_assert(index < (guint)(HANDLE_TO_MATERIAL_MAP(material_map)->Num));
82  return MATERIAL_TO_HANDLE(&HANDLE_TO_MATERIAL_MAP(material_map)->Map[index]);
83 }
#define HANDLE_TO_MATERIAL_MAP(handle)
#define MATERIAL_TO_HANDLE(material)

Here is the caller graph for this function:

guint c4_material_map_handle_get_num ( C4MaterialMapHandle material_map)

Definition at line 74 of file material-handle.cpp.

References HANDLE_TO_MATERIAL_MAP.

Referenced by mape_material_map_get_material(), mape_material_map_get_material_by_name(), and mape_material_map_get_material_count().

75 {
76  return HANDLE_TO_MATERIAL_MAP(material_map)->Num;
77 }
#define HANDLE_TO_MATERIAL_MAP(handle)

Here is the caller graph for this function:

guint c4_material_map_handle_load ( C4MaterialMapHandle material_map,
C4GroupHandle group 
)

Definition at line 50 of file material-handle.cpp.

References HANDLE_TO_GROUP, and HANDLE_TO_MATERIAL_MAP.

Referenced by mape_material_map_load().

51 {
52  return HANDLE_TO_MATERIAL_MAP(material_map)->Load(*HANDLE_TO_GROUP(group));
53 }
#define HANDLE_TO_GROUP(handle)
#define HANDLE_TO_MATERIAL_MAP(handle)

Here is the caller graph for this function:

C4MaterialMapHandle* c4_material_map_handle_new ( void  )

Definition at line 34 of file material-handle.cpp.

References C4MaterialMap::Clear(), MATERIAL_MAP_TO_HANDLE, and MaterialMap.

35 {
36  // Simply return a pointer to the global material map. This is a bit stupid,
37  // but when looking up a material-texture combination, C4TextureMap uses the
38  // global material map for the material lookup when the default texture is
39  // requested. This should be changed to get rid of the global variable, but yeah...
41  map->Clear();
42  return MATERIAL_MAP_TO_HANDLE(map); //new C4MaterialMap);
43 }
#define MATERIAL_MAP_TO_HANDLE(material_map)
C4MaterialMap MaterialMap
Definition: C4Material.cpp:969

Here is the call graph for this function: