Back to API reference

Frame rendering

Frame rendering process is a sequence of view port rendering acts. To get list of viewport setups frame setup callback have to be called.

local function draw_background (x, y, w, h)
   holos.fill ({color = 0x00000000})
local function draw_scene (x, y, w, h)
   holos.lines ("xy", {
                   {-1, -1},
                   {1, 1},

local function frame_setup_handler (w, h)
   return {
      {dmat4.identity (), 0, 0, w, h, 0, 1, draw_background},
      {perspective_matrix, 0, 0, w, h, 0, 1, draw_scene},

-- Render setup:
system.frame_setup_handler (frame_setup_handler)
system.render_thread (true) -- Main thread

Scene rendering

All rendering occurs in thread specified by system.render_thread () function including calling frame setup handler. All rendering functions are called from holos module. Rendering to textures should be done inside frame setup handler. There are 3 groups of graphical calls:

Also there are two ways to setup and render a scene: directly and by building a node tree. Direct rendering is a fastest possible way only if an entire scene is generated for each new frame. If not, building a node tree helps to speed up dramatically: some calls are driven from Lua to C, some other calls are driven into OpenGL display lists. Node tree also takes an advantage of OpenGL attribute stack.

Additional components.

Node setup is managed using node module. After node tree is built it have to be called using holos.node () function in scene handler. Note that adding a mesh or a texture to a node prevents it from garbage collection.

Mesh loading is implemented in mesh module. A mesh can be loaded from table or from file.

Texture setup

Texture is managed by texture module. Usually you have to load an image using image module and then put it inside a texture.

Programs and shaders

Programs and shaders are maintained through program and shader module. Once prepared a program can be used by holos.program () function to active it.

Module reference

See the list of all modules related to graphics:

Back to API reference