Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access violation. when using GLEW and GLFW

I am sure that everything is linked correcly. I initially was using glload and glfw from the Unofficial GLSDK but then I decided to do away with glload which meant that I had to use glew in order to get at the modern headers.

#include <GL/glew.h>
#include <GL/glfw.h>

I have included glew before glfw as per the instructions.

During run time the OpenGL window opens

//(relevant code)
if(!glewInit()) {return -1; }
if(!glfwInit()) {return -1; }
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// also tried glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);

if(!glfwOpenWindow(1024, 768, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)){
    glfwTerminate();
    return -1;
}

glfwSetWindowTitle("OpenGL 3.2");

//init method
glGenVertexArrays(1, &vao);  //<<  Access violation here.

Any ideas what my problem is here?

I have looked at. "Access violation using VBO with glew" But it was no help.

like image 506
Andrew Avatar asked Dec 19 '12 00:12

Andrew


1 Answers

glewInit is to be called after a OpenGL context has been created and bound to the current thread, i.e. after glfwOpenWindow in your case.

like image 118
datenwolf Avatar answered Sep 27 '22 00:09

datenwolf