< 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: 245
- gh_utils.box_create ()
- gh_utils.box_update_size ()
- gh_utils.buffer_copy ()
- gh_utils.buffer_crc32 ()
- gh_utils.buffer_create ()
- gh_utils.buffer_kill ()
- gh_utils.buffer_md5 ()
- gh_utils.buffer_read_1f ()
- gh_utils.buffer_read_2f ()
- gh_utils.buffer_read_3f ()
- gh_utils.buffer_read_4f ()
- gh_utils.buffer_read_byte ()
- gh_utils.buffer_read_line ()
- gh_utils.buffer_sha1 ()
- gh_utils.buffer_sha256 ()
- gh_utils.buffer_sha512 ()
- gh_utils.buffer_to_file ()
- gh_utils.buffer_write_1f ()
- gh_utils.buffer_write_2f ()
- gh_utils.buffer_write_3f ()
- gh_utils.buffer_write_4f ()
- gh_utils.buffer_write_byte ()
- gh_utils.circle_create ()
- gh_utils.circle_create_v2 ()
- gh_utils.circle_update_radius ()
- gh_utils.clipboard_get_text ()
- gh_utils.clipboard_set_text ()
- gh_utils.cpu_get_mem_available_size_mb ()
- gh_utils.cpu_get_mem_size_mb ()
- gh_utils.cpu_get_name ()
- gh_utils.cpu_get_speed_mhz ()
- gh_utils.cpu_usage_cleanup ()
- gh_utils.cpu_usage_get_core_count ()
- gh_utils.cpu_usage_get_core_usage ()
- gh_utils.cpu_usage_init ()
- gh_utils.cpu_usage_update ()
- gh_utils.do_file_from_sqlite3_blob ()
- gh_utils.do_file_from_zip ()
- gh_utils.do_screenshot ()
- gh_utils.do_screenshot_v2 ()
- gh_utils.do_screenshot_v3 ()
- gh_utils.do_screenshot_v4 ()
- gh_utils.do_screenshot_v5 ()
- gh_utils.do_screenshot_v6 ()
- gh_utils.screenshot_threaded_get_stats ()
- gh_utils.screenshot_kill_image_saving_thread ()
- gh_utils.drop_files_get_file_by_index ()
- gh_utils.drop_files_get_file_by_index_w ()
- gh_utils.drop_files_get_num_files ()
- gh_utils.dylib_frame ()
- gh_utils.dylib_get_message ()
- gh_utils.dylib_load ()
- gh_utils.dylib_resize ()
- gh_utils.dylib_set_message ()
- gh_utils.dylib_start ()
- gh_utils.dylib_stop ()
- gh_utils.dylib_unload ()
- gh_utils.exe_from_buffer ()
- gh_utils.exe_script ()
- gh_utils.exe_script_v2 ()
- gh_utils.exe_script_v3 ()
- gh_utils.exe_string ()
- gh_utils.extract_dir_from_filename ()
- gh_utils.extract_file_name ()
- gh_utils.file_buffer_create ()
- gh_utils.file_crc32 ()
- gh_utils.file_md5 ()
- gh_utils.file_sha1 ()
- gh_utils.file_sha256 ()
- gh_utils.file_sha512 ()
- gh_utils.crc32 ()
- gh_utils.md5 ()
- gh_utils.sha1 ()
- gh_utils.sha256 ()
- gh_utils.sha512 ()
- gh_utils.file_size ()
- gh_utils.font_create ()
- gh_utils.font_render ()
- gh_utils.font_render3d ()
- gh_utils.font_set_viewport_info ()
- gh_utils.ftgl_font_add_text2d ()
- gh_utils.ftgl_font_add_text3d ()
- gh_utils.ftgl_font_clear ()
- gh_utils.ftgl_font_create ()
- gh_utils.ftgl_font_kill ()
- gh_utils.ftgl_font_render ()
- gh_utils.ftgl_font_texture_kill ()
- gh_utils.ftgl_font_texture_load ()
- gh_utils.get_app_dir ()
- gh_utils.get_app_version ()
- gh_utils.get_command_line ()
- gh_utils.get_date_str ()
- gh_utils.get_date_str_v2 ()
- gh_utils.get_demo_dir ()
- gh_utils.get_demo_zip_filename ()
- gh_utils.get_elapsed_time ()
- gh_utils.get_time ()
- gh_utils.get_time_microseconds ()
- gh_utils.get_lib_dir ()
- gh_utils.get_desktop_resolution ()
- gh_utils.get_os_info ()
- gh_utils.get_platform ()
- gh_utils.get_platform_name ()
- gh_utils.get_time_step ()
- gh_utils.get_uptime ()
- gh_utils.global_array_char_alloc ()
- gh_utils.global_array_char_get ()
- gh_utils.global_array_char_set ()
- gh_utils.global_array_float_alloc ()
- gh_utils.global_array_float_get ()
- gh_utils.global_array_float_set ()
- gh_utils.global_array_int_alloc ()
- gh_utils.global_array_int_get ()
- gh_utils.global_array_int_set ()
- gh_utils.grid_create ()
- gh_utils.grid_set_display_lines_options ()
- gh_utils.grid_set_geometry_params ()
- gh_utils.grid_set_lines_color ()
- gh_utils.grid_set_main_lines_color ()
- gh_utils.grid_set_main_x_axis_color ()
- gh_utils.grid_set_main_z_axis_color ()
- gh_utils.hex_color_to_rgb ()
- gh_utils.is_64bit ()
- gh_utils.is_luajit ()
- gh_utils.is_rpi ()
- gh_utils.line_create ()
- gh_utils.line_set_end_color ()
- gh_utils.line_set_end_position ()
- gh_utils.line_set_start_color ()
- gh_utils.line_set_start_position ()
- gh_utils.math_length_vec3 ()
- gh_utils.math_normalize_vec3 ()
- gh_utils.math_quat_from_lookat ()
- gh_utils.math_quat_from_vectors_rotation ()
- gh_utils.math_quat_from_euler_angles ()
- gh_utils.nfd_open_dialog ()
- gh_utils.nfd_pick_folder ()
- gh_utils.nfd_save_dialog ()
- gh_utils.open_url ()
- gh_utils.printc ()
- gh_utils.progress_bar_inc ()
- gh_utils.progress_bar_set ()
- gh_utils.project_3d_to_2d_v1 ()
- gh_utils.project_3d_to_2d_v2 ()
- gh_utils.random ()
- gh_utils.srandom ()
- gh_utils.random16 ()
- gh_utils.random32 ()
- gh_utils.random_init ()
- gh_utils.random_uniform_real ()
- gh_utils.random_uniform_int ()
- gh_utils.random_poisson ()
- gh_utils.random_normal ()
- gh_utils.raycast_cast_ray ()
- gh_utils.raycast_cast_ray_v2 ()
- gh_utils.raycast_get_ray ()
- gh_utils.raycast_get_ray_ortho_cam ()
- gh_utils.sanitize_string ()
- gh_utils.shared_variable_create ()
- gh_utils.shared_variable_create_array ()
- gh_utils.shared_variable_get_array_value_1f ()
- gh_utils.shared_variable_get_array_value_1i ()
- gh_utils.shared_variable_get_array_value_str ()
- gh_utils.shared_variable_get_value_4f ()
- gh_utils.shared_variable_get_value_str ()
- gh_utils.shared_variable_get_value_buffer ()
- gh_utils.shared_variable_get_value_buffer ()
- gh_utils.shared_variable_get_value_ptr ()
- gh_utils.shared_variable_is_exist ()
- gh_utils.shared_variable_kill ()
- gh_utils.shared_variable_set_array_value_1f ()
- gh_utils.shared_variable_set_array_value_1i ()
- gh_utils.shared_variable_set_array_value_str ()
- gh_utils.shared_variable_set_value_4f ()
- gh_utils.shared_variable_set_value_str ()
- gh_utils.shared_variable_set_value_buffer ()
- gh_utils.shared_variable_set_value_ptr ()
- gh_utils.sphere_create ()
- gh_utils.sphere_update_radius ()
- gh_utils.stop_demo ()
- gh_utils.sys_exec ()
- gh_utils.shell_exe ()
- gh_utils.shell_exe_v2 ()
- gh_utils.thread_sleep ()
- gh_utils.thread_lock_create ()
- gh_utils.thread_lock_kill_all ()
- gh_utils.thread_lock_acquire ()
- gh_utils.thread_lock_release ()
- gh_utils.trace ()
- gh_utils.trackball_get_orientation ()
- gh_utils.trackball_init ()
- gh_utils.tripod_visualizer_camera_render ()
- gh_utils.vendor_name_from_vendor_id ()
- gh_utils.webcam_create ()
- gh_utils.webcam_get_frame_size ()
- gh_utils.webcam_get_name ()
- gh_utils.webcam_get_num ()
- gh_utils.webcam_grab_frame ()
- gh_utils.webcam_kill ()
- gh_utils.webcam_start ()
- gh_utils.webcam_start_v2 ()
- gh_utils.webcam_stop ()
- gh_utils.webcam_update_texture ()
- gh_utils.zip_buffer_create ()
- gh_utils.zip_to_file ()
- gh_utils.win_registry_read_value_dword ()
- gh_utils.win_registry_write_value_dword ()
- gh_utils.win_registry_read_value_string ()
- gh_utils.win_registry_write_value_string ()
- gh_utils.win_registry_create_key ()
- gh_utils.win_registry_delete_key ()
- gh_utils.pack_rgba_u8 ()
- gh_utils.unpack_rgba_u8 ()
- gh_utils.set_new_scene_data ()
- gh_utils.temp_directory_path ()
- gh_utils.get_app_name ()
- gh_utils.spirv_to_smolv ()
- gh_utils.smolv_to_spirv ()
- gh_utils.math_from_to_rotation_matrix3x3 ()
- gh_utils.file_read ()
- gh_utils.file_write ()
- gh_utils.file_size ()
- gh_utils.shmem_create ()
- gh_utils.shmem_kill ()
- gh_utils.shmem_is_available ()
- gh_utils.shmem_map ()
- gh_utils.shmem_unmap ()
- gh_utils.win32_audio_volume_control ()
- gh_utils.qr_code_scan ()
- gh_utils.qr_code_gen ()
- gh_utils.set_app_title_bar ()
- gh_utils.get_app_title_bar ()
- gh_utils.spout_create_sender ()
- gh_utils.spout_kill_sender ()
- gh_utils.spout_send_texture ()
- gh_utils.spout_send_texture_rt ()
- gh_utils.spout_register_directshow_filter ()
- gh_utils.curl_download_file_v1 ()
- gh_utils.curl_download_file_in_buffer ()
- gh_utils.curl_get_file_time_and_size ()
- gh_utils.align_up ()
- gh_utils.align_down ()
- gh_utils.dnd_set_check_scene_file ()
- gh_utils.get_lua_version ()
- gh_utils.get_app_build_date ()
box_create
Description
Creates a simple box.
Syntax
box_id = gh_utils.box_create(
w, h, d,
r, g, b, a
)
Languages
Parameters
- w, h, d [REAL]: width, height and depth of the box
- r, g, b, a [REAL]: RGBA color
Return Values
- box_id [ID]: box identifier
Code sample
box_id = gh_utils.box_create(10.0, 10.0, 10.0, 1.0, 1.0, 0.0, 1.0)
box_update_size
Description
Updates the size of a box.
Syntax
gh_utils.box_update_size(
box_id,
w, h, d
)
Languages
Parameters
- box_id [ID]: box identifier
- w, h, d [REAL]: width, height and depth of the box
Return Values
This function has no return value(s).
Code sample
gh_utils.box_update_size(box_id, 12.0, 12.0, 12.0)
buffer_copy
Description
Copies a source memory buffer to a destination memory buffer.
Syntax
gh_utils.buffer_copy(
src_buff_ptr,
src_offset,
dst_buff_ptr,
dst_offset,
num_bytes
)
Languages
Parameters
- src_buff_ptr [POINTER]: pointer to the source buffer
- src_offset [INTEGER]: offset in the source buffer in bytes
- dst_buff_ptr [POINTER]: pointer to the destination buffer
- dst_offset [INTEGER]: offset in the destination buffer in bytes
- num_bytes [INTEGER]: number of bytes that will be copied
Return Values
This function has no return value(s).
Code sample
src_ptr, size = gh_utils.buffer_create(1024)
dst_ptr, size = gh_utils.buffer_create(1024)
...
gh_utils.buffer_create(src_ptr, 0, dst_ptr, 0, 1024)
...
buffer_crc32
Description
Helper function to get the CRC32 hash code of a memory buffer.
Syntax
hashcode = gh_utils.buffer_crc32(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- hashcode [STRING]: hashcode of the buffer
Code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_crc32(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
buffer_create
Description
Creates an empty memory buffer.
Syntax
buff_ptr, buff_size = gh_utils.buffer_create(
size
)
Languages
Parameters
- size [INTEGER]: size in bytes.
Return Values
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
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(), file_buffer_create() or zip_buffer_create.
Syntax
gh_utils.buffer_kill(
buff_ptr
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
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_md5
Description
Helper function to get the MD5 hash code of a memory buffer.
Syntax
hashcode = gh_utils.buffer_md5(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- hashcode [STRING]: hashcode of the buffer
Code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_md5(buffer_ptr, buffer_size)
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(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
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(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
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(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
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(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
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_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(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
Return Values
- x [INTEGER]: value of the byte
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_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(
buff_ptr,
buff_size,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- line [STRING]: content of a line
- line_size [INTEGER]: size of the line in bytes. If line_size==0, the end of the buffer is reached.
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, buffer_size, line_offset)
line_offset = line_offset + line_size
-- read the second line:
line, line_size = gh_utils.buffer_read_line(buffer_ptr, buffer_size, line_offset)
...
...
...
gh_utils.file_buffer_kill(buffer_ptr)
buffer_sha1
Description
Helper function to get the SHA1 hash code of a memory buffer.
Syntax
hashcode = gh_utils.buffer_sha1(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- hashcode [STRING]: hashcode of the buffer
Code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_sha1(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
buffer_sha256
Description
Helper function to get the SHA256 hash code of a memory buffer.
Syntax
hashcode = gh_utils.buffer_sha256(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- hashcode [STRING]: hashcode of the buffer
Code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_sha256(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
buffer_sha512
Description
Helper function to get the SHA512 hash code of a memory buffer.
Syntax
hashcode = gh_utils.buffer_sha512(
buff_ptr,
offset
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the line to read in bytes
Return Values
- hashcode [STRING]: hashcode of the buffer
Code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_sha512(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
buffer_to_file
Description
Save the content of a memory buffer into a file.
Syntax
ret = gh_utils.buffer_to_file(
buff_ptr,
buff_size,
dst_filename
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
- dst_filename [STRING]: absolute path of the file on the file system
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
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
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(
buff_ptr,
offset,
x
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
- x [REAL]: value
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(
buff_ptr,
offset,
x, y
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
- x, y [REAL]: value
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(
buff_ptr,
offset,
x, y, z
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
- x, y, z [REAL]: value
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(
buff_ptr,
offset,
x, y, z, w
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
- x, y, z, w [REAL]: value
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_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(
buff_ptr,
offset,
x
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- offset [INTEGER]: offset of the byte to read in bytes
- x [INTEGER]: value of the byte
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)
circle_create
Description
Creates a simple circle in the XZ plane.
Syntax
circle_id = gh_utils.circle_create(
radius,
subdivisions,
r, g, b, a
)
Languages
Parameters
- radius [REAL]: radius
- subdivisions [INTEGER]: subdivisions
- r, g, b, a [REAL]: RGBA color
Return Values
- circle_id [ID]: circle identifier
Code sample
circle_id = gh_utils.circle_create(10.0, 20, 1.0, 1.0, 0.0, 1.0)
circle_create_v2
Description
Creates a simple circle.
Syntax
circle_id = gh_utils.circle_create_v2(
plane_type,
radius,
subdivisions,
r, g, b, a
)
Languages
Parameters
- plane_type [ENUM]: 0 (XZ), 1 (XY) or 2 (YZ)
- radius [REAL]: radius
- subdivisions [INTEGER]: subdivisions
- r, g, b, a [REAL]: RGBA color
Return Values
- circle_id [ID]: circle identifier
Code sample
plane_type = 1
circle_id = gh_utils.circle_create_v2(plane_type, 10.0, 20, 1.0, 1.0, 0.0, 1.0)
circle_update_radius
Description
Updates the radius of a circle.
Syntax
gh_utils.circle_update_radius(
circle_id,
radius
)
Languages
Parameters
- circle_id [ID]: circle identifier
- radius [REAL]: radius
Return Values
This function has no return value(s).
Code sample
gh_utils.circle_update_radius(circle_id, 12.0)
clipboard_get_text
Description
Allows to get the content (text type) of the clipboard (Windows and Linux only). It's the past operation of 'Copy and Paste'
Syntax
text, text_len = gh_utils.clipboard_get_text()
Languages
Parameters
This function has no input parameter(s).
Return Values
- text [STRING]: text from the clipboard
- text_len [INTEGER]: length of the text
Code sample
text, text_len = gh_utils.clipboard_get_text()
clipboard_set_text
Description
Allows to copy a string to the clipboard (Windows only). It's the copy operation of 'Copy and Paste'
Syntax
gh_utils.clipboard_set_text(
text
)
Languages
Parameters
- text [STRING]: text to be copied in the clipboard
Return Values
This function has no return value(s).
Code sample
gh_utils.clipboard_set_text("Hello!")
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
Parameters
This function has no input parameter(s).
Return Values
- size [INTEGER]: size in MB
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
Parameters
This function has no input parameter(s).
Return Values
- size [INTEGER]: size in MB
Code sample
mem_size_mb = gh_utils.cpu_get_mem_size_mb()
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
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
Parameters
This function has no input parameter(s).
Return Values
Code sample
local cpu_speed = gh_utils.cpu_get_speed_mhz()
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
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_get_core_count
Description
Returns the number of CPU cores (Windows only).
Syntax
num_cores = gh_utils.cpu_usage_get_core_count()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_cores [INTEGER]: number of cores
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
Parameters
- index [INTEGER]: core index from 0 to cpu_usage_get_core_count()-1
Return Values
- usage [INTEGER]: core usage in percent
Code sample
local core_index = 0
local usage = gh_utils.cpu_usage_get_core_usage(core_index)
cpu_usage_init
Description
Initializes the CPU usage code. Should be called in INIT scripts (Windows only).
Syntax
ret = gh_utils.cpu_usage_init()
Languages
Parameters
This function has no input parameter(s).
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
local ret = gh_utils.cpu_usage_init()
cpu_usage_update
Description
Updates the CPU usage. Should be called in a FRAME script (Windows only).
Syntax
gh_utils.cpu_usage_update()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
gh_utils.cpu_usage_update()
do_file_from_sqlite3_blob
Description
Executes a script stored in a SQLite3 blob.
Syntax
ret = gh_utils.do_file_from_sqlite3_blob(
db_id,
column
)
Languages
Parameters
- db_id [ID]: database identifier
- column [INTEGER]: index of the column
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
gh_utils.do_file_from_sqlite3_blob(db_id, 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
Parameters
- zip_filename [STRING]: absolute path of the zip file
- filename [STRING]: script file in the zip archive
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
zip_filename = demo_dir .. "data.zip"
gh_utils.do_file_from_zip(zip_filename, "scripts/init02.lua")
do_screenshot
Description
Does a screenshot and write it to a file (JPEG file) - OpenGL and Vulkan renderers.
Syntax
gh_utils.do_screenshot(
filename,
absolute_path
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- absolute_path [BOOLEAN]: file path: 1 (absolute) or 0 (relative)
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 and Vulkan renderers.
Syntax
gh_utils.do_screenshot_v2(
filename,
flip_image
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- flip_image [BOOLEAN]: vertical flip of the image before saving: 1 (true) or 0 (false)
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 and Vulkan renderers.
Syntax
gh_utils.do_screenshot_v3(
filename,
x, y, width, height,
flip_image
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- x, y, width, height [INTEGER]: zone of the viewport to save
- flip_image [BOOLEAN]: vertical flip of the image before saving: 1 (true) or 0 (false)
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)
do_screenshot_v4
Description
Does a screenshot and write it to a file - OpenGL and Vulkan renderers.
Syntax
gh_utils.do_screenshot_v4(
filename,
x, y, width, height,
flip_image,
format,
saving_options
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- x, y, width, height [INTEGER]: zone of the viewport to save
- flip_image [BOOLEAN]: vertical flip of the image before saving: 1 (true) or 0 (false)
- format [STRING]: image format (.jpg, .bmp, etc) (depends on the image plugin)
- saving_options [STRING]: saving options (depends on the image plugin)
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
format = "jpg"
saving_options = ""
gh_utils.do_screenshot_v4(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options)
do_screenshot_v5
Description
Does a screenshot and write it to a file - OpenGL and Vulkan renderers.
Syntax
gh_utils.do_screenshot_v5(
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- x, y, width, height [INTEGER]: zone of the viewport to save
- flip_image [BOOLEAN]: vertical flip of the image before saving: 1 (true) or 0 (false)
- format [STRING]: image format (.jpg, .bmp, etc) (depends on the image plugin)
- saving_options [STRING]: saving options (depends on the image plugin)
- image_codec_name [STRING]: name of the image plugin used to save the image: stb, FreeImage, ImageMagick.
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
format = "jpg"
saving_options = ""
image_codec_name = "FreeImage" # default codec: "stb"
gh_utils.do_screenshot_v5(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options, image_codec_name)
do_screenshot_v6
Description
Does a screenshot and write it to a file - OpenGL and Vulkan renderers. The image saving is done in a separate system thread, leading to performance gain compared to do_screenshot_v5.
Syntax
gh_utils.do_screenshot_v6(
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
Languages
Parameters
- filename [STRING]: relative path of the screenshot file
- x, y, width, height [INTEGER]: zone of the viewport to save
- flip_image [BOOLEAN]: vertical flip of the image before saving: 1 (true) or 0 (false)
- format [STRING]: image format (.jpg, .bmp, etc) (depends on the image plugin)
- saving_options [STRING]: saving options (depends on the image plugin)
- image_codec_name [STRING]: name of the image plugin used to save the image: stb, FreeImage, ImageMagick.
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
format = "jpg"
saving_options = ""
image_codec_name = "FreeImage" # default codec: "stb"
gh_utils.do_screenshot_v6(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options, image_codec_name)
screenshot_threaded_get_stats
Description
Returns the number of images currently saved and the number of images queued (that are not saved yet). This function works with do_screenshot_v6().
Syntax
num_saved_images, num_queued_images = gh_utils.screenshot_threaded_get_stats()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_saved_images [INTEGER]: number of images already saved
- num_queued_images [INTEGER]: number of images queued (not yet saved)
Code sample
gh_utils.do_screenshot_v6(.......)
num_saved_images, num_queued_images = gh_utils.screenshot_threaded_get_stats()
screenshot_kill_image_saving_thread
Description
Stops and kills the image saving thread created by do_screenshot_v6().
Syntax
gh_utils.screenshot_kill_image_saving_thread()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
gh_utils.screenshot_kill_image_saving_thread()
drop_files_get_file_by_index
Description
Returns the name of a particular file that has been dropped on the application. This function is useful in a DRAG_N_DROP script (Windows only).
Syntax
filename = gh_utils.drop_files_get_file_by_index(
index
)
Languages
Parameters
- index [INTEGER]: index of the file: from 0 to drop_files_get_num_files()-1
Return Values
- filename [STRING]: name of a dropped file
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
drop_files_get_file_by_index_w
Description
Wide character / unicode version of drop_files_get_file_by_index. Returns the name of a particular file that has been dropped on the application. This function is useful in a DRAG_N_DROP script (Windows only).
Syntax
filename = gh_utils.drop_files_get_file_by_index_w(
index
)
Languages
Parameters
- index [INTEGER]: index of the file: from 0 to drop_files_get_num_files()-1
Return Values
- filename [STRING]: name of a dropped file
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_w(0)
end
drop_files_get_num_files
Description
Returns the number of files that have been dropped on the application. This function is useful in a DRAG_N_DROP script (Windows only).
Syntax
num_dropped = gh_utils.drop_files_get_num_files()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_dropped [INTEGER]: number of dropped files
Code sample
num_files = gh_utils.drop_files_get_num_files()
dylib_frame
Description
Calls the frame function of a dynamic library.
Syntax
gh_utils.dylib_frame(
dylib_id,
elapsed_time,
data
)
Languages
Parameters
- dylib_id [ID]: dylib identifier
- elapsed_time [REAL]: elapsed time in seconds
- data [STRING]: user data
Return Values
This function has no return value(s).
Code sample
gh_utils.dylib_frame(dylib_id, elapsed_time, "")
dylib_get_message
Description
Gets a message. Allows to communicate with the dylib.
Syntax
message = gh_utils.dylib_get_message(
dylib_id
)
Languages
Parameters
- dylib_id [ID]: dylib identifier
Return Values
- message [STRING]: message
Code sample
message = gh_utils.dylib_get_message(dylib_id)
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
Parameters
- dylib_filename [STRING]: absolute path of the dynamic lib
Return Values
- dylib_id [ID]: dylib identifier
Code sample
dylib_id = gh_utils.dylib_load("/Users/toto/my3dcode.dylib")
dylib_resize
Description
Calls the frame function of a dynamic library.
Syntax
gh_utils.dylib_resize(
dylib_id,
width, height,
data
)
Languages
Parameters
- dylib_id [ID]: dylib identifier
- width, height [INTEGER]: width and height of the 3D window
- data [STRING]: user data
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
Parameters
- dylib_id [ID]: dylib identifier
- message [STRING]: message
Return Values
This function has no return value(s).
Code sample
message = "....."
gh_utils.dylib_set_message(dylib_id, message)
dylib_start
Description
Calls the start function of a dynamic library.
Syntax
gh_utils.dylib_start(
dylib_id,
width, height,
data
)
Languages
Parameters
- dylib_id [ID]: dylib identifier
- width, height [INTEGER]: width and height of the 3D window
- data [STRING]: user data
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
Parameters
- dylib_id [ID]: dylib identifier
- data [STRING]: user data
Return Values
This function has no return value(s).
Code sample
gh_utils.dylib_stop(dylib_id, "")
dylib_unload
Description
Unloads a dynamic library.
Syntax
gh_utils.dylib_unload(
dylib_id
)
Languages
Parameters
- dylib_id [ID]: dylib identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.dylib_unload(dylib_id)
exe_from_buffer
Description
Executes a script from a memory buffer.
Syntax
ret = gh_utils.exe_from_buffer(
buff_ptr,
buff_size
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
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)
exe_script
Description
Executes a script.
Syntax
gh_utils.exe_script(
name,
threaded
)
Languages
Parameters
- name [STRING]: name of the script
- threaded [BOOLEAN]: runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
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
Parameters
- name [STRING]: name of the script
- threaded [BOOLEAN]: runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
- create_worker_wind3d [BOOLEAN]: creates a worker 3D window: 1 (yes) or 0 (no). The worker 3D window is required if you plan to call an OpenGL related function in the threaded script
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
Parameters
- name [STRING]: name of the script
- threaded [BOOLEAN]: runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
- create_worker_wind3d [BOOLEAN]: creates a worker 3D window: 1 (yes) or 0 (no). The worker 3D window is required if you plan to call an OpenGL related function in the threaded script
- thread_affinity_mask [INTEGER]: specifies the affinity mask for the thread. Only on Windows. A thread affinity mask is a bit vector in which each bit represents a logical processor. Set this mask to 0 to disable it.
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
Parameters
- lua_python_commands [STRING]: commands in Lua or Python
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
gh_utils.exe_string("demo_folder = gh_utils.get_demo_dir()")
print(demo_folder)
extract_dir_from_filename
Description
Utility function that extracts a path / folder from a file name.
Syntax
dir_path = gh_utils.extract_dir_from_filename(
filename
)
Languages
Parameters
- filename [STRING]: filename
Return Values
- dir_path [STRING]: directory path
Code sample
dir_path = gh_utils.extract_dir_from_filename(filename)
extract_file_name
Description
Utility function that extracts a file name from a full path.
Syntax
filename = gh_utils.extract_file_name(
fullpath
)
Languages
Parameters
- fullpath [STRING]: full path
Return Values
- filename [STRING]: filename
Code sample
filename = gh_utils.extract_file_name(full_filename)
file_buffer_create
Description
Gets a pointer to the memory buffer of a file stored in the file system.
Syntax
buff_ptr, buff_size = gh_utils.file_buffer_create(
filename
)
Languages
Parameters
- filename [STRING]: absolute path of the file
Return Values
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
Code sample
filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
...
gh_utils.buffer_kill(buffer_ptr)
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
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- crc32 [INTEGER]: CRC32 code
- crc32_str [STRING]: string version of the CRC32 code
Code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
crc32, crc32_str = gh_utils.file_crc32(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
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_md5(zip_filename, filename)
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
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- hashcode [STRING]: hashcode of the file
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
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha256(zip_filename, filename)
file_sha512
Description
Helper function to get the SHA-512 hash code of a file on the disk or in a zip file.
Syntax
hashcode = gh_utils.file_sha512(
zip_filename,
filename
)
Languages
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha512(zip_filename, filename)
crc32
Description
Helper function to get the CRC32 hash code of a string.
Syntax
hashcode = gh_utils.crc32(
str
)
Languages
Parameters
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
hashcode = gh_utils.crc32("hello")
md5
Description
Helper function to get the MD5 hash code of a string.
Syntax
hashcode = gh_utils.md5(
str
)
Languages
Parameters
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
hashcode = gh_utils.md5("hello")
sha1
Description
Helper function to get the SHA-1 hash code of a string.
Syntax
hashcode = gh_utils.sha1(
str
)
Languages
Parameters
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
hashcode = gh_utils.sha1("hello")
sha256
Description
Helper function to get the SHA-256 hash code of a string.
Syntax
hashcode = gh_utils.sha256(
str
)
Languages
Parameters
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
hashcode = gh_utils.sha256("hello")
sha512
Description
Helper function to get the SHA-512 hash code of a string.
Syntax
hashcode = gh_utils.sha512(
str
)
Languages
Parameters
Return Values
- hashcode [STRING]: hashcode of the file
Code sample
hashcode = gh_utils.sha512("hello")
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
Parameters
- zip_filename [STRING]: absolute path of a zip file. Optional
- filename [STRING]: absolute or relative path of the file
Return Values
- size [INTEGER]: size of the file in bytes
Code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
size = gh_utils.file_size(zip_filename, filename)
font_create
Description
Creates a new font.
Syntax
font_id = gh_utils.font_create(
font_name,
height
)
Languages
Parameters
- font_name [STRING]: TrueType font name, ex: Arial, Verdana
- height [INTEGER]: font height
Return Values
- font_id [ID]: font identifier
Code sample
font_id = gh_utils.font_create("Arial", 14)
font_render
Description
Renders (draws) a text.
Syntax
gh_utils.font_render(
font_id,
x, y,
r, g, b, a,
text
)
Languages
Parameters
- font_id [ID]: font identifier
- x, y [INTEGER]: X and Y start offsets in the current viewport
- r, g, b, a [REAL]: RGBA color of the text
- text [STRING]: text to render
Return Values
This function has no return value(s).
Code sample
gh_utils.font_set_viewport_info(font_id, 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_id,
x, y, z,
r, g, b, a,
text
)
Languages
Parameters
- font_id [ID]: font identifier
- x, y, z [REAL]: 3D position of the beginning of the text
- r, g, b, a [REAL]: RGBA color of the text
- text [STRING]: text to render
Return Values
This function has no return value(s).
Code sample
gh_utils.font_render3d(font_id, 0, 20.0, -20.0, 0.2, 1.0, 0.0, 1.0, "V1")
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_id,
x, y,
width, height
)
Languages
Parameters
- font_id [ID]: font identifier
- x, y [INTEGER]: viewport offsets
- width, height [INTEGER]: viewport size
Return Values
This function has no return value(s).
Code sample
gh_utils.font_set_viewport_info(font_id, 0, 0, width, height)
ftgl_font_add_text2d
Description
Adds a 2D text in a font.
Syntax
gh_utils.ftgl_font_add_text2d(
font_id,
x, y,
r, g, b, a,
text
)
Languages
Parameters
- font_id [ID]: font identifier
- x, y [INTEGER]: screen coordiantes of the beginning of the text
- r, g, b, a [REAL]: color of the text
- text [STRING]: text
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font_id, 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_id,
x, y, z,
r, g, b, a,
text
)
Languages
Parameters
- font_id [ID]: font identifier
- x, y, z [REAL]: 3D position of the beginning of the text
- r, g, b, a [REAL]: color of the text
- text [STRING]: text
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_add_text3d(font_id, x, y, z, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font_id, 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_id
)
Languages
Parameters
- font_id [ID]: font identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_clear(font_id)
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font_id)
ftgl_font_create
Description
Creates a font object from a font texture.
Syntax
font_id = gh_utils.ftgl_font_create(
font_tex_id
)
Languages
Parameters
- font_tex_id [ID]: font texture identifier
Return Values
- font_id [ID]: font identifier
Code sample
font_id = gh_utils.ftgl_font_create(font_tex_id)
ftgl_font_kill
Description
Kills a font (TERMINATE script).
Syntax
gh_utils.ftgl_font_kill(
font_id
)
Languages
Parameters
- font_id [ID]: font identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_kill(font_id)
ftgl_font_render
Description
Renders a 2D font.
Syntax
gh_utils.ftgl_font_render(
font_id
)
Languages
Parameters
- font_id [ID]: font identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_clear(font_id)
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font_id)
ftgl_font_texture_kill
Description
Kills a font texture (TERMINATE script).
Syntax
gh_utils.ftgl_font_texture_kill(
font_tex_id
)
Languages
Parameters
- font_tex_id [ID]: font texture identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.ftgl_font_texture_kill(font_tex_id)
ftgl_font_texture_load
Description
Loads a font texture from a TrueType (TTF) font file.
Syntax
font_tex_id = gh_utils.ftgl_font_texture_load(
filename,
height,
tex_width, tex_height,
_5, _6
)
Languages
Parameters
- filename [STRING]: TrueType font file
- height [INTEGER]: height of font glyphs
- tex_width, tex_height [INTEGER]: width and height of the font texture
- _5, _6 [INTEGER]: reserved
Return Values
- font_tex_id [ID]: font texture identifier
Code sample
font_tex_id = gh_utils.ftgl_font_texture_load(filename, 50, 1024, 1024, 0, 0)
get_app_dir
Description
Gets the directory of GeeXLab.
Syntax
dir = gh_utils.get_app_dir()
Languages
Parameters
This function has no input parameter(s).
Return Values
Code sample
app_dir = gh_utils.get_app_dir()
get_app_version
Description
Returns the four numbers that define the GeeXLab version.
Syntax
major, minor, patch, build = gh_utils.get_app_version()
Languages
Parameters
This function has no input parameter(s).
Return Values
- major, minor, patch, build [INTEGER]: version of GeeXLab
Code sample
major, minor, patch, build = gh_utils.get_app_version()
get_command_line
Description
Returns the command line used to lauch GeeXLab.
Syntax
command_line = gh_utils.get_command_line()
Languages
Parameters
This function has no input parameter(s).
Return Values
- command_line [STRING]: command line
Code sample
command_line = gh_utils.get_command_line()
get_date_str
Description
Gets the current date/time with the following format: Y.M.D.h.m.s. Handy funtion for naming files.
Syntax
date = gh_utils.get_date_str()
Languages
Parameters
This function has no input parameter(s).
Return Values
- date [STRING]: date (Y.M.D.h.m.s)
Code sample
date = gh_utils.get_date_str()
get_date_str_v2
Description
Gets the current date/time with the several formats: Y.M.D.h.m.s or Y.M.D@h:m:s. Handy funtion for naming files.
Syntax
date = gh_utils.get_date_str_v2(
format
)
Languages
Parameters
- format [INTEGER]: 0 (Y.M.D.h.m.s) or 1 (Y.M.D@h:m:s)
Return Values
Code sample
date = gh_utils.get_date_str_v2(1)
get_demo_dir
Description
Gets the directory of the current scene file.
Syntax
dir = gh_utils.get_demo_dir()
Languages
Parameters
This function has no input parameter(s).
Return Values
- dir [STRING]: directory of the current scene file
Code sample
demo_dir = gh_utils.get_demo_dir()
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
Parameters
This function has no input parameter(s).
Return Values
- demo_zip_filename [STRING]: filename of the main zip archive
Code sample
main_zip_filename = gh_utils.get_demo_zip_filename()
get_elapsed_time
Description
Gets the elapsed time since the start of the current scene but a a frame step resolution (for example 0.016 sec if FPS=60).
Syntax
elapsed_time = gh_utils.get_elapsed_time()
Languages
Parameters
This function has no input parameter(s).
Return Values
- elapsed_time [REAL]: elapsed time in seconds
Code sample
local elapsed_time = gh_utils.get_elapsed_time()
get_time
Description
Gets the elapsed time since the start of the current scene. Useful if you need to measure the processing time of a piece of code.
Syntax
time = gh_utils.get_time()
Languages
Parameters
This function has no input parameter(s).
Return Values
- time [REAL]: elapsed time in seconds
Code sample
local curr_time = gh_utils.get_time()
get_time_microseconds
Description
Gets the elapsed time since the start of the current scene. Useful if you need to measure the processing time of a piece of code.
Syntax
time = gh_utils.get_time_microseconds()
Languages
Parameters
This function has no input parameter(s).
Return Values
- time [INTEGER]: elapsed time in micro-seconds
Code sample
local curr_time_us = gh_utils.get_time_microseconds()
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
Parameters
This function has no input parameter(s).
Return Values
Code sample
lib_dir = gh_utils.get_lib_dir()
get_desktop_resolution
Description
Gets the default / native resolution of the desktop. For example, with a fullHD monitor, you should get 1920, 1080.
Syntax
width, height = gh_utils.get_desktop_resolution()
Languages
Parameters
This function has no input parameter(s).
Return Values
- width, height [STRING]: resolution of the desktop in pixels
Code sample
width, height = gh_utils.get_desktop_resolution()
get_os_info
Description
Gets some basic information about the host Operating System (OS).
Syntax
major, minor, build, name, codename = gh_utils.get_os_info()
Languages
Parameters
This function has no input parameter(s).
Return Values
- major, minor, build [INTEGER]: version of the OS
- name, codename [STRING]: string identication of the OS
Code sample
name, codename, major, minor, build = gh_utils.get_os_info()
get_platform
Description
Returns the platform: 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
Syntax
platform = gh_utils.get_platform()
Languages
Parameters
This function has no input parameter(s).
Return Values
- platform [ENUM]: 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
Code sample
platform = gh_utils.get_platform()
get_platform_name
Description
Returns the platform name: Windows xx-bit, macOS 10.x, Linux xx-bit, Raspberry Pi.
Syntax
platform_name = gh_utils.get_platform_name()
Languages
Parameters
This function has no input parameter(s).
Return Values
- platform_name [STRING]: the name of the platform
Code sample
platform_name = gh_utils.get_platform_name()
get_time_step
Description
Returns the time step between two consecutive frames.
Syntax
dt = gh_utils.get_time_step()
Languages
Parameters
This function has no input parameter(s).
Return Values
- dt [REAL]: time step in seconds
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
Parameters
This function has no input parameter(s).
Return Values
- uptime [REAL]: up time in seconds
Code sample
local uptime = gh_utils.get_uptime()
global_array_char_alloc
Description
Allocates a global array of string. This array is readable and writable by any script in any thread.
Syntax
gh_utils.global_array_char_alloc(
num_elements,
max_string_len
)
Languages
Parameters
- num_elements [INTEGER]: number of elements
- max_string_len [INTEGER]: max length of a string in a the array
Return Values
This function has no return value(s).
Code sample
num_elements = 256
max_string_len = 1024
gh_utils.global_array_char_alloc(num_elements, max_string_len)
global_array_char_get
Description
Reads a value from the global char array.
Syntax
value = gh_utils.global_array_char_get(
index
)
Languages
Parameters
- index [INTEGER]: index in the array
Return Values
Code sample
index = 2
value = gh_utils.global_array_char_get(index)
global_array_char_set
Description
Writes a value to the global char array.
Syntax
gh_utils.global_array_char_set(
index,
value
)
Languages
Parameters
- index [INTEGER]: index in the array
- value [STRING]: value
Return Values
This function has no return value(s).
Code sample
index = 2
value = "Hello"
gh_utils.global_array_char_set(index, value)
global_array_float_alloc
Description
Allocates a global array of floats. This array is readable and writable by any script in any thread.
Syntax
gh_utils.global_array_float_alloc(
num_elements
)
Languages
Parameters
- num_elements [INTEGER]: number of elements
Return Values
This function has no return value(s).
Code sample
num_elements = 256
gh_utils.global_array_float_alloc(num_elements)
global_array_float_get
Description
Reads a value from the global float array.
Syntax
value = gh_utils.global_array_float_get(
index
)
Languages
Parameters
- index [INTEGER]: index in the array
Return Values
Code sample
index = 2
value = gh_utils.global_array_float_get(index)
global_array_float_set
Description
Writes a value to the global float array.
Syntax
gh_utils.global_array_float_set(
index,
value
)
Languages
Parameters
- index [INTEGER]: index in the array
- value [REAL]: value
Return Values
This function has no return value(s).
Code sample
index = 2
value = 3.14
gh_utils.global_array_float_set(index, value)
global_array_int_alloc
Description
Allocates a global array of integers. This array is readable and writable by any script in any thread.
Syntax
gh_utils.global_array_int_alloc(
num_elements
)
Languages
Parameters
- num_elements [INTEGER]: number of elements
Return Values
This function has no return value(s).
Code sample
num_elements = 256
gh_utils.global_array_int_alloc(num_elements)
global_array_int_get
Description
Reads a value from the global int array.
Syntax
value = gh_utils.global_array_int_get(
index
)
Languages
Parameters
- index [INTEGER]: index in the array
Return Values
Code sample
index = 2
value = gh_utils.global_array_int_get(index)
global_array_int_set
Description
Writes a value to the global int array.
Syntax
gh_utils.global_array_int_set(
index,
value
)
Languages
Parameters
- index [INTEGER]: index in the array
- value [INTEGER]: value
Return Values
This function has no return value(s).
Code sample
index = 2
value = 10
gh_utils.global_array_int_set(index, value)
grid_create
Description
Creates a grid object.
Syntax
grid_id = gh_utils.grid_create()
Languages
Parameters
This function has no input parameter(s).
Return Values
- grid_id [ID]: grid identifier
Code sample
grid_id = gh_utils.grid_create()
grid_set_display_lines_options
Description
Sets various grid options for rendering.
Syntax
gh_utils.grid_set_display_lines_options(
grid_id,
display_main_lines,
display_lines
)
Languages
Parameters
- grid_id [ID]: grid identifier
- display_main_lines [BOOLEAN]: display of main lines (axis + border): 1 (enabled) or 0 (disabled)
- display_lines [BOOLEAN]: display of lines: 1 (enabled) or 0 (disabled)
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_display_lines_options(grid_id, 1, 1)
grid_set_geometry_params
Description
Sets grid sizes and subdivisions.
Syntax
gh_utils.grid_set_geometry_params(
grid_id,
x_size, z_size,
x_div, z_div
)
Languages
Parameters
- grid_id [ID]: grid identifier
- x_size, z_size [REAL]: size
- x_div, z_div [INTEGER]: subdivisions
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_geometry_params(grid_id, 20, 20, 10, 10)
grid_set_lines_color
Description
Sets grid color.
Syntax
gh_utils.grid_set_lines_color(
grid_id,
r, g, b, a
)
Languages
Parameters
- grid_id [ID]: grid identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_lines_color(grid_id, 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_id,
r, g, b, a
)
Languages
Parameters
- grid_id [ID]: grid identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_main_lines_color(grid_id, 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_id,
r, g, b, a
)
Languages
Parameters
- grid_id [ID]: grid identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_main_x_axis_color(grid_id, 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_id,
r, g, b, a
)
Languages
Parameters
- grid_id [ID]: grid identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.grid_set_main_z_axis_color(grid_id, 0.0, 0.0, 1.0, 1)
hex_color_to_rgb
Description
Converts an HTML style color to three RGB components.
Syntax
r, g, b = gh_utils.hex_color_to_rgb(
html_color
)
Languages
Parameters
- html_color [STRING]: color in HTML style
Return Values
- r, g, b [STRING]: RGB color
Code sample
r, g, b = gh_utils.hex_color_to_rgb("#ff0044")
is_64bit
Description
Checks if the host application is a 64-bit or a 32-bit application.
Syntax
state = gh_utils.is_64bit()
Languages
Parameters
This function has no input parameter(s).
Return Values
- state [BOOLEAN]: 1 (64-bit) or 0 (otherwise)
Code sample
app_64bit = gh_utils.is_64bit()
is_luajit
Description
Checks if the LuaJIT engine is used in place of the regular Lua engine (Windows only).
Syntax
state = gh_utils.is_luajit()
Languages
Parameters
This function has no input parameter(s).
Return Values
- state [BOOLEAN]: 1 (LuaJIT) or 0 (otherwise)
Code sample
is_luajit = gh_utils.is_luajit()
is_rpi
Description
Checks if the platform is Raspberry Pi (RPi).
Syntax
state = gh_utils.is_rpi()
Languages
Parameters
This function has no input parameter(s).
Return Values
- state [BOOLEAN]: 1 if RPi and 0 otherwise
Code sample
rpi = gh_utils.is_rpi()
line_create
Description
Creates a simple line.
Syntax
line_id = gh_utils.line_create()
Languages
Parameters
This function has no input parameter(s).
Return Values
- line_id [ID]: line identifier
Code sample
line_id = gh_utils.line_create()
gh_utils.line_set_start_position(line_id, -10, -10, 0.0)
gh_utils.line_set_start_color(line_id, 1, 1, 0, 1)
gh_utils.line_set_end_position(line_id, 10, 10, 0.0)
gh_utils.line_set_end_color(line_id, 1, 1, 1, 1)
line_set_end_color
Description
Sets the end color of a line.
Syntax
gh_utils.line_set_end_color(
line_id,
r, g, b, a
)
Languages
Parameters
- line_id [ID]: line identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.line_set_end_color(line_id, 1, 1, 0, 1)
line_set_end_position
Description
Sets the end position of a line.
Syntax
gh_utils.line_set_end_position(
line_id,
x, y, z
)
Languages
Parameters
- line_id [ID]: line identifier
- x, y, z [REAL]: position
Return Values
This function has no return value(s).
Code sample
gh_utils.line_set_end_position(line_id, 10, 10, 0.0)
line_set_start_color
Description
Sets the start color of a line.
Syntax
gh_utils.line_set_start_color(
line_id,
r, g, b, a
)
Languages
Parameters
- line_id [ID]: line identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_utils.line_set_start_color(line_id, 1, 1, 0, 1)
line_set_start_position
Description
Sets the start position of a line.
Syntax
gh_utils.line_set_start_position(
line_id,
x, y, z
)
Languages
Parameters
- line_id [ID]: line identifier
- x, y, z [REAL]: position
Return Values
This function has no return value(s).
Code sample
gh_utils.line_set_start_position(line_id, -10, -10, 0.0)
math_length_vec3
Description
Gets the length of a vec3 vector.
Syntax
len = gh_utils.math_length_vec3(
x, y, z
)
Languages
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
Parameters
Return Values
- vx, vy, vz [REAL]: normalized vector
Code sample
vx, vy, vz = gh_utils.math_normalize_vec3(x, y, z)
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,
tx, ty, tz,
ux, uy, uz
)
Languages
Parameters
- px, py, pz [REAL]: position
- tx, ty, tz [REAL]: target
- ux, uy, uz [REAL]: up
Return Values
- qx, qy, qz, qw [REAL]: rotation quaternion
Code sample
qx, qy, qz, qw = gh_utils.math_quat_from_lookat(px, py, pz, tx, ty, tz, ux, uy, uz)
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
Parameters
- x0, y0, z0 [REAL]: vector 0
- x1, y1, z1 [REAL]: vector 1
Return Values
- qx, qy, qz, qw [REAL]: rotation quaternion
Code sample
qx, qy, qz, qw = gh_utils.math_quat_from_vectors_rotation(x0, y0, z0, x1, y1, z1)
math_quat_from_euler_angles
Description
Creates a quaternion from Euler's angles.
Syntax
qx, qy, qz, qw = gh_utils.math_quat_from_euler_angles(
pitch, yaw, roll
)
Languages
Parameters
- pitch, yaw, roll [REAL]: Euler angles
Return Values
- qx, qy, qz, qw [REAL]: rotation quaternion
Code sample
qx, qy, qz, qw = gh_utils.math_quat_from_euler_angles(pitch, yaw, roll)
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
Parameters
- filters_list [STRING]: filters list like jpg,png,txt... Can be empty.
- default_path [STRING]: default path
Return Values
- filename [STRING]: selected filename
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
filename, ret = gh_utils.nfd_open_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
Parameters
- default_path [STRING]: default path
Return Values
- folder [STRING]: selected folder
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
filename, ret = gh_utils.nfd_pick_folder("")
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
Parameters
- filters_list [STRING]: filters list like jpg,png,txt... Can be empty.
- default_path [STRING]: default path
Return Values
- filename [STRING]: selected filename
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
filename, ret = gh_utils.nfd_save_dialog("jgp,png", "")
open_url
Description
Open an URL in the default browser.
Syntax
gh_utils.open_url(
str
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
gh_utils.open_url("https://geeks3d.com")
printc
Description
(zzz) Helper function to print text directly in the console.
Syntax
gh_utils.printc(
text
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
gh_utils.printc(text)
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
Parameters
- percent_inc [REAL]: increment in percent
- caption [STRING]: caption of the progress bar
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
Parameters
- percent [REAL]: percent
- caption [STRING]: caption of the progress bar
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.")
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(
cam_id,
obj_id,
x, y, z, w
)
Languages
Parameters
- cam_id [ID]: camera identifier
- obj_id [ID]: object identifier. The transformation matrix of the object will be used.
- x, y, z, w [REAL]: 3D position (w=1.0) of the point to project
Return Values
- px, py [REAL]: 2D position on the screen space
Code sample
px, py = gh_utils.project_3d_to_2d_v1(cam_id, obj_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(
cam_id,
x, y, z, w
)
Languages
Parameters
- cam_id [ID]: camera identifier
- x, y, z, w [REAL]: 3D position (w=1.0) of the point to project
Return Values
- px, py [REAL]: 2D position on the screen space
Code sample
px, py = gh_utils.project_3d_to_2d_v2(cam_id, x, y, z, 1.0)
random
Description
Returns a random floating point number between 0.0 and 1.0.
Syntax
x = gh_utils.random()
Languages
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()
srandom
Description
Initializes the random number generator (random, random16 and random32).
Syntax
gh_utils.srandom(
seed
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
s = 1234321
gh_utils.srandom(s)
random16
Description
Returns a random floating point number between 0.0 and 1.0. random16() tries to mimic original C rand() function available on Windows / Visual Studio.
Syntax
x = gh_utils.random16(
a, b
)
Languages
Parameters
- a, b [REAL]: random number range: a must be smaller than b
Return Values
Code sample
a = 0
b = 2.0
x = gh_utils.random16(a, b)
random32
Description
Returns a random floating point number between 0.0 and 1.0. random32() tries to mimic original C rand() function available in the GLIBC on Linux / gcc.
Syntax
x = gh_utils.random32(
a, b
)
Languages
Parameters
- a, b [REAL]: random number range: a must be smaller than b
Return Values
Code sample
a = 0
b = 2.0
x = gh_utils.random32(a, b)
random_init
Description
Initializes the random number generator (random_uniform_real, random_uniform_int, random_poisson and random_normal).
Syntax
gh_utils.random_init(
s
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
s = 123456789
gh_utils.random_init(s)
random_uniform_real
Description
Returns a random floating point number between a and b. This distribution produces random numbers in a range [a,b) where all intervals of the same length within it are equally probable.
Syntax
x = gh_utils.random_uniform_real(
a, b
)
Languages
Parameters
- a, b [REAL]: random number range: a must be smaller than b
Return Values
Code sample
a = 0
b = 2.0
x = gh_utils.random_uniform_real(a, b)
random_uniform_int
Description
Returns a random integer number between a and b. This distribution produces random integers in a range [a,b] where each possible value has an equal likelihood of being produced. This is the distribution function that appears on many trivial random processes (like the result of rolling a die).
Syntax
x = gh_utils.random_uniform_int(
a, b
)
Languages
Parameters
- a, b [INTEGER]: random number range: a must be smaller than b
Return Values
- x [INTEGER]: random number
Code sample
a = 0
b = 10
x = gh_utils.random_uniform_int(a, b)
random_poisson
Description
Returns a random floating point number using a Poisson distribution. This distribution produces random integers where each value represents a specific count of independent events occurring within a fixed interval, based on the observed mean rate at which they appear to happen.
Syntax
x = gh_utils.random_poisson(
mean
)
Languages
Parameters
- mean [REAL]: distribution parameter
Return Values
- x [INTEGER]: random number
Code sample
mean = 4.1
x = gh_utils.random_poisson(mean)
random_normal
Description
Returns a random floating point number using a Normal distribution. This distribution produces random numbers around the distribution mean with a specific standard deviation.
Syntax
x = gh_utils.random_normal(
mean,
deviation
)
Languages
Parameters
- mean [REAL]: distribution parameter
- deviation [REAL]: distribution parameter
Return Values
- x [INTEGER]: random number
Code sample
mean = 4.1
deviation = 0.1
x = gh_utils.random_normal(mean, deviation)
raycast_cast_ray
Description
Casts a ray in the 3D scene and returns collision information (with a mesh).
Syntax
coll_pos_x, coll_pos_y, coll_pos_z, coll_time, face_index = gh_utils.raycast_cast_ray(
mesh_id,
ro_x, ro_y, ro_z, rd_x, rd_y, rd_z
)
Languages
Parameters
- mesh_id [INTEGER]: tested mesh
- ro_x, ro_y, ro_z, rd_x, rd_y, rd_z [REAL]: 3D ray: ro (ray origin) and rd (ray direction)
Return Values
- coll_pos_x, coll_pos_y, coll_pos_z [REAL]: collision point
- coll_time [REAL]: collision time
- face_index [INTEGER]: collision face index
Code sample
face_index, coll_time, coll_pos_x, coll_pos_y, coll_pos_z = gh_utils.raycast_cast_ray(mesh_id, 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
coll_pos_x, coll_pos_y, coll_pos_z, coll_time, face_index = gh_utils.raycast_cast_ray_v2(
mesh_id,
ro_x, ro_y, ro_z, rd_x, rd_y, rd_z,
do_bounding_volume_test
)
Languages
Parameters
- mesh_id [INTEGER]: tested mesh
- ro_x, ro_y, ro_z, rd_x, rd_y, rd_z [REAL]: 3D ray: ro (ray origin) and rd (ray direction)
- do_bounding_volume_test [BOOLEAN]: performs the bounding volume test before doing deep mesh test: 1 (true) or 0 (false)
Return Values
- coll_pos_x, coll_pos_y, coll_pos_z [REAL]: collision point
- coll_time [REAL]: collision time
- face_index [INTEGER]: collision face index
Code sample
do_bounding_volume_test = 1
face_index, coll_time, coll_pos_x, coll_pos_y, coll_pos_z = gh_utils.raycast_cast_ray_v2(mesh_id, ro_x, ro_y, ro_z, rd_x, rd_y, rd_z, do_bounding_volume_test)
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,
cam_id
)
Languages
Parameters
- screen_x, screen_y [INTEGER]: screen position
- cam_id [ID]: camera identifier
Return Values
- ro_x, ro_y, ro_z, rd_x, rd_y, rd_z [REAL]: 3D ray: ro (ray origin) and rd (ray direction)
Code sample
ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray(200, 100, cam_id)
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,
cam_id
)
Languages
Parameters
- screen_x, screen_y [INTEGER]: screen position
- cam_id [ID]: camera identifier
Return Values
- ro_x, ro_y, ro_z, rd_x, rd_y, rd_z [REAL]: 3D ray: ro (ray origin) and rd (ray direction)
Code sample
ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray_ortho_cam(100, 200, cam_id)
sanitize_string
Description
Sanitize a string.
Syntax
gh_utils.sanitize_string(
text,
filter_type
)
Languages
Parameters
- text [STRING]: str
- filter_type [ENUM]: type the filter used to sanitize. Currently the only filter is FILTER_FLAG_STRIP_LOW_HIGH (value = 0) that removes characters with ASCII value lesser than 32 and greater than 127.
Return Values
This function has no return value(s).
Code sample
sanitized_text = gh_utils.sanitize_string(text, 0)
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_id = gh_utils.shared_variable_create(
name
)
Languages
Parameters
Return Values
- sv_id [ID]: shared variable identifier
Code sample
sv_name = "sv1"
sv_id = gh_utils.shared_variable_create(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
Parameters
- sv_name [STRING]: shared var name
- sv_type [ENUM]: type of the shared var elements
- num_elements [INTEGER]: number of elements in the array
Return Values
- sv_id [ID]: shared variable identifier
Code sample
num_textures = 16
sv_id = gh_utils.shared_variable_create_array("texture_ids", "integer", num_textures)
shared_variable_get_array_value_1f
Description
Gets the value of a particular element of an array.
Syntax
elem_value = gh_utils.shared_variable_get_array_value_1f(
sv_name,
elem_index
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
Return Values
- elem_value [REAL]: value of the element
Code sample
elem_value = gh_utils.shared_variable_get_array_value_1f("texture_ids", 0)
shared_variable_get_array_value_1i
Description
Gets the value of a particular element of an array.
Syntax
elem_value = gh_utils.shared_variable_get_array_value_1i(
sv_name,
elem_index
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
Return Values
- elem_value [INTEGER]: value of the element
Code sample
elem_value = gh_utils.shared_variable_get_array_value_1i("texture_ids", 0)
shared_variable_get_array_value_str
Description
Gets the value of a particular element of an array.
Syntax
elem_value = gh_utils.shared_variable_get_array_value_str(
sv_name,
elem_index
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
Return Values
- elem_value [STRING]: value of the element
Code sample
elem_value = gh_utils.shared_variable_get_array_value_str("texture_ids", 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
Parameters
- sv_name [STRING]: shared var name
Return Values
- x, y, z, w [REAL]: 4D value
Code sample
x, y, z, w = gh_utils.shared_variable_get_value_4f(sv_name)
shared_variable_get_value_str
Description
Gets a string value.
Syntax
str = gh_utils.shared_variable_get_value_str(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
- str [STRING]: string value
Code sample
str = gh_utils.shared_variable_get_value_str(sv_name)
shared_variable_get_value_buffer
Description
Gets a string value.
Syntax
str = gh_utils.shared_variable_get_value_buffer(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
- str [STRING]: string value
Code sample
str = gh_utils.shared_variable_get_value_str(sv_name)
shared_variable_get_value_buffer
Description
Gets a memory buffer value.
Syntax
buffer_ptr, buffer_size = gh_utils.shared_variable_get_value_buffer(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
- buffer_ptr [POINTER]: memory buffer pointer
- buffer_size [INTEGER]: size of the memory buffer in bytes
Code sample
buffer_ptr, buffer_size = gh_utils.shared_variable_get_value_buffer(sv_name)
shared_variable_get_value_ptr
Description
Gets a pointer value.
Syntax
ptr = gh_utils.shared_variable_get_value_ptr(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
Code sample
ptr = gh_utils.shared_variable_get_value_ptr(sv_name)
shared_variable_is_exist
Description
Checks if a shared variable exists.
Syntax
is_exist = gh_utils.shared_variable_is_exist(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
- is_exist [BOOLEAN]: exists: 1 (true) or 0 (false)
Code sample
state = gh_utils.shared_variable_is_exist(sv_name)
shared_variable_kill
Description
Destroys a shared variable.
Syntax
gh_utils.shared_variable_kill(
sv_name
)
Languages
Parameters
- sv_name [STRING]: shared var name
Return Values
This function has no return value(s).
Code sample
gh_utils.shared_variable_kill(sv1_name)
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,
elem_index,
elem_value
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
- elem_value [REAL]: value of the element
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_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,
elem_index,
elem_value
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
- elem_value [INTEGER]: value of the element
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_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,
elem_index,
elem_value
)
Languages
Parameters
- sv_name [STRING]: shared var name
- elem_index [INTEGER]: 0-based index of the element
- elem_value [STRING]: value of the element
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_set_value_4f
Description
Sets a 4D value.
Syntax
gh_utils.shared_variable_set_value_4f(
sv_name,
x, y, z, w
)
Languages
Parameters
- sv_name [STRING]: shared var name
- x, y, z, w [REAL]: 4D value
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_set_value_str
Description
Sets a string value.
Syntax
gh_utils.shared_variable_set_value_str(
sv_name,
str
)
Languages
Parameters
- sv_name [STRING]: shared var name
- str [STRING]: string value
Return Values
This function has no return value(s).
Code sample
gh_utils.shared_variable_set_value_str(sv_name, str)
shared_variable_set_value_buffer
Description
Sets a memory buffer value.
Syntax
gh_utils.shared_variable_set_value_buffer(
sv_name,
buffer_ptr,
buffer_size
)
Languages
Parameters
- sv_name [STRING]: shared var name
- buffer_ptr [POINTER]: memory buffer pointer
- buffer_size [INTEGER]: size of the memory buffer in bytes
Return Values
This function has no return value(s).
Code sample
filename = demo_dir .. "data/my_kool_image.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
gh_utils.shared_variable_set_value_buffer(sv_name, buffer_ptr, buffer_size)
shared_variable_set_value_ptr
Description
Sets a pointer value.
Syntax
gh_utils.shared_variable_set_value_ptr(
sv_name,
ptr
)
Languages
Parameters
- sv_name [STRING]: shared var name
- ptr [POINTER]: pointer
Return Values
This function has no return value(s).
Code sample
filename = demo_dir .. "data/my_kool_image.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
gh_utils.shared_variable_set_value_ptr(sv_name, buffer_ptr)
sphere_create
Description
Creates a simple sphere made up of several circles.
Syntax
sphere_id = gh_utils.sphere_create(
radius,
subdivisions,
r, g, b, a
)
Languages
Parameters
- radius [REAL]: radius
- subdivisions [INTEGER]: subdivisions
- r, g, b, a [REAL]: RGBA color
Return Values
- sphere_id [ID]: sphere identifier
Code sample
sphere_id = gh_utils.sphere_create(10.0, 20, 1.0, 1.0, 0.0, 1.0)
sphere_update_radius
Description
Updates the radius of a sphere.
Syntax
gh_utils.sphere_update_radius(
sphere_id,
radius
)
Languages
Parameters
- sphere_id [ID]: sphere identifier
- radius [REAL]: radius
Return Values
This function has no return value(s).
Code sample
gh_utils.sphere_update_radius(sphere_id, 12.0)
stop_demo
Description
Stops a demo and quits GeeXLab.
Syntax
gh_utils.stop_demo()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
gh_utils.stop_demo()
sys_exec
Description
Executes a system command.
Syntax
gh_utils.sys_exec(
command,
parameters,
exe_dir
)
Languages
Parameters
- command [STRING]: command
- parameters [STRING]: command parameters
- exe_dir [STRING]: command execution folder
Return Values
This function has no return value(s).
Code sample
demo_dir = gh_utils.get_demo_dir()
gh_utils.sys_exec("ffmpeg", "-i input.mp4 output.avi", demo_dir)
shell_exe
Description
Executes a command (Windows only).
Syntax
gh_utils.shell_exe(
command,
parameters,
exe_dir
)
Languages
Parameters
- command [STRING]: command
- parameters [STRING]: command parameters
- exe_dir [STRING]: command execution folder
Return Values
This function has no return value(s).
Code sample
demo_dir = gh_utils.get_demo_dir()
gh_utils.shell_exe("firefox", "/new-window https://www.geeks3d.com/geexlab/", demo_dir)
shell_exe_v2
Description
Executes a command with admin rights (Windows only).
Syntax
gh_utils.shell_exe_v2(
command,
parameters,
exe_dir,
show_mode,
mask,
run_as_admin
)
Languages
Parameters
- command [STRING]: command
- parameters [STRING]: command parameters
- exe_dir [STRING]: command execution folder
- show_mode [INTEGER]: show mode: 0 (hidden) or 1 (show)
- mask [INTEGER]: mask: essentially SEE_MASK_NO_CONSOLE (32768) to show or hide the console. Default: 0
- run_as_admin [INTEGER]: run as admin (1) or not (0)
Return Values
This function has no return value(s).
Code sample
demo_dir = gh_utils.get_demo_dir()
gh_utils.shell_exe_v2("firefox", "/new-window https://www.geeks3d.com/geexlab/", demo_dir, 1, 0, 0)
thread_sleep
Description
Allows to pause the current thread.
Syntax
gh_utils.thread_sleep(
delay
)
Languages
Parameters
- delay [INTEGER]: pause delay in milliseconds
Return Values
This function has no return value(s).
Code sample
gh_utils.thread_sleep(2000)
thread_lock_create
Description
Creates a thread lock (critical section / mutex). A thread lock object can be useful in threaded scripts (ZOMBIE scripts that have been launched with exe_script()).
Syntax
index = gh_utils.thread_lock_create()
Languages
Parameters
This function has no input parameter(s).
Return Values
- index [INTEGER]: index of the thread lock object.
Code sample
tl1 = gh_utils.thread_lock_create()
thread_lock_kill_all
Description
Kills all thread locks that have been created with thread_lock_create().
Syntax
gh_utils.thread_lock_kill_all()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
gh_utils.thread_lock_kill_all()
thread_lock_acquire
Description
Acquires the thread lock.
Syntax
gh_utils.thread_lock_acquire(
index
)
Languages
Parameters
- index [INTEGER]: index of the thread lock object.
Return Values
This function has no return value(s).
Code sample
gh_utils.thread_lock_acquire(tl)
...
gh_utils.thread_lock_release(tl)
thread_lock_release
Description
Releases the thread lock.
Syntax
gh_utils.thread_lock_release(
index
)
Languages
Parameters
- index [INTEGER]: index of the thread lock object.
Return Values
This function has no return value(s).
Code sample
gh_utils.thread_lock_acquire(tl)
...
gh_utils.thread_lock_release(tl)
trace
Description
Writes a trace in the log file and in the debug window.
Syntax
gh_utils.trace(
str
)
Languages
Parameters
- str [STRING]: trace to write
Return Values
This function has no return value(s).
Code sample
gh_utils.trace("Hello world!")
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
Parameters
- x, y [INTEGER]: current mouse position
- prev_x, prev_y [INTEGER]: previous mouse position
Return Values
- x, y, z, w [REAL]: rotation quaternion
Code sample
x, y, z, w = gh_utils.trackball_get_orientation(x, y, prev_x, prev_y)
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
Parameters
- radius [REAL]: radius of the trackball. The radius is in screen space.
- x, y [INTEGER]: size of the screen
Return Values
This function has no return value(s).
Code sample
gh_utils.trackball_init(radius, w, h)
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(
cam_id,
x_offset, y_offset, width, height
)
Languages
Parameters
- cam_id [ID]: camera identifier
- x_offset, y_offset, width, height [INTEGER]: viewport size
Return Values
This function has no return value(s).
Code sample
gh_utils.tripod_visualizer_camera_render(cam_id, 0, 0, 100, 100)
vendor_name_from_vendor_id
Description
Gets the vendor name from its vendor ID.
Syntax
date = gh_utils.vendor_name_from_vendor_id(
vendorID
)
Languages
Parameters
- vendorID [INTEGER]: vendor ID (like 4318 for NVIDIA)
Return Values
- date [STRING]: date (Y.M.D.h.m.s)
Code sample
name = gh_utils.vendor_name_from_vendor_id(4318)
if (name == "NVIDIA") then
-- do something
end
webcam_create
Description
Creates a new webcam object. A max of 8 webcams can be created (Windows only).
Syntax
webcam_id = gh_utils.webcam_create()
Languages
Parameters
This function has no input parameter(s).
Return Values
- webcam_id [ID]: webcam identifier
Code sample
webcam_id = gh_utils.webcam_create()
webcam_get_frame_size
Description
Gets the size of a frame (Windows only).
Syntax
width, height = gh_utils.webcam_get_frame_size(
webcam_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
Return Values
- width, height [INTEGER]: size of a frame
Code sample
w, h = gh_utils.webcam_get_frame_size(webcam_id)
webcam_get_name
Description
Gets the webcam name, for example: 'Microsoft LifeCam Studio' (Windows only).
Syntax
gh_utils.webcam_get_name(
webcam_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
Return Values
This function has no return value(s).
Code sample
name = gh_utils.webcam_get_name(webcam_id)
webcam_get_num
Description
Returns the number of webcams detected by GeeXLab (Windows only).
Syntax
num_webcams = gh_utils.webcam_get_num()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_webcams [ID]: number of webcams
Code sample
num_webcam = gh_utils.webcam_get_num()
webcam_grab_frame
Description
Updates the webcam (Windows only).
Syntax
gh_utils.webcam_grab_frame(
webcam_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.webcam_grab_frame(webcam_id)
webcam_kill
Description
Kills a webcam object (Windows only).
Syntax
gh_utils.webcam_kill(
webcam_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.webcam_kill(webcam_id)
webcam_start
Description
Initializes a webcam (Windows only).
Syntax
ret = gh_utils.webcam_start(
webcam_id,
webcam_number
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
- webcam_number [INTEGER]: index of the webcam. Default: 1. First webcam=1, second=2, and so on.
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_utils.webcam_start(webcam_id, 1)
if (ret == 1) then
-- Webcam started ok.
end
webcam_start_v2
Description
Initializes a webcam (Windows only).
Syntax
ret = gh_utils.webcam_start_v2(
webcam_id,
webcam_number,
capture_width, capture_height
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
- webcam_number [INTEGER]: index of the webcam. Default: 1. First webcam=1, second=2, and so on.
- capture_width, capture_height [INTEGER]: size of the captured video frame. For a full HD webcam your can set this size to (1920, 1080). On Windows, the default webcam capture size is 640x480
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_utils.webcam_start_v2(webcam_id, 1, 1280, 720)
if (ret == 1) then
-- Webcam started ok.
end
webcam_stop
Description
Stops a webcam (Windows only).
Syntax
gh_utils.webcam_stop(
webcam_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.webcam_stop(webcam_id)
webcam_update_texture
Description
Updates a texture pixmap with the current webcam frame (Windows only).
Syntax
gh_utils.webcam_update_texture(
webcam_id,
tex_id
)
Languages
Parameters
- webcam_id [ID]: webcam identifier
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.webcam_update_texture(webcam_id, tex_id)
zip_buffer_create
Description
Allocates a memory buffer of a file stored in a zip archive and returns the pointer to the memory buffer.
Syntax
buff_ptr, buff_size = gh_utils.zip_buffer_create(
zip_filename,
filename
)
Languages
Parameters
- zip_filename [STRING]: absolute path of the zip file
- filename [STRING]: path of the file in the zip archive
Return Values
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
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.buffer_kill(buffer_ptr)
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
Parameters
- zip_filename [STRING]: absolute path of the zip file
- src_filename [STRING]: path of the file in the zip archive
- dst_filename [STRING]: absolute path of the file on the file system
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
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
win_registry_read_value_dword
Description
Read an integer (REG_DWORD) value from Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret, x = gh_utils.win_registry_read_value_dword(
key_name,
subkey_name,
value_name
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
- value_name [STRING]: value_name
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
- x [INTEGER]: dword value
Code sample
key_name = "HKEY_LOCAL_MACHINE"
subkey_name = "HARDWARE\\DESCRIPTION\\System\\BIOS"
value_name = "BiosMajorRelease"
ret, x = gh_utils.win_registry_read_value_dword(key_name, subkey_name, value_name)
win_registry_write_value_dword
Description
Write an integer (REG_DWORD) value into Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret = gh_utils.win_registry_write_value_dword(
key_name,
subkey_name,
value_name,
x
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
- value_name [STRING]: value_name
- x [INTEGER]: dword value
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
key_name = "HKEY_LOCAL_MACHINE"
subkey_name = "HARDWARE\\DESCRIPTION\\System\\BIOS"
value_name = "BiosMajorRelease"
ret = gh_utils.win_registry_write_value_dword(key_name, subkey_name, value_name, 5)
win_registry_read_value_string
Description
Read a string (REG_SZ) value from Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret, str = gh_utils.win_registry_read_value_string(
key_name,
subkey_name,
value_name
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
- value_name [STRING]: value_name
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
- str [STRING]: string value
Code sample
key_name = "HKEY_LOCAL_MACHINE"
subkey_name = "HARDWARE\\DESCRIPTION\\System\\BIOS"
value_name = "BIOSVendor"
ret, str = gh_utils.win_registry_read_value_string(key_name, subkey_name, value_name)
win_registry_write_value_string
Description
Write a string (REG_SZ) value into Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret = gh_utils.win_registry_write_value_string(
key_name,
subkey_name,
value_name,
str
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
- value_name [STRING]: value_name
- str [STRING]: string value
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
key_name = "HKEY_LOCAL_MACHINE"
subkey_name = "HARDWARE\\DESCRIPTION\\System\\BIOS"
value_name = "BIOSVendor"
ret = gh_utils.win_registry_write_value_string(key_name, subkey_name, value_name, "American Megatrends Inc.")
win_registry_create_key
Description
Create a subkey in Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret = gh_utils.win_registry_create_key(
key_name,
subkey_name,
options
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
- options [STRING]: options - reserved
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
key_name = "HKEY_CURRENT_USER"
subkey_name = "Software\\MyKoolUtility"
options = ""
ret = gh_utils.win_registry_create_key(key_name, subkey_name, options)
win_registry_delete_key
Description
Delete a subkey from Windows registry (Windows only). WARNING: serious problems might occur if you modify the registry incorrectly.
Syntax
ret = gh_utils.win_registry_delete_key(
key_name,
subkey_name
)
Languages
Parameters
- key_name [STRING]: key name
- subkey_name [STRING]: subkey name
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
key_name = "HKEY_CURRENT_USER"
subkey_name = "Software\\MyKoolUtility"
ret = gh_utils.win_registry_delete_key(key_name, subkey_name)
pack_rgba_u8
Description
Pack four R, G, B and A channels into a single integer.
Syntax
rgba = gh_utils.pack_rgba_u8(
r, g, b, a
)
Languages
Parameters
- r, g, b, a [INTEGER]: the four R, G, B and A channels
Return Values
- rgba [INTEGER]: the rgba color coded in a single integer
Code sample
color = gh_utils.pack_rgba_u8(r, g, b, a)
unpack_rgba_u8
Description
Unpack a single integer inti four R, G, B and A channels.
Syntax
r, g, b, a = gh_utils.unpack_rgba_u8(
rgba
)
Languages
Parameters
- rgba [INTEGER]: the rgba color coded in a single integer
Return Values
- r, g, b, a [INTEGER]: the four R, G, B and A channels
Code sample
r, g, b, a = gh_utils.unpack_rgba_u8(color)
set_new_scene_data
Description
Stops and kills the current demo and launch a new demo.
Syntax
gh_utils.set_new_scene_data(
filename,
width, height,
fullscreen,
msaa
)
Languages
Parameters
- filename [STRING]: absolute path to the new demo file
- width, height [INTEGER]: size of the demo. To use size specified by the demo, set width and height to -1
- fullscreen [INTEGER]: fullscreen mode if 1
- msaa [STRING]: anti-aliasing mode: 'Off', '2X MSAA', '4X MSAA' or '8X MSAA'
Return Values
This function has no return value(s).
Code sample
gh_utils.set_new_scene_data(filename, -1, -1, 0, "Off")
temp_directory_path
Description
Returns the path of user's temp folder - Windows only.
Syntax
temp_folder = gh_utils.temp_directory_path()
Languages
Parameters
This function has no input parameter(s).
Return Values
- temp_folder [STRING]: absolute path of the temp folder
Code sample
temp_folder = gh_utils.temp_directory_path()
get_app_name
Description
Returns the name of the host application (here GeeXLab). GeeXLab scripts can be executed by another host app that embeds the GeeXLab SDK (like GPU Caps Viewer) and
get_app_name() can return a name that is not GeeXLab.
Syntax
name = gh_utils.get_app_name()
Languages
Parameters
This function has no input parameter(s).
Return Values
- name [STRING]: name of the host application
Code sample
app_name = gh_utils.get_app_name()
spirv_to_smolv
Description
Converts a SPIR-V file to a SMOL-V file (compressed version of the SPIR-V file).
Syntax
ret = gh_utils.spirv_to_smolv(
spirv_filename,
smolv_filename,
flags
)
Languages
Parameters
- spirv_filename [STRING]: absolute path to the SPIR-V file (source)
- smolv_filename [STRING]: absolute path to the SMOL-V file (destination)
- flags [INTEGER]: conversion options: 0 (none) or 1 (kEncodeFlagStripDebugInfo)
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
local kEncodeFlagStripDebugInfo = 1
local flags = kEncodeFlagStripDebugInfo
ret = gh_utils.spirv_to_smolv(spirv_filename, smolv_filename, flags)
smolv_to_spirv
Description
Converts a SPIR-V file to a SMOL-V file (compressed version of the SPIR-V file).
Syntax
ret = gh_utils.smolv_to_spirv(
smolv_filename,
spirv_filename
)
Languages
Parameters
- smolv_filename [STRING]: absolute path to the SMOL-V file (source)
- spirv_filename [STRING]: absolute path to the SPIR-V file (destination)
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_utils.smolv_to_spirv(smolv_filename, spirv_filename)
math_from_to_rotation_matrix3x3
Description
Creates a 3x3 rotation matrix from two vectors.
Syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8 = gh_utils.math_from_to_rotation_matrix3x3(
from_x, from_y, from_z,
to_x, to_y, to_z
)
Languages
Parameters
- from_x, from_y, from_z [REAL]: from 3D vector
- to_x, to_y, to_z [REAL]: to 3D vector
Return Values
- m0,m1,m2,m3,m4,m5,m6,m7,m8 [REAL]: the 9 floats that make the 3x3 matrix
Code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8 = gh_utils.math_from_to_rotation_matrix3x3(from_x, from_y, from_z, to_x, to_y, to_z)
file_read
Description
Returns the content of a file.
Syntax
data, data_size = gh_utils.file_read(
zip_filename,
filename
)
Languages
Parameters
- zip_filename [STRING]: zip archive. Can be empty.
- filename [STRING]: file name (absolute path).
Return Values
- data [STRING]: file data
- data_size [INTEGER]: file data size
Code sample
data, data_size = gh_utils.file_read(zip_filename, filename)
file_write
Description
Writes data to a file.
Syntax
ret = gh_utils.file_write(
filename,
data
)
Languages
Parameters
- filename [STRING]: file name (absolute path).
- data [STRING]: file data
Return Values
- ret [INTEGER]: 0 (error) or 1 (success)
Code sample
ret = gh_utils.file_write(filename, data)
file_size
Description
Returns the size in bytes of a file.
Syntax
size = gh_utils.file_size(
zip_filename,
filename
)
Languages
Parameters
- zip_filename [STRING]: zip archive. Can be empty.
- filename [STRING]: file name (absolute path).
Return Values
- size [INTEGER]: size in bytes
Code sample
size = gh_utils.file_size(zip_filename, filename)
shmem_create
Description
Creates a shared memory. Shared memory is a memory that can be accessed by different processes or applications on the same machine.
Syntax
ret = gh_utils.shmem_create(
shmem_name,
shmem_size
)
Languages
Parameters
- shmem_name [STRING]: shared memory name. The name is the shared memory identifier used by all other functions.
- shmem_size [INTEGER]: shared memory size in bytes.
Return Values
- ret [INTEGER]: return code: 1 (no error), 0 (error)
Code sample
ret = gh_utils.shmem_create(shmem_name, shmem_size)
shmem_kill
Description
Destroys a shared memory.
Syntax
gh_utils.shmem_kill(
shmem_name
)
Languages
Parameters
- shmem_name [STRING]: shared memory name. The name is the shared memory identifier used by all other functions.
Return Values
This function has no return value(s).
Code sample
gh_utils.shmem_kill(shmem_name)
shmem_is_available
Description
Checks if a shared memory is available.
Syntax
ret = gh_utils.shmem_is_available(
shmem_name,
shmem_size
)
Languages
Parameters
- shmem_name [STRING]: shared memory name. The name is the shared memory identifier used by all other functions.
- shmem_size [INTEGER]: shared memory size in bytes.
Return Values
- ret [INTEGER]: return code: 1 (shared memory is available), 0 (shared memory not available)
Code sample
ret = gh_utils.shmem_is_available(shmem_name, shmem_size)
shmem_map
Description
Maps a shared memory. The pointer returned by this function can be used with memory buffer functions like gh_utils.buffer_read_u32().
Syntax
buffer_ptr = gh_utils.shmem_map(
shmem_name,
shmem_size
)
Languages
Parameters
- shmem_name [STRING]: shared memory name. The name is the shared memory identifier used by all other functions.
- shmem_size [INTEGER]: shared memory size in bytes.
Return Values
- buffer_ptr [POINTER]: memory buffer pointer
Code sample
buffer = gh_utils.shmem_map(shmem_name, shmem_size)
gh_utils.buffer_write_byte(buffer, index, 255)
gh_utils.shmem_unmap(shmem_name)
shmem_unmap
Description
Unmaps a shared memory. The pointer returned by shmem_map() is no longer valid after a call to shmem_unmap().
Syntax
gh_utils.shmem_unmap(
shmem_name
)
Languages
Parameters
- shmem_name [STRING]: shared memory name. The name is the shared memory identifier used by all other functions.
Return Values
This function has no return value(s).
Code sample
buffer = gh_utils.shmem_map(shmem_name, shmem_size)
gh_utils.buffer_write_byte(buffer, index, 255)
gh_utils.shmem_unmap(shmem_name)
win32_audio_volume_control
Description
Sends commands to control the audio volume on Windows platform.
Syntax
gh_utils.win32_audio_volume_control(
command
)
Languages
Parameters
- command [STRING]: command. Possible values: mute, up and down
Return Values
This function has no return value(s).
Code sample
local command0 = "mute"
local command1 = "up"
local command2 = "down"
gh_utils.win32_audio_volume_control(command1)
qr_code_scan
Description
Scans a QR Code stored in a texture and return the payload information.
Syntax
payload, payload_len, corner0, corner1, corner2, ... corner7 = gh_utils.qr_code_scan(
texture_id,
bthreshold
)
Languages
Parameters
- texture_id [INTEGER]: texture identifier.
- bthreshold [INTEGER]: color treshhold - A default value of 50 works fine.
Return Values
- payload [STRING]: the QR code payload
- payload_len [INTEGER]: the QR code payload size in bytes
- corner0, corner1, corner2, ... corner7 [INTEGER]: the coordinates (x, y) of the four corners of the QR code in the texture. First corner is {corner0, corner1}. Second is {corner2, corner3} and so on.
Code sample
corners = {}
local color_threshold = 50
payload, payload_size, corners[1], corners[2], corners[3], corners[4], corners[5], corners[6], corners[7], corners[8] = gh_utils.qr_code_scan(tex01, color_threshold)
qr_code_gen
Description
Generates a QR Code with a specific payload. The QR code is stored in a texture.
Syntax
texture_id = gh_utils.qr_code_gen(
payload,
err_correction_level
)
Languages
Parameters
- payload [STRING]: the QR code payload
- err_correction_level [INTEGER]: ECC correction level: 0 (ECC_LOW, 7% of data bytes can be restored), 1 (ECC_MEDIUM, 15% of data bytes can be restored), 2 (ECC_QUARTILE, 25% of data bytes can be restored) or 4 (ECC_HIGH, 30% of data bytes can be restored).
Return Values
- texture_id [INTEGER]: texture identifier.
Code sample
ECC_LOW = 0
ECC_MEDIUM = 1
ECC_QUARTILE = 2
ECC_HIGH = 3
err_correction_level = ECC_LOW
tex0 = gh_utils.qr_code_gen(payload, err_correction_level)
set_app_title_bar
Description
Sets the text of the main title bar of the app.
Syntax
gh_utils.set_app_title_bar(
text
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
gh_utils.set_app_title_bar("GeeXLab!")
get_app_title_bar
Description
Gets the text of the main title bar of the app.
Syntax
text = gh_utils.get_app_title_bar()
Languages
Parameters
This function has no input parameter(s).
Return Values
Code sample
text = gh_utils.get_app_title_bar()
spout_create_sender
Description
Creates a Spout sender.
Syntax
sender_id = gh_utils.spout_create_sender(
sender_name,
texture_id
)
Languages
Parameters
- sender_name [STRING]:
- texture_id [ID]: texture identifier
Return Values
- sender_id [ID]: sender identifier
Code sample
senderid = gh_utils.spout_create_sender("GeeXLab", tex0)
spout_kill_sender
Description
Destroys a Spout sender.
Syntax
gh_utils.spout_kill_sender(
sender_id
)
Languages
Parameters
- sender_id [ID]: sender identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.spout_kill_sender(senderid)
spout_send_texture
Description
Sends a texture to the Spout engine.
Syntax
gh_utils.spout_send_texture(
sender_id,
texture_id
)
Languages
Parameters
- sender_id [ID]: sender identifier
- texture_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_utils.spout_send_texture(senderid, texture_id)
spout_send_texture_rt
Description
Sends a render target texture to the Spout engine.
Syntax
gh_utils.spout_send_texture_rt(
sender_id,
rt_id,
color_index,
width, height
)
Languages
Parameters
- sender_id [ID]: sender identifier
- rt_id [ID]: render target identifier
- color_index [INTEGER]: index of the color target (default: 0, first color target)
- width, height [INTEGER]: size of the color target texture
Return Values
This function has no return value(s).
Code sample
gh_utils.spout_send_texture_rt(senderid, rt_id, color_index, width, height)
spout_register_directshow_filter
Description
Register the Spout plugin as a DirectShow filter.
Syntax
gh_utils.spout_register_directshow_filter(
state
)
Languages
Parameters
Return Values
This function has no return value(s).
Code sample
gh_utils.spout_register_directshow_filter(1)
curl_download_file_v1
Description
Works on Windows, Linux and Raspberry Pi OS - macOS not supported. This function allows to easily download a file from Internet.
Syntax
gh_utils.curl_download_file_v1(
curl_lib,
url,
local_file
)
Languages
Parameters
- curl_lib [STRING]: path to the curl dynamic libray (.dll, .so, .dylib).
- url [STRING]: URL of the file to download.
- local_file [STRING]: absolute path to the file on local machine.
Return Values
This function has no return value(s).
Code sample
gh_utils.curl_download_file_v1("", "https://m.media-amazon.com/images/I/319KAiGobEL._AC_SY200_.jpg", demo_dir .. "images/319KAiGobEL._AC_SY200_.jpg")
curl_download_file_in_buffer
Description
Works on Windows, Linux and Raspberry Pi OS. This function allows to easily download a file from an url and store it in a memory buffer. You can then use memory buffer related functions to use this buffer.
Syntax
buffer, buffer_size = gh_utils.curl_download_file_in_buffer(
curl_lib,
url
)
Languages
Parameters
- curl_lib [STRING]: path to the curl dynamic libray (.dll, .so, .dylib).
- url [STRING]: URL of the file to download.
Return Values
- buffer [POINTER]: memory buffer.
- buffer_size [INTEGER]: size of the memory buffer in bytes.
Code sample
buffer, buffer_size = gh_utils.curl_download_file_in_buffer("", "https://m.media-amazon.com/images/I/319KAiGobEL._AC_SY200_.jpg")
tex = gh_texture.create_from_buffer(buffer, buffer_size, upload_to_gpu, pixel_format, texture_unit, gen_mipmaps, compressed_texture)
curl_get_file_time_and_size
Description
Works on Windows, Linux and Raspberry Pi OS. This function allows to easily download a file from an url and store it in a memory buffer. You can then use memory buffer related functions to use this buffer.
Syntax
filesize, filetime, filetime_str128 = gh_utils.curl_get_file_time_and_size(
curl_lib,
url
)
Languages
Parameters
- curl_lib [STRING]: path to the curl dynamic libray (.dll, .so, .dylib).
- url [STRING]: URL of the file to download.
Return Values
- filesize [INTEGER]: size of the remote file in bytes.
- filetime [INTEGER]: timestamp of the remote file.
- filetime_str128 [STRING]: time of the remote file.
Code sample
filesize, filetime, filetime_str128 = gh_utils.curl_get_file_time_and_size(curl_dylib, remote_filename)
align_up
Description
Gets the aligned value that is greater or equal to the input value.
Syntax
aligned = gh_utils.align_up(
x,
a
)
Languages
Parameters
- x [INTEGER]: input value.
- a [INTEGER]: alignment value.
Return Values
- aligned [INTEGER]: aligned value.
Code sample
aligned_size = gh_utils.align_up(25, 4)
align_down
Description
Gets the aligned value that is lesser or equal to the input value.
Syntax
aligned = gh_utils.align_down(
x,
a
)
Languages
Parameters
- x [INTEGER]: input value.
- a [INTEGER]: alignment value.
Return Values
- aligned [INTEGER]: aligned value.
Code sample
aligned_size = gh_utils.align_down(25, 4)
dnd_set_check_scene_file
Description
Allows to enable (default) or disable the check of a GeeXLab scene file during a drag and drop operation.
Syntax
gh_utils.dnd_set_check_scene_file(
state
)
Languages
Parameters
- state [BOOLEAN]: state (0 or 1).
Return Values
This function has no return value(s).
Code sample
gh_utils.dnd_set_check_scene_file(0)
get_lua_version
Description
Description not available.
Syntax
gh_utils.get_lua_version()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
major, minor, patch = gh_utils.get_lua_version()
get_app_build_date
Description
Description not available.
Syntax
gh_utils.get_app_build_date()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
build_date = gh_utils.get_app_build_date()
| |