From 0560925f38932af4ce76a5fc0f5ff9b2953b1d79 Mon Sep 17 00:00:00 2001 From: iann Date: Mon, 29 Sep 2025 01:20:24 +0900 Subject: [PATCH] opengl3.3 and es2 need the color array allocated in order to allow for updates later (unlike opengl11) --- src/rmodels.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rmodels.c b/src/rmodels.c index 9d175ace4..01e85475c 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4430,6 +4430,11 @@ static Model LoadOBJ(const char *fileName) model.meshes[i].vertices = (float *)MemAlloc(sizeof(float)*vertexCount*3); model.meshes[i].normals = (float *)MemAlloc(sizeof(float)*vertexCount*3); model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2); + #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + model.meshes[i].colors = (unsigned char *)MemAlloc(sizeof(unsigned char)*vertexCount*4); + #else + model.meshes[i].colors = NULL; + #endif } MemFree(localMeshVertexCounts); @@ -4504,6 +4509,9 @@ static Model LoadOBJ(const char *fileName) model.meshes[meshIndex].normals[localMeshVertexCount*3 + 1] = 1.0f; model.meshes[meshIndex].normals[localMeshVertexCount*3 + 2] = 0.0f; } + #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + for (int i = 0; i < 4; i++) model.meshes[meshIndex].colors[localMeshVertexCount*4 + i] = 255; + #endif faceVertIndex++; localMeshVertexCount++; }