REVIEWED: Material params #1649
Just assigned a fixed memory size for custom Material parameters in case of being required, so we shouldn't worry about allocating/freeing them.
This commit is contained in:
parent
ca1f2f9078
commit
664fbb87f5
3 changed files with 8 additions and 17 deletions
21
src/models.c
21
src/models.c
|
@ -797,15 +797,11 @@ void UnloadModel(Model model)
|
||||||
// Unload meshes
|
// Unload meshes
|
||||||
for (int i = 0; i < model.meshCount; i++) UnloadMesh(model.meshes[i]);
|
for (int i = 0; i < model.meshCount; i++) UnloadMesh(model.meshes[i]);
|
||||||
|
|
||||||
// Unload materials maps and params
|
// Unload materials maps
|
||||||
// NOTE: As the user could be sharing shaders and textures between models,
|
// NOTE: As the user could be sharing shaders and textures between models,
|
||||||
// we don't unload the material but just free it's maps and params,
|
// we don't unload the material but just free it's maps,
|
||||||
// the user is responsible for freeing models shaders and textures
|
// the user is responsible for freeing models shaders and textures
|
||||||
for (int i = 0; i < model.materialCount; i++)
|
for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
|
||||||
{
|
|
||||||
RL_FREE(model.materials[i].maps);
|
|
||||||
RL_FREE(model.materials[i].params);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unload arrays
|
// Unload arrays
|
||||||
RL_FREE(model.meshes);
|
RL_FREE(model.meshes);
|
||||||
|
@ -822,15 +818,11 @@ void UnloadModel(Model model)
|
||||||
// Unload model (but not meshes) from memory (RAM and/or VRAM)
|
// Unload model (but not meshes) from memory (RAM and/or VRAM)
|
||||||
void UnloadModelKeepMeshes(Model model)
|
void UnloadModelKeepMeshes(Model model)
|
||||||
{
|
{
|
||||||
// Unload materials maps and params
|
// Unload materials maps
|
||||||
// NOTE: As the user could be sharing shaders and textures between models,
|
// NOTE: As the user could be sharing shaders and textures between models,
|
||||||
// we don't unload the material but just free it's maps and params,
|
// we don't unload the material but just free it's maps,
|
||||||
// the user is responsible for freeing models shaders and textures
|
// the user is responsible for freeing models shaders and textures
|
||||||
for (int i = 0; i < model.materialCount; i++)
|
for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
|
||||||
{
|
|
||||||
RL_FREE(model.materials[i].maps);
|
|
||||||
RL_FREE(model.materials[i].params);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unload arrays
|
// Unload arrays
|
||||||
RL_FREE(model.meshes);
|
RL_FREE(model.meshes);
|
||||||
|
@ -1013,7 +1005,6 @@ void UnloadMaterial(Material material)
|
||||||
}
|
}
|
||||||
|
|
||||||
RL_FREE(material.maps);
|
RL_FREE(material.maps);
|
||||||
RL_FREE(material.params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
|
// Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
|
||||||
|
|
|
@ -349,7 +349,7 @@ typedef struct MaterialMap {
|
||||||
typedef struct Material {
|
typedef struct Material {
|
||||||
Shader shader; // Material shader
|
Shader shader; // Material shader
|
||||||
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
||||||
float *params; // Material generic parameters (if required)
|
float params[4]; // Material generic parameters (if required)
|
||||||
} Material;
|
} Material;
|
||||||
|
|
||||||
// Transformation properties
|
// Transformation properties
|
||||||
|
|
|
@ -316,7 +316,7 @@ typedef enum {
|
||||||
typedef struct Material {
|
typedef struct Material {
|
||||||
Shader shader; // Material shader
|
Shader shader; // Material shader
|
||||||
MaterialMap *maps; // Material maps (MAX_MATERIAL_MAPS)
|
MaterialMap *maps; // Material maps (MAX_MATERIAL_MAPS)
|
||||||
float *params; // Material generic parameters (if required)
|
float params[4]; // Material generic parameters (if required)
|
||||||
} Material;
|
} Material;
|
||||||
|
|
||||||
// Camera type, defines a camera position/orientation in 3d space
|
// Camera type, defines a camera position/orientation in 3d space
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue