Access Violation Exception [VC++]

Hello there guys!

I’ve been given a sample code for my upcoming assignment in Computer Graphics and, according to the guide available in the course’s site, I’ve set up Visual Studio 2008. What we’ve been given is a solution with some sample code which we must use as a base for all of our upcoming assignments.

The thing is, when I try to run the sample application [a simple program that draws a triangle], I get an exception, precisely:
Unhandled exception at 0x00000000 in SimpleTriangle.exe: 0xC0000005: Access violation reading location 0x00000000.

What I came to realise after some Googling around is that it basically means I got a null-pointer exception while trying to create the Vector Array Object I need. That is, the line of code that causes the error is:
GLuint vao;
glGenVertexArrays( 1, &vao ); // <-- this one
glBindVertexArray( vao );

I searched a little more, and I found out that the GLEW_ARB_vertex_array_object is NULL, so that’s the source of my problem. And there’s been no help from the teacher or the TAs yet. At least not any helpful advise.

If anyone got any idea, it would be most welcome. I thought of initializing or allocating memory for the GLEW_ARB_vertex_array_object, but I’m not quite sure I’d even be able to do something like that. I also thought it might be caused by my graphics card drivers being out of date, but the update I did was of no help. And, what’s more, I’m not the only one with the problem in discussion.

Thanks in advance! :slight_smile:

There’s a tutorial in the wiki that uses GLEW: OpenGL 3.1 The First Triangle

Did you call glewInit() prior to calling the first GL function? The thing with any extension wrapper library is that unless you have it actually retrieve the function pointers (mostly done in some init function) provided by the implementation running on your system, its going to crash since your trying to use a null pointer.

This, but also please state what graphics hardware you have. If your driver doesn’t support the necessary extension then I’m afraid that you’re SOL.

You may also try adding glewExperimental=GL_TRUE; before glewInit call.