Need to translate from OpenGL 2.1 code to at least OpenGL 3.3

I have some (a lot) of old win32 C code that is OpenGL 2.1 compliant. The code still work on today’s computers, but is in great need of support for shaders. Thus I need to translate it to at least OpenGL 3.3. So in interest of spending 1 month that I have instead of 1 year that I do not have doing the conversion. I have this questions.

Is there any library that would emulate the missing functionality of OpenGL 2.1 under OpenGL 3.3? Specially lines with patterns.

Is there a way to automatize the process of translating from 2.1 to 3.3?

Is there a way to at least identify the parts that are incompatible at compile time?

First point: there might be one. But to my opinion, you shouldn’t.

Second point: There is no since this is the essence of it: this is no more fixed, but flexible, programmable. So which way to go ? It all depends on what you want to achieve.

Third point: Yes. Use a header that provides only the version you are targetting. I guess this might help you.

[QUOTE=rxantos;1284276]I have some (a lot) of old win32 C code that is OpenGL 2.1 compliant. The code still work on today’s computers, but is in great need of support for shaders. Thus I need to translate it to at least OpenGL 3.3.
[/QUOTE]
Why? OpenGL 2.1 supports shaders, and much of the fixed-function pipeline’s state (matrices, material parameters, lighting parameters, pre-defined vertex attributes) is available to the shaders.

The main features which were added between 2.1 and 3.3 are framebuffer objects (FBOs), vertex array objects (VAOs) and instanced rendering.

Also, your existing code should work with a 3.3 compatibility profile, so you don’t necessarily need to re-write it to use more modern features, unless you need to support Macs (which don’t support the compatibility profile) or OpenGL ES (which is somewhat compatible with modern desktop OpenGL, but not legacy OpenGL).

Re-writing it to use modern OpenGL would be ideal, but IMHO using the compatibility profile would be preferable to an automated conversion or some kind of emulation layer (these are sometimes used to port legacy code to OpenGL ES, which doesn’t support e.g. glBegin/glEnd, but they tend to be tailored to the specific code being ported).

Just so the OP is 100% clear, the following is a non-exhaustive list of “modern” rendering features that are fully implemented under OpenGL 2.1; depending on where one looks online, one may get the impression that these are somehow bleeding-edge features; they’re not; they’re old, they’re robust and they’re well-supported.

[ul]
[li]3D textures[/li][li]Multitexture[/li][li]Cube maps[/li][li]Additional blend modes[/li][li]Depth textures[/li][li]Basic multi-draw[/li][li]LOD bias[/li][li]Vertex buffer objects[/li][li]Occlusion queries[/li][li]Generic vertex attributes[/li][li]Vertex shaders via GLSL[/li][li]Fragment shaders via GLSL[/li][li]Basic multiple render targets[/li][li]Non-power-of-two textures[/li][li]Pixel buffer objects[/li][/ul]

Your GL 2.1 program is able to use these features right now, and in some cases you can incrementally add them to performance-critical or higher-quality code paths.