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).

So, a lot of confusion there, as you can see - any clarity would be appreciated.

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.

Do I have to create a 3.x context in order to use 3.x features, or does GLEW allow me to use them?

You create the GL 3.x context, then you use GLEW to get the function pointers for GL.

There is an app for that
http://www.opengl.org/wiki/Tutorials

Not all of those are using GLEW.
This one
Tutorial: OpenGL 3.1 The First Triangle (C++/Win)

and this one
Tutorial1: Rendering shapes with glDrawRangeElements, VAO, VBO, shaders (C++ / freeGLUT)

are using GLEW.

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.

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)?

GLEW is an arbiter, not the arbiter. It is one extension loading library among many. It is probably the oldest GL loader around. There are others, some of which do only cover core stuff.

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

Yes.

Ah, I see. Thanks for clearing that up.