问题
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 );
...
}
回答1:
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.
回答2:
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 :-)
来源:https://stackoverflow.com/questions/15165863/glgenframebuffers-access-violation-when-using-glfw-glew