< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_utils library

Description

gh_utils is the module that provides various utility functions.


Number of functions: 142

  1. gh_utils.get_platform (Lua - Python)
  2. gh_utils.get_command_line (Lua - Python)
  3. gh_utils.get_platform_name (Lua - Python)
  4. gh_utils.is_64bit (Lua - Python)
  5. gh_utils.is_rpi (Lua - Python)
  6. gh_utils.is_luajit (Lua)
  7. gh_utils.random (Lua - Python)
  8. gh_utils.cpu_get_name (Lua - Python)
  9. gh_utils.cpu_get_speed_mhz (Lua - Python)
  10. gh_utils.cpu_usage_init (Lua - Python)
  11. gh_utils.cpu_usage_cleanup (Lua - Python)
  12. gh_utils.cpu_usage_update (Lua - Python)
  13. gh_utils.cpu_usage_get_core_count (Lua - Python)
  14. gh_utils.cpu_usage_get_core_usage (Lua - Python)
  15. gh_utils.get_elapsed_time (Lua - Python)
  16. gh_utils.get_time_step (Lua - Python)
  17. gh_utils.get_uptime (Lua - Python)
  18. gh_utils.trace (Lua - Python)
  19. gh_utils.open_url (Lua - Python)
  20. gh_utils.get_date_str (Lua - Python)
  21. gh_utils.vendor_name_from_vendor_id (Lua - Python)
  22. gh_utils.math_quat_from_vectors_rotation (Lua - Python)
  23. gh_utils.math_quat_from_lookat (Lua - Python)
  24. gh_utils.math_length_vec3 (Lua - Python)
  25. gh_utils.math_normalize_vec3 (Lua - Python)
  26. gh_utils.project_3d_to_2d_v1 (Lua - Python)
  27. gh_utils.project_3d_to_2d_v2 (Lua - Python)
  28. gh_utils.raycast_get_ray (Lua - Python)
  29. gh_utils.raycast_get_ray_ortho_cam (Lua - Python)
  30. gh_utils.raycast_cast_ray (Lua - Python)
  31. gh_utils.raycast_cast_ray_v2 (Lua - Python)
  32. gh_utils.stop_demo (Lua - Python)
  33. gh_utils.trackball_init (Lua - Python)
  34. gh_utils.trackball_get_orientation (Lua - Python)
  35. gh_utils.webcam_create (Lua - Python)
  36. gh_utils.webcam_get_num (Lua - Python)
  37. gh_utils.webcam_kill (Lua - Python)
  38. gh_utils.webcam_start (Lua - Python)
  39. gh_utils.webcam_stop (Lua - Python)
  40. gh_utils.webcam_get_name (Lua - Python)
  41. gh_utils.webcam_grab_frame (Lua - Python)
  42. gh_utils.webcam_get_frame_size (Lua - Python)
  43. gh_utils.webcam_update_texture (Lua - Python)
  44. gh_utils.font_create (Lua - Python)
  45. gh_utils.font_set_viewport_info (Lua - Python)
  46. gh_utils.font_render (Lua - Python)
  47. gh_utils.font_render3d (Lua - Python)
  48. gh_utils.thread_sleep (Lua - Python)
  49. gh_utils.get_demo_dir (Lua - Python)
  50. gh_utils.get_app_dir (Lua - Python)
  51. gh_utils.get_lib_dir (Lua - Python)
  52. gh_utils.get_os_info (Lua - Python)
  53. gh_utils.drop_files_get_num_files (Lua - Python)
  54. gh_utils.drop_files_get_file_by_index (Lua - Python)
  55. gh_utils.progress_bar_inc (Lua - Python)
  56. gh_utils.progress_bar_set (Lua - Python)
  57. gh_utils.do_screenshot (Lua - Python)
  58. gh_utils.do_screenshot_v2 (Lua - Python)
  59. gh_utils.do_screenshot_v3 (Lua - Python)
  60. gh_utils.exe_script (Lua - Python)
  61. gh_utils.exe_script_v2 (Lua - Python)
  62. gh_utils.exe_script_v3 (Lua - Python)
  63. gh_utils.exe_string (Lua - Python)
  64. gh_utils.exe_from_buffer (Lua - Python)
  65. gh_utils.do_file_from_sqlite3_blob (Lua - Python)
  66. gh_utils.do_file_from_zip (Lua - Python)
  67. gh_utils.get_demo_zip_filename (Lua - Python)
  68. gh_utils.extract_dir_from_filename (Lua - Python)
  69. gh_utils.clipboard_set_text (Lua - Python)
  70. gh_utils.clipboard_get_text (Lua - Python)
  71. gh_utils.file_size (Lua - Python)
  72. gh_utils.zip_to_file (Lua - Python)
  73. gh_utils.buffer_to_file (Lua - Python)
  74. gh_utils.zip_buffer_create (Lua - Python)
  75. gh_utils.zip_buffer_kill (Lua - Python)
  76. gh_utils.file_buffer_create (Lua - Python)
  77. gh_utils.file_buffer_kill (Lua - Python)
  78. gh_utils.buffer_create (Lua - Python)
  79. gh_utils.buffer_kill (Lua - Python)
  80. gh_utils.buffer_read_byte (Lua - Python)
  81. gh_utils.buffer_read_1f (Lua - Python)
  82. gh_utils.buffer_read_2f (Lua - Python)
  83. gh_utils.buffer_read_3f (Lua - Python)
  84. gh_utils.buffer_read_4f (Lua - Python)
  85. gh_utils.buffer_write_byte (Lua - Python)
  86. gh_utils.buffer_write_1f (Lua - Python)
  87. gh_utils.buffer_write_2f (Lua - Python)
  88. gh_utils.buffer_write_3f (Lua - Python)
  89. gh_utils.buffer_write_4f (Lua - Python)
  90. gh_utils.buffer_read_line (Lua - Python)
  91. gh_utils.file_sha1 (Lua - Python)
  92. gh_utils.file_sha256 (Lua - Python)
  93. gh_utils.file_md5 (Lua - Python)
  94. gh_utils.file_crc32 (Lua - Python)
  95. gh_utils.printc (Lua - Python)
  96. gh_utils.sanitize_string (Lua - Python)
  97. gh_utils.get_app_version (Lua - Python)
  98. gh_utils.hex_color_to_rgb (Lua - Python)
  99. gh_utils.cpu_get_mem_available_size_mb (Lua - Python)
  100. gh_utils.cpu_get_mem_size_mb (Lua - Python)
  101. gh_utils.grid_create (Lua - Python)
  102. gh_utils.grid_set_geometry_params (Lua - Python)
  103. gh_utils.grid_set_lines_color (Lua - Python)
  104. gh_utils.grid_set_main_lines_color (Lua - Python)
  105. gh_utils.grid_set_main_x_axis_color (Lua - Python)
  106. gh_utils.grid_set_main_z_axis_color (Lua - Python)
  107. gh_utils.grid_set_display_lines_options (Lua - Python)
  108. gh_utils.tripod_visualizer_camera_render (Lua - Python)
  109. gh_utils.nfd_open_dialog (Lua - Python)
  110. gh_utils.nfd_save_dialog (Lua - Python)
  111. gh_utils.nfd_pick_folder (Lua - Python)
  112. gh_utils.shared_variable_create (Lua - Python)
  113. gh_utils.shared_variable_kill (Lua - Python)
  114. gh_utils.shared_variable_is_exist (Lua - Python)
  115. gh_utils.shared_variable_set_value_4f (Lua - Python)
  116. gh_utils.shared_variable_get_value_4f (Lua - Python)
  117. gh_utils.shared_variable_set_value_str (Lua - Python)
  118. gh_utils.shared_variable_get_value_str (Lua - Python)
  119. gh_utils.shared_variable_create_array (Lua - Python)
  120. gh_utils.shared_variable_set_array_value_1f (Lua - Python)
  121. gh_utils.shared_variable_get_array_value_1f (Lua - Python)
  122. gh_utils.shared_variable_set_array_value_1i (Lua - Python)
  123. gh_utils.shared_variable_get_array_value_1i (Lua - Python)
  124. gh_utils.shared_variable_set_array_value_str (Lua - Python)
  125. gh_utils.shared_variable_get_array_value_str (Lua - Python)
  126. gh_utils.sys_exec (Lua - Python)
  127. gh_utils.dylib_load (Lua - Python)
  128. gh_utils.dylib_unload (Lua - Python)
  129. gh_utils.dylib_start (Lua - Python)
  130. gh_utils.dylib_stop (Lua - Python)
  131. gh_utils.dylib_frame (Lua - Python)
  132. gh_utils.dylib_resize (Lua - Python)
  133. gh_utils.dylib_set_message (Lua - Python)
  134. gh_utils.dylib_set_message (Lua - Python)
  135. gh_utils.ftgl_font_texture_load (Lua - Python)
  136. gh_utils.ftgl_font_create (Lua - Python)
  137. gh_utils.ftgl_font_add_text2d (Lua - Python)
  138. gh_utils.ftgl_font_add_text3d (Lua - Python)
  139. gh_utils.ftgl_font_clear (Lua - Python)
  140. gh_utils.ftgl_font_render (Lua - Python)
  141. gh_utils.ftgl_font_kill (Lua - Python)
  142. gh_utils.ftgl_font_texture_kill (Lua - Python)



get_platform

Description

Returns the platform: Windows (1), OSX (2), Linux (3) and Raspberry Pi (4).


Syntax

platform = gh_utils.get_platform()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


platform = gh_utils.get_platform()
            


get_command_line

Description

Returns the command line used to lauch GeeXLab.


Syntax

command_line = gh_utils.get_command_line()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


command_line = gh_utils.get_command_line()
            


get_platform_name

Description

Returns the platform name: Windows xx-bit, OS X 10.x, Linux xx-bit, Raspberry Pi.


Syntax

platform_name = gh_utils.get_platform_name()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


platform_name = gh_utils.get_platform_name()
            


is_64bit

Description

Checks if the host application is a 64-bit or a 32-bit application.


Syntax

state = gh_utils.is_64bit()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


app_64bit = gh_utils.is_64bit()
            


is_rpi

Description

Checks if the platform is Raspberry Pi (RPi).


Syntax

state = gh_utils.is_rpi()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


rpi = gh_utils.is_rpi()
            


is_luajit

Description

Checks if LuaJIT engine is used in place of regular Lua. Windows platform only.


Syntax

state = gh_utils.is_luajit()

Languages

Lua


Parameters

This function has no input parameter(s).


Return Values


Code sample


is_luajit = gh_utils.is_luajit()
            


random

Description

Returns a random floating point number between 0.0 and 1.0.


Syntax

x = gh_utils.random()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local x = gh_utils.random()
local y = gh_utils.random()
local z = gh_utils.random()
            


cpu_get_name

Description

Returns the CPU name - This function requires the GPU monitoring plugin (Windows, Linux and macOS)


Syntax

str = gh_utils.cpu_get_name()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local cpu_name = gh_utils.cpu_get_name()
            


cpu_get_speed_mhz

Description

Returns the CPU speed in MHz - This function requires the GPU monitoring plugin (Windows, Linux and macOS)


Syntax

speed = gh_utils.cpu_get_speed_mhz()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local cpu_speed = gh_utils.cpu_get_speed_mhz()
            


cpu_usage_init

Description

Initializes the CPU usage code. Should be called in INIT scripts - Windows only.


Syntax

state = gh_utils.cpu_usage_init()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local ret = gh_utils.cpu_usage_init()
            


cpu_usage_cleanup

Description

Cleans up the CPU usage code. Should be called in a TERMINATE script - Windows only.


Syntax

gh_utils.cpu_usage_cleanup()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values

This function has no return value(s).


Code sample


gh_utils.cpu_usage_cleanup()
            


cpu_usage_update

Description

Updates the CPU usage. Should be called in a FRAME script - Windows only.


Syntax

gh_utils.cpu_usage_update()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values

This function has no return value(s).


Code sample


gh_utils.cpu_usage_update()
            


cpu_usage_get_core_count

Description

Returns the number of CPU cores - Windows only.


Syntax

num = gh_utils.cpu_usage_get_core_count()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local cores = gh_utils.cpu_usage_get_core_count()
            


cpu_usage_get_core_usage

Description

Returns the usage of a particular core - Windows only.


Syntax

usage = gh_utils.cpu_usage_get_core_usage(
 index
)

Languages

Lua - Python


Parameters


Return Values


Code sample


local core_index = 0
local usage = gh_utils.cpu_usage_get_core_usage(core_index)
            


get_elapsed_time

Description

Gets the elapsed time since the start of the current scene.


Syntax

elapsed_time = gh_utils.get_elapsed_time()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local elapsed_time = gh_utils.get_elapsed_time()
            


get_time_step

Description

Returns the time step between two consecutive frames.


Syntax

dt = gh_utils.get_time_step()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local dt = gh_utils.get_time_step()
            


get_uptime

Description

Gets the up time since the launch of GeeXLab.


Syntax

uptime = gh_utils.get_uptime()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


local uptime = gh_utils.get_uptime()
            


trace

Description

Writes a trace in the log file and in the debug window.


Syntax

gh_utils.trace(
 str
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.trace("Hello world!")
            


open_url

Description

Open an URL in the default browser.


Syntax

gh_utils.open_url(
 str
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.open_url("https://www.geeks3d.com")
            


get_date_str

Description

Gets the date with the following format: Y.M.D.h.m.s. Handy funtion for naming files.


Syntax

date = gh_utils.get_date_str()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


date = gh_utils.get_date_str()
            


vendor_name_from_vendor_id

Description

Gets the vendor name from its vendor ID.


Syntax

date = gh_utils.vendor_name_from_vendor_id(
 vendor_id
)

Languages

Lua - Python


Parameters


Return Values


Code sample


name = gh_utils.vendor_name_from_vendor_id(4318)
if (name == "NVIDIA") then
    -- do something
end
            


math_quat_from_vectors_rotation

Description

Creates a quaternion from two vectors.


Syntax

qx, qy, qz, qw = gh_utils.math_quat_from_vectors_rotation(
 x0, y0, z0,
 x1, y1, z1
)

Languages

Lua - Python


Parameters


Return Values


Code sample


qx, qy, qz, qw = gh_utils.math_quat_from_vectors_rotation(x0, y0, z0, x1, y1, z1)
            


math_quat_from_lookat

Description

Creates a quaternion from vectors of a look-at matrix (position, target and up).


Syntax

qx, qy, qz, qw = gh_utils.math_quat_from_lookat(
 px, py, pz,
 px, py, pz,
 ux, uy, uz
)

Languages

Lua - Python


Parameters


Return Values


Code sample


qx, qy, qz, qw = gh_utils.math_quat_from_lookat(px, py, pz,   px, py, pz,  ux, uy, uz)
            


math_length_vec3

Description

Gets the length of a vec3 vector.


Syntax

len = gh_utils.math_length_vec3(
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values


Code sample


len = gh_utils.math_length_vec3(x, y, z)
            


math_normalize_vec3

Description

Normalizes a vec3 vector.


Syntax

vx, vy, vz = gh_utils.math_normalize_vec3(
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values


Code sample


vx, vy, vz = gh_utils.math_normalize_vec3(x, y, z)
            


project_3d_to_2d_v1

Description

Projects a 3D point into the 2D screen space. Useful to know if a vertex is under the mouse for example.


Syntax

px, py = gh_utils.project_3d_to_2d_v1(
 camera_id,
 object_id,
 x, y, z, w
)

Languages

Lua - Python


Parameters


Return Values


Code sample


px, py = gh_utils.project_3d_to_2d_v1(camera_id, object_id, x, y, z, 1.0)
            


project_3d_to_2d_v2

Description

Projects a 3D point into the 2D screen space. Useful to know if a vertex is under the mouse for example.


Syntax

px, py = gh_utils.project_3d_to_2d_v2(
 camera_id,
 x, y, z, w
)

Languages

Lua - Python


Parameters


Return Values


Code sample


px, py = gh_utils.project_3d_to_2d_v2(camera_id, x, y, z, 1.0)
            


raycast_get_ray

Description

Gets a 3D ray from a screen position (mouse for example) for a perspective camera.


Syntax

ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray(
 screen_x, screen_y,
 camera_id
)

Languages

Lua - Python


Parameters


Return Values


Code sample


ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray(200, 100, camera)
            


raycast_get_ray_ortho_cam

Description

Gets a 3D ray from a screen position (mouse for example) for an orthographic camera.


Syntax

ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray_ortho_cam(
 screen_x, screen_y,
 camera_id
)

Languages

Lua - Python


Parameters


Return Values


Code sample


ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray_ortho_cam(100, 200, camera)
            


raycast_cast_ray

Description

Casts a ray in the 3D scene and returns collision information (with a mesh).


Syntax

face_index, collision_time, collision_pos_x, collision_pos_y, collision_pos_z = gh_utils.raycast_cast_ray(
 object_id,
 ro_x, ro_y, ro_z, rd_x, rd_y, rd_z
)

Languages

Lua - Python


Parameters


Return Values


Code sample


face_index, collision_time, collision_pos_x, collision_pos_y, collision_pos_z = gh_utils.raycast_cast_ray(mesh, ro_x, ro_y, ro_z, rd_x, rd_y, rd_z)
            


raycast_cast_ray_v2

Description

Casts a ray in the 3D scene and returns collision information (with a mesh).


Syntax

face_index, collision_time, collision_pos_x, collision_pos_y, collision_pos_z = gh_utils.raycast_cast_ray_v2(
 object_id,
 ro_x, ro_y, ro_z, rd_x, rd_y, rd_z,
 do_bounding_volume_test
)

Languages

Lua - Python


Parameters


Return Values


Code sample


do_bounding_volume_test = 1            
face_index, collision_time, collision_pos_x, collision_pos_y, collision_pos_z = gh_utils.raycast_cast_ray_v2(mesh, ro_x, ro_y, ro_z, rd_x, rd_y, rd_z, do_bounding_volume_test)
            


stop_demo

Description

Stops a demo and quits GeeXLab.


Syntax

gh_utils.stop_demo()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values

This function has no return value(s).


Code sample


gh_utils.stop_demo()
            


trackball_init

Description

Inits the trackball engine. The trackball allows to naturally rotate an object as we rotate a sphere.


Syntax

gh_utils.trackball_init(
 radius,
 x, y
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.trackball_init(radius, w, h)
            


trackball_get_orientation

Description

Returns the rotation quaternion of the trackball.


Syntax

x, y, z, w = gh_utils.trackball_get_orientation(
 x, y,
 prev_x, prev_y
)

Languages

Lua - Python


Parameters


Return Values


Code sample


x, y, z, w = gh_utils.trackball_get_orientation(x, y, prev_x, prev_y)
            


webcam_create

Description

Creates a new webcam object. A max of 8 webcams can be created - Windows platform only.


Syntax

webcam = gh_utils.webcam_create()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


webcam = gh_utils.webcam_create()
            


webcam_get_num

Description

Returns the number of webcams detected by GeeXLab - Windows platform only.


Syntax

webcam = gh_utils.webcam_get_num()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


n = gh_utils.webcam_get_num()
            


webcam_kill

Description

Kills a webcam object - Windows platform only.


Syntax

gh_utils.webcam_kill(
 webcam
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.webcam_kill(webcam)
            


webcam_start

Description

Initializes a webcam - Windows platform only.


Syntax

ret = gh_utils.webcam_start(
 webcam,
 webcam_number
)

Languages

Lua - Python


Parameters


Return Values


Code sample


ret = gh_utils.webcam_start(webcam, 1)
if (ret == 1) then
  -- Webcam started ok.
end
            


webcam_stop

Description

Stops a webcam - Windows platform only.


Syntax

gh_utils.webcam_stop(
 webcam
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.webcam_stop(webcam)
            


webcam_get_name

Description

Gets the webcam name, for example: 'Microsoft LifeCam Studio' - Windows platform only.


Syntax

gh_utils.webcam_get_name(
 webcam
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


name = gh_utils.webcam_get_name(webcam)
            


webcam_grab_frame

Description

Updates the webcam - Windows platform only.


Syntax

gh_utils.webcam_grab_frame(
 webcam
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.webcam_grab_frame(webcam)
            


webcam_get_frame_size

Description

Gets the size of a frame - Windows platform only.


Syntax

width, height = gh_utils.webcam_get_frame_size(
 webcam
)

Languages

Lua - Python


Parameters


Return Values


Code sample


w, h = gh_utils.webcam_get_frame_size(webcam)
            


webcam_update_texture

Description

Updates a texture pixmap with the current webcam frame - Windows platform only.


Syntax

gh_utils.webcam_update_texture(
 webcam,
 texture
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.webcam_update_texture(webcam, texture)
            


font_create

Description

Creates a new font.


Syntax

font = gh_utils.font_create(
 font_name,
 height
)

Languages

Lua - Python


Parameters


Return Values


Code sample


font = gh_utils.font_create("Arial", 14)
            


font_set_viewport_info

Description

Sets the viewport information. You have to call this function when the window is resized.


Syntax

gh_utils.font_set_viewport_info(
 font,
 x, y,
 width, height
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.font_set_viewport_info(font, 0, 0, width, height)
            


font_render

Description

Renders (draws) a text.


Syntax

gh_utils.font_render(
 font,
 x, y,
 r, g, b, a,
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.font_set_viewport_info(font, 0, 0, width, height)
gh_utils.font_render(font, 10, 40, 0.2, 1.0, 0.0, 1.0, string.format("Image filename: %s", texture_filename))
            


font_render3d

Description

Renders (draws) a text at a 3D position.


Syntax

gh_utils.font_render3d(
 font,
 x, y, z,
 r, g, b, a,
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.font_render3d(font, 0, 20.0, -20.0, 0.2, 1.0, 0.0, 1.0, "V1")
            


thread_sleep

Description

Allows to pause the current thread.


Syntax

gh_utils.thread_sleep(
 delay
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.thread_sleep(2000)
            


get_demo_dir

Description

Gets the directory of the current scene file.


Syntax

dir = gh_utils.get_demo_dir()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


demo_dir = gh_utils.get_demo_dir()
            


get_app_dir

Description

Gets the directory of GeeXLab.


Syntax

dir = gh_utils.get_app_dir()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


app_dir = gh_utils.get_app_dir()
            


get_lib_dir

Description

Gets the directory of GeeXLab common librairies (Lua and Python) used by demos. The defaulkt location is {GeeXLab_folder}/libs/


Syntax

dir = gh_utils.get_lib_dir()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


lib_dir = gh_utils.get_lib_dir()
            


get_os_info

Description

Gets some basic information about the host Operating System (OS)


Syntax

name, codename, major, minor, build = gh_utils.get_os_info()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


name, codename, major, minor, build = gh_utils.get_os_info()
            


drop_files_get_num_files

Description

Windows only - Returns the number of files that have been dropped on the application. This function is useful in a DRAG_N_DROP script.


Syntax

num_files = gh_utils.drop_files_get_num_files()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


num_files = gh_utils.drop_files_get_num_files()
            


drop_files_get_file_by_index

Description

Windows only - Returns the name of a particular file that has been dropped on the application. This function is useful in a DRAG_N_DROP script.


Syntax

filename = gh_utils.drop_files_get_file_by_index(
 index
)

Languages

Lua - Python


Parameters


Return Values


Code sample


num_files = gh_utils.drop_files_get_num_files()
if (num_files >  0) then
	-- Gets the first dropped file:
	filename = gh_utils.drop_files_get_file_by_index(0)
end
            


progress_bar_inc

Description

Increments the progress bar size in percent of the current window width. This functions can be used in an INIT script to draw a progress bar while loading data. To enable the progress bar, the display_progress_bar=1 attribute must be used in the window XML node.


Syntax

gh_utils.progress_bar_inc(
 percent_inc,
 caption
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.progress_bar_set(20, "Initializing...")
...
... do some stuff
...
for i=1, 50 do
  ...
  gh_utils.progress_bar_inc(1)
end    
...
... do some stuff
...
gh_utils.progress_bar_set(100, "Initialization complete.")
            


progress_bar_set

Description

Sets the progress bar size in percent of the current window width. This functions can be used in an INIT script to draw a progress bar while loading data. To enable the progress bar, the display_progress_bar=1 attribute must be used in the window XML node.


Syntax

gh_utils.progress_bar_set(
 percent,
 caption
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.progress_bar_set(20, "Initializing...")
...
... do some stuff
...
gh_utils.progress_bar_set(50, "Still initializing...")
...
... do some stuff
...
gh_utils.progress_bar_set(100, "Initialization complete.")
            


do_screenshot

Description

Does a screenshot and write it to a file (JPEG file) - OpenGL renderer only.


Syntax

gh_utils.do_screenshot(
 filename,
 is_absolute_path
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.do_screenshot("image.jpg", 0)
            


do_screenshot_v2

Description

Does a screenshot and write it to a file (JPEG file) - OpenGL renderer only.


Syntax

gh_utils.do_screenshot_v2(
 filename,
 flip_image
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
gh_utils.do_screenshot_v2(demo_dir .. "image.jpg", flip_image)
            


do_screenshot_v3

Description

Does a screenshot and write it to a file (JPEG file) - OpenGL renderer only.


Syntax

gh_utils.do_screenshot_v3(
 filename,
 x, y, width, height,
 flip_image
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
local x = 0
local y = 0
gh_utils.do_screenshot_v3(demo_dir .. "image.jpg", x, y, winW, winH, flip_image)
            


exe_script

Description

Executes a script.


Syntax

gh_utils.exe_script(
 name,
 threaded
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local threaded = 0
gh_utils.exe_script("init_meshes", threaded)
            


exe_script_v2

Description

Executes a script.


Syntax

gh_utils.exe_script_v2(
 name,
 threaded,
 create_worker_wind3d
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local threaded = 1
local create_worker_wind3d = 0
gh_utils.exe_script_v2("load_textures_cpu", threaded, create_worker_wind3d)
            


exe_script_v3

Description

Executes a script.


Syntax

gh_utils.exe_script_v3(
 name,
 threaded,
 create_worker_wind3d,
 thread_affinity_mask
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local threaded = 1
local create_worker_wind3d = 0
local thread_affinity_mask = 0
gh_utils.exe_script_v3("load_textures_cpu", threaded, create_worker_wind3d, thread_affinity_mask)
            


exe_string

Description

Executes a script.


Syntax

ret = gh_utils.exe_string(
 lua_python_commands
)

Languages

Lua - Python


Parameters


Return Values


Code sample


gh_utils.exe_string("demo_folder = gh_utils.get_demo_dir()")
print(demo_folder)
            


exe_from_buffer

Description

Executes a script from a memory buffer.


Syntax

ret = gh_utils.exe_from_buffer(
 buffer_ptr,
 buffer_size
)

Languages

Lua - Python


Parameters


Return Values


Code sample


local demo_dir = gh_utils.get_demo_dir()
filename = demo_dir .. "assets/init_textures.lua"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
if (gh_utils.exe_from_buffer(buffer, buffer_size) == 1) then
    -- ok
end
gh_utils.file_buffer_kill(buffer)
            


do_file_from_sqlite3_blob

Description

Executes a script stored in a SQLite3 blob.


Syntax

ret = gh_utils.do_file_from_sqlite3_blob(
 dbid,
 column
)

Languages

Lua - Python


Parameters


Return Values


Code sample


gh_utils.do_file_from_sqlite3_blob(dbid, column)
            


do_file_from_zip

Description

Executes a script file stored in a zip archive.


Syntax

ret = gh_utils.do_file_from_zip(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = demo_dir .. "data.zip"
gh_utils.do_file_from_zip(zip_filename, "scripts/init02.lua")
            


get_demo_zip_filename

Description

Gets the file name of the main zip archive (the zip archive that contains the main XML demo).


Syntax

demo_zip_filename = gh_utils.get_demo_zip_filename()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


main_zip_filename = gh_utils.get_demo_zip_filename()
            


extract_dir_from_filename

Description

Utility function that extracts a path / folder from a file name.


Syntax

filename = gh_utils.extract_dir_from_filename(
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


folder = gh_utils.extract_dir_from_filename(filename)
            


clipboard_set_text

Description

Allows to copy a string to the clipboard (currently on Windows only).


Syntax

gh_utils.clipboard_set_text(
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.clipboard_set_text("Hello!")
            


clipboard_get_text

Description

Allows to get the content (text type) of the clipboard (currently on Windows only).


Syntax

text, text_len = gh_utils.clipboard_get_text()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


text, text_len = gh_utils.clipboard_get_text()
            


file_size

Description

Helper function to get the size of a file on the disk or in a zip file.


Syntax

size = gh_utils.file_size(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
size = gh_utils.file_size(zip_filename, filename)
            


zip_to_file

Description

Extracts a file from a zip and save it on the file system.


Syntax

ret = gh_utils.zip_to_file(
 zip_filename,
 src_filename,
 dst_filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = gh_utils.get_demo_dir() .. "demo.zip"
src_filename = "assets/image01.jpg"
dst_filename = gh_utils.get_demo_dir() .. "image01.jpg"
if (gh_utils.file_size(zip_filename, src_filename, dst_filename) == 1) then
  -- OK!
end
            


buffer_to_file

Description

Save the content of a memory buffer into a file.


Syntax

ret, buffer_ptr, buffer_size = gh_utils.buffer_to_file(
 dst_filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


dst_filename = gh_utils.get_demo_dir() .. "image01.jpg"
if (gh_utils.buffer_to_file(buffer, buffer_size, dst_filename) == 1) then
  -- OK!
end
            


zip_buffer_create

Description

Allocs a memory buffer of a file stored in a zip archive and returns the pointer to the memory buffer.


Syntax

buffer_ptr, buffer_size = gh_utils.zip_buffer_create(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = gh_utils.get_demo_dir() .. "demo.zip"
filename = "config.txt"
buffer_ptr, buffer_size = gh_utils.zip_buffer_create(zip_filename, filename)
           


zip_buffer_kill

Description

Frees the pointer returned by zip_buffer_create().


Syntax

gh_utils.zip_buffer_kill(
 buffer_ptr
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


zip_filename = gh_utils.get_demo_dir() .. "demo.zip"
filename = "config.txt"
buffer_ptr, buffer_size = gh_utils.zip_buffer_create(zip_filename, filename)

...

gh_utils.zip_buffer_kill(buffer_ptr)
           


file_buffer_create

Description

Gets a pointer to the memory buffer of a file stored in the file system.


Syntax

buffer_size, buffer_ptr = gh_utils.file_buffer_create(
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
           


file_buffer_kill

Description

Frees the pointer returned by file_buffer_create().


Syntax

gh_utils.file_buffer_kill(
 buffer_ptr
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_create

Description

Creates an empty memory buffer.


Syntax

buffer_size, buffer_ptr = gh_utils.buffer_create(
 size
)

Languages

Lua - Python


Parameters


Return Values


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

...

gh_utils.buffer_kill(buffer_ptr)
           


buffer_kill

Description

Frees the pointer returned by buffer_create().


Syntax

gh_utils.buffer_kill(
 buffer_ptr
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

...

gh_utils.buffer_kill(buffer_ptr)
           


buffer_read_byte

Description

Reads a byte from a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

x = gh_utils.buffer_read_byte(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

-- read the first byte:
x = gh_utils.buffer_read_byte(buffer_ptr, 0)
-- read the second byte:
x = gh_utils.buffer_read_byte(buffer_ptr, 1)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_read_1f

Description

Reads a float from a memory buffer via a pointer. The pointer must have been created by buffer_create(), zip_buffer_create() or file_buffer_create().


Syntax

x, y = gh_utils.buffer_read_1f(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

offset = 0
x = gh_utils.buffer_read_1f(buffer_ptr, offset)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_read_2f

Description

Reads a vec2 from a memory buffer via a pointer. The pointer must have been created by buffer_create(), zip_buffer_create() or file_buffer_create().


Syntax

x, y = gh_utils.buffer_read_2f(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

offset = 0
x, y = gh_utils.buffer_read_2f(buffer_ptr, offset)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_read_3f

Description

Reads a vec3 from a memory buffer via a pointer. The pointer must have been created by buffer_create(), zip_buffer_create() or file_buffer_create().


Syntax

x, y, z = gh_utils.buffer_read_3f(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

offset = 0
x, y, z = gh_utils.buffer_read_3f(buffer_ptr, offset)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_read_4f

Description

Reads a vec4 from a memory buffer via a pointer. The pointer must have been created by buffer_create(), zip_buffer_create() or file_buffer_create().


Syntax

x, y, z, w = gh_utils.buffer_read_4f(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

offset = 0
x, y, z, w = gh_utils.buffer_read_4f(buffer_ptr, offset)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_write_byte

Description

Writes a byte to a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

gh_utils.buffer_write_byte(
 buffer_ptr,
 offset,
 x
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

-- write the first byte:
x = 100
gh_utils.buffer_write_byte(buffer_ptr, 0, x)
-- write the second byte:
x = 112
gh_utils.buffer_write_byte(buffer_ptr, 1, x)

...

gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.file_buffer_kill(buffer_ptr)
           


buffer_write_1f

Description

Writes a float to a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

gh_utils.buffer_write_1f(
 buffer_ptr,
 offset,
 x
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

x = 3.14
gh_utils.buffer_write_1f(buffer_ptr, 0, x)

...

gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
           


buffer_write_2f

Description

Writes a vec2 to a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

gh_utils.buffer_write_2f(
 buffer_ptr,
 offset,
 x, y
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

x = 3.14
y = 1.22
gh_utils.buffer_write_2f(buffer_ptr, 0, x, y)

...

gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
           


buffer_write_3f

Description

Writes a vec3 to a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

gh_utils.buffer_write_3f(
 buffer_ptr,
 offset,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

x = 3.14
y = 1.22
z = -0.57
gh_utils.buffer_write_3f(buffer_ptr, 0, x, y, z)

...

gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
           


buffer_write_4f

Description

Writes a vec4 to a memory buffer via a pointer. The pointer must have been created by zip_buffer_create() or file_buffer_create().


Syntax

gh_utils.buffer_write_4f(
 buffer_ptr,
 offset,
 x, y, z, w
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


buffer_ptr, buffer_size = gh_utils.buffer_create(1024)

x = 3.14
y = 1.22
z = -0.57
w = 1.0
gh_utils.buffer_write_4f(buffer_ptr, 0, x, y, z, w)

...

gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
           


buffer_read_line

Description

Reads a line from a memory buffer via a pointer. The pointer must have created by zip_buffer_create() or file_buffer_create().


Syntax

line, line_size = gh_utils.buffer_read_line(
 buffer_ptr,
 offset
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)

line_offset = 0
-- read the first line:
line, line_size = gh_utils.buffer_read_line(buffer_ptr, line_offset)
line_offset = line_offset + line_size

-- read the second line:
line, line_size = gh_utils.buffer_read_line(buffer_ptr, line_offset)

...

gh_utils.file_buffer_kill(buffer_ptr)
           


file_sha1

Description

Helper function to get the SHA1 hash code of a file on the disk or in a zip file.


Syntax

hashcode = gh_utils.file_sha1(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha1(zip_filename, filename)
            


file_sha256

Description

Helper function to get the SHA-256 hash code of a file on the disk or in a zip file.


Syntax

hashcode = gh_utils.file_sha256(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha256(zip_filename, filename)
            


file_md5

Description

Helper function to get the MD5 hash code of a file on the disk or in a zip file.


Syntax

hashcode = gh_utils.file_md5(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_md5(zip_filename, filename)
            


file_crc32

Description

Helper function to get the CRC32 hash code of a file on the disk or in a zip file.


Syntax

crc32, crc32_str = gh_utils.file_crc32(
 zip_filename,
 filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
crc32, crc32_str = gh_utils.file_crc32(zip_filename, filename)
            


printc

Description

Helper function to print text directly in the console.


Syntax

gh_utils.printc(
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.printc(text)
            


sanitize_string

Description

Sanitize a string.


Syntax

gh_utils.sanitize_string(
 text,
 filter_type
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


sanitized_text = gh_utils.sanitize_string(text, 0)
            


get_app_version

Description

Returns the four numbers that define the GeeXLab version.


Syntax

major, minor, patch, build = gh_utils.get_app_version()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


major, minor, patch, build = gh_utils.get_app_version()
            


hex_color_to_rgb

Description

Converts an HTML style color to three RGB components.


Syntax

html_color = gh_utils.hex_color_to_rgb(
 html_color
)

Languages

Lua - Python


Parameters


Return Values


Code sample


r, g, b = gh_utils.hex_color_to_rgb("#ff0044")
            


cpu_get_mem_available_size_mb

Description

Returns the size of the available physical system memory in MB.


Syntax

size = gh_utils.cpu_get_mem_available_size_mb()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


mem_size_mb = gh_utils.cpu_get_mem_available_size_mb()
            


cpu_get_mem_size_mb

Description

Returns the size of the physical system memory in MB.


Syntax

size = gh_utils.cpu_get_mem_size_mb()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


mem_size_mb = gh_utils.cpu_get_mem_size_mb()
            


grid_create

Description

Creates a grid object.


Syntax

grid = gh_utils.grid_create()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample


grid = gh_utils.grid_create()
            


grid_set_geometry_params

Description

Sets grid sizes and subdivisions.


Syntax

gh_utils.grid_set_geometry_params(
 grid,
 x_size, z_size,
 x_div, z_div
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_geometry_params(grid, 20, 20, 10, 10)
            


grid_set_lines_color

Description

Sets grid color.


Syntax

gh_utils.grid_set_lines_color(
 grid,
 r, g, b, a
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_lines_color(grid, 0.7, 0.7, 0.7, 1)
            


grid_set_main_lines_color

Description

Sets the color of main lines.


Syntax

gh_utils.grid_set_main_lines_color(
 grid,
 r, g, b, a
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_main_lines_color(grid, 1.0, 1.0, 0.0, 1)
            


grid_set_main_x_axis_color

Description

Sets the color of the main X axis.


Syntax

gh_utils.grid_set_main_x_axis_color(
 grid,
 r, g, b, a
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_main_x_axis_color(grid, 1.0, 0.0, 0.0, 1)
            


grid_set_main_z_axis_color

Description

Sets the color of the main Z axis.


Syntax

gh_utils.grid_set_main_z_axis_color(
 grid,
 r, g, b, a
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_main_z_axis_color(grid, 0.0, 0.0, 1.0, 1)
            


grid_set_display_lines_options

Description

Sets various grid options for rendering.


Syntax

gh_utils.grid_set_display_lines_options(
 grid,
 display_main_lines,
 display_lines
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.grid_set_display_lines_options(grid, 1, 1)
            


tripod_visualizer_camera_render

Description

Draws in a viewport the tripod of a camera. Useful to visualize the current orientation of the camera.


Syntax

gh_utils.tripod_visualizer_camera_render(
 camera,
 x_offset, y_offset, width, height
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.tripod_visualizer_camera_render(camera, 0, 0, 100, 100)
            


nfd_open_dialog

Description

NativeFileDialog - opens a dialog box for opening a file. Works on Windows, Linux (GTK3+) and Raspberry Pi (Raspibian with GTK3+). Does not work on macOS because macOS UI functions must be called from application main thread only (sucks!).


Syntax

filename, ret = gh_utils.nfd_open_dialog(
 filters_list,
 default_path
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename, ret = gh_utils.nfd_open_dialog("jgp,png", "")
            


nfd_save_dialog

Description

NativeFileDialog - opens a dialog box for saving a file. Works on Windows, Linux (GTK3+) and Raspberry Pi (Raspibian with GTK3+). Does not work on macOS because macOS UI functions must be called from application main thread only (sucks!).


Syntax

filename, ret = gh_utils.nfd_save_dialog(
 filters_list,
 default_path
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename, ret = gh_utils.nfd_save_dialog("jgp,png", "")
            


nfd_pick_folder

Description

NativeFileDialog - opens a dialog box for selecting a folder. Works on Windows, Linux (GTK3+) and Raspberry Pi (Raspibian with GTK3+). Does not work on macOS because macOS UI functions must be called from application main thread only (sucks!).


Syntax

folder, ret = gh_utils.nfd_pick_folder(
 default_path
)

Languages

Lua - Python


Parameters


Return Values


Code sample


filename, ret = gh_utils.nfd_pick_folder("")
            


shared_variable_create

Description

Creates a named shared variables. Shared variables allow to pass values between two windows or between Lua and Python scripts.


Syntax

sv = gh_utils.shared_variable_create(
 name
)

Languages

Lua - Python


Parameters


Return Values


Code sample


sv_name = "sv1"
sv = gh_utils.shared_variable_create(sv_name)
            


shared_variable_kill

Description

Destroys a shared variable.


Syntax

gh_utils.shared_variable_kill(
 sv_name
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_kill(sv1_name)
            


shared_variable_is_exist

Description

Checks if a shared variable exists.


Syntax

is_exist = gh_utils.shared_variable_is_exist(
 sv_name
)

Languages

Lua - Python


Parameters


Return Values


Code sample


state = gh_utils.shared_variable_is_exist(sv_name)
            


shared_variable_set_value_4f

Description

Sets a 4D value.


Syntax

gh_utils.shared_variable_set_value_4f(
 sv_name,
 x, y, z, w
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_set_value_4f(sv_name, 0.2, 0.3, 0.4, 1.0)
            


shared_variable_get_value_4f

Description

Gets a 4D value.


Syntax

x, y, z, w = gh_utils.shared_variable_get_value_4f(
 sv_name
)

Languages

Lua - Python


Parameters


Return Values


Code sample


x, y, z, w = gh_utils.shared_variable_get_value_4f(sv_name)
            


shared_variable_set_value_str

Description

Sets a string value.


Syntax

gh_utils.shared_variable_set_value_str(
 sv_name,
 str
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_set_value_str(sv_name, str)
            


shared_variable_get_value_str

Description

Gets a string value.


Syntax

str = gh_utils.shared_variable_get_value_str(
 sv_name
)

Languages

Lua - Python


Parameters


Return Values


Code sample


str = gh_utils.shared_variable_get_value_str(sv_name)
            


shared_variable_create_array

Description

Creates a shared variable that holds an array of elements of same type.


Syntax

sv_id = gh_utils.shared_variable_create_array(
 sv_name,
 sv_type,
 num_elements
)

Languages

Lua - Python


Parameters


Return Values


Code sample


num_textures = 16
gh_utils.shared_variable_create_array("texture_ids", "integer", num_textures)
            


shared_variable_set_array_value_1f

Description

Sets the value of a particular element of an array.


Syntax

gh_utils.shared_variable_set_array_value_1f(
 sv_name,
 element_index,
 element_value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_set_array_value_1f("texture_ids", 0, 16.0)
            


shared_variable_get_array_value_1f

Description

Gets the value of a particular element of an array.


Syntax

element_value = gh_utils.shared_variable_get_array_value_1f(
 sv_name,
 element_index
)

Languages

Lua - Python


Parameters


Return Values


Code sample


value = gh_utils.shared_variable_get_array_value_1f("texture_ids", 0)
            


shared_variable_set_array_value_1i

Description

Sets the value of a particular element of an array.


Syntax

gh_utils.shared_variable_set_array_value_1i(
 sv_name,
 element_index,
 element_value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_set_array_value_1i("texture_ids", 0, 2)
            


shared_variable_get_array_value_1i

Description

Gets the value of a particular element of an array.


Syntax

element_value = gh_utils.shared_variable_get_array_value_1i(
 sv_name,
 element_index
)

Languages

Lua - Python


Parameters


Return Values


Code sample


value = gh_utils.shared_variable_get_array_value_1i("texture_ids", 0)
            


shared_variable_set_array_value_str

Description

Sets the value of a particular element of an array.


Syntax

gh_utils.shared_variable_set_array_value_str(
 sv_name,
 element_index,
 element_value
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.shared_variable_set_array_value_str("texture_ids", 0, "abcd")
            


shared_variable_get_array_value_str

Description

Gets the value of a particular element of an array.


Syntax

element_value = gh_utils.shared_variable_get_array_value_str(
 sv_name,
 element_index
)

Languages

Lua - Python


Parameters


Return Values


Code sample


value = gh_utils.shared_variable_get_array_value_str("texture_ids", 0)
            


sys_exec

Description

Executes a system command.


Syntax

gh_utils.sys_exec(
 command,
 parameters,
 exe_dir
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


local demo_dir = gh_utils.getdemo_dir() 
gh_utils.sys_exec("ffmpeg", "-i input.mp4 output.avi", demo_dir)
            


dylib_load

Description

Loads a dynamic library. Check the forum for more information about loading dynamic libraries


Syntax

dylib_id = gh_utils.dylib_load(
 dylib_filename
)

Languages

Lua - Python


Parameters


Return Values


Code sample


dylib_id = gh_utils.dylib_load("/Users/toto/my3dcode.dylib")
            


dylib_unload

Description

unloads a dynamic library.


Syntax

gh_utils.dylib_unload(
 dylib_id
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


 gh_utils.dylib_unload(dylib_id)
            


dylib_start

Description

Calls the start function of a dynamic library.


Syntax

gh_utils.dylib_start(
 dylib_id,
 width, height,
 data
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


 gh_utils.dylib_start(dylib_id, width, height, "")
            


dylib_stop

Description

Calls the stop function of a dynamic library.


Syntax

gh_utils.dylib_stop(
 dylib_id,
 data
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


 gh_utils.dylib_stop(dylib_id, "")
            


dylib_frame

Description

Calls the frame function of a dynamic library.


Syntax

gh_utils.dylib_frame(
 dylib_id,
 elapsed_time,
 data
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


 gh_utils.dylib_frame(dylib_id, elapsed_time, "")
            


dylib_resize

Description

Calls the frame function of a dynamic library.


Syntax

gh_utils.dylib_resize(
 dylib_id,
 width, height,
 data
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


 gh_utils.dylib_resize(dylib_id, width, height, "")
            


dylib_set_message

Description

Sets a message. Allows to communicate with the dylib.


Syntax

gh_utils.dylib_set_message(
 dylib_id,
 message
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


message = "....."
 gh_utils.dylib_set_message(dylib_id, message)
            


dylib_set_message

Description

Gets a message. Allows to communicate with the dylib.


Syntax

message = gh_utils.dylib_set_message(
 dylib_id
)

Languages

Lua - Python


Parameters


Return Values


Code sample


 message = gh_utils.dylib_get_message(dylib_id)
            


ftgl_font_texture_load

Description

Loads a font texture from a true type font (TTF) file.


Syntax

font_texture = gh_utils.ftgl_font_texture_load(
 filename,
 height,
 texture_width, texture_height,
 _5, _6
)

Languages

Lua - Python


Parameters


Return Values


Code sample


font_texture = gh_utils.ftgl_font_texture_load(filename, 50, 1024, 1024, 0, 0)
            


ftgl_font_create

Description

Creates a font object from a font texture.


Syntax

font = gh_utils.ftgl_font_create(
 font_texture
)

Languages

Lua - Python


Parameters


Return Values


Code sample


font = gh_utils.ftgl_font_create(font_texture)
            


ftgl_font_add_text2d

Description

Adds a 2D text in a font.


Syntax

gh_utils.ftgl_font_add_text2d(
 font,
 x, y,
 r, g, b, a,
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_add_text2d(font, 10, 20, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font, 10, 40, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line2")
            


ftgl_font_add_text3d

Description

Adds a 3D text in a font.


Syntax

gh_utils.ftgl_font_add_text3d(
 font,
 x, y, z,
 r, g, b, a,
 text
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_add_text3d(font, x, y, z, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font, x+20, y-30, z-30, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line2")
            


ftgl_font_clear

Description

Clears all 2D texts in a font. Useful with dynamic texts


Syntax

gh_utils.ftgl_font_clear(
 font
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_clear(font)
gh_utils.ftgl_font_add_text2d(font, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font)
            


ftgl_font_render

Description

Renders a 2D font.


Syntax

gh_utils.ftgl_font_render(
 font
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_clear(font)
gh_utils.ftgl_font_add_text2d(font, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font)
            


ftgl_font_kill

Description

Kills a font (TERMINATE script)


Syntax

gh_utils.ftgl_font_kill(
 font
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_kill(font)
            


ftgl_font_texture_kill

Description

Kills a font texture (TERMINATE script)


Syntax

gh_utils.ftgl_font_texture_kill(
 font_texture
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample


gh_utils.ftgl_font_texture_kill(font_texture)
            






GeeXLab Rootard Guide | Downloads | Contact | Newsletter