mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-05 15:05:36 +00:00
Revert reordering of shader preprocessing statements.
Position of "shader_body" is reused in the next find call, which was broken because of the changed order.
This commit is contained in:
@ -154,21 +154,8 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
|
||||
throw ShaderException("Preset shader is missing \"shader_body\" entry point.");
|
||||
}
|
||||
|
||||
// replace "}" with return statement (this can probably be optimized for the GLSL conversion...)
|
||||
found = program.rfind('}');
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
//std::cout << "last '}' found at: " << int(found) << std::endl;
|
||||
program.replace(int(found), 1, "_return_value = float4(ret.xyz, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ShaderException("Preset shader has no closing brace.");
|
||||
}
|
||||
|
||||
// replace "{" with some variable declarations
|
||||
found = program.find('{',found);
|
||||
// replace the "{" immediately following shader_body with some variable declarations
|
||||
found = program.find('{', found);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
//std::cout << "first '{' found at: " << int(found) << std::endl;
|
||||
@ -182,6 +169,20 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
|
||||
throw ShaderException("Preset shader has no opening braces.");
|
||||
}
|
||||
|
||||
// replace "}" with return statement (this can probably be optimized for the GLSL conversion...)
|
||||
found = program.rfind('}');
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
//std::cout << "last '}' found at: " << int(found) << std::endl;
|
||||
program.replace(int(found), 1, "_return_value = float4(ret.xyz, 1.0);\n"
|
||||
"}\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ShaderException("Preset shader has no closing brace.");
|
||||
}
|
||||
|
||||
|
||||
// Find matching closing brace and cut off excess text after shader's main function
|
||||
int bracesOpen = 1;
|
||||
size_t pos = found + 1;
|
||||
|
||||
Reference in New Issue
Block a user