本文介绍了OpenGL:如何检查用户是否支持glGenBuffers()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查过文档,它说OpenGL版本必须至少为1.5,使 glGenBuffers()工作。用户具有版本1.5,但是函数调用将导致崩溃。这是文档中的错误,还是用户的驱动程序问题?



我使用此 glGenBuffers() 编辑: im使用glew与 glewInit()初始化VBO



Edit2: > glGenBuffersARB()函数调用。但我仍然在寻找一个方法来找出什么时候应该使用 glGenBuffers()和什么时候应该使用 glGenBuffersARB()



我也发现 if(GLEW_VERSION_1_5)对用户返回false,但 GL_VERSION 给出1.5.0,这是没有任何意义的!

解决方案

我要告诉你现在远离GLEW或任何这些库主要是因为它们是无用的,这是我一直这样做。

  #ifndef STRINGIFY 
#define STRINGIFY(x)#x
#endif
#ifdef WIN32
#include< windows.h>
#define glGetProcAddress(a)wglGetProcAddress(a)
#endif
#ifdef X11
#define glGetProcAddress(a)glXGetProcAddress(\
reinterpret_cast< const unsigned char *>(a)\

#endif

#ifndef GetExtension
#define GetExtension(Type,ExtenName)\
ExtenName = (Type)\
glGetProcAddress(STRINGIFY(ExtenName)); \
if(!ExtenName)\
{\
std:cout< 您的计算机不会\
<< 支持GL扩展:\
<< STRINGIFY(ExtenName)\
<< std :: endl; \
exit(1); \
} \
else \
{\
std :: cout< 加载扩展:\
<< STRINGIFY(ExtenName)\
<< std :: endl; \
}
#endif

//然后只需使用:D
GetExtension(PFNGLGENBUFFERSARBPROC,glGenBuffersARB)
//做这个
#undef GetExtension
#undef glGetProcAddress
//然后你也可以取消定义STRINGIFY宏
//虽然它派上用场了。


I checked docs, and it says OpenGL version must be at least 1.5 to make glGenBuffers() work. The user has version 1.5 but the function call will cause a crash. Is this a mistake in the docs, or a driver problem on the user?

I am using this glGenBuffers() for VBO, how do i check if the user has support for this?

Edit: im using glew with glewInit() to initialize VBO

Edit2: I got it working on the user with glGenBuffersARB() function calls. But im still looking a way to find out when should i use glGenBuffers() and when should i use glGenBuffersARB() AND when should i use VertexArrays if none of the VBO function calls are supported.

I also found out that if(GLEW_VERSION_1_5) returns false on the user, but GL_VERSION gives 1.5.0, which just doesnt make any sense!

解决方案

I'm going to tell you now to stay far away from GLEW or any of these libraries mostly because they're useless, this is how I have always done it.

#ifndef STRINGIFY
  #define STRINGIFY(x) #x
#endif
#ifdef WIN32
  #include <windows.h>
  #define glGetProcAddress(a) wglGetProcAddress(a)
#endif
#ifdef X11
  #define glGetProcAddress(a) glXGetProcAddress ( \
    reinterpret_cast<const unsigned char*>(a)     \
  )
#endif

#ifndef GetExtension
  #define GetExtension(Type, ExtenName)     \
    ExtenName = (Type)                      \
    glGetProcAddress(STRINGIFY(ExtenName)); \
    if(!ExtenName)                          \
    {                                       \
      std:cout << "Your Computer Does Not " \
               << "Support GL Extension: "  \
               << STRINGIFY(ExtenName)      \
               << std::endl;                \
      exit(1);                              \
    }                                       \
    else                                    \
    {                                       \
      std::cout << "Loadded Extension: "    \
                << STRINGIFY(ExtenName)     \
                << std::endl;               \
    }
#endif

// then just use this :D
GetExtension(PFNGLGENBUFFERSARBPROC, glGenBuffersARB)
// after your done you can do this
#undef GetExtension
#undef glGetProcAddress
// you can then also undef the STRINGIFY macro
// though it does come in handy.

这篇关于OpenGL:如何检查用户是否支持glGenBuffers()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 16:14