Hi,
I'm learning OpenGL, and using glfw and glew. but after searching all over the internet I still don't know why my program crashes every time at the call of glGenBuffers. it pops up the run time error "Unhandled exception at 0x54C00647 (nvoglv32.dll) in OpenglGLFW.exe: 0xC0000005: Access violation writing location 0x003D5000."
I cannot move on without fixing this bug. So can someone help detect the problem of my program? Thanks very much!
following is my code snippet:
if( !glfwInit() )
{
exit( EXIT_FAILURE );
}
// Open an OpenGL window
if( !glfwOpenWindow( 640, 480, 0,0,0,0,0,0, GLFW_WINDOW ) )
{
glfwTerminate();
exit( EXIT_FAILURE );
}
glewExperimental = GL_TRUE;
GLenum glewErr = glewInit();
if (GLEW_OK != glewErr)
{
std::cerr << "Failed to initialize GLEW." << std::endl;
std::cerr << glewGetErrorString(glewErr) << std::endl;
}
if(!glewIsSupported("GL_ARB_vertex_buffer_object GL_ARB_vertex_array_object"))
{
std::cerr << "some extensions are not supported!" << std::endl;
}
//initializing shaders
shaderProg = initShaderProgram(2, "shaders/shader0.vert", "shaders/shader0.frag");
glGenVertexArrays(1, &avao);
glGenBuffers(GL_ARRAY_BUFFER, &vertBO);
glBindVertexArray(avao);
glBindBuffer(GL_ARRAY_BUFFER, vertBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);