1
\$\begingroup\$

I'm starting with OpenGL and found out that after OpenGL 3.x you must write your own shaders (think it's obligatory). Am I right here?

I have made some research but I can't seem to find the answer. If it's necessary to write the shaders for OpenGL 3 the I still can use 2.x right? Just because I'm just starting and OpenGL seems a little bit more level than I'm accustomed to. So I think I'll have a really hard time writing a shader myself.

P.S. My GPU only supports up to OpenGL 3.0. I think it's because of the drivers, I'm running a Linux distro that only has FLOSS (no proprietary software).

\$\endgroup\$
1
  • \$\begingroup\$ You can mix modern and older features using the compatibility profile in 3.0+ versions of OpenGL. So you can use VBOs for specifying geometry but the fixed function pipeline for the standard lighting model. \$\endgroup\$ – usm Feb 10 '15 at 7:13
2
\$\begingroup\$

In the OpenGL 3+ Core profile, the fixed function pipeline is deprecated or removed. However, all drivers by default give compatibility profiles which still have glVertex, glBegin and friends. You won't get as much performance out of these old functions (which is why they were removed), but they still work. You may use "OpenGL 3" with these old ways, but you'd be essentially writing an OpenGL 2 program. OpenGL only adds things in later revisions.

That being said, shaders are a core part of modern rendering, and learning how to use the old fixed function pipeline is mostly a matter of understanding how to setup the data the way OpenGL expected it back in the day. If you follow a tutorial like this one, you should be set up with a basic framework that replicates most of the old OpenGL fixed-function pipeline. What that pipeline did was:

  1. Set up the appropriate matrices, using functions like glRotate, glTranslate, and gluLookAt. This part of the tutorial uses the glm library to make this just as simple as OpenGL 2.
  2. Handle the transforms in the vertex shader. This is really rather simple. Using the common matrix setup, it is just glVertex = projection * modelview * vertex;
  3. Apply texturing/lighting automatically, assuming you set up everything correctly. Getting this to work is probably equivalent in difficultly to writing your own shaders and getting the textures & light data set up. This part explains lighting and this part explains textures.

The only tough part about shaders is that there is a lot of magic commands to get them compiled and the data for them loaded, but once you are through that boilerplate it really isn't that complicated.

\$\endgroup\$
1
  • \$\begingroup\$ Not all drivers support compatibility profiles. Mac OS X is the simplest example (Intel and Mesa are another example, but more complicated to explain). On OS X, you either get OpenGL 2.1 if you do not explicitly request a core context or 3.2+ core if you do. You could probably address all this just by writing "However, if your driver supports compatibility profiles," \$\endgroup\$ – Andon M. Coleman Feb 13 '15 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.