Using Both LWJGL and JOGL

Hello,

Looking for some advice here. I have a hang up with having my code work both with LWJGL and JOGL. However I am completly stuck with creating a generic interface to both. Is there anything really wrong with just creating an interface with all the gl commands I will use? Somehow I have in my head that that won’t work that great seems a waste of having methods that only call one line, but that is the best way to generically call gl methods and have total flexibility.
For example I want an interface called Renderable that has the method render(GLContext), now GLContext will be the interface and will have all the gl methods that I need on it. Then obviously I have an LWJGL or JOGL class that will create an appropriate GLContext. I am probably not making any sense and should just go with LWJGL but anyone have any advice?

Doesn’t Xith3D do something like this already?

It means that you’re not tied to a given implementation. This also lets you implement a software only renderer should you ever need to.

I like the idea but it could be a lot of work to put in before you even start your game or whatever.

Andy.

We did a similar thing for 2D a while ago in the J2DA project.

http://j2da.sf.net

However, the abstraction was initially over Java2D and JOGL. It would have been pretty easy to implement an additional layer to support LWJGL.

As advice goes a wise man once remarked to me that if you’re just “playing” then abstraction of this type can be good fun. If you writing a game you want to complete then make an informed choice on rendering layer and stick to it. *

Kev

  • Strictly, he wasn’t as eloquent but its what he meant :wink:

LWJGL utils package already contains a GL interface with GL1.1 to 1.5 and all the extensions, and a class that implements it using LWJGL. You could write a fairly simple adapter for JOGL that implemented that interface (and if you do we’d be grateful if you gave it to us ;)). Expect it to largely be a waste of time, as Kev sort of says…

Alternatively why not use a cut-down JOGL to create your contexts for you if you need AWT, and then use LWJGL to render if you prefer the API.

Cas :slight_smile:

I have a library with Typhon that allows this. A lot of code at least for Auriga3D can use the generic library; loading levels, etc. Auriga3D allows for separate renderering components/plugins that are specific to LWJGL and JOGL in order to be as efficient as possible. The actual renderering loop to display a level in Auriga3D is not long.

I will be releasing Typhon/Auriga3D most likely in December.