Wednesday, November 22, 2006

Using OpenGL in SWT with Java 5

Following my last idea about an OSGi based game engine, I thought I'd start experimenting with various game engine stuff. So far, I've managed to get a bundle that has OpenGL binding working quite nicely. I used LWJGL, and created two bundles for it:
1) org.lwjgl -- the Java classes and source code is in this bundle.
2) org.lwjgl.win32 -- platform specific fragment for the above bundle, which has the Windows DLL-s and OSGi knows how to load them because I specified the Bundle-NativeCode header for them in the manifest.

I used the SWT OpenGL support to test this and after experimenting with some snippets, and copying some code from the famous NeHe OpenGL tutorials, I thought that since I was using Java 5, I could do the following:

import static org.lwjgl.opengl.GL11.*;

to import the static methods and lo and behold -- now I can paste the C code from NeHe tutorials into Java files without making any changes! :)

Now I'm getting the urge to start learning OpenGL again. I've already done some of the NeHe tutorials in C++, but I never really liked to write code in C or C++ that much.

Saturday, October 07, 2006

Idea: OSGi based game engine

There has been a little talk in the Eclipse related blogs about Eclipse's relationship with games. Which currently seems to be minimal. Here's an interesting idea for a new Eclipse Technology project: an OSGi-based game engine. It could be named EDGE for Eclipse Dynamic Game Engine. Another (sub-)project would add developement tools.

A project like this should define API/interfaces for sub-systems that are required by most game engines and create exemplary open source based implementations. There are some fine open source engines out there (there are others, but these are the ones I know about):
  • OGRE graphics engine. Someone else develops a Java wrapper for it
  • ODE physics engine. There seems to be a plethora physics engines out there lately, but I'm not sure how many are open source. I remember that ODE is one of them. It has a Java wrapper too
  • OpenAL 3D audio library. I think there are Java wrappers for this too, but you'll have to find the links yourself.
Maybe there are even pure Java solutions out there that are better to use in Java? I looked into game engines before I became a Java fan, so I'm not very aware how good the Java ones are.

Other things needed:
  • entity/actor system
  • a scripting language
  • the glue to hold it all together
  • 2D graphics engine (start simple)?
  • extensions for specific genres
There are efforts like this out there, like Yake (although I'm not very familiar with them), but we all know there is no other component platform like OSGi (+ Equinox) :)