mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user