Jump to content
  • Advertisement
Sign in to follow this  
guywithknife

OpenGL OpenGL 2 questions

This topic is 4372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been playing with OpenGL over the past while and want to use some of the OpenGL 2 core functions and am having some problems. I can't really find any information on importing them into my program. I downloaded the latest glext.h from he 3dlabs website (i think it was) and all the prototypes are there. How do I go about actually using them? Using GLEW, everything works grand. I just call glewInit() and I'm set, but how do I access them without using GLEW (I was using GLFW for everything else and as GLFW has extension handling functions, I'd rather use those than using a seperate library just for extensions). So, my question is, do I have to manually create the function pointers and then use the GLFW extension mechanism to load, for example, glCretaeProgramARB, or is there another way I can access it? I figured glCreateProgram was the OpenGL 2 core function and glCreateProgramARB is the 1.5 extension? If so, how do I use the OpenGL 2 version without making GLEW do it for me? OpenGL 2 has been doing nothing but confuze me over the past two days... Any and all help is greatly appreciated. THANKS IN ADVANCE!!

Share this post


Link to post
Share on other sites
Advertisement
You are correct, the ARB suffix is dropped in the 2.0 spec on these functions. The OpenGL Shading Language (the Orange Book) makes mention of this.

Loading the functions is pretty straight-forward, except that it gets tedious after the 10th or so function. :)

The following uses SDL to get the function address, through GetProcAddress from Win32 also works (in fact, it's the same thing):

1) Typedef the function pointer type:
typedef GLuint (APIENTRY *glCreateProgram_ptr)(void);

2) Create a function pointer variable:
glCreateProgram_ptr glCreateProgram;

3) Initialize it by finding the function inside of the OpenGL library:
if(0 == (glCreateProgram = reinterpret_cast<glCreateProgram_ptr>(SDL_GL_GetProcAddress("glCreateProgram"))))
return false;

4) Call it like normal:
GLuint a_program = glCreateProgram();

Share this post


Link to post
Share on other sites
Oh, Ok.
So I get the address as I would with any other extension but the name is (using glCreateProgram as an example again) "glCreateProgram" for the core function and "glCreateProgramARB" for the extension?

Share this post


Link to post
Share on other sites
Quote:
Original post by issch
Oh, Ok.
So I get the address as I would with any other extension but the name is (using glCreateProgram as an example again) "glCreateProgram" for the core function and "glCreateProgramARB" for the extension?


Yes, you are correct. That said, if you used either, I'm assuming they would both point to the same function entry-point in the DLL.

I'm pretty sure the keeping of the extension names is only for backward-compatibility, since both versions of the function really do the same thing.

Share this post


Link to post
Share on other sites
Quote:
Original post by taby
Yes, you are correct. That said, if you used either, I'm assuming they would both point to the same function entry-point in the DLL.

I'm pretty sure the keeping of the extension names is only for backward-compatibility, since both versions of the function really do the same thing.


Ah, you shouldn't assume that, sometimes there are changes between the ARB and core functionality which effects how the functions work.

As such the two entry points might not be the same and the functionality might also differ, so don't confuse the two.

However, I still don't see why the OP doesn't let GLEW or GLee take care of this problem? I know for sure GLee has the most recent extensions and core functionality added and I'd be surpirsed if GLEW doesn't as well..

Share this post


Link to post
Share on other sites
I read someplace not to assume them to be the same too.

I have used GLEW and, oike I said, everything worked fine. The reason I would preffer to avoid using a library just to do this is because the library I'm using for everything else, GLFW, already has an extension mechanism and I'd preffer to make use of it rather than using yet another library just to do something that a library I'm already using does too.

Of course, now I have to manually add the functions whilst if I use GLEW (and GLee, by the sounds of things) I won't, so perhaps I'll end up using one of those anyway.

The purpose of this thread was for me to figure out how to work with OpenGL 2 core functions, without forcing me to use any particular library. Now I know.

Thanks for taking the time to reply!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!