I trying to use RenderMonkey 1.82 on Win10 PC, and graphics card is NVIDIA Geforce 405 v342.01. I cannot use the OpenGL ES examples that comes with it. I remember once I could do this on another machine. Is this an compatibility problem?
Vertex shader:
uniform mat4 view_proj_matrix;
uniform vec4 view_position;
attribute vec4 rm_Vertex;
attribute vec3 rm_Normal;
varying vec3 vNormal;
varying vec3 vViewVec;
void main(void)
{
gl_Position = view_proj_matrix * rm_Vertex;
// World-space lighting
vNormal = rm_Normal;
vViewVec = view_position.xyz - rm_Vertex.xyz;
}
Fragment shader:
precision mediump float;
uniform vec4 color;
varying vec3 vNormal;
varying vec3 vViewVec;
void main(void)
{
float v = 0.5 * (1.0 + dot(normalize(vViewVec), vNormal));
gl_FragColor = v * color;
}
The error message is:
OpenGL ES Preview Window: Compiling vertex shader API(OpenGL ES)
/../Plastic_OpenGL_ES/Single Pass/Vertex Program/ ... failure
0(8) :
error C0118: macros prefixed with 'GL_' are reserved
OpenGL ES Preview
Window: Compiling fragment shader API(OpenGL ES)
/../Plastic_OpenGL_ES/Single Pass/Fragment Program/ ... failure
0(3) :
error C0118: macros prefixed with 'GL_' are reserved
RENDERING
ERROR(s): Vertex program 'Vertex Program' failed to compile in pass
'Single Pass'. See Output window for details Fragment program
'Fragment Program' failed to compile in pass 'Single Pass'. See
Output window for details
RenderMonkey adds a bunch of definitions onto the shaders before sending them to the GLSL compiler. You can verify this by running it through CodeXL, and then inspecting the text of the shaders. For my machine, this seems to be the standard (for vertex shaders, fragment shaders are similar):
As you can see, on line 8,
#define GL_ES
is the error you are hitting (and this occurs on line 3 for fragment shaders).In the GLSL ES spec, it states:
Thus, your driver is doing the correct thing, and rejecting this shader because it in fact violates the spec. Likely in very old Nvidia drivers, this error was not reported. You would need to recompile RenderMonkey to property resolve this issue, and the sources are not public.
However, you can hack RenderMonkey to get this to compile these shaders. These extra strings that are prepended are contained in the
libGLESv2.dll
in plain text, and you can use a hex editor to change them to something that doesn't start withGL_
. They occur at offsets 0x16052E and 0x1606A0.Or, instead just use the GL2 workspaces for developing your shaders, since GLSL and GLSL ES are very similar.