问题
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!
回答1:
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.
回答2:
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;
来源:https://stackoverflow.com/questions/4317062/opengl-how-to-check-if-the-user-supports-glgenbuffers