Tuesday, November 22, 2011

LWJGL, full screen and Win7 issue...

Summary:
I couldn't get full screen mode to work. The spaceinvaders demo app (provided right in the LWJGL download) would just silently crash straight back to Eclipse. There was no error output at all. It turns out Direct3D doesn't work well with Vista/Win7. And there's a simple VM argument to turn it off, "-Dsun.java2d.d3d=false". 


Details:
Ah, the joys of computer configuration complexity. It ensures I spend lots of time on damn near useless tangents. After a nice time burn like this, I so can see why developing for only one specific platform can be quite desirable. Anywho...

So, in my quest towards writing a space invaders clone in Scala, I decided to first get the space invaders Java application supplied as a demo in the main LWJGL download's demo folder. I was able to get all the .java files copied into the proper path. And then was happy when it worked first time with almost no editing. I did go and clean up several warnings that were shown by the compiler.

And then I decided to try and turn on full screen mode (as opposed to the windowed mode that was the default). The application would clearly start, appear to get close to running (full screen of black would appear) and then it just sat there until I clicked with the mouse. Then it would crash right back to Eclipse with no error output whatsoever. Quite frustrating.

After spending several hours slowly going through the code placing copious amounts of System.out.println() statements and lots of try{...} catch (Throwable t) {t.printStackTrace()}, I finally narrowed the intermittent failures down to a line in LWJGL itself, Display.sync(60). I have the LWJGL source attached so I can examine the related source code easily.

After examining the code for sync() and then evaluating whether I wanted to go to the trouble of making the LWJGL source editable, I decided to stop and see if I could Google and see if anyone else was having the issue. It only took 5 minutes using the starting search terms of "LWJGL full screen crash" to discover a possible answer on a forum message thread (related StackOverflow topic). For Vista/Win7, I must pass a VM argument of "-Dsun.java2d.d3d=false" to turn off Direct3D. Of course, as soon as I did that, everything sprang up and worked like a charm.

Lesson Learned:
Google with simplest set of key words as soon as possible. It might save a whole bunch of time attempting to isolate an intermittent issue.

Sunday, November 6, 2011

I'm back from my gaming hiatus...

I've been away enjoying my personal time. I have not done anything related to coding other than my standard JavaEE stuff at work. I've kept studying all the Scala blogs and have been following the Scala tag on StackOverflow and CodeReview sites. I've continued to want to dive right in and just start coding. It is so obvious to me that I would find designing and writing code very enjoyable in Scala. And I am slowly finding it more and more laborious to produce all the boilerplate necessary when I coding in Java, even with the assistance of code completion and code generation tools in Eclipse.

As I am returning to creating time to play directly with Scala again, I am not finding myself all that motivated to continue on the Life project. I don't want to code a little and then blog alot. It just feels too much like doing Java boilerplate; a huge amount of writing with a very small portion that actually does the interesting work. So, for now I am postponing my Scala Life project. I will very likely return to it.

I am finding myself interested in playing around with Scala and creating a simple retro style video game (from the early 80s); Asteroids, Space Invaders, PacMan Missile Command, Defender, etc. These are the games I initially reproduced when I started learning to program on the TI99/4a 30 years ago. And I don't care that there are hundreds of variations of these games. I am not writing it to be consumed by anyone else. I am writing it to feel the delight of achievement, the thrill of viceral learning, the joy of being playful yet inquisitive while minimize the occurrences of and duration of breakdowns, frustrations (configuration challenges, deployment errors, etc.) and technical challenges.

I have spent about 8 hours researching how to go about writing an OpenGL game using Scala. I looked at a number of possible game engines. And it turns out there is an interesting project called LWJGL (LightWeight Java Game Library) which ties together all sorts of C++/C libraries and APIs such that Java programs can utilize them. And anything Java can utilize, Scala can also. So, I am going to do a Scala + LWJGL project. And for now, I am planning to write a very simple version of Space Invaders. Whoohoo!