Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a SDL game project and this window popped up while trying to compile:

First-chance exception at 0x00000000 in SDL_Game.exe: 0xC0000005: 
Access violation executing location 0x00000000.

If there is a handler for this exception, the program may be safely continued.

The buttons gave the option to break, continue, ignore.

Code shows no errors whatsoever. Has anyone ran into this sort of problem in the past? I've googled around, but nothing was in line with this that I've found.

UPDATE: Through the debugger, error points to vShaderID:

GLint Shader::makeVertexShader (char* shaderSource) 
    GLint vShaderID = glCreateShader(GL_VERTEX_SHADER); //<<----- Debugger 
    glShaderSource (vShaderID, 1, (const GLchar**) &shaderSource, NULL);
    bool compiledCorrectly = compiledStatus(vShaderID);

    if (compiledCorrectly) 
        return vShaderID;
    return -1;

And the second line in the debugger points inside the constructor to vertexID:

Shader::Shader(const char* vertexFilename, const char* fragmentFilename)
    // Read in the vertex program file
    char* vertexCode = readFile(vertexFilename);
    GLint vertexID = makeVertexShader(vertexCode); //<<--------Debugger
share|improve this question
When you compiled? Looks like a runtime issue, in which case, I'd suggest you run through your debugger. – stephelton Apr 17 '13 at 3:50
@stephelton Thanks for the input. The 1st to line in the debugger points vShaderID and vertexID. – ChocoMan Apr 17 '13 at 4:18
I had sort of this problem once and my program was just int main() { return 0} It was an access violation at 0x00000000 I restarted my computer and it went away. Maybe give that a try. – Azaral Apr 17 '13 at 4:55
make sure that read file actually returns a valid string. And btw I doubt an exception handler will will make your program continue since this is not a C++ exception, but rather an OS exception (which can be catched in a non-portable way -not recommended- for example SEH on windows.) – concept3d Apr 17 '13 at 5:14
up vote 3 down vote accepted

You have an execute violation at 0x00000000 which means a function call tries to jump to this location.

By the position your debugger points out it looks like glCreateShader is null.

Some of the possible reaons:

  • You did not intialize OpenGl correctly/at all? Did you check the return values from the SDL initialization for errors?
  • You did initialize an OpenGL version not supporting this function. (glCreateShader requires OpenGL >= 2.0)
  • Your platform/driver does not support this feature. This should return an error during initialization as the requested OpenGL is not supported.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.