Nov 16, 2009

Dusting Off sdljava

I've been wanting to use Scala for little graphical apps fairly often these days, however the major issue is that doing any basic graphics operations with Java seems to be a pain in the ass. You have to go through AWT, which is a big mess. In fact, I can't even do a basic plot pixel! (If I'm wrong, please correct me.)

So I looked up sdljava, which is a port of SDL to Java. They pretty much just wrap up the C calls using JNI, and put some nice little objects everywhere. It's a bit cleaner than regular SDL using C.

However after trying it out, I found that it crashed all the time. Which was pretty lame. So I decided to roll up my sleeves and make it work. After a little while, I realized that what was causing it to crash was some pointer tricks generated by SWIG, which is an interface generator for C/C++ code. I fixed up some of these pointer tricks and voila! It works again.

I was initially excited and was planning on notifying the maintainer of sdljava, however since there haven't been any commits to the repo for about 4 years, I figured that it has been abandoned. I forked the CVS repo, converted it to git (since I don't know how to use CVS and don't really feel like learning it) and have put up my own repo of it on Github here if you are interested in checking it out. I don't know if I will be actively repairing things, more just fixing things as they come up (since for the most part the system is complete).

Update: At some point I removed the sdljava repo, forgetting about this link. Sorry about the inconvenience.


Michael Mol said...

If you have time, could I put it upon you to apply it in the few GUI-related tasks we have?

(It's also be sweet if you could add a few more tasks, as our selection is a bit thin, but that might be asking a bit much of your time.)

Rob Britton said...

Hmm, SDL isn't really a GUI library, it's more of a cross-platform DirectX with less features. I mainly use it for rendering basic primitives like dots or circles really quickly.