WARNING: BREAKING: Renamed several functions for data validation #3930
This commit is contained in:
parent
9b3d019502
commit
8cbf34ddc4
7 changed files with 66 additions and 50 deletions
16
src/raudio.c
16
src/raudio.c
|
@ -892,8 +892,8 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||||
return wave;
|
return wave;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if wave data is ready
|
// Checks if wave data is valid (data loaded and parameters)
|
||||||
bool IsWaveReady(Wave wave)
|
bool IsWaveValid(Wave wave)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
@ -993,8 +993,8 @@ Sound LoadSoundAlias(Sound source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks if a sound is ready
|
// Checks if a sound is valid (data loaded and buffers initialized)
|
||||||
bool IsSoundReady(Sound sound)
|
bool IsSoundValid(Sound sound)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
@ -1726,8 +1726,8 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||||
return music;
|
return music;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if a music stream is ready
|
// Checks if a music stream is valid (context and buffers initialized)
|
||||||
bool IsMusicReady(Music music)
|
bool IsMusicValid(Music music)
|
||||||
{
|
{
|
||||||
return ((music.ctxData != NULL) && // Validate context loaded
|
return ((music.ctxData != NULL) && // Validate context loaded
|
||||||
(music.frameCount > 0) && // Validate audio frame count
|
(music.frameCount > 0) && // Validate audio frame count
|
||||||
|
@ -2119,8 +2119,8 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if an audio stream is ready
|
// Checks if an audio stream is valid (buffers initialized)
|
||||||
bool IsAudioStreamReady(AudioStream stream)
|
bool IsAudioStreamValid(AudioStream stream)
|
||||||
{
|
{
|
||||||
return ((stream.buffer != NULL) && // Validate stream buffer
|
return ((stream.buffer != NULL) && // Validate stream buffer
|
||||||
(stream.sampleRate > 0) && // Validate sample rate is supported
|
(stream.sampleRate > 0) && // Validate sample rate is supported
|
||||||
|
|
22
src/raylib.h
22
src/raylib.h
|
@ -1044,7 +1044,7 @@ RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR s
|
||||||
// NOTE: Shader functionality is not available on OpenGL 1.1
|
// NOTE: Shader functionality is not available on OpenGL 1.1
|
||||||
RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
|
RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
|
||||||
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations
|
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations
|
||||||
RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready
|
RLAPI bool IsShaderValid(Shader shader); // Check if a shader is valid (loaded on GPU)
|
||||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||||
RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location
|
RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location
|
||||||
RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value
|
RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value
|
||||||
|
@ -1319,7 +1319,7 @@ RLAPI Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *f
|
||||||
RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'
|
RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'
|
||||||
RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data
|
RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data
|
||||||
RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)
|
RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)
|
||||||
RLAPI bool IsImageReady(Image image); // Check if an image is ready
|
RLAPI bool IsImageValid(Image image); // Check if an image is valid (data and parameters)
|
||||||
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
||||||
RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success
|
RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success
|
||||||
RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer
|
RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer
|
||||||
|
@ -1405,9 +1405,9 @@ RLAPI Texture2D LoadTexture(const char *fileName);
|
||||||
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
|
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 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 RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
|
||||||
RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
|
RLAPI bool IsTextureValid(Texture2D texture); // Check if a texture is valid (loaded in GPU)
|
||||||
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
||||||
RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
|
RLAPI bool IsRenderTextureValid(RenderTexture2D target); // Check if a render texture is valid (loaded in GPU)
|
||||||
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
|
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 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
|
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
|
||||||
|
@ -1454,7 +1454,7 @@ RLAPI Font LoadFont(const char *fileName);
|
||||||
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set, font size is provided in pixels height
|
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set, font size is provided in pixels height
|
||||||
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
|
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
|
||||||
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
|
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
|
||||||
RLAPI bool IsFontReady(Font font); // Check if a font is ready
|
RLAPI bool IsFontValid(Font font); // Check if a font is valid (font data loaded, WARNING: GPU texture not checked)
|
||||||
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
|
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
|
||||||
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
|
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
|
||||||
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
|
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
|
||||||
|
@ -1544,7 +1544,7 @@ RLAPI void DrawGrid(int slices, float spacing);
|
||||||
// Model management functions
|
// Model management functions
|
||||||
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
|
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 Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
|
||||||
RLAPI bool IsModelReady(Model model); // Check if a model is ready
|
RLAPI bool IsModelValid(Model model); // Check if a model is valid (loaded in GPU, VAO/VBOs)
|
||||||
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
|
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
|
||||||
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
|
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
|
||||||
|
|
||||||
|
@ -1587,7 +1587,7 @@ RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
|
||||||
// Material loading/unloading functions
|
// Material loading/unloading functions
|
||||||
RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file
|
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 Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
|
||||||
RLAPI bool IsMaterialReady(Material material); // Check if a material is ready
|
RLAPI bool IsMaterialValid(Material material); // Check if a material is valid (shader assigned, map textures loaded in GPU)
|
||||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
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 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
|
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
|
||||||
|
@ -1625,11 +1625,11 @@ RLAPI float GetMasterVolume(void); // Get mas
|
||||||
// Wave/Sound loading/unloading functions
|
// Wave/Sound loading/unloading functions
|
||||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||||
RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
|
RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
|
||||||
RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready
|
RLAPI bool IsWaveValid(Wave wave); // Checks if wave data is valid (data loaded and parameters)
|
||||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||||
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
||||||
RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
|
RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
|
||||||
RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready
|
RLAPI bool IsSoundValid(Sound sound); // Checks if a sound is valid (data loaded and buffers initialized)
|
||||||
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
|
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
|
||||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||||
|
@ -1655,7 +1655,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
|
||||||
// Music management functions
|
// Music management functions
|
||||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||||
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data
|
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data
|
||||||
RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready
|
RLAPI bool IsMusicValid(Music music); // Checks if a music stream is valid (context and buffers initialized)
|
||||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||||
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing
|
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing
|
||||||
|
@ -1672,7 +1672,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
|
||||||
|
|
||||||
// AudioStream management functions
|
// AudioStream management functions
|
||||||
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
|
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
|
||||||
RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready
|
RLAPI bool IsAudioStreamValid(AudioStream stream); // Checks if an audio stream is valid (buffers initialized)
|
||||||
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
|
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
|
||||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data
|
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data
|
||||||
RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
||||||
|
|
|
@ -1342,10 +1342,10 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a shader is ready
|
// Check if a shader is valid (loaded on GPU)
|
||||||
bool IsShaderReady(Shader shader)
|
bool IsShaderValid(Shader shader)
|
||||||
{
|
{
|
||||||
return ((shader.id > 0) && // Validate shader id (loaded successfully)
|
return ((shader.id > 0) && // Validate shader id (GPU loaded successfully)
|
||||||
(shader.locs != NULL)); // Validate memory has been allocated for default shader locations
|
(shader.locs != NULL)); // Validate memory has been allocated for default shader locations
|
||||||
|
|
||||||
// The following locations are tried to be set automatically (locs[i] >= 0),
|
// The following locations are tried to be set automatically (locs[i] >= 0),
|
||||||
|
|
|
@ -347,7 +347,6 @@
|
||||||
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES
|
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
|
||||||
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS
|
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS
|
||||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
|
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
|
||||||
|
|
|
@ -1155,8 +1155,8 @@ Model LoadModelFromMesh(Mesh mesh)
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a model is ready
|
// Check if a model is valid (loaded in GPU, VAO/VBOs)
|
||||||
bool IsModelReady(Model model)
|
bool IsModelValid(Model model)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
@ -1165,8 +1165,24 @@ bool IsModelReady(Model model)
|
||||||
(model.meshMaterial != NULL) && // Validate mesh-material linkage
|
(model.meshMaterial != NULL) && // Validate mesh-material linkage
|
||||||
(model.meshCount > 0) && // Validate mesh count
|
(model.meshCount > 0) && // Validate mesh count
|
||||||
(model.materialCount > 0)) result = true; // Validate material count
|
(model.materialCount > 0)) result = true; // Validate material count
|
||||||
|
|
||||||
// NOTE: This is a very general model validation, many elements could be validated from a model...
|
// NOTE: Many elements could be validated from a model, including every model mesh VAO/VBOs
|
||||||
|
// but some VBOs could not be used, it depends on Mesh vertex data
|
||||||
|
for (int i = 0; i < model.meshCount; i++)
|
||||||
|
{
|
||||||
|
if ((model.meshes[i].vertices != NULL) && (model.meshes[i].vboId[0] == 0)) { result = false; break; } // Vertex position buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].texcoords != NULL) && (model.meshes[i].vboId[1] == 0)) { result = false; break; } // Vertex textcoords buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].normals != NULL) && (model.meshes[i].vboId[2] == 0)) { result = false; break; } // Vertex normals buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].colors != NULL) && (model.meshes[i].vboId[3] == 0)) { result = false; break; } // Vertex colors buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].tangents != NULL) && (model.meshes[i].vboId[4] == 0)) { result = false; break; } // Vertex tangents buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].texcoords2 != NULL) && (model.meshes[i].vboId[5] == 0)) { result = false; break; } // Vertex texcoords2 buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].indices != NULL) && (model.meshes[i].vboId[6] == 0)) { result = false; break; } // Vertex indices buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].boneIds != NULL) && (model.meshes[i].vboId[7] == 0)) { result = false; break; } // Vertex boneIds buffer not uploaded to GPU
|
||||||
|
if ((model.meshes[i].boneWeights != NULL) && (model.meshes[i].vboId[8] == 0)) { result = false; break; } // Vertex boneWeights buffer not uploaded to GPU
|
||||||
|
|
||||||
|
// NOTE: Some OpenGL versions do not support VAO, so we don't check it
|
||||||
|
//if (model.meshes[i].vaoId == 0) { result = false; break }
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2182,13 +2198,15 @@ Material LoadMaterialDefault(void)
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a material is ready
|
// Check if a material is valid (map textures loaded in GPU)
|
||||||
bool IsMaterialReady(Material material)
|
bool IsMaterialValid(Material material)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if ((material.maps != NULL) && // Validate material contain some map
|
if ((material.maps != NULL) && // Validate material contain some map
|
||||||
(material.shader.id > 0)) result = true; // Validate material shader is valid
|
(material.shader.id > 0)) result = true; // Validate material shader is valid
|
||||||
|
|
||||||
|
// TODO: Check if available maps contain loaded textures
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
11
src/rtext.c
11
src/rtext.c
|
@ -581,17 +581,16 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a font is ready
|
// Check if a font is valid (font data loaded)
|
||||||
bool IsFontReady(Font font)
|
// WARNING: GPU texture not checked
|
||||||
|
bool IsFontValid(Font font)
|
||||||
{
|
{
|
||||||
return ((font.texture.id > 0) && // Validate OpenGL id for font texture atlas
|
return ((font.baseSize > 0) && // Validate font size
|
||||||
(font.baseSize > 0) && // Validate font size
|
|
||||||
(font.glyphCount > 0) && // Validate font contains some glyph
|
(font.glyphCount > 0) && // Validate font contains some glyph
|
||||||
(font.recs != NULL) && // Validate font recs defining glyphs on texture atlas
|
(font.recs != NULL) && // Validate font recs defining glyphs on texture atlas
|
||||||
(font.glyphs != NULL)); // Validate glyph data is loaded
|
(font.glyphs != NULL)); // Validate glyph data is loaded
|
||||||
|
|
||||||
// NOTE: Further validations could be done to verify if recs count and glyphs count
|
// NOTE: Further validations could be done to verify if recs and glyphs contain valid data (glyphs values, metrics...)
|
||||||
// match glyphCount and to verify that data contained is valid (glyphs values, metrics...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load font data for further use
|
// Load font data for further use
|
||||||
|
|
|
@ -600,15 +600,15 @@ Image LoadImageFromScreen(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if an image is ready
|
// Check if an image is ready
|
||||||
bool IsImageReady(Image image)
|
bool IsImageValid(Image image)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if ((image.data != NULL) && // Validate pixel data available
|
if ((image.data != NULL) && // Validate pixel data available
|
||||||
(image.width > 0) &&
|
(image.width > 0) && // Validate image width
|
||||||
(image.height > 0) && // Validate image size
|
(image.height > 0) && // Validate image height
|
||||||
(image.format > 0) && // Validate image format
|
(image.format > 0) && // Validate image format
|
||||||
(image.mipmaps > 0)) result = true; // Validate image mipmaps (at least 1 for basic mipmap level)
|
(image.mipmaps > 0)) result = true; // Validate image mipmaps (at least 1 for basic mipmap level)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -4224,16 +4224,16 @@ RenderTexture2D LoadRenderTexture(int width, int height)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a texture is ready
|
// Check if a texture is valid (loaded in GPU)
|
||||||
bool IsTextureReady(Texture2D texture)
|
bool IsTextureValid(Texture2D texture)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
// TODO: Validate maximum texture size supported by GPU?
|
// TODO: Validate maximum texture size supported by GPU
|
||||||
|
|
||||||
if ((texture.id > 0) && // Validate OpenGL id
|
if ((texture.id > 0) && // Validate OpenGL id (texture uplaoded to GPU)
|
||||||
(texture.width > 0) &&
|
(texture.width > 0) && // Validate texture width
|
||||||
(texture.height > 0) && // Validate texture size
|
(texture.height > 0) && // Validate texture height
|
||||||
(texture.format > 0) && // Validate texture pixel format
|
(texture.format > 0) && // Validate texture pixel format
|
||||||
(texture.mipmaps > 0)) result = true; // Validate texture mipmaps (at least 1 for basic mipmap level)
|
(texture.mipmaps > 0)) result = true; // Validate texture mipmaps (at least 1 for basic mipmap level)
|
||||||
|
|
||||||
|
@ -4251,14 +4251,14 @@ void UnloadTexture(Texture2D texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a render texture is ready
|
// Check if a render texture is valid (loaded in GPU)
|
||||||
bool IsRenderTextureReady(RenderTexture2D target)
|
bool IsRenderTextureValid(RenderTexture2D target)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if ((target.id > 0) && // Validate OpenGL id
|
if ((target.id > 0) && // Validate OpenGL id (loaded on GPU)
|
||||||
IsTextureReady(target.depth) && // Validate FBO depth texture/renderbuffer
|
IsTextureValid(target.depth) && // Validate FBO depth texture/renderbuffer attachment
|
||||||
IsTextureReady(target.texture)) result = true; // Validate FBO texture
|
IsTextureValid(target.texture)) result = true; // Validate FBO texture attachment
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue