How do I determine what extension a function belongs to?

Started by
3 comments, last by sammyjojo 17 years, 7 months ago
Okay so I learned about no OpenGL functions past 1.1 being defined in the Windows gl.h and how I have to load everything else with the extension hooey, but one thing that doesn't really get explained is how I'm supposed to figure out what extension name the functions I want to use belong to. For example I want to use glGenBuffers() which my book says is defined in OpenGL 1.5, but that doesn't tell me what string to look for when I search though the string returned from glGetString(GL_VERSION). I kinda figured out what extension that one belongs to because in my book it's under the buffer object section of using vertex arrays. So I went to the OpenGL Extension Registry and looked for "buffer object" and found GL_ARB_vertex_buffer_object. After clicking on that I found that the function was defined under that extention, but the name is a little different (genBuffersARB). So my question is, how am I supposed to figure out the extension name that the functions I want to use belong to? Is it by doing what I did? Also can I assume that if GL_ARB_vertex_buffer_object is available that glGenBuffers() is also available since genBuffersARB() is? Just so you know, I know there are libriaries where people have already taken care of the extensions (I read the FAQ), so please don't tell me to just download that. I'm just trying to understand how all this stuff works and when I do and if I still think it's a pain... I'll use it :)
Advertisement
Quote:Original post by sammyjojo
So my question is, how am I supposed to figure out the extension name that the functions I want to use belong to? Is it by doing what I did?

Would probably be easier to search glext.h. Functions and constants are nicely listed in groups of corresponding extension name or version.

Quote:Original post by sammyjojo
Also can I assume that if GL_ARB_vertex_buffer_object is available that glGenBuffers() is also available since genBuffersARB() is?

No. They are technically different things. glGenBuffersARB is the function in the extension, and glGenBuffers is the one that was promoted into the core. Some functions change behaviour, or maybe even signature, when being moved into the core. Even if it doesn't, you can't assume they are both present.

Quote:Original post by sammyjojo
Just so you know, I know there are libriaries where people have already taken care of the extensions (I read the FAQ), so please don't tell me to just download that. I'm just trying to understand how all this stuff works and when I do and if I still think it's a pain... I'll use it :)

If you need to use a function, it's always good to know what extension, or version, they require. Otherwise you may distribute an application and you have no clue what extensions or versions it needs to run properly.
Quote:Original post by Brother Bob
Would probably be easier to search glext.h. Functions and constants are nicely listed in groups of corresponding extension name or version.


I've looked through glext.h and didn't quite notice that before (didn't look hard enough), but just to continue with my example. I see that glGenBuffers is defined near GL_VERSION_1.5 in glext.h, is that an extension name? Can I just assume that if the version number that I get from glGetString(GL_VERSION) is 1.5 or higher that I can use glGenBuffers after I get a function pointer to it?

I guess the thing that I'm trying to get at is, if I'm using OpenGL on windows, which doesn't have header support for anything higher then 1.1, how am I supposed add support for 1.2 and higher functions. I read the article in the FAQ and it says to treat everything else like and extension, but the way they talk about about makes it seem like I should use glGenBuffersARB by checking to see if the GL_ARB_vertex_buffer_object extension is available. According to you though, the normal gl version and the ARB version of the functions may not be the same, so what am I supposed to do to check to see if the normal gl function exists, just the opengl version on the machine?
glGenBuffers being listed under GL_VERSION_1_5 indicates that as of OpenGL 1.5 it is promoted to a core function. That's because it's not an extension function (all of which have the extension category acronym after the function name in caps). If, however, you were to search for glGenBuffersARB, you would find it under GL_ARB_vertex_buffer_object.

EDIT: And yes, if you want to know whether glGenBuffers is available, just see whether the version number returned by glGet() is >= 1.5.
Thanks for the help :)

This topic is closed to new replies.

Advertisement