Results 1 to 4 of 4

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

  1. #1
    Newbie Newbie
    Join Date
    Oct 2016
    Posts
    1

    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?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    459
    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.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,105
    Quote Originally Posted by rxantos View Post
    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.
    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).

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    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.


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


    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.

Similar Threads

  1. Translate and scale a rectangle with OpenGL 3+
    By Wah0airo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-29-2018, 03:57 AM
  2. how can i translate a clipping plane using keyboard in opengl?
    By wishi riz in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 09-18-2015, 01:07 AM
  3. Replies: 3
    Last Post: 07-09-2014, 07:19 AM
  4. Is this correct code to translate a matrix?
    By skippyj777 in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 08-25-2000, 12:56 PM
  5. Represent Rotate and Translate by one Translate
    By Luin in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-02-2000, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean