# OpenGL Difference between OpenGL 2.1 and 3.0?

## Recommended Posts

[color=#333333]This aspect has been bothering me for a while now: what are the differences I need to be aware of between OpenGL 2.1 and 3.0? I do know that 3 introduces a deprecation mechanism, but what types of functions have been deprecated? I'd like to know this so that I can look for OpenGL resources without having to be worried about whether a certain feature/practice is "deprecated" or not. I also don't really want to run away from tuts that use OGL 2 if there's still valuable information that applies to OpenGL in general.
Another thing I'm wondering about is how I can present newer OGL 3+ projects on older PCs that don't support it. What compatibility methods should I use to get the most benefits out of 3.0+ while still maintaining compatibility with older systems? Or will I have to resort to finding a capable PC to present my applications?

##### Share on other sites
You can freely download [url="http://www.opengl.org/documentation/specs/"]OpenGL specifications[/url]. Each GL3.0+ spec contains a section on deprecation which lists deprecated and already removed features.

Generally, to maintain compatibility with older GL you'll have to either disable some features of your application that rely on modern GL functionality or create additional implementation of those in terms of older GL version. For example, GL3+ code would use VAOs, while code for 2.1 would have to stick with manual vertex layout specification. This example is almost harmless, but in general such quirks can quickly saturate your maintenance effort, so you should think twice if you really need it. I'm not even mentioning shaders and GLSL version support

Furthermore, your initialization code will have to be written so that it creates proper context. Also you'll have to choose whether or not to rely on compatibility profile when writing modern GL code (i.e. using deprecated features). Currently, compatibility profile seems to be available for both nVidia and AMD, but the spec does not require that drivers provide it.

##### Share on other sites
The main difference in 3.0 is, that all fixed functions are gone. No more glMultMatrix, glLoadMatrix etc.
You have to do that with shaders.
GLM is a library that helps here, since it is written against the glsl spec and can dirctly be transmitted to the shader.
It also provides a replacement of glOrtho and glFrustum etc.
Have a look here:
[url="http://arcsynthesis.org/gltut/"]Learning Modern 3D Graphics Programming Through OpenGL[/url]

##### Share on other sites
[color="#333333"]I'm starting to like the idea of having different rendering configurations (disabling unsupported features according to system specs). I could make some graphics wrappers and use those to encapsulate various collections of dynamic libraries (holding the platform-specific functionality), depending on the OGL version supported. That way my code will be lighter and I can leave it to an installer to provide the correct libraries depending on the system specs.

This might be a bit more work, but it does give me a better perspective of how I should manage the platform-specific code. I suppose the real question is [i]how[/i] to write these theoretical "graphics wrappers"... Also, what are fixed functions? Do they basically manipulate the graphics pipeline?[/color]

##### Share on other sites
[quote name='AutoBot' timestamp='1312673718' post='4845603']
[color="#333333"]This might be a bit more work, but it does give me a better perspective of how I should manage the platform-specific code. I suppose the real question is how to write these theoretical "graphics wrappers"...[/color]
[color="#333333"][/quote][/color]
[color="#333333"]Trust me, as soon as you start digging into it, you'll see that this "a bit more work" will turn into "a lot of pain" [/color]
[color="#333333"][quote][/color]
[color="#333333"]Also, what are fixed functions? Do they basically manipulate the graphics pipeline?[/color]
[/quote]

NicoG meant "fixed-function" (i.e. non-programmable) pipeline.

##### Share on other sites
[quote name='AutoBot' timestamp='1312673718' post='4845603']
[color="#333333"]I'm starting to like the idea of having different rendering configurations (disabling unsupported features according to system specs). I could make some graphics wrappers and use those to encapsulate various collections of dynamic libraries (holding the platform-specific functionality), depending on the OGL version supported. That way my code will be lighter and I can leave it to an installer to provide the correct libraries depending on the system specs.

This might be a bit more work, but it does give me a better perspective of how I should manage the platform-specific code. I suppose the real question is [i]how[/i] to write these theoretical "graphics wrappers"... Also, what are fixed functions? Do they basically manipulate the graphics pipeline?[/color]
[/quote]

Fixed Functions is the non-programmable pipeline in OpenGL. As I said it is functions like glMultMatrix, glMatrixMode etc.

If you want the same code with 2 different backends, use the pimpl-idiom.
Like this, assuming C++:

[code]

class OpenGL
{
public:
virtual void draw_something()
{}
};

class OpenGL2 : public OpenGL
{
public:
virtual void draw_something() {}
};

class OpenGL3 : public OpenGL
{
public:
virtual void draw_something() {}
};

class FrontendAPI
{
public:
FrontendAPI(int OpenGLVersion)
{
if ( OpenGLVersion == 2 )
{
m_impl = new OpenGL2();
}
else if ( OpenGLVersion == 3 )
{
m_impl = new OpenGL3();
}
};

void draw_something()
{
m_impl->draw_something();
}

private:
OpenGL* m_impl;
}

[/code]

##### Share on other sites
[quote name='capricorn' timestamp='1312674166' post='4845604']
[quote name='AutoBot' timestamp='1312673718' post='4845603']
[color="#333333"]This might be a bit more work, but it does give me a better perspective of how I should manage the platform-specific code. I suppose the real question is how to write these theoretical "graphics wrappers"...[/color]
[color="#333333"][/quote][/color]
[color="#333333"]Trust me, as soon as you start digging into it, you'll see that this "a bit more work" will turn into "a lot of pain" [/color]
[/quote]

Yeah I suppose it can't be too easy to do it. Then again NicoG represented a good implementation that may make the pains a bit easier. I'll look into doing either that or just starting from 2.1 and adding stuff from there. I guess it's still good to get into the multiplatform stuff though.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627667
• Total Posts
2978539
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 10
• 10
• 12
• 22