From e621efe79ff47318969c2b4f7885bfdeb83a4cf9 Mon Sep 17 00:00:00 2001 From: Matthew Owens Date: Thu, 13 Jan 2022 17:42:44 +0000 Subject: [PATCH] rlLoadShaderCode - set ShaderId variables to RLGL.State.default[VF]ShaderId if repesctive Code is NULL (#2281) --- src/rlgl.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index 37af998fc..52d8a9e83 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3544,8 +3544,16 @@ unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode) unsigned int vertexShaderId = 0; unsigned int fragmentShaderId = 0; - if (vsCode != NULL) vertexShaderId = rlCompileShader(vsCode, GL_VERTEX_SHADER); - if (fsCode != NULL) fragmentShaderId = rlCompileShader(fsCode, GL_FRAGMENT_SHADER); + if (vsCode != NULL) { + vertexShaderId = rlCompileShader(vsCode, GL_VERTEX_SHADER); + } else { + vertexShaderId = RLGL.State.defaultVShaderId; + } + if (fsCode != NULL) { + fragmentShaderId = rlCompileShader(fsCode, GL_FRAGMENT_SHADER); + } else { + fragmentShaderId = RLGL.State.defaultFShaderId; + } // Load shader program if provided vertex/fragment shaders compile successfully if ((vertexShaderId != 0) && (fragmentShaderId != 0)) id = rlLoadShaderProgram(vertexShaderId, fragmentShaderId);