Monday, February 9, 2009

Game Programming With Lua

Love sold me on lua as a scripting language and provided a great excuse to learn it. As I get time I intend to keep working on Militia Defense, but I'm at a point now where I need to make some significant changes and there just hasn't been time.

Presently, what time I have has been occupied with some reading and a little work on lua-driven 3D library. I'm using SDL with Bob Pendleton's fastevents and net2. My older openGL framework used GLFW. GLFW is actually really nice, but for this project I wanted to use fastevents and net2 for network access, so it's SDL. Honestly it's just a little trickier to load textures, but beyond that they're pretty equivalent. GLFW has a higher precision timer on the platforms I use, but the perceptual difference between 3k fps and 1k fps is probably negligible, and neither one of the libraries require you to use their timer.
Right now I initialize everything and load up a lua script file that sets the video mode and has functions for the main loop.
I've started using lua's userdata element to create procedural shapes and draw them in 3D. I need to work out matrix transformations and camera functions, but none of this should be particularly daunting. At this point I figure it would be best to implement the scene graph in lua, as well as the camera, but my main concern is texturing and defining static and dynamic mesh formats.
I'm using display lists for static geometry for the somewhat marginal performance increase over VBO's, but I'll be using vertex buffer objects for anything animated. Blender will be the content generator of choice, of course.

Once I start getting tired of this I'll probably go back and re-work Militia Defense. Changing projects form time to time helps me avoid burnout and I can usually come back to old work with new perspective, so rest assured there will be updates to this.

No comments: