rlLoadShaderCode - set ShaderId variables to RLGL.State.default[VF]ShaderId if repesctive Code is NULL (#2281)

This commit is contained in:
Matthew Owens 2022-01-13 17:42:44 +00:00 committed by GitHub
parent 464026f15c
commit e621efe79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);