glGenVertexArrays Access violation Error

Hi guys,
I’ve created an application with SFML, GLEW and OpenGL. With SFML I manage the window and I’ve created an OpenGL 3.2 context. With GLEW I simplify the management of extension, I only call the glewInit() function.
In my code, when glGenVertexArrays() is called, I obtain an Access violation Error.
Can someone help me?

I’ve added this code:

	std::cout << "ARB_vertex_array_object not available." << std::endl; 

he told me that the extension is not available, but if I run the programs included with GLEW (glewinfo, visualinfo), I obtain:

GL_ARB_vertex_array_object:                                    OK 
  glBindVertexArray:                                           OK
  glDeleteVertexArrays:                                        OK
  glGenVertexArrays:                                           OK
  glIsVertexArray:                                             OK

I’m a bit confused, where is the problem?

Did you checked that glewInit is called after the opengl rendering context creation? Show us the window and extension setup please.

Yes, I try to explain my code. This is a simplified version of main function:

int _tmain(int argc, _TCHAR* argv[])
	sf::ContextSettings contextSettings; 
	sf::Window app;
	CGLRenderer* glRenderer = new CGLRenderer();

	contextSettings.MajorVersion = 3;
	contextSettings.MinorVersion = 2;

	app.Create(sf::VideoMode(800, 600, 32), "", sf::Style::Titlebar, contextSettings);



	return 0;

and the CGLRenderer class:

void CGLRenderer::init()

		std::cout << "ARB_vertex_array_object not available." << std::endl; 

void CGLRenderer::draw()
	//Some code...

	glGenVertexArrays(1, &vao);

	//Some code...

That’s look weird indeed. I advise you to look for ARB_vertex_array_object in the gl extension string: glGetString( GL_EXTENSIONS ); See if it still not available. If not, you hardware may simply not support it or you need to update your driver.

BTW, if your are using the extension, shouldn’t it be glGenVertexArraysARB instead of glGenVertexArrays. Are your sure that your gl 3.2 RC is setup correctly? Because I may be wrong since I am not very well experienced with the latest gl specs but, vertex array objects should be part of the core if I am correct. So no need for extensions.

BTW, if your are using the extension, shouldn’t it be glGenVertexArraysARB instead of glGenVertexArrays.

No. ARB_vertex_array_object is a core ARB extension. As such, its entrypoints and enums do not have an extension suffix. This allows the same code that is written against the extension or the core to work regardless of which is available. GL 2.1 code written against core extensions will magically work with 3.x implementations.

There are several other core extensions in GL 3.0.

Ok thank you for that clarification, I should just have taken a look the ARB_vertex_array_object specification.

Using this code (on main function):

contextSettings.MajorVersion = 3;
contextSettings.MinorVersion = 1;

does not appear any error. I’ve got a black screen.
But I’m confused, this function is supported in OpenGL 3.1?
However, tomorrow, I try with other test.

I had a very similar problem (same symptoms). I’m using GLEW too. The “OpenGL Extensions Viewer” (useful app on the Mac App Store) told me that the extension GL_APPLE_vertex_array_object was available in the compatibility profile, but not in the core profile… Not sure what to make of that :S

Anyway, I managed to solve the issue by using the function glGenVertexArraysAPPLE instead (it was defined in GLEW).

Did you have the same issue for glBindVertexArray?