Fix opengl uniforms

This commit is contained in:
EmeraldLoc 2026-06-18 23:20:43 -05:00
parent 5f3cf69fac
commit b8d683b0d5
2 changed files with 11 additions and 2 deletions

View file

@ -195,23 +195,31 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
if (usingCustomVertexShader) {
// make sure it compiles with glslang first
if (!gfx_compile_shader_to_spirv(GLSLANG_STAGE_VERTEX, vsShaderCode, vertexShader)) {
LOG_ERROR("Failed to compile vertex shader!");
LOG_ERROR("Failed to compile custom vertex shader to SPIR-V!");
usingCustomVertexShader = false;
free(vsShaderCode);
vsShaderCode = (char*)vs_buf;
}
}
if (!gfx_compile_shader_to_spirv(GLSLANG_STAGE_VERTEX, vsShaderCode, vertexShader)) {
sys_fatal("Failed to compile vertex shader to SPIR-V!");
}
if (usingCustomFragmentShader) {
// make sure it compiles with glslang first
if (!gfx_compile_shader_to_spirv(GLSLANG_STAGE_FRAGMENT, fsShaderCode, fragmentShader)) {
LOG_ERROR("Failed to compile fragment shader!");
LOG_ERROR("Failed to compile custom fragment shader to SPIR-V!");
usingCustomFragmentShader = false;
free(fsShaderCode);
fsShaderCode = (char*)fs_buf;
}
}
if (!gfx_compile_shader_to_spirv(GLSLANG_STAGE_FRAGMENT, fsShaderCode, fragmentShader)) {
sys_fatal("Failed to compile fragment shader to SPIR-V!");
}
const GLchar *sources[2] = { vsShaderCode, fsShaderCode };
GLint lengths[2] = { strlen(vsShaderCode), strlen(fsShaderCode) };
GLint success;

View file

@ -616,6 +616,7 @@ static void process_shader_line(struct Shader *shader, struct ShaderInput *refer
// add to shader uniforms
snprintf(shader->shaderUniforms[sShaderUniformCount].name, MAX_SHADER_VARIABLE_NAME, "%s", name);
shader->shaderUniforms[sShaderUniformCount].location = sShaderUniformCount;
shader->shaderUniforms[sShaderUniformCount].size = 1;
if (sShaderUniformCount < MAX_SHADER_UNIFORMS - 1) { sShaderUniformCount++; }
}
}