REVIEWED: Avoid program crash if GPU data is tried to be loaded before InitWindow() #4751

Following raylib design, a warning log message is shown and program can continue execution.
Some early return checks have been added on most  critical functions.
[rtext] Previous implementation checking `isGpuReady` cross-module variable is not needed any more, resulting in a more decoupled code, load failure is managed at rlgl level
This commit is contained in:
Ray
2025-12-11 18:21:57 +01:00
parent 8fa5f1fe2c
commit 2853b28d6d
5 changed files with 53 additions and 44 deletions

View File

@ -1282,6 +1282,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
mesh->vaoId = rlLoadVertexArray();
if (mesh->vaoId == 0) return;
rlEnableVertexArray(mesh->vaoId);
// NOTE: Vertex attributes must be uploaded considering default locations points and available vertex data
@ -1470,6 +1472,8 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
// Bind shader program
rlEnableShader(material.shader.id);
if (material.shader.locs == NULL) return;
// Send required data to shader (matrices, values)
//-----------------------------------------------------
// Upload to shader material.colDiffuse