glGenBuffers 为 NULL,使用 glew 时会出现 0x0000000 访问冲突
>我有 Visual Studio C++ Express 和 NVIDIA GeForce 7900 GS。我正在使用 glew 来获取 openGL 扩展。调用 glGenBuffers 会崩溃,因为它是 NULL 指针。在进行调用之前,我有一个开放的 GL 上下文 ( wglGetCurrentContext() != NULL )。我在调用之前调用 glewInit() 。 glewGetString( GLEW_VERSION ) 返回 GLEW_VERSION_1_5。我做错了什么?是不是卡太旧了?是司机吗?
> 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
请记住在代码中进行
glewInit()
调用,以便获得指向 GL 函数的有效指针。希望有帮助。
Remember to make a
glewInit()
call in your code so that you get valid pointers to GL functions.Hope it helps.
如果没有看到您的代码,就很难判断,但是您尝试做的事情似乎可以通过使用 GLee。它旨在加载所有当前扩展,您可以检查支持的扩展,例如:
上面的内容是从 GLee 站点,但它显示了我试图展示的功能。
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. :
The above was shamelessly copy/pasted from the GLee site, but it displays the functionality I'm trying to showcase.
您需要在具有有效上下文的情况下调用 glewInit() 。那就是,在 glew 的世界中,在您调用 glfwMakeContextCurrent(myWindow); 之后
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);
我实际上在使用 GLEW 时遇到过这个问题。对我来说,它使 glGenerateMipmap 的函数指针无效。我通过简单地将指针恢复到适当的函数来修复它。这是我在 Linux 中的示例:
glXGetProcAddress 有一个等效的 WGL;我只是不记得这个名字了。尝试使用此方法手动恢复功能。如果您遇到许多函数为空,那么您的设置过程中肯定有问题。我记得必须恢复的唯一其他函数是 glGenVertexArrays、glBindVertexArray 和 glDeleteVertexArrays。如果您的 glGenBuffers 为 null,则 glBindBuffer 和 glDeleteBuffers 也可能为 null。 :(
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:
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. :(
通过检查 glGetString(GL_EXTENSIONS) 返回的字符串来测试所需的扩展是否确实受支持;如果它不存在,您就知道是什么导致了您的问题。
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.