
GeeXLab 0.12.1 comes with a new framework for OpenGL and Vulkan demos. This Lua framework has been created in order to have a common solution to display statistics (FPS, frame time, GPU usage, etc) in any GL/VK demo.
The kx framework is available in GeeXLab Lua libs folder: {GeeXLab folder}/libs/lua/framework_v1/.
In its current version, kx does not support OpenGL ES and Direct3D 12 demos. This support will be added later.
Let’s see how to use it in all kind of scripts. The following code snippets can be found in the samples provided in the framework folder (sample_opengl.xml and sample_vulkan.xml).
1/ INIT script
local lib_dir = gh_utils.get_scripting_libs_dir()
local framework_dir = lib_dir .. "lua/framework_v1/"
dofile(framework_dir .. "kx.lua")
kx_init_begin(framework_dir)
----------------------------------------------------
-- Put your init code here
----------------------------------------------------
kx_init_end()
2/ FRAME script
kx_frame_begin(0.2, 0.2, 0.2)
kx_check_input()
local elapsed_time = kx_gettime()
----------------------------------------------------
-- Put your frame code here
kx_write_text(20, 60 + 20*math.sin(elapsed_time*2.0), 1.0, 1.0, 0.0, 1.0, "The kx framework is kool!!!")
----------------------------------------------------
local show_osi = kx_get_osi_state()
kx_frame_end(show_osi)
The kx_check_input() function checks the I and P keys. The I key toggles the display of all information (you can retrieve this state with kx_get_osi_state()). The P key toggles the animation (the elapsed time -kx_gettime()- is no longer updated). The default keys can be changed with kx_set_time_animation_toggle_key() and kx_set_osi_toggle_key() functions.
3/ SIZE script
kx_resize()
4/ TERMINATE script
kx_terminate()
sample_opengl.xml

sample_vulkan.xml
The main title (in the bottom-left corner) can be changed:
kx_set_main_title("My Kool OpenGL Demo")
If you don’t need a title:
kx_set_main_title("") -- no main title...
And if a function does not do what you want, just hack the kx.lua file…