diff options
| author | Ray <[email protected]> | 2022-11-29 10:45:10 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2022-11-29 10:45:10 +0100 |
| commit | 2edf5a958484f8dc8fb6d3be14606852b696e379 (patch) | |
| tree | 0ea806fc369d817a81099475e937a2b6e7956bb9 /src/rcore.c | |
| parent | 50a716c0d91f90e73f1fe2b910b3f7426a0d1360 (diff) | |
| download | raylib-2edf5a958484f8dc8fb6d3be14606852b696e379.tar.gz raylib-2edf5a958484f8dc8fb6d3be14606852b696e379.zip | |
REVIEWED: Issue with shader linkage
Diffstat (limited to 'src/rcore.c')
| -rw-r--r-- | src/rcore.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/rcore.c b/src/rcore.c index 8f5b63b1..118a5736 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2446,10 +2446,6 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName) Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode) { Shader shader = { 0 }; - shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int)); - - // NOTE: All locations must be reseted to -1 (no location) - for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1; shader.id = rlLoadShaderCode(vsCode, fsCode); @@ -2465,6 +2461,11 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode) // vertex texcoord2 location = 5 // NOTE: If any location is not found, loc point becomes -1 + + shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int)); + + // All locations reseted to -1 (no location) + for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1; // Get handles to GLSL input attibute locations shader.locs[SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION); @@ -2497,6 +2498,8 @@ void UnloadShader(Shader shader) if (shader.id != rlGetShaderIdDefault()) { rlUnloadShaderProgram(shader.id); + + // NOTE: If shader loading failed, it should be 0 RL_FREE(shader.locs); } } |
