glGenBuffers 为 NULL,使用 glew 时会出现 0x0000000 访问冲突

发布于 2024-10-17 21:24:29 字数 273 浏览 7 评论 0原文

>我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蓬勃野心 2024-10-24 21:24:29

请记住在代码中进行 glewInit() 调用,以便获得指向 GL 函数的有效指针。

希望有帮助。

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

Hope it helps.

独享拥抱 2024-10-24 21:24:29

如果没有看到您的代码,就很难判断,但是您尝试做的事情似乎可以通过使用 GLee。它旨在加载所有当前扩展,您可以检查支持的扩展,例如:

#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
}

上面的内容是从 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. :

#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.

漆黑的白昼 2024-10-24 21:24:29

您需要在具有有效上下文的情况下调用 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);

飘过的浮云 2024-10-24 21:24:29

我实际上在使用 GLEW 时遇到过这个问题。对我来说,它使 glGenerateMipmap 的函数指针无效。我通过简单地将指针恢复到适当的函数来修复它。这是我在 Linux 中的示例:

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

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:

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. :(

沐歌 2024-10-24 21:24:29

通过检查 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文