开发者

OpenGL: How to check if the user supports glGenBuffers()?

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 t开发者_Python百科he 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.


Check this link. Maybe it will help you;)

if (GLEW_VERSION_1_5)
{
  /* You have OpenGL 1.5 */
}

Try glGenBuffersARB insted glGenBuffers; I think you only need to check 1.5 support;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜