2010-11-30 37 views
2

我检查了文档,它说OpenGL版本必须至少1.5才能使glGenBuffers()工作。用户有版本1.5,但函数调用会导致崩溃。这是文档中的错误还是用户的驱动程序问题?OpenGL:如何检查用户是否支持glGenBuffers()?

我使用这个glGenBuffers()为VBO,我如何检查用户是否有此支持?

编辑:使用GLEW与glewInit() IM初始化VBO

EDIT2:我得到了它的用户正与glGenBuffersARB()函数调用。但即时通讯仍在寻找一种方法来找出我应该什么时候应该使用glGenBuffers()以及何时应该使用glGenBuffersARB(),以及在什么时候应该使用VertexArrays,如果没有支持VBO函数调用的话。

我还发现if(GLEW_VERSION_1_5)返回false,但GL_VERSION给出1.5.0,这只是没有任何意义!

+0

您是否在调用之前验证了您有有效的OpenGL上下文? – Bart 2010-11-30 18:28:49

+0

我不知道那是什么,它在哪里检查。 – Newbie 2010-11-30 18:32:53

+0

如果你不使用VBO,在OpenGL渲染工作正常吗? – Bart 2010-11-30 18:35:33

回答

0

检查此link。也许它会帮助你;)

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

尝试glGenBuffersARB insted glGenBuffers;我认为你只需要检查1.5的支持;

2

我现在要告诉你远离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 << "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.