Mark Watt
Mark Watt

Reputation: 29

glGenBuffers is NULL giving a 0x0000000 access violation when using glew

> I have visual studio c++ express and a NVIDIA GeForce 7900 GS. I'm using glew to get at the openGL extensions. Calling glGenBuffers crashes as its a NULL pointer tho. I have an open GL context before I make the call ( wglGetCurrentContext() != NULL ). I'm calling glewInit() before the call. glewGetString( GLEW_VERSION ) is returning GLEW_VERSION_1_5. What am I doing wrong ? Is the card too old ? Is it the driver ?

Upvotes: 2

Views: 6636

Answers (5)

grenangen
grenangen

Reputation: 188

You need to call glewInit() post having a valid context. And that would be, in the world of glew, after you've called glfwMakeContextCurrent(myWindow);

Upvotes: 1

Cacho Santa
Cacho Santa

Reputation: 6924

Remember to make a glewInit() call in your code so that you get valid pointers to GL functions.

Hope it helps.

Upvotes: 6

datenwolf
datenwolf

Reputation: 162367

Test if the desired extension is actually supported by checking the string returned by glGetString(GL_EXTENSIONS); if it's not there you know what's causing your problems.

Upvotes: 0

TheBuzzSaw
TheBuzzSaw

Reputation: 8836

I have actually run into this problem with GLEW. For me, it was nullifying the function pointer for glGenerateMipmap. I fixed it by simply restoring the pointer to the appropriate function. This is my example in Linux:

glGenerateMipmap = (void(*)(GLenum))
    glXGetProcAddressARB((GLubyte*)"glGenerateMipmap");

There is a WGL equivalent for glXGetProcAddress; I just don't remember the name off the top of my head. Try manually restoring the functions using this method. If you come across many functions that are null, something is definitely wrong in your setup process. The only other functions I recall having to restore were glGenVertexArrays, glBindVertexArray, and glDeleteVertexArrays. If your glGenBuffers is null, odds are that glBindBuffer and glDeleteBuffers are null as well. :(

Upvotes: 0

James
James

Reputation: 5425

Without seeing your code it would be difficult to tell, but what you are attempting to do seems like it could be helped a lot by using GLee. It is designed to load all current extensions and you have the ability to check what is supported, e.g. :

#include <gl\GLee.h>          // (no need to link to gl.h) 

...

if (GLEE_ARB_multitexture)    //is multitexture support available?
{
  glMultiTexCoord2fARB(...);  //safe to use multitexture
}
else
{
 //fallback
}

The above was shamelessly copy/pasted from the GLee site, but it displays the functionality I'm trying to showcase.

Upvotes: 1

Related Questions