Tuesday, January 27, 2009

Write once, debug everywhere.

Java was initially heralded as the "Write once, run anywhere" language, and with its Swing GUI library this would end all programmers frustrations of porting code. Right? Of course this myth didn't last two long as there are a lot of undocumented hacks necessary to get our programs to play nicely on different systems. I remember one hack specifically from Game Programming in Java regarding an additional method call to the event queue to properly process events on Linux.

And of course I've run into this again on Windows with QtRuby. Something in several of my examples which use Qt::Timer (QTimer) for stepping simulations and repaints work fine on Linux, but not at all on Windows. Since I use Linux exclusively this isn't a critical issue right now, but I'm going to have to look into it if I plan to distribute any of my programs on Windows.

Friday, January 23, 2009

New Beginnings

Lately I've been working a lot of QtRuby. Linux development with it is quite quick, and and the desert color scheme of gvim makes things easy to read. I've already managed to use both a custom QWidget for 2D display and a QGLWidget using OpenGL together displaying information based upon the same model. Being able to use slots and signals is also helpful for breaking up your GUI into manageable and distinct parts.

There is a good translation of the Qt tutorials for Ruby, and explains many of the subtleties of how to do slots/signals in Ruby, and some other things which had been implemented as macros.

Getting QtRuby to run on Windows is a different story. The gem I tried was broken because of a buffer error in zlib, so I had to find a work around. This installation guide was very helpful and covers everything from installing Ruby to getting Qt, and getting the QtRuby bindings. Make sure you install mingw.exe as part of the Qt installation, and have qtruby4installer.exe pick the correct directory to find QtCore4.dll in (where you just installed Qt). Also, after you install Qt, you need to fire up a new console, or restart Explorer to get the new paths to load to find this .dll.