Pārlūkot izejas kodu

ADDED: IsModelReady(), IsMaterialReady(), IsTextureReady(), IsRenderTextureReady() (#2895)

pull/2899/head
Rob Loach pirms 2 gadiem
committed by GitHub
vecāks
revīzija
7fff1ba0b0
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 4AEE18F83AFDEB23
3 mainītis faili ar 29 papildinājumiem un 1 dzēšanām
  1. +4
    -0
      src/raylib.h
  2. +12
    -0
      src/rmodels.c
  3. +13
    -1
      src/rtextures.c

+ 4
- 0
src/raylib.h Parādīt failu

@ -1311,7 +1311,9 @@ RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
@ -1441,6 +1443,7 @@ RLAPI void DrawGrid(int slices, float spacing);
// Model management functions
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
RLAPI bool IsModelReady(Model model); // Check if a model is ready
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
RLAPI void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM)
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
@ -1481,6 +1484,7 @@ RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
// Material loading/unloading functions
RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file
RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
RLAPI bool IsMaterialReady(Material material); // Check if a material is ready
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh

+ 12
- 0
src/rmodels.c Parādīt failu

@ -1109,6 +1109,12 @@ Model LoadModelFromMesh(Mesh mesh)
return model;
}
// Check if a model is ready
bool IsModelReady(Model model)
{
return model.meshes != NULL && model.materials != NULL && model.meshMaterial != NULL && model.meshCount > 0 && model.materialCount > 0;
}
// Unload model (meshes/materials) from memory (RAM and/or VRAM)
// NOTE: This function takes care of all model elements, for a detailed control
// over them, use UnloadMesh() and UnloadMaterial()
@ -1950,6 +1956,12 @@ Material LoadMaterialDefault(void)
return material;
}
// Check if a material is ready
bool IsMaterialReady(Material material)
{
return material.maps != NULL;
}
// Unload material from memory
void UnloadMaterial(Material material)
{

+ 13
- 1
src/rtextures.c Parādīt failu

@ -505,7 +505,7 @@ Image LoadImageFromScreen(void)
// Check if an image is ready
bool IsImageReady(Image image)
{
return image.data != NULL;
return image.data != NULL && image.width > 0 && image.height > 0 && image.format > 0;
}
// Unload image from CPU memory (RAM)
@ -3330,6 +3330,12 @@ RenderTexture2D LoadRenderTexture(int width, int height)
return target;
}
// Check if a texture is ready
bool IsTextureReady(Texture2D texture)
{
return texture.id > 0 && texture.width > 0 && texture.height > 0 && texture.format > 0;
}
// Unload texture from GPU memory (VRAM)
void UnloadTexture(Texture2D texture)
{
@ -3341,6 +3347,12 @@ void UnloadTexture(Texture2D texture)
}
}
// Check if a render texture is ready
bool IsRenderTextureReady(RenderTexture2D target)
{
return target.id > 0 && IsTextureReady(target.depth) && IsTextureReady(target.texture);
}
// Unload render texture from GPU memory (VRAM)
void UnloadRenderTexture(RenderTexture2D target)
{

Notiek ielāde…
Atcelt
Saglabāt