3

I am getting this error:

"Access violation executing location 0x00000000."

when I use GLFW + GLEW on Windows.

I am using Windows 7. I also have my own implementation (from scratch) that that creates a window, initializes OpenGL context, initializes GLEW, etc... and everything works fine. So of course my video card has the Frame Buffer capability and everything is pretty fine with the drivers... the problem only happens when I try to use GLFW.

Any suggestion?

The code:

void start()
{
    if( !glfwInit() )
    {
        glfwTerminate();
        throw exception( "Failed to initialize GLFW" );
    }

    glfwOpenWindowHint( GLFW_FSAA_SAMPLES, 4 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MAJOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MINOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );

    if( !glfwOpenWindow( m_width, m_height, 0, 0, 0, 0, 32, 0, GLFW_WINDOW ) )
    {
        throw exception( "Failed to open GLFW window." );
        glfwTerminate();
    }

    if ( glewInit() != GLEW_OK )
    {
        throw exception( "Failed to initialize GLEW" );
    }

    // texture
    glGenTextures( 1, &m_texture );
    glBindTexture( GL_TEXTURE_2D, m_texture );

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    // frame buffer
    glGenFramebuffers( 1, &m_frameBuffer ); // IT CRASHES HERE! :-(
    glBindFramebuffer( GL_FRAMEBUFFER, m_frameBuffer );

    glBindTexture( GL_TEXTURE_2D, m_texture );

    ...
}
Wagner Patriota
  • 5,494
  • 26
  • 49

2 Answers2

7

GLEW has known problems when working with a core OpenGL profile. You can either use the GLEW workaround or abandon GLEW for extension loaders that actually work.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • good! I could bypass it using your advice... it doesn't crash anymore but my render is getting everything black. maybe this is another issue... I will check a little deeper! thanks – Wagner Patriota Mar 01 '13 at 21:24
  • 1
    FYI, the bug in glew still exists. – squid Jun 07 '16 at 04:11
1

I just stumbled over the same problem. Solution: instad of using glGenFramebuffers use "glGenFramebuffersEXT" and on any other function that has someting todo with the framebuffer always put "EXT" at the end of it and it should work. The problem is here, that there exist two version of the extension the ARB version and the EXT version and if you don't write "EXT" you use the "ARB" version which allmost does the same but is part of the core profile of newer gl versions. So to be compatible, allways use the "EXT" versions of the functions :-)

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
J-MAN
  • 11
  • 1
  • 1
  • 2
    I wouldn't recommend using the EXT variant of this functionality at all nowadays. The ARB API is much cleaner and also wideline available on GL 2.x capable implementations. – derhass Mar 02 '15 at 20:29
  • @J-MAN glew.h also defines glGenFrameBuffersEXT as a macro so it's still crashing for me just the same. – SparkyNZ Jun 07 '17 at 23:54
  • 1
    @J-MAN My problem was that I wasn't calling glewInit(). – SparkyNZ Jun 08 '17 at 00:01