FragColor variable name is implicitly reserved on GL3Plus
Posted: Mon Dec 07, 2020 6:43 am
Simple fragment glsl shader produce error, that was not trivial to debug:
It took me a while to figure out, that FragColor is defined inside Ogre's code in RenderSystems/GL3Plus/src/GLSL/src/OgreGLSLShader.cpp :
I suggest to rename FragColor to something that would not clash with user's variables (for example Ogre_FragColor)
I can create pull request if suggested change is ok.
Code: Select all
ERROR: 0:22: Regular non-array variable 'FragColor' may not be redeclared
Code: Select all
#version 130
precision highp int;
precision highp float;
uniform sampler2D sampleTexture;
in vec4 outUV0;
in vec4 outColor;
out vec4 FragColor;
// Texturing fragment program for GLSL
void main()
{
FragColor = outColor * texture(sampleTexture, outUV0.xy);
}
Code: Select all
if(shouldUpgradeToVersion150)
{
if(belowVersionPos != 0)
mSource = mSource.erase(0, belowVersionPos); // drop old definition
// automatically upgrade to glsl150. thank you apple.
const char* prefixFp =
"#version 150\n"
"#define varying in\n"
"#define texture1D texture\n"
"#define texture2D texture\n"
"#define texture3D texture\n"
"#define textureCube texture\n"
"#define texture2DLod textureLod\n"
"#define texture2DProj textureProj\n"
"#define textureCubeLod textureLod\n"
"#define shadow2DProj textureProj\n"
"#define gl_FragColor FragColor\n"
"out vec4 FragColor;\n";
I can create pull request if suggested change is ok.