I have a very simple-minded pixel shader that just writes out blue pixels. The purpose of this shader is to show up what I think is either a bug or something I'm not doing correctly with OpenGL, because when I adjust this shader such that it should fail to compile, I get an access violation in my code rather than a simple OpenGL error that I can inspect.
I have the following pixel shader:
#version 420
out vec4 Out_Colou3r;
void main(void)
{
Out_Colour = vec4(0.0, 0.0, 1.0, 0.0);
}
The obvious mistake is in how I've spelt Out_Colou3r, which doesn't match the assignment in "main". Now when I compile this shader with:
const GLchar * data = shaderString.c_str();
CoreBase::Expose().glShaderSource(id, 1, &data, nullptr);
CoreBase::Expose().glCompileShader(id);
, where CoreBase:Expose() exposes the set of GL function pointers, I get the following error at glCompileShader.
Unhandled exception at 0x0000015E in TestCGI.exe: 0xC0000005: Access violation executing location 0x0000015E.
Now glCompileShader function pointer is assigned correctly as this very same function had no problem compiling the previous vertex shader and indeed it will compile the above pixel shader OK if I correct the typo. Obviously if I've got an access violation, my code can't thereafter read glGetShaderInfoLog to get the reason why it failed. Access violations are terminal. For info, I'm using Visual Studio 2012 and the latest ATI drivers.
So my question is as follows: Why would an error in a shader throw an access violation?
User contributions licensed under CC BY-SA 3.0