PDA

View Full Version : glGenVertexArrays Access violation Error



enigmagame
01-10-2010, 07:31 AM
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?
Thanks!

enigmagame
01-10-2010, 08:02 AM
I've added this code:


if(!GLEW_ARB_vertex_array_object)
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?
Thanks.

dletozeun
01-10-2010, 09:12 AM
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?
Thanks!

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

enigmagame
01-10-2010, 09:20 AM
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);

glRenderer->init();

while(app.IsOpened())
{
glRenderer->draw();
app.Display();
}

return 0;
}

and the CGLRenderer class:


void CGLRenderer::init()
{
glewInit();

if(!GLEW_ARB_vertex_array_object)
std::cout << "ARB_vertex_array_object not available." << std::endl;
}

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

glGenVertexArrays(1, &amp;vao);

//Some code...
}

dletozeun
01-10-2010, 11:23 AM
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.

Alfonse Reinheart
01-10-2010, 01:29 PM
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.

dletozeun
01-10-2010, 02:59 PM
ARB_vertex_array_object is a core ARB extension. As such, its entrypoints and enums do not have an extension suffix

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

enigmagame
01-10-2010, 06:12 PM
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.

JamesBedford
10-09-2011, 04:28 PM
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?

V-man
10-10-2011, 02:50 AM
http://www.opengl.org/wiki/OpenGL_Loading_Library