tags:

views:

106

answers:

2

Hi, quite new to the subject, and in college we were provided with the .dlls each time we needed them. But I never had any idea what actual version I was using, what extensions I was using...This is very confusing to be honest. I couldn't find any download link on the official khronos site. Clicking on the OpenGL SDK link, just presents me with more documentation. I'm used to DirectX, which makes it pretty clear what version you are using. (by the device you create).

  1. How would I start using OpenGL 4.0 today?
  2. How would I enable an extension?
  3. How do I know what version of OpenGL my machine is capable of?
  4. Did anything big change in 4.0? I don't think I need to care about old versions because I code OpenGL purely for educational purposes for at least another 2 years.

Thank you.

+2  A: 

How would I start using OpenGL 4.0 today?

Simple answer: today, it's probably hard. There is almost no commodity hardware supporting OpenGL 4.0 available and the specification itself has only been released four months ago.

How would I enable an extension?

Use a solution like GLEW or GLee.

How do I know what version of OpenGL my machine is capable of?

See answer 2, both packages provide that info.

Did anything big change in 4.0? I don't think I need to care about old versions because I code OpenGL purely for educational purposes for at least another 2 years.

You definitely need to care about "old" versions, see answer 1, especially because not even OpenGL 3.x support is widely available today.

For some further information, you might want to take a look at this question: http://stackoverflow.com/questions/3296014/how-many-users-could-run-software-that-uses-opengl-3-x

Greg S
May I correct you on the fact that consumer hardware had had OpenGL 3.x for a couple of months now. Nvidia and ATI have done a nice job getting us support fast on the newer cards (which include everything back to 2 years (!)). Don't know about Intel, but if using fancy OpenGL is a concern, Intel wouldn't be an option, really.
rubenvb
So what do I need to download where to be able to use OpenGL? Whatever the latest supported version is?
Blub
NVIDIA supports OpenGL 4.0 in Windows driver 197.44 and Linux driver 195.36.07.04 and later on all of the 400-series "Fermi" chips. I believe ATi supports it on their 5000 series. OpenGL 3 support comes with every card since the GeForce 8-series and I think the Radeon 3000-series.
greyfade
@Blub: as pointed out by Tomaka17, OpenGL is not really a library but a standard. There is no OpenGL SDK you can download. Instead, use a library like SDL (http://www.libsdl.org/), which tremendously simplifies getting your first OpenGL window on the screen.
Greg S
What do you mean by "support comes with the card". Where do I find the .dll or lib which I need to include? I need to include some headers in my visual studio project, what I'm asking is, where to get those and everything else that is necessary for OpenGL development. I'm sure SDL also got it's libraries from somewhere right?
Blub
@Blub: a quick google search turned up this: http://thoughtsfrommylife.com/article-748-OpenGL_and_Visual_Studio_Express_2008
Greg S
You have to include <gl/gl.h> and link with OpenGL32.lib. In fact the OpenGL functions you call come directly from you video drivers but OpenGL32.lib acts as a bridge.
Tomaka17
for everbody else: apparently the header and .lib already exist in a folder: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
Blub
+2  A: 

OpenGL is not a library with different version numbers, and such. Instead it is one big standard which graphics drivers must support by themselves. Consequently, some graphics cards may not support latest OpenGL versions, while in the future some cards may not support older versions.

You don't need to include a different header or link to a different library if you use OpenGL 1.0 or if you use OpenGL 4.0. However to use OpenGL 4.0 you have to detect if it is supported by the machine your program is running on. For the moment, only very recent GPUs support OpenGL 4.0. You may have better chances with OpenGL 3.0

If you are on Windows, include "gl/gl.h" and link your program with "OpenGL32.lib"

Once your program is started, you can detect the version of OpenGL supported by the GPU or enable an extension using glString and wglGetProcAddress. However I strongly advise you to use a third-party library (GLee being my favorite).

Programming with OpenGL is quite different than programming with DirectX. DirectX is guaranteed to support all the functionnalities of the version you're using. When you code something with OpenGL, you should rather detect each functionnality individually.

For example, say you want to use a vertex buffer. Your code should be like this:

  • if OpenGL version >= 2, then use glGenBuffers, glBindBuffer, etc.
  • else, allocate and fill data in RAM

You can see some examples in the GLee page I linked above

Of course you can't do this for everything. Shaders, for example, can't be done without a certain extension and you should simply display an error message if they are not available.

More complicated: starting from OpenGL 3, some functions have been deprecated. You now have two ways to initialisate OpenGL:

  • the new way (wglCreateContextAttribsARB on Windows) where you precise the minimum OpenGL version you want
  • the old way (wglCreateContext) which requests a minimum of OpenGL 1.1 (recent versions being accessible, too)

If you request a version superior to OpenGL 3, the deprecated functions are theorically only accessible thanks to the extension ARB_compatibility which may be supported or not by the card. For the moment ARB_compatibility is supported by all existing GPUs but in the future it may no longer be so.

If you request a version inferior to OpenGL 3, these functions are not considered deprecated but the initialisation will fail if they are no longer supported by the card.

Tomaka17
So is Glee the new Glut ?
Martin Beckett
GLUT is a portable library which allows you to create an OpenGL window and retrieve user input, while GLee allows you to easily use functions coming from extensions or more recent versions
Tomaka17
Note that GLEW supports OpenGL 4.0, while GLee only supports OpenGL up to version 3.0.
Greg S
GLEW and GLee are almost the same, I personnally prefer GLee because it is lighter but the difference is not big
Tomaka17
Alright, it looks like we used GLUT in all our programming samples in college. I'll use freeglut or something like that. I'll mark this as answer because it has much more info related to what I asked.
Blub