OpenGL 1.1 to OpenGL 3 wrapper

Started by
0 comments, last by TheChubu 11 years ago

Hi. I came across TWL (Themable Widget Library, http://twl.l33tlabs.org/) when looking for a GUI library for Java + OpenGL (LWJGL).

It looks pretty nice and there is an editor and all. The drawback is that is coded against OpenGL 1.1 spec and I'm using OpenGL 3.3 core.

So I looked at the sources to see if I could code a wrapper to get TWL working with my core context. Thing is, OGL 3 is all the OGL I know, so I don't know exactly how OpenGL 1 calls would be "translated".

I know only renderer>lwjgl has GL1.1 calls, which is a 2.5k line long package, so its not that bad (rest of the project is 35k line long or so).

So far I've seen a few matrix stack calls, attrib stack calls, calls for things I have no experience so far (textures, fixed function anti aliasing) and a few things that I don't quite know how to replace (GL_QUADS and GL_LINE_LOOP are deprecated in 3.3 i think).

As you probably notice, I'm not quite experienced yet. While I have gotten to the point of implementing soft per fragment shading with shader programs (with normals math and all that) there are quite a few spots I've jumped over without touching them (texturing being one of them). Besides the point that even if I manage to translate the GL11 calls, I don't how I would integrate the GUI library into my project (passing around my context to the GUI renderer I think?).

Do you think I'm biting more than I can handle? I know I could just create a compat context and see how it works but making the wrapper to 3.3 core sounds like a good learning experience. And while I don't have the time to do this right now (finals, exams, courses and all that good stuff) I'll probably want to do it in the near future.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Advertisement

Can't you just create your context with CONTEXT_COMPATIBILITY_PROFILE_BIT? This will ask for a compatibility context, which supports all deprecated functionality (including OpenGL 1.1), so you should be able to plug in this library without any modifications.

Although support for the compatibility profile is optional, I don't know a single implementor that doesn't support it (that's unlikely to happen any time soon, too). In fact, I remember a guy from nVidia holding a lecture once (some title like "What's new in OpenGL 3") which basically advised to always use it because your programs don't get any slower and most/all of the deprecated functionality is well-supported in hardware anyway, so there was no reason not to use it. I'm somewhat disinclined to agree with that statement, but if that's an official statement from an IHV, then that's what it is. They gotta know better than you and me.

Found it, that "nVidia guy" was Mark Kilgard, see page 97:

Lots of easy-to-use, effective API got labeled deprecated [...] Best advice for real developers: Simply use the “compatibility” profile.

No, your program won’t go faster for using the “core” profile. It may go slower because of extra “is this allowed to work?” checks.

Can't you just create your context with CONTEXT_COMPATIBILITY_PROFILE_BIT?

This is a quote, the editor just bricks it when I press backspace for some reason:

"Do you think I'm biting more than I can handle? I know I could just create a compat context and see how it works but making the wrapper to 3.3 core sounds like a good learning experience."

Basically that. I know that a compatibility context doesn't affects your performance (I believe Valve stated that in their GDC presentation on OpenGL recently) . I was asking if I you thought I could make it with my current experience (probably not glMaterial for example) and if you could make any recommendation.

I thought of checking all the GL11 calls TWL does, categorize them and see what kind of structures I'd need to support them (matrix stack for glMatrix, some boolean state flags, buffers to hold glVertex call data, and so on) and slap everything in a single class with static methods, replacing the "GL11.glVertex" call with "wrapper.glVertex" or something like that (I thought of AGL.glVertex but AGL is already Apple's naming scheme for OpenGL calls heh).

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

This topic is closed to new replies.

Advertisement