APOCALYX is a...

free Game Engine based on OpenGL (MAIL) (SITE) (FORUM) (BLOG)

Wednesday, September 3, 2008

Lua-OpenGL binding

Someone may think that the basic radar-like screens on which I show the MekaWars' simulator capabilities and rendered thanks to specific code written in C++. In reality, those simple screens are drawn through code written in Lua, thanks to the LuaGL library.

LuaGL is a library that provides access to all the OpenGL functionality from Lua. It is a free software and can be used at no cost for both academic and commercial purposes. You can download LuaGL from its SourceForge project home page. That library works as a binding for all OpenGL commands, so you can have full access to the graphics hardware from Lua. Of course, there are performance penalties, so it's always better to use the high-level APOCALYX functions, except when a customized renderings are necessary.

In APOCALYX, the LuaGL support is useful mainly to create the so called ScriptObject, as shown in the "ScriptObject.lua" demo.
In practice, a ScriptObject is a graphical object that a programmer can add to the 3D world, but its particularity is an empty render() method. This means that no C++ drawing method is defined by default, while a Lua functions is called, instead. To explicitly draw the object, the programmer can use the LuaGL binding functions.
In the screenshot above, there is the usual background in which you can see a ScriptObject: a simple triangle strip with different colors defined at its vertexes.

No comments: