http://www.opengl.org/discussion_boards/showthread.php/175645-Why-is-gl3-h-necessary


09-19-2011, 01:36 AM

Junior MemberNewbie
Join Date
Sep 2011
Posts
11

Why is gl3.h necessary?

Probably a silly question for an experienced OpenGL developer, but this is a beginners forum (and I am a beginner - more or less), so I guess it's the right place to ask.

I mean, this is the first library that I used where the header carries a version number, and I find that very bizarre. So, if someone could explain why that was done (or point me to some documentation that explains it), I would appreciate that.

Also, in regards to 3.x and higher: Do I have to create a 3.x context in order to use 3.x features, or does GLEW allow me to use them? My current understanding is that this is what GLEW is for ... although, I have to use it even for just basic shaders, and that's supposed to be in 2.x domain, from what I understand (it's like everything in 2.x is being treated like an extension on my system - I would like to know if this is generally how things work, or if it's something specific to my system that maybe needs fixing).


Senior MemberOpenGL Guru
Join Date
May 2009
Posts
4,413

Re: Why is gl3.h necessary?

I mean, this is the first library that I used where the header carries a version number, and I find that very bizarre.
That's because most libraries are not backwards compatible. Or if they are, then they are backwards compatible by not removing old APIs.

Various functions and enumerators were removed from OpenGL at version 3.1. The purpose of gl3.h is to provide a header that includes only the functions and enumerators relevant to 3.1 and above.

Do I have to create a 3.x context in order to use 3.x features, or does GLEW allow me to use them?
It depends on what you mean by that. If you're using GLEW, then you should not care about gl3.h; just use GLEW's headers and you'll be fine.

OpenGL since version 3.2 has been divided into two specifications: core and compatibility. As the name suggests, compatibility means that all of the removed functions are restored. Core means that they're gone.

On most platforms, you must specifically ask for an OpenGL core context, via wgl/glXCreateContextAttribs. If you do not, then you will get a compatibility context. MacOSX has a different way of dealing with it, primarily centered around the fact that they don't provide a compatibility implementation. You either get 2.1 or 3.2 core.

it's like everything in 2.x is being treated like an extension on my system
The OpenGL Wiki's Getting Started page explains this.

Junior MemberNewbie
Join Date
Sep 2011
Posts
11

Re: Why is gl3.h necessary?

Quote Originally Posted by Alfonse Reinheart
That's because most libraries are not backwards compatible. Or if they are, then they are backwards compatible by not removing old APIs.

Various functions and enumerators were removed from OpenGL at version 3.1. The purpose of gl3.h is to provide a header that includes only the functions and enumerators relevant to 3.1 and above.
So, it's not so much about new functions, as it is about breaking the old ones?

It depends on what you mean by that. If you're using GLEW, then you should not care about gl3.h; just use GLEW's headers and you'll be fine.
Yea, well, that's really what I'm asking: If GLEW makes gl3.h irrelevant (in terms of available features - where I can still access the latest GPU capabilities without gl3.h), then what's the point of having gl3.h in the first place?

Is it just to break the old stuff? Why can't GLEW be configured to do that (since it seems to be the arbiter of what's actually made available to the application)?

The OpenGL Wiki's Getting Started page explains this.
That means that all OpenGL functions have to be "loaded in" like that, extension or not - this is how I interpreted those 3 passages.

So, even with a 3.x context, I would still need GLEW.

PS: 

Hey, I've been reading your tutorial - thanks for making that: You can remove deprecated features from the API, but old documentation tends to linger like a bad smell.

Your modern tutorial is a breath of fresh air.

@V-man

Thanks for the info.