syntax
gh_bullet3.actor_apply_central_force (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL force
return values
none
code sample
gh_bullet3.actor_apply_central_force(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_central_impulse (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL force
return values
none
code sample
gh_bullet3.actor_apply_central_impulse(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_torque (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL torque
return values
none
code sample
gh_bullet3.actor_apply_torque(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_transform (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_bullet3.actor_apply_transform(actor_id, o3d_id)
syntax
gh_bullet3.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.actor_clear_forces(actor_id)
actor_create_box
Creates a box actor.
syntax
actor_id = gh_bullet3.actor_create_box (
w, h, d,
x, y, z,
mass,
mat_id
)
parameters
w, h, d REAL dimensions of the box
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_box(w, h, d, x, y, z, mass, mat_id)
actor_create_box_v2
Creates a box actor.
syntax
actor_id = gh_bullet3.actor_create_box_v2 (
w, h, d,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
w, h, d REAL dimensions of the box
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_box_v2(w, h, d, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_cylinder (
main_axis,
height,
radius,
x, y, z,
mass,
mat_id
)
parameters
main_axis ENUM( along_axis ) direction of the main axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
height REAL cylinder height
radius REAL cylinder radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_cylinder(central_axis, height, radius, x, y, z, mass, mat_id)
syntax
actor_id = gh_bullet3.actor_create_cylinder_v2 (
main_axis,
height,
radius,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
main_axis ENUM( along_axis ) direction of the main axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
height REAL cylinder height
radius REAL cylinder radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_cylinder_v2(central_axis, height, radius, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_mesh (
mesh_id,
convex,
x, y, z,
mass,
mat_id
)
parameters
mesh_id ID mesh identifier
convex BOOLEAN convex mesh: 1 (yes) or 0 (no)
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_mesh(mesh_id, convex, x, y, z, mass, mat_id)
syntax
actor_id = gh_bullet3.actor_create_mesh_v2 (
mesh_id,
convex,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
mesh_id ID mesh identifier
convex BOOLEAN convex mesh: 1 (yes) or 0 (no)
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_mesh_v2(mesh_id, convex, x, y, z, mass, ix, iy, iz, mat_id)
actor_create_sphere
Creates a sphere actor.
syntax
actor_id = gh_bullet3.actor_create_sphere (
radius,
x, y, z,
mass,
mat_id
)
parameters
radius REAL sphere radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_sphere(radius, x, y, z, mass, mat_id)
actor_create_sphere_v2
Creates a sphere actor.
syntax
actor_id = gh_bullet3.actor_create_sphere_v2 (
radius,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
radius REAL sphere radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_sphere_v2(radius, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_static_plane (
nx, ny, nz, d,
mat_id
)
parameters
nx, ny, nz, d REAL plane equation
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
nx = 0
ny = 1
nz = 0
d = 0
actor_id = gh_bullet3.actor_create_static_plane(nx, ny, nz, d, mat_id)
syntax
actor_id = gh_bullet3.actor_create_static_plane_v2 (
nx, ny, nz,
px, py, pz,
mat_id
)
parameters
nx, ny, nz REAL plane normal vector
px, py, pz REAL plane position
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
nx = 1
ny = 0
nz = 0
px = 5
py = 0
pz = 0
actor_id = gh_bullet3.actor_create_static_plane_v2(nx, ny, nz, px, py, pz, mat_id)
syntax
state = gh_bullet3.actor_get_activation_state (
actor_id
)
parameters
actor_id ID actor identifier
return values
state INTEGER activation state (0 or 1)
code sample
state = gh_bullet3.actor_get_activation_state(actor_id)
syntax
s = gh_bullet3.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_bullet3.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z= gh_bullet3.actor_get_angular_velocity(actor_id)
syntax
contact_actor_id = gh_bullet3.actor_get_contact_actor (
actor_id,
contact_index
)
parameters
actor_id ID actor identifier
contact_index INTEGER contact index
return values
contact_actor_id ID ID of the actor in contact
code sample
num_contacts, x, y, z = gh_bullet3.actor_get_contact_info(actor_id)
for i=0, num_contacts-1 do
contact_actor_id = gh_bullet3.actor_get_contact_actor(actor_id, i)
...
end
syntax
num_contacts = gh_bullet3.actor_get_contact_info (
actor_id,
px, py, pz
)
parameters
actor_id ID actor identifier
px, py, pz REAL position of the first contact
return values
num_contacts INTEGER number of contacts
code sample
num_contacts, px, py, pz = gh_bullet3.actor_get_contact_info(actor_id)
syntax
s = gh_bullet3.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_bullet3.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z= gh_bullet3.actor_get_linear_velocity(actor_id)
syntax
qx, qy, qz, qw = gh_bullet3.actor_get_orientation (
actor_id
)
parameters
actor_id ID actor identifier
return values
qx, qy, qz, qw REAL orientation quaternion
code sample
qx, qy, qz, qw = gh_bullet3.actor_get_orientation(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_position (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL 3D position
code sample
x, y, z = gh_bullet3.actor_get_position(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_bullet3.actor_get_transform_mat16 (
actor_id
)
parameters
actor_id ID actor identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_bullet3.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_bullet3.actor_get_transform_pos_qrot (
actor_id
)
parameters
actor_id ID actor identifier
return values
px, py, pz REAL position
qx, qy, qz, qw REAL rotation quaternion
code sample
px, py, pz, qx, qy, qz, qw = gh_bullet3.actor_get_transform_pos_qrot(actor_id)
actor_kill
Destroys an actor.
syntax
gh_bullet3.actor_kill (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.actor_kill(actor_id)
syntax
gh_bullet3.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_bullet3.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_bullet3.actor_set_activation_state (
actor_id,
state
)
parameters
actor_id ID actor identifier
state INTEGER activation state (0 or 1)
return values
none
code sample
gh_bullet3.actor_set_activation_state(actor_id, state)
syntax
gh_bullet3.actor_set_angular_factor (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL XX factor
return values
none
code sample
gh_bullet3.actor_set_angular_factor(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_angular_velocity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL velocity vector
return values
none
code sample
gh_bullet3.actor_set_angular_velocity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_ccd_params (
actor_id,
motion_threshold,
swept_sphere_radius
)
parameters
actor_id ID actor identifier
motion_threshold REAL CCD is not performed if the motion (in one step) is less then motion_threshold
swept_sphere_radius REAL swept sphere radius (0.0 by default)
return values
none
code sample
gh_bullet3.actor_set_ccd_params(actor_id, motion_threshold, swept_sphere_radius)
syntax
gh_bullet3.actor_set_collision_margin (
actor_id,
margin
)
parameters
actor_id ID actor identifier
margin REAL collision margin
return values
none
code sample
gh_bullet3.actor_set_collision_margin(actor_id, margin)
actor_set_damping
Sets damping factors.
syntax
gh_bullet3.actor_set_damping (
actor_id,
linear,
angular
)
parameters
actor_id ID actor identifier
linear REAL linear damping
angular REAL angular damping
return values
none
code sample
gh_bullet3.actor_set_damping(actor_id, linear, angular)
syntax
gh_bullet3.actor_set_gravity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_bullet3.actor_set_gravity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_linear_factor (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL XX factor
return values
none
code sample
gh_bullet3.actor_set_linear_factor(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_linear_velocity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL velocity vector
return values
none
code sample
gh_bullet3.actor_set_linear_velocity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_bullet3.actor_set_material(actor_id, mid)
syntax
gh_bullet3.actor_set_orientation (
actor_id,
qx, qy, qz, qw
)
parameters
actor_id ID actor identifier
qx, qy, qz, qw REAL orientation quaternion
return values
none
code sample
gh_bullet3.actor_set_orientation(actor_id, qx, qy, qz, qw)
syntax
gh_bullet3.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL 3d position
return values
none
code sample
gh_bullet3.actor_set_position(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_sleeping_thresholds (
actor_id,
linear,
angular
)
parameters
actor_id ID actor identifier
linear REAL linear sleeping threshold
angular REAL angular sleeping threshold
return values
none
code sample
gh_bullet3.actor_set_sleeping_thresholds(actor_id, linear, angular)
syntax
gh_bullet3.actor_update_mass (
actor_id,
mass
)
parameters
actor_id ID actor identifier
mass REAL mass
return values
none
code sample
gh_bullet3.actor_update_mass(actor_id, mass)
syntax
version = gh_bullet3.get_version()
parameters
none
return values
version INTEGER API version
code sample
version = gh_bullet3.get_version()
syntax
ret = gh_bullet3.init()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_bullet3.init()
material_create
Creates a new material.
syntax
mat_id = gh_bullet3.material_create (
restitution,
friction
)
parameters
restitution REAL restitution factor
friction REAL friction factor
return values
mat_id ID material identifier
code sample
mat_id = gh_bullet3.material_create(restitution, friction)
material_kill
Destroys a material.
syntax
gh_bullet3.material_kill (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_bullet3.material_kill(mat_id)
syntax
gh_bullet3.material_update (
mat_id,
friction,
restitution
)
parameters
mat_id ID material identifier
friction REAL friction
restitution REAL resilience / restitution
return values
none
code sample
restitution = 0.9
friction = 0.5
gh_bullet3.material_update(mat_id, restitution, friction)
-- now update the material for a particular actor
gh_bullet3.actor_set_material(actor_id, mat_id)
syntax
gh_bullet3.scene_add_actor (
scene_id,
actor_id
)
parameters
scene_id ID scene identifier
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.scene_add_actor(scene_id, actor_id)
syntax
num_contacts = gh_bullet3.scene_check_contacts (
scene_id
)
parameters
scene_id ID scene identifier
return values
num_contacts INTEGER number of contacts
code sample
num_contacts = gh_bullet3.scene_check_contacts(scene_id)
syntax
scene_id = gh_bullet3.scene_create()
parameters
none
return values
scene_id ID scene identifier
code sample
scene_id = gh_bullet3.scene_create()
syntax
scene_id = gh_bullet3.scene_create_sap (
min_x, min_y, min_z,
max_x, max_y, max_z
)
parameters
min_x, min_y, min_z REAL world dimensions (minimal AABB values)
max_x, max_y, max_z REAL world dimensions (maximal AABB values)
return values
scene_id ID scene identifier
code sample
scene_id = gh_bullet3.scene_create_sap(x0, y0, z0, x1, x1, z1)
syntax
gh_bullet3.scene_kill (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_kill(scene_id)
syntax
gh_bullet3.scene_remove_actor (
scene_id,
actor_id
)
parameters
scene_id ID scene identifier
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.scene_remove_actor(scene_id, actor_id)
syntax
gh_bullet3.scene_reset_all_contacts (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_reset_all_contacts(scene_id)
syntax
gh_bullet3.scene_set_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_bullet3.scene_set_gravity(scene_id, x, y, z)
syntax
gh_bullet3.scene_set_solver_num_iterations (
scene_id,
num_iterations
)
parameters
scene_id ID scene identifier
num_iterations INTEGER number of iterations - default value is 10.
return values
none
code sample
gh_bullet3.scene_set_solver_num_iterations(scene_id, iterations)
syntax
gh_bullet3.scene_step_simulation (
scene_id,
time_step,
max_sub_steps,
fixed_time_step
)
parameters
scene_id ID scene identifier
time_step REAL time step between two frames
max_sub_steps INTEGER number of sub steps
fixed_time_step REAL fixed time step - default value: 1.0/60.0
return values
none
code sample
gh_bullet3.scene_step_simulation(scene_id, dt, max_sub_steps, 1.0/60.0)
syntax
gh_bullet3.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_sync_3d_objects(scene_id)
syntax
ret = gh_bullet3.terminate()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_bullet3.terminate()
gh_camera
Camera module
gh_camera is the module that manages cameras: creation, destruction, setting the parameters (position, filed of view, etc.).
syntax
gh_camera.bind (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.bind(camera)
syntax
gh_camera.bind_v2 (
cam_id,
update_viewport,
update_scissor,
update_proj_mat,
update_view_mat,
update_fixed_pipeline
)
parameters
cam_id ID camera identifier
update_viewport BOOLEAN updates the viewport: 1 (true) or 0 (false)
update_scissor BOOLEAN updates the scissor rectangle (same size than the viewport): 1 (true) or 0 (false)
update_proj_mat BOOLEAN updates the projection matrix: 1 (true) or 0 (false)
update_view_mat BOOLEAN updates the view matrix: 1 (true) or 0 (false)
update_fixed_pipeline BOOLEAN updates the fixed pipeline (so you will have access to gl_ModelViewProjectionMatrix in a vertex shader for example): 1 (true) or 0 (false)
return values
none
code sample
local update_viewport = 1
local update_scissor = 0
local update_proj_mat = 1
local update_view_mat = 1
local update_fixed_pipeline = 0
gh_camera.bind_v2(cam_id, update_viewport, update_scissor, update_proj_mat, update_view_mat, update_fixed_pipeline)
syntax
cam_id = gh_camera.create_ortho (
left,
right,
bottom,
top,
znear,
zfar
)
parameters
left REAL left clipping plane
right REAL right clipping plane
bottom REAL bottom clipping plane
top REAL top clipping plane
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
w = screen_width
h = screen_height
cam_id = gh_camera.create_ortho(-w/2, w/2, -h/2, h/2, -1.0, 1.0)
create_orthographic
Creates an orthographic camera with default values: left, right, top, bottom are derived from the window size.
syntax
cam_id = gh_camera.create_orthographic()
parameters
none
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_orthographic()
syntax
cam_id = gh_camera.create_persp (
fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp(60, 1.333, 0.1, 1000.0)
syntax
cam_id = gh_camera.create_persp_v2 (
fov,
is_vertical_fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
is_vertical_fov BOOLEAN 1 (vertical fov) or 0 (horizontal fov)
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp_v2(60, 1, 1.333, 0.1, 1000.0)
syntax
cam_id = gh_camera.create_persp_v3 (
fov_x,
fov_y,
aspect,
znear,
zfar
)
parameters
fov_x REAL horizontal field of view in degres
fov_y REAL vertical field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp_v3(60, 70, 1.333, 0.1, 1000.0)
create_perspective
Creates a perspective camera with default values (fov=60, znear=1, zfar=1000, aspect=win_width/win_height).
syntax
cam_id = gh_camera.create_perspective (
pos_x, pos_y, pos_z,
lookat_x, lookat_y, lookat_z
)
parameters
pos_x, pos_y, pos_z REAL position of the camera
lookat_x, lookat_y, lookat_z REAL look at point of the camera
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_perspective(0, 20, 0, 0, 0, 0)
syntax
cam_id = gh_camera.create_perspective_vk (
fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_perspective_vk(60.0, winW/winH, 1.0, 1000.0)
syntax
collision = gh_camera.frustum_check_object_aa_box (
cam_id,
obj_id
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_object_aa_box(cam_id, obj_id)
syntax
collision = gh_camera.frustum_check_object_sphere (
cam_id,
obj_id
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_object_sphere(cam_id, obj_id)
syntax
collision = gh_camera.frustum_check_point (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL position of the point
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_point(cam_id, x, y, z)
syntax
collision = gh_camera.frustum_check_sphere (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL position of the sphere center
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_sphere(cam_id, radius, x, y, z)
frustum_update
Updates the frustum volume of the camera.
The frustum needs to be updated as soon as the camera view matrix has changed (position or orientation).
Once the frustumn is updated, you can perform collision checks (frustum_check_sphere for example).
syntax
gh_camera.frustum_update (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.frustum_update(cam_id)
get_euler_angles
Gets the Euler's angles.
syntax
pitch, yaw, roll = gh_camera.get_euler_angles (
cam_id
)
parameters
cam_id ID camera identifier
return values
pitch, yaw, roll REAL Euler's angles in degrees
code sample
pitch, yaw, roll = gh_camera.get_euler_angles(cam_id)
syntax
fov = gh_camera.get_fov (
cam_id
)
parameters
cam_id ID camera identifier
return values
fov REAL vertical field of view in degrees
code sample
fov = gh_camera.get_fov(cam_id)
syntax
x, y, z = gh_camera.get_position (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_camera.get_position(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix (
cam_id
)
parameters
cam_id ID camera identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix_4x4 (
cam_id
)
parameters
cam_id ID camera identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix_4x4(cam_id)
syntax
x, y, z = gh_camera.get_up_vector (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL up vector
code sample
x, y, z = gh_camera.get_up_vector(cam_id)
syntax
x, y, z = gh_camera.get_view (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL view vector
code sample
x, y, z = gh_camera.get_view(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_view_matrix (
cam_id
)
parameters
cam_id ID camera identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_view_matrix(cam_id)
syntax
x, y, z, w = gh_camera.get_view_quaternion (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z, w REAL view quaternion
code sample
x, y, z, w = gh_camera.get_view_quaternion(cam_id)
syntax
gh_camera.load_gl2_matrix (
cam_id,
load_proj_mat,
load_view_mat,
object_id
)
parameters
cam_id ID camera identifier
load_proj_mat BOOLEAN load the projection matrix (0 or 1)
load_view_mat BOOLEAN load the view matrix (0 or 1)
object_id ID object identifier
return values
none
code sample
load_proj_mat = 1
load_view_mat = 1
gh_camera.load_gl2_matrix(cam_id, load_proj_mat, load_view_mat, object_id)
reset_reflection_matrix
Resets the reflection matrix initialized by set_reflection_matrix_v1() or set_reflection_matrix_v2().
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix.
syntax
gh_camera.reset_reflection_matrix (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.reset_reflection_matrix(cam_id)
syntax
gh_camera.set_fov (
cam_id,
fov
)
parameters
cam_id ID camera identifier
fov REAL vertical field of view in degrees
return values
none
code sample
gh_camera.set_fov(cam_id, 90)
syntax
gh_camera.set_lookat (
cam_id,
x, y, z,
lookat_mode
)
parameters
cam_id ID camera identifier
x, y, z REAL the target
lookat_mode REAL 1: the target is a point (3D position) or 0: the target is a direction (3D vector)
return values
none
code sample
-- Look at the center of the scene:
gh_camera.set_lookat(cam_id, 0, 0, 0, 1)
syntax
gh_camera.set_orientation_cubemap (
cam_id,
face
)
parameters
cam_id ID camera identifier
face INTEGER cubemap face (0 to 5)
return values
none
code sample
for face = 0, 5 do
gh_camera.set_orientation_cubemap(cam_id, face)
...
end
syntax
gh_camera.set_pitch (
cam_id,
pitch
)
parameters
cam_id ID camera identifier
pitch REAL pitch in degrees
return values
none
code sample
gh_camera.set_pitch(cam_id, pitch)
syntax
gh_camera.set_position (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL 3D position of the camera
return values
none
code sample
gh_camera.set_position(cam_id, 0, 10, 20)
syntax
gh_camera.set_projection_matrix (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
return values
none
code sample
gh_camera.set_projection_matrix(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
set_reflection_matrix_v1
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v1 (
cam_id,
px, py, pz,
nx, ny, nz,
y
)
parameters
cam_id ID camera identifier
px, py, pz REAL mirror plane position
nx, ny, nz REAL mirror plane normal
y REAL y offset - default: 0
return values
none
code sample
gh_camera.set_reflection_matrix_v1(cam_id, 0, 10, 0, 0, 0, 1)
set_reflection_matrix_v2
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v2 (
cam_id,
a, b, c, d
)
parameters
cam_id ID camera identifier
a, b, c, d REAL mirror plane equation
return values
none
code sample
a, b, c, d = gh_object.get_plane_equation(mirror_plane)
gh_camera.set_reflection_matrix_v2(cam_id, a, b, c, d)
set_reflection_matrix_v3
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v3 (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
return values
none
code sample
gh_camera.set_reflection_matrix_v3(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_camera.set_roll (
cam_id,
roll
)
parameters
cam_id ID camera identifier
roll REAL roll in degrees
return values
none
code sample
gh_camera.set_roll(cam_id, roll)
syntax
gh_camera.set_up_vec (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL direction of the up vector
return values
none
code sample
-- The up vector is the unit Y axis.
gh_camera.set_up_vec(cam_id, 0, 1, 0)
syntax
gh_camera.set_view_matrix (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
return values
none
code sample
gh_camera.set_view_matrix(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_camera.set_viewport (
cam_id,
x,
y,
width,
height
)
parameters
cam_id ID camera identifier
x INTEGER x offset - default: 0
y INTEGER y offset - default: 0
width INTEGER width of the viewport
height INTEGER height of the viewport
return values
none
code sample
gh_camera.set_viewport(cam_id, 0, 0, screen_width, screen_height)
syntax
gh_camera.set_yaw (
cam_id,
yaw
)
parameters
cam_id ID camera identifier
yaw REAL yaw in degrees
return values
none
code sample
gh_camera.set_yaw(cam_id, yaw)
syntax
gh_camera.update_ortho (
cam_id,
left,
right,
bottom,
top,
znear,
zfar
)
parameters
cam_id ID camera identifier
left REAL left clipping plane
right REAL right clipping plane
bottom REAL bottom clipping plane
top REAL top clipping plane
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
w = screen_width
h = screen_height
gh_camera.update_ortho(cam_id, -w/2, w/2, -h/2, h/2, 1.0, -1.0)
syntax
gh_camera.update_persp (
cam_id,
fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
gh_camera.update_persp(cam_id, 60, 1.333, 0.1, 1000.0)
syntax
gh_camera.update_persp_v2 (
cam_id,
fov,
is_vertical_fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
is_vertical_fov BOOLEAN 1 (vertical fov) or 0 (horizontal fov)
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
local is_vertical_fov = 1
gh_camera.update_persp_v2(cam_id, 60, is_vertical_fov, 1.333, 0.1, 1000.0)
syntax
gh_camera.update_perspective_vk (
cam_id,
fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
gh_camera.update_perspective_vk(cam_id, 60.0, winW/winH, 1.0, 1000.0)
gh_gpu_program
GPU program module
gh_gpu_program is the module that manages GPU programs based on the GLSL language: creation, destruction, binding, uniforms settings.
add_shader_from_buffer
Adds a shader, specified by a memory buffer, to an existing GPU program, created by create_empty().
syntax
ret = gh_gpu_program.add_shader_from_buffer (
gpuprog_id,
buff_ptr,
buff_size,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
-- shader types:
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
filename = demo_dir .. "assets/vertex_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_VERTEX)
gh_utils.file_buffer_kill(buffer)
filename = demo_dir .. "assets/pixel_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_PIXEL)
gh_utils.file_buffer_kill(buffer)
syntax
gh_gpu_program.bind (
gpuprog_id
)
parameters
gpuprog_id ID gpu program identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id) -- Binding
...
gh_gpu_program.bind(0) -- Unbinding
create
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control and evaluation (tcs and tes) or compute (cs) shaders.
syntax
gpuprog_id = gh_gpu_program.create (
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
vs STRING vertex shader source code string
ps STRING pixel shader source code string
gs STRING geometry shader source code string
tcs STRING tessellation control shader source code string
tes STRING tessellation eval shader source code string
cs STRING compute shader source code string
return values
gpuprog_id ID gpu program identifier
code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create(vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_empty (
program_name
)
parameters
program_name STRING name of the GPU program
return values
gpuprog_id ID gpu program identifier
code sample
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
syntax
gpuprog_id = gh_gpu_program.create_from_file (
filename,
absolute_path
)
parameters
filename STRING GPU program source code filename
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
gpuprog_id ID gpu program identifier
code sample
abs_path = 0 -- relative path
gpuprog_id = gh_gpu_program.create_from_file("data/shader.glsl", abs_path)
syntax
gpuprog_id = gh_gpu_program.create_from_file_v3 (
program_name,
filename
)
parameters
program_name STRING name of the GPU program
filename STRING absolute path of the GPU program source code file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
gpuprog_id = gh_gpu_program.create_from_file_v3("LightingProg", demo_dir .. "./data/lighting_prog.glsl")
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files (
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
parameters
program_name STRING name of the GPU program
vs_filename STRING absolute path of the vertex shader file
ps_filename STRING absolute path of the pixel shader file
gs_filename STRING absolute path of the geometry shader file
tcs_filename STRING absolute path of the tessellation control shader file
tes_filename STRING absolute path of the tessellation eval shader file
cs_filename STRING absolute path of the compute shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.txt"
ps = demo_dir .. "./shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_shader_files("LightingProg", vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv (
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
program_name STRING name of the GPU program
vs_fname STRING vertex shader: absolute path of the SMOL-V file
ps_fname STRING pixel shader: absolute path of the SMOL-V file
gs_fname STRING geometry shader: absolute path of the SMOL-V file
tcs_fname STRING tessellation control shader: absolute path of the SMOL-V file
tes_fname STRING tessellation eval shader: absolute path of the SMOL-V file
cs_fname STRING compute shader: absolute path of the SMOL-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv (
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
program_name STRING name of the GPU program
vs_fname STRING vertex shader: absolute path of the SPIR-V file
ps_fname STRING pixel shader: absolute path of the SPIR-V file
gs_fname STRING geometry shader: absolute path of the SPIR-V file
tcs_fname STRING tessellation control shader: absolute path of the SPIR-V file
tes_fname STRING tessellation eval shader: absolute path of the SPIR-V file
cs_fname STRING compute shader: absolute path of the SPIR-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_from_zip_file (
zip_filename,
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
parameters
zip_filename STRING absolute path of the zip file
program_name STRING name of the GPU program
vs_filename STRING absolute path of the vertex shader file
ps_filename STRING absolute path of the pixel shader file
gs_filename STRING absolute path of the geometry shader file
tcs_filename STRING absolute path of the tessellation control shader file
tes_filename STRING absolute path of the tessellation eval shader file
cs_filename STRING absolute path of the compute shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
local zip_filename = demo_dir .. "demo.zip"
vs = "shaders/vs.txt"
ps = "shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_zip_file(zip_filename, "LightingProg", vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_from_zip_file_gl_spirv (
zip_fname,
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
zip_fname STRING absolute path to the zip file
program_name STRING name of the GPU program
vs_fname STRING vertex shader: path of the SPIR-V file in the zip archive
ps_fname STRING pixel shader: path of the SPIR-V file in the zip archive
gs_fname STRING geometry shader: path of the SPIR-V file in the zip archive
tcs_fname STRING tessellation control shader: path of the SPIR-V file in the zip archive
tes_fname STRING tessellation eval shader: path of the SPIR-V file in the zip archive
cs_fname STRING compute shader: path of the SPIR-V file in the zip archive
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zip_fname = demo_dir .. "data.zip"
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv(zip_fname, "prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_gl_spirv (
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
program_name STRING name of the GPU program
vs STRING vertex shader source code
ps STRING pixel shader source code
gs STRING geometry shader source code
tcs STRING tessellation control shader source code
tes STRING tessellation eval shader source code
cs STRING compute shader source code
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = "void main(){ ... }"
ps = "void main(){ ... }"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files (
program_name,
ms_filename,
ts_filename,
ps_filename
)
parameters
program_name STRING name of the GPU program
ms_filename STRING absolute path of the mesh shader file
ts_filename STRING absolute path of the task shader file
ps_filename STRING absolute path of the pixel shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/ms.txt"
ps = demo_dir .. "./shaders/ps.txt"
mesh_prog = gh_gpu_program.create_mesh_task_from_shader_files("MeshProg", ms, "", ps)
syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv (
program_name,
ms_fname,
ts_fname,
ps_fname
)
parameters
program_name STRING name of the GPU program
ms_fname STRING mesh shader: absolute path of the SPIR-V file
ts_fname STRING task shader: absolute path of the SPIR-V file
ps_fname STRING pixel shader: absolute path of the SPIR-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
ts = ""
meshprog = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv("prog", ms, ts, ps)
create_v2
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control (tcs), evaluation (tes) or compute (cs) shaders.
All these shaders are memory buffers.
syntax
gpuprog_id = gh_gpu_program.create_v2 (
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
program_name STRING name of the GPU program
vs STRING vertex shader source code string
ps STRING pixel shader source code string
gs STRING geometry shader source code string
tcs STRING tessellation control shader source code string
tes STRING tessellation eval shader source code string
cs STRING compute shader source code string
return values
gpuprog_id ID gpu program identifier
code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create_v2("LightingProg", vs, ps, "", "", "", "")
syntax
block_index = gh_gpu_program.get_interface_block_index (
gpuprog_id,
block_type,
block_name
)
parameters
gpuprog_id ID gpu program identifier
block_type ENUM( gpu_buffer_type ) type of the block: 'UNIFORM', 'SHADER_STORAGE'
block_name STRING name of the block
return values
block_index INTEGER block index
code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
syntax
stride = gh_gpu_program.get_uniform_array_stride (
gpuprog_id,
variable_name
)
parameters
gpuprog_id ID gpu program identifier
variable_name STRING name of the variable
return values
stride INTEGER stride in bytes
code sample
stride = gh_gpu_program.get_uniform_array_stride(gpuprog_id, "positions")
syntax
block_size = gh_gpu_program.get_uniform_block_size (
gpuprog_id,
block_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
return values
block_size INTEGER block size in bytes
code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
size = gh_gpu_program.get_uniform_block_size(gpuprog_id, index)
syntax
size, offset = gh_gpu_program.get_uniform_size_and_offset (
gpuprog_id,
variable_name
)
parameters
gpuprog_id ID gpu program identifier
variable_name STRING name of the variable
return values
size, offset INTEGER size and offset in bytes
code sample
size, offset = gh_gpu_program.get_uniform_size_and_offset(gpuprog_id, "positions")
syntax
name = gh_gpu_program.get_vertex_attrib_name (
gpuprog_id,
vertex_index
)
parameters
gpuprog_id ID gpu program identifier
vertex_index INTEGER vertex attribute index
return values
name STRING vertex attrib name
code sample
gh_gpu_program.bind(gpuprog_id)
name = gh_gpu_program.get_vertex_attrib_name(gpuprog_id, 0)
syntax
gh_gpu_program.run_compute (
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z
)
parameters
gpuprog_id ID gpu program identifier
num_groups_x, num_groups_y, num_groups_z INTEGER specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute(gpuprog_id, 16, 16, 16)
syntax
gh_gpu_program.run_compute_group_size (
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z,
work_group_size_x, work_group_size_y, work_group_size_z
)
parameters
gpuprog_id ID gpu program identifier
num_groups_x, num_groups_y, num_groups_z INTEGER specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
work_group_size_x, work_group_size_y, work_group_size_z INTEGER specifies the work group size in the X, Y and Z dimensions
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute_group_size(gpuprog_id, num_groups_x, num_groups_y, num_groups_z, work_group_size_x, work_group_size_y, work_group_size_z)
syntax
gh_gpu_program.set_livecoding_state (
gpuprog_id,
shader_type,
state
)
parameters
gpuprog_id ID gpu program identifier
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
state BOOLEAN live coding: 1 (enabled) or 0 (disabled)
return values
none
code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
shader_type = GPU_SHADER_PIXEL
state = 1
gh_gpu_program.set_livecoding_state(gpuprog_id, shader_type, state)
syntax
gh_gpu_program.set_shader_storage_block_binding (
gpuprog_id,
block_index,
binding_point_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
binding_point_index INTEGER index of a GPU buffer binding point
return values
none
code sample
gh_gpu_program.set_shader_storage_block_binding(gpuprog_id, index, 3)
syntax
gh_gpu_program.set_uniform_block_binding (
gpuprog_id,
block_index,
binding_point_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
binding_point_index INTEGER index of a GPU buffer binding point
return values
none
code sample
gh_gpu_program.set_uniform_block_binding(gpuprog_id, index, 2)
syntax
gh_gpu_program.set_vertex_attrib_name (
gpuprog_id,
vertex_index,
name
)
parameters
gpuprog_id ID gpu program identifier
vertex_index INTEGER vertex attribute index
name STRING vertex attrib name
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.set_vertex_attrib_name(gpuprog_id, 0, "gxl3d_Position")
syntax
gh_gpu_program.uniform1d (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1d(gpuprog_id, "r", 0.25)
syntax
gh_gpu_program.uniform1f (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x REAL uniform value
return values
none
code sample
elapsed_time = gh_utils.get_elapsed_time()
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1f(gpuprog_id, "time", elapsed_time)
syntax
gh_gpu_program.uniform1fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
temperatures = {}
temperatures[1] = 20.0
temperatures[2] = 21.0
temperatures[3] = 24.0
temperatures[4] = 29.0
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1fv(gpuprog_id, "temperatures", 4, temperatures)
syntax
gh_gpu_program.uniform1i (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1i(gpuprog_id, "index", 2)
syntax
gh_gpu_program.uniform1iv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
material_ids = {}
InitMaterialIDs(material_ids)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1iv(gpuprog_id, "material_ids", material_ids, 10)
syntax
gh_gpu_program.uniform1ui64 (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64(gpuprog_id, "tex", bindless_texture_handle)
syntax
gh_gpu_program.uniform1ui64v (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
all_texture_handles = {}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64v(gpuprog_id, "all_textures", 32, all_texture_handles)
syntax
gh_gpu_program.uniform2d (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2d(gpuprog_id, "rg", 0.25, 0.22)
syntax
gh_gpu_program.uniform2f (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2f(gpuprog_id, "uv", 0.1, 1.0)
syntax
gh_gpu_program.uniform2fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=...}. In Python, each element is a tuple: (0.25, 0.59)
return values
none
code sample
uv = {}
uv[1]={x=0, y=0}
uv[2]={x=0.2, y=0}
uv[3]={x=0.4, y=0.2}
uv[4]={x=0.6, y=0.25}
uv[5]={x=0.8, y=0.5}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2fv(gpuprog_id, "uv", 5, uv)
syntax
gh_gpu_program.uniform2i (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2i(gpuprog_id, "rg", 250, 25)
syntax
gh_gpu_program.uniform3d (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3d(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
syntax
gh_gpu_program.uniform3f (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3f(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
syntax
gh_gpu_program.uniform3fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0)
return values
none
code sample
xyz = {} -- array element: {x=0, y=0, z=0}
InitXYZ(xyz)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3fv(gpuprog_id, "xyz", 10, xyz)
syntax
gh_gpu_program.uniform3i (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3i(gpuprog_id, "rgb", 250, 25, 45)
syntax
gh_gpu_program.uniform4d (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4d(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
syntax
gh_gpu_program.uniform4f (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
syntax
gh_gpu_program.uniform4f_array (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL Uniform value. The four elements of an uniform array: float xyzw[4]
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f_array(gpuprog_id, "all_params", 0.2, 10.4, 0.003, 0.001)
syntax
gh_gpu_program.uniform4fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=..., w=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0, 1.0)
return values
none
code sample
xyzw = {} -- array element: {x=0, y=0, z=0, w=0}
InitXYZW(xyzw)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4fv(gpuprog_id, "xyzw", 10, xyzw)
syntax
gh_gpu_program.uniform4i (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i(gpuprog_id, "rgba", 250, 25, 45, 100)
syntax
gh_gpu_program.uniform4i_array (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w INTEGER Uniform value. The four elements of an uniform array: int xyzw[4]
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i_array(gpuprog_id, "all_textures", 0, 1, 2, 3)
syntax
gh_gpu_program.uniform_3x3f (
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
m0,m1,m2,m3,m4,m5,m6,m7,m8 REAL the 9 floats that make the 3x3 matrix
return values
none
code sample
gh_gpu_program.uniform_3x3f(gpuprog_id, "rotMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8)
syntax
gh_gpu_program.uniform_4x4f (
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
return values
none
code sample
gh_gpu_program.uniform_4x4f(gpuprog_id, "myMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_gpu_program.uniform_camera_matrices (
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
uniform_name_view_mat STRING name of the view matrix
uniform_name_proj_mat STRING name of the projection matrix
return values
none
code sample
gh_gpu_program.uniform_camera_matrices(gpuprog_id, camera, "ViewMat", "ProjMat")
syntax
gh_gpu_program.uniform_camera_matrices_v2 (
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat,
uniform_name_viewproj_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
uniform_name_view_mat STRING name of the view matrix
uniform_name_proj_mat STRING name of the projection matrix
uniform_name_viewproj_mat STRING name of the view projection matrix
return values
none
code sample
gh_gpu_program.uniform_camera_matrices_v2(gpuprog_id, camera, "ViewMat", "ProjMat", "ViewProjMat")
uniform_matrix
Sets an uniform 4x4 matrix (mat4 in GLSL) built from the transformation matrix of an object (camera, mesh, etc.).
syntax
gh_gpu_program.uniform_matrix (
gpuprog_id,
object_id,
uniform_name,
matrix_type,
upload_to_gpu
)
parameters
gpuprog_id ID gpu program identifier
object_id ID object identifier
uniform_name STRING name of the uniform 4x4 matrix
matrix_type INTEGER type of the matrix: 'camera_view_projection', 'camera_view', 'camera_inv_view', 'camera_projection', 'camera_inv_projection' 'object_local_tranform', 'object_global_tranform'
upload_to_gpu INTEGER If 1, the uniform value is immedialtly uploaded to the GPU. If 0, the value will be uploaded later during the rendering.
return values
none
code sample
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ViewMatrix", "camera_view")
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ProjMatrix", "camera_projection")
gh_gpu_program.uniform_matrix(gpuprog_id, object_id, "ModelMatrix", "object_global_tranform")
syntax
gh_gpu_program.uniform_modelviewproj_matrices (
gpuprog_id,
cam_id,
obj_id,
uniform_name_modelviewproj_mat,
uniform_name_modelview_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
obj_id ID object identifier
uniform_name_modelviewproj_mat STRING name of the model view projection matrix
uniform_name_modelview_mat STRING name of the model view matrix
return values
none
code sample
gh_gpu_program.uniform_modelviewproj_matrices(gpuprog_id, camera, mesh, "ModelViewProj", "ModelView")
syntax
gh_gpu_program.uniform_object_matrix (
gpuprog_id,
obj_id,
uniform_name_mat
)
parameters
gpuprog_id ID gpu program identifier
obj_id ID object identifier
uniform_name_mat STRING name of the uniform variable
return values
none
code sample
gh_gpu_program.uniform_object_matrix(gpuprog_id, object, "ModelMat")
syntax
gh_gpu_program.uniform_subroutine (
gpuprog_id,
shader_type,
subroutine_uniform_name,
subroutine_name
)
parameters
gpuprog_id ID gpu program identifier
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
subroutine_uniform_name STRING uniform name of the subroutine
subroutine_name STRING name of the real subroutine
return values
none
code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gh_gpu_program.uniform_subroutine(gpuprog_id, GPU_SHADER_PIXEL, "Color", "ColorBlue")
syntax
gh_gpu_program.uniform_transform_matrix_v1 (
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
pitch, yaw, roll,
sx, sy, sz,
transform_order
)
parameters
gpuprog_id ID gpu program identifier
uniform_matrix_name STRING name of the uniform variable
posx, posy, posz REAL 3D position
pitch, yaw, roll REAL Euler angles in degrees
sx, sy, sz REAL 3D scale
transform_order INTEGER order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
return values
none
code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, pitch, yaw, roll, sx, sy, sz, transform_order)
syntax
gh_gpu_program.uniform_transform_matrix_v2 (
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
qx, qy, qz, qw,
sx, sy, sz,
transform_order
)
parameters
gpuprog_id ID gpu program identifier
uniform_matrix_name STRING name of the uniform variable
posx, posy, posz REAL 3D position
qx, qy, qz, qw REAL Orientation quaternion
sx, sy, sz REAL 3D scale
transform_order INTEGER order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
return values
none
code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, qx, qy, qz, qw, sx, sy, sz, transform_order)
syntax
gh_gpu_program.update_shader_from_file (
gpuprog_id,
filename,
is_abs_path,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
filename STRING shader filename
is_abs_path INTEGER filename is specified with an absolute (1) or relative (0) path
shader_type STRING type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
return values
none
code sample
gh_gpu_program.update_shader_from_file(gpuprog_id, "data/ps.txt", 0, "pixel")
syntax
gh_gpu_program.update_shader_from_memory (
gpuprog_id,
shader_code,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
shader_code STRING shader code (a string)
shader_type STRING type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
return values
none
code sample
pixel_shader = "....."
gh_gpu_program.update_shader_from_memory(gpuprog_id, pixel_shader, "pixel")
syntax
gh_gpu_program.vk_add_spirv_module_file (
gpuprog_id,
filename,
entry_point,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
filename STRING filename of the SPIR-V module
entry_point STRING entry point of the SPIR-V module. Usually main.
shader_type INTEGER type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
filename_vs = demo_dir .. "./spirv/vs.spv"
filename_ps = demo_dir .. "./spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_file(prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_file(prog, filename_ps, "main", GPU_SHADER_PIXEL)
syntax
gh_gpu_program.vk_add_spirv_module_zip (
zip_filename,
gpuprog_id,
filename,
entry_point,
shader_type
)
parameters
zip_filename STRING filename of the zip archive
gpuprog_id ID gpu program identifier
filename STRING filename of the SPIR-V module in the zip archive
entry_point STRING entry point of the SPIR-V module. Usually main.
shader_type INTEGER type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
zip_filename = demo_dir .. "data.zip"
filename_vs = "spirv/vs.spv"
filename_ps = "spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_ps, "main", GPU_SHADER_PIXEL)
syntax
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file (
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file (
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip (
zip_filename,
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
zip_filename STRING absolute path to the zip archive
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
vs = "shaders/vs.spv"
ps = "shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip(zipfile, "LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file (
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
parameters
program_name STRING name of the GPU program
ms_fname, ms_entry_point STRING mesh shader: absolute path of the shader file, entry point name
ts_fname, ts_entry_point STRING task shader: ...
ps_fname, ps_entry_point STRING pixel shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file("MeshProg", ms,"main", "","", ps,"main")
syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip (
zip_filename,
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
parameters
zip_filename STRING absolute path to the zip archive
program_name STRING name of the GPU program
ms_fname, ms_entry_point STRING mesh shader: absolute path of the shader file, entry point name
ts_fname, ts_entry_point STRING task shader: ...
ps_fname, ps_entry_point STRING pixel shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
ms = "shaders/ms.spv"
ps = "shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip(zipfile, "MeshProg", ms,"main", "","", ps,"main")
syntax
gh_imgui.add_bezier_curve_to_drawlist (
x0, y0,
cp0x, cp0y,
cp1x, cp1y,
x1, y1,
r, g, b, a
)
parameters
x0, y0 REAL start position
cp0x, cp0y REAL control point 0
cp1x, cp1y REAL control point 1
x1, y1 REAL end position
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.add_bezier_curve_to_drawlist(p0_x, p0_y, ctrl0_x, ctrl0_y, ctrl1_x, ctrl1_y, p1_x, p1_y, r, g, b, a)
syntax
gh_imgui.add_circle_to_drawlist (
center_x, center_y,
radius,
r, g, b, a,
line_thickness,
num_segments,
filled
)
parameters
center_x, center_y REAL position of the circle center
radius REAL radius of the circle
r, g, b, a REAL RGBA color
line_thickness REAL line thickness
num_segments INTEGER number of segments of the circle
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
num_segments = 20
filled = 1
gh_imgui.add_circle_to_drawlist(center_x, center_y, radius, r, g, b, a, thickness, num_segments, filled)
syntax
font_id = gh_imgui.add_font_from_buffer (
buff_ptr,
buff_size,
font_size
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
filename = demo_dir .. "assets/arial.ttf"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
font_id = gh_imgui.add_font_from_buffer(buffer, buffer_size, 24)
gh_utils.file_buffer_kill(buffer)
syntax
font_id = gh_imgui.add_font_from_file (
font_filename,
font_size
)
parameters
font_filename STRING absolute path of the font file
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
font_id = gh_imgui.add_font_from_file(font_filename, 24)
syntax
font_id = gh_imgui.add_font_from_zip_file (
zip_filename,
font_filename,
font_size
)
parameters
zip_filename STRING absolute path of the zip file
font_filename STRING absolute path of the font file
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
font_id = gh_imgui.add_font_from_zip_file(zip_filename, font_filename, 24)
syntax
gh_imgui.add_line_to_drawlist (
x0, y0,
x1, y1,
r, g, b, a
)
parameters
x0, y0 REAL start position
x1, y1 REAL end position
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.add_line_to_drawlist(start_x, start_y, end_x, end_y, r, g, b, a)
syntax
gh_imgui.add_quad_to_drawlist (
ax, ay,
bx, by,
cx, cy,
dx, dy,
r, g, b, a,
thickness,
filled
)
parameters
ax, ay REAL position of the 1st point
bx, by REAL position of the 2nd point
cx, cy REAL position of the 3rd point
dx, dy REAL position of the 4th point
r, g, b, a REAL RGBA color
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
filled = 1
gh_imgui.add_quad_to_drawlist(ax, ay, bx, by, cx, cy, dx, dy, r, g, b, a, thickness, filled)
syntax
gh_imgui.add_rect_filled_multicolor_to_drawlist (
p_min_x, p_min_y,
p_max_x, p_max_y,
r0, g0, b0, a0,
r1, g1, b1, a1,
r2, g2, b2, a2,
r3, g3, b3, a3
)
parameters
p_min_x, p_min_y REAL position of the bottom_left corner
p_max_x, p_max_y REAL position of the top right corner
r0, g0, b0, a0 REAL RGBA up-left
r1, g1, b1, a1 REAL RGBA up-right
r2, g2, b2, a2 REAL RGBA bottom-right
r3, g3, b3, a3 REAL RGBA bottom-left
return values
none
code sample
gh_imgui.add_rect_filled_multicolor_to_drawlist(p_min_x, p_min_y, p_max_x, p_max_y,
r0, g0, b0, a0,
r1, g1, b1, a1,
r2, g2, b2, a2,
r3, g3, b3, a3)
syntax
gh_imgui.add_rect_to_drawlist (
p_min_x, p_min_y,
p_max_x, p_max_y,
r, g, b, a,
rounding,
thickness,
filled
)
parameters
p_min_x, p_min_y REAL position of the bottom_left corner
p_max_x, p_max_y REAL position of the top right corner
r, g, b, a REAL RGBA color
rounding REAL corner rounding
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
rounding = 0
thickness = 2
filled = 1
gh_imgui.add_rect_to_drawlist(p_min_x, p_min_y, p_max_x, p_max_y, r, g, b, a, rounding, thickness, filled)
syntax
gh_imgui.add_triangle_to_drawlist (
p1x, p1y,
p2x, p2y,
p3x, p3y,
r, g, b, a,
thickness,
filled
)
parameters
p1x, p1y REAL position of the first vertex
p2x, p2y REAL position of the second vertex
p3x, p3y REAL position of the third vertex
r, g, b, a REAL RGBA color
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
filled = 1
gh_imgui.add_triangle_to_drawlist(p1x, p1y, p2x, p2y, p3x, p3y, r, g, b, a, thickness, filled)
syntax
gh_imgui.begin_child (
label,
width, height,
border,
flags
)
parameters
label STRING name of the button
width, height REAL size of the region
border BOOLEAN border: 1 (enabled) or 0 (disabled)
flags ENUM( imgui_WindowFlags ) see window flags (ImGuiWindowFlags_xxx) in imgui.lua
return values
none
code sample
gh_imgui.begin_child(label, w, h, border, flags)
syntax
gh_imgui.begin_disabled (
disabled
)
parameters
disabled INTEGER 0 or 1
return values
none
code sample
gh_imgui.begin_disabled(1)
syntax
gh_imgui.bullet()
parameters
none
return values
none
code sample
gh_imgui.bullet()
syntax
pressed = gh_imgui.button (
label,
width, height
)
parameters
label STRING name of the button
width, height INTEGER width and height of the button
return values
pressed BOOLEAN pressed: 1 (true) or 0 (false)
code sample
pressed = gh_imgui.button("Fire", 200, 20)
syntax
pressed = gh_imgui.button_arrow (
label,
direction
)
parameters
label STRING name of the button
direction ENUM( arrow_dir ) arrow direction: 0 (left), 1 (right), 2(up) and 3(down)
return values
pressed BOOLEAN pressed: 1 (true) or 0 (false)
code sample
pressed = gh_imgui.button_arrow("Fire", 1)
syntax
x, y = gh_imgui.calc_text_size (
text
)
parameters
text STRING text
return values
x, y REAL size of the text
code sample
x, y = gh_imgui.calc_text_size("Hello")
checkbox
Create a checkbox.
syntax
checked = gh_imgui.checkbox (
label,
current_state
)
parameters
label STRING name of the button
current_state BOOLEAN checked: 1 (true) or 0 (false)
return values
checked BOOLEAN checked: 1 (true) or 0 (false)
code sample
checked = gh_imgui.checkbox("Wireframe", checked)
syntax
r, g, b, a = gh_imgui.color_edit_rgba (
label,
r0, b0, g0, a0
)
parameters
label STRING name of the slider
r0, b0, g0, a0 REAL initial 4D value
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_imgui.color_edit_rgba("coloredit01", r0, b0, g0, a0)
syntax
r, g, b, a = gh_imgui.color_edit_rgba_v2 (
label,
r0, b0, g0, a0,
flags
)
parameters
label STRING name of the slider
r0, b0, g0, a0 REAL initial 4D value
flags ENUM( imgui_ColorEditFlags ) ImGuiColorEditFlags_xxx options
return values
r, g, b, a REAL RGBA color value
code sample
flags = ImGuiColorEditFlags_None
r, g, b, a = gh_imgui.color_edit_rgba_v2("coloredit01", r0, b0, g0, a0, flags)
color_picker_rgba
Displays a color picker.
syntax
r, g, b, a = gh_imgui.color_picker_rgba (
label,
r0, b0, g0, a0
)
parameters
label STRING name of the color picker
r0, b0, g0, a0 REAL initial 4D value
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_imgui.color_picker_rgba("coloredit01", r0, b0, g0, a0)
color_picker_rgba_v2
Displays a color picker.
syntax
r, g, b, a = gh_imgui.color_picker_rgba_v2 (
label,
r0, b0, g0, a0,
flags
)
parameters
label STRING name of the color picker
r0, b0, g0, a0 REAL initial 4D value
flags ENUM( imgui_ColorEditFlags ) ImGuiColorEditFlags_xxx options
return values
r, g, b, a REAL RGBA color value
code sample
flags = ImGuiColorEditFlags_None
r, g, b, a = gh_imgui.color_picker_rgba_v2("coloredit01", r0, b0, g0, a0, flags)
syntax
gh_imgui.color_text_editor_copy_paste_cut (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING operation: copy, paste or cut
return values
none
code sample
gh_imgui.color_text_editor_copy_paste_cut(te_id, "copy")
syntax
te_id = gh_imgui.color_text_editor_create()
parameters
none
return values
te_id ID text editor identifier
code sample
te_id = gh_imgui.color_text_editor_create()
color_text_editor_get_current_line_text
Gets the current line.
syntax
line = gh_imgui.color_text_editor_get_current_line_text (
te_id
)
parameters
te_id ID text editor identifier
return values
line STRING current line
code sample
line = gh_imgui.color_text_editor_get_current_line_text(te_id)
syntax
x, y = gh_imgui.color_text_editor_get_cursor_position (
te_id
)
parameters
te_id ID text editor identifier
return values
x, y INTEGER current cursor position
code sample
x, y = gh_imgui.color_text_editor_get_cursor_position(te_id)
color_text_editor_get_selected_text
Gets the selected text.
syntax
text = gh_imgui.color_text_editor_get_selected_text (
te_id
)
parameters
te_id ID text editor identifier
return values
text STRING selected text
code sample
text = gh_imgui.color_text_editor_get_selected_text(te_id)
syntax
text = gh_imgui.color_text_editor_get_text (
te_id
)
parameters
te_id ID text editor identifier
return values
text STRING text
code sample
text = gh_imgui.color_text_editor_get_text(te_id)
syntax
n = gh_imgui.color_text_editor_get_total_lines (
te_id
)
parameters
te_id ID text editor identifier
return values
n INTEGER number of lines
code sample
n = gh_imgui.color_text_editor_get_total_lines(te_id)
syntax
x = gh_imgui.color_text_editor_is_text_changed (
te_id
)
parameters
te_id ID text editor identifier
return values
x INTEGER 1 if text changed, 0 if not.
code sample
x = gh_imgui.color_text_editor_is_text_changed(te_id)
color_text_editor_kill
Destroys a text editor.
syntax
gh_imgui.color_text_editor_kill (
te_id
)
parameters
te_id ID text editor identifier
return values
none
code sample
gh_imgui.color_text_editor_kill(te_id)
syntax
r, g, b, a = gh_imgui.color_text_editor_palette_get_color (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING element name: Default, Keyword, Number, String, Punctuation, Preprocessor, Identifier, KnownIdentifier, PreprocIdentifier, Comment, MultiLineComment, Background, Cursor, Selection, ErrorMarker, Breakpoint, LineNumber, CurrentLineFill, CurrentLineFillInactive, CurrentLineEdge
return values
r, g, b, a REAL RGBA color
code sample
r, g, b, a = gh_imgui.color_text_editor_palette_get_color(te_id, "Background")
syntax
gh_imgui.color_text_editor_palette_set_color (
te_id,
what,
r, g, b, a
)
parameters
te_id ID text editor identifier
what STRING element name: Default, Keyword, Number, String, Punctuation, Preprocessor, Identifier, KnownIdentifier, PreprocIdentifier, Comment, MultiLineComment, Background, Cursor, Selection, ErrorMarker, Breakpoint, LineNumber, CurrentLineFill, CurrentLineFillInactive, CurrentLineEdge, XT95Line
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.color_text_editor_palette_set_color(te_id, "Background", r, g, b, a)
gh_imgui.color_text_editor_palette_set_color(te_id, "XT95Line", 0.2, 0.2, 0.2, 0.8)
color_text_editor_render
Draws a text editor.
syntax
gh_imgui.color_text_editor_render (
te_id,
title,
size_x, size_y,
border
)
parameters
te_id ID text editor identifier
title STRING title
size_x, size_y REAL frame size
border INTEGER border (1: yes, 0: no)
return values
none
code sample
gh_imgui.color_text_editor_render(te_id, "Lua Editor", 400, 600, 0)
syntax
gh_imgui.color_text_editor_selection (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING operation: start, end or clear
return values
none
code sample
gh_imgui.color_text_editor_selection(te_id, "start")
syntax
gh_imgui.color_text_editor_set_language (
te_id,
lang
)
parameters
te_id ID text editor identifier
lang STRING langaue: lua, glsl, hlsl, cpp, c, sql
return values
none
code sample
gh_imgui.color_text_editor_set_language(te_id, "lua")
syntax
gh_imgui.color_text_editor_set_palette (
te_id,
pal
)
parameters
te_id ID text editor identifier
pal STRING palette: dark, light, retro_blue
return values
none
code sample
gh_imgui.color_text_editor_set_palette(te_id, "dark")
syntax
gh_imgui.color_text_editor_set_property_bool (
te_id,
what,
x
)
parameters
te_id ID text editor identifier
what STRING property name: whitespaces, readonly, colorizer, handle_mouse_inputs, handle_keyboard_inputs
x INTEGER value
return values
none
code sample
gh_imgui.color_text_editor_set_property_bool(te_id, "whitespaces", 1)
syntax
gh_imgui.color_text_editor_set_property_int (
te_id,
what,
x
)
parameters
te_id ID text editor identifier
what STRING property name: tabsize
x INTEGER value
return values
none
code sample
gh_imgui.color_text_editor_set_property_int(te_id, "tabsize", 2)
syntax
gh_imgui.color_text_editor_set_text (
te_id,
text
)
parameters
te_id ID text editor identifier
text STRING text
return values
none
code sample
gh_imgui.color_text_editor_set_text(te_id, text)
syntax
offset = gh_imgui.column_get_offset (
index
)
parameters
index INTEGER column index
return values
offset REAL offset
code sample
offset = gh_imgui.column_get_offset(index)
syntax
width = gh_imgui.column_get_width (
index
)
parameters
index INTEGER column index
return values
width REAL width
code sample
width = gh_imgui.column_get_width(index)
column_next
Starts a new column.
syntax
gh_imgui.column_next()
parameters
none
return values
none
code sample
gh_imgui.columns(2, 1)
-- display widgets
...
-- next column
gh_imgui.column_next()
-- display widgets
...
-- reset to default layout (one column)
gh_imgui.columns(1, 0)
syntax
gh_imgui.column_set_offset (
index,
offset
)
parameters
index INTEGER column index
offset REAL offset
return values
none
code sample
gh_imgui.column_set_offset(index, width)
syntax
gh_imgui.column_set_width (
index,
width
)
parameters
index INTEGER column index
width REAL width
return values
none
code sample
gh_imgui.column_set_width(index, width)
syntax
gh_imgui.columns (
num_columns,
border
)
parameters
num_columns INTEGER number of columns
border INTEGER display column border ot not
return values
none
code sample
gh_imgui.columns(2, 1)
-- display widgets
...
-- next column
gh_imgui.column_next()
-- display widgets
...
-- reset to default layout (one column)
gh_imgui.columns(1, 0)
syntax
gh_imgui.combo_box_add_item (
cb_id,
item_label
)
parameters
cb_id ID combo box identifier
item_label STRING label of the item
return values
none
code sample
gh_imgui.combo_box_add_item(cb_id, "Item1")
syntax
cb_id = gh_imgui.combo_box_create (
label
)
parameters
label STRING combo box label
return values
cb_id ID combo box identifier
code sample
cb_id = gh_imgui.combo_box_create(label)
combo_box_draw
Draws the combo box.
syntax
selected_item = gh_imgui.combo_box_draw (
cb_id,
initial_selected_item
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.combo_box_draw(cb_id, 0)
combo_box_draw_v2
Draws the combo box.
syntax
selected_item = gh_imgui.combo_box_draw_v2 (
cb_id,
initial_selected_item,
height_in_items
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
height_in_items INTEGER height of the combo box in items
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.combo_box_draw_v2(cb_id, 0, 10)
syntax
gh_imgui.dummy (
width, height
)
parameters
width, height INTEGER dimensions of the box in pixels
return values
none
code sample
gh_imgui.dummy(10, 5)
end_child
End a scrolling region.
syntax
gh_imgui.end_child()
parameters
none
return values
none
code sample
gh_imgui.end_child()
end_disabled
Ends a disabled section.
syntax
gh_imgui.end_disabled()
parameters
none
return values
none
code sample
gh_imgui.end_disabled()
file_browser_add_type_filter
Adds a type filter.
syntax
gh_imgui.file_browser_add_type_filter (
type
)
parameters
type STRING type filter
return values
none
code sample
gh_imgui.file_browser_add_type_filter(".lua")
gh_imgui.file_browser_add_type_filter(".xml")
gh_imgui.file_browser_add_type_filter(".txt")
syntax
gh_imgui.file_browser_clear_type_filters()
parameters
none
return values
none
code sample
gh_imgui.file_browser_clear_type_filters()
syntax
gh_imgui.file_browser_close()
parameters
none
return values
none
code sample
gh_imgui.file_browser_close()
syntax
gh_imgui.file_browser_display (
width, height
)
parameters
width, height INTEGER size of the file browser window
return values
none
code sample
gh_imgui.file_browser_display(600, 400)
syntax
filename = gh_imgui.file_browser_get_selected()
parameters
none
return values
filename STRING the selected filename
code sample
if (gh_imgui.file_browser_has_selected() == 1) then
filename = gh_imgui.file_browser_get_selected()
end
syntax
ret = gh_imgui.file_browser_has_selected()
parameters
none
return values
ret INTEGER 1 (selected) or 0 (not selected)
code sample
if (gh_imgui.file_browser_has_selected() == 1) then
DoSomething()
end
syntax
gh_imgui.file_browser_init (
flags
)
parameters
flags INTEGER options. See ImGuiFileBrowserFlags_xxxx values in imgui.lua
return values
none
code sample
gh_imgui.file_browser_init(0)
syntax
gh_imgui.file_browser_open()
parameters
none
return values
none
code sample
gh_imgui.file_browser_open()
syntax
gh_imgui.file_browser_set_current_directory (
dir
)
parameters
dir STRING directory
return values
none
code sample
gh_imgui.file_browser_set_current_directory(demo_dir)
syntax
gh_imgui.file_browser_set_title (
text
)
parameters
text STRING title
return values
none
code sample
gh_imgui.file_browser_set_title(title)
syntax
gh_imgui.frame_begin (
width, height,
mouse_x, mouse_y,
mouse_left_button, mouse_right_button,
dt
)
parameters
width, height INTEGER size of the main 3D window (gh_window.getsize(0))
mouse_x, mouse_y INTEGER position of the mouse (gh_input.mouse_get_position())
mouse_left_button, mouse_right_button BOOLEAN state of mouse left and right buttons (gh_input.mouse_get_button_state())
dt REAL time step
return values
none
code sample
gh_imgui.frame_begin(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button, dt)
syntax
gh_imgui.frame_begin_v2 (
width, height,
mouse_x, mouse_y,
mouse_left_button, mouse_right_button,
mouse_wheel,
dt
)
parameters
width, height INTEGER size of the main 3D window (gh_window.getsize(0))
mouse_x, mouse_y INTEGER position of the mouse (gh_input.mouse_get_position())
mouse_left_button, mouse_right_button BOOLEAN state of mouse left and right buttons (gh_input.mouse_get_button_state())
mouse_wheel INTEGER mouse wheel delta
dt REAL time step
return values
none
code sample
gh_imgui.frame_begin_v2(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button, mouse_wheel, dt)
syntax
gh_imgui.frame_end()
parameters
none
return values
none
code sample
gh_imgui.frame_end()
syntax
gh_imgui.fx_drawlist_coding_party_demo (
fx_name,
title,
window_flags,
width, height,
size_flags,
x, y,
position_flags
)
parameters
fx_name STRING name of the demo or effect
title STRING window title
window_flags INTEGER window flags
width, height INTEGER window size
size_flags INTEGER size flags
x, y INTEGER window position
position_flags INTEGER position flags
return values
none
code sample
Current demos:
"ocornut_squares"
"ocornut_waves"
"kudaba_thunder_storm"
"crowbarous_blobs"
"badlydrawnrod_racetrack"
"floooh_googly_eyes"
"bdero_particles"
pos_size_flag_always = 1
pos_size_flag_once = 2
pos_size_flag_first_use_ever = 4
pos_size_flag_appearing = 8
pos_size_flag = pos_size_flag_always
window_default = 0
window_no_resize = 2
window_no_move = 4
window_no_collapse = 32
window_show_border = 128
window_no_save_settings = 256
window_flags = window_default
gh_imgui.fx_drawlist_coding_party_demo("ocornut_squares", "squares", window_flags, 320, 180, pos_size_flag, 20, 20, pos_size_flag_once)
syntax
r, g, b, a = gh_imgui.get_color (
item_type
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see values in the code sample)
return values
r, g, b, a REAL RGBA color value
code sample
widget_type = IMGUI_BUTTON_COLOR
r, g, b, a = gh_imgui.get_color(widget_type)
syntax
width = gh_imgui.get_content_region_available_width()
parameters
none
return values
width REAL available width
code sample
width = gh_imgui.get_content_region_available_width()
syntax
x, y = gh_imgui.get_cur_font_display_offset()
parameters
none
return values
x, y REAL offsets
code sample
x, y = gh_imgui.get_cur_font_display_offset()
syntax
x, y = gh_imgui.get_cursor_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_cursor_pos()
syntax
x, y = gh_imgui.get_cursor_screen_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_cursor_screen_pos()
syntax
x, y = gh_imgui.get_cursor_start_pos()
parameters
none
return values
x, y REAL cursor position
code sample
x, y = gh_imgui.get_cursor_start_pos()
syntax
size = gh_imgui.get_font_size()
parameters
none
return values
size REAL size
code sample
size = gh_imgui.get_font_size()
syntax
x, y, z, w = gh_imgui.get_item_rect()
parameters
none
return values
x, y, z, w INTEGER size of the current item
code sample
x, y, z, w = gh_imgui.get_item_rect()
syntax
x, y = gh_imgui.get_item_rect_max()
parameters
none
return values
x, y REAL 2D coordinates
code sample
x, y = gh_imgui.get_item_rect_max()
syntax
x, y = gh_imgui.get_item_rect_min()
parameters
none
return values
x, y REAL 2D coordinates
code sample
x, y = gh_imgui.get_item_rect_min()
syntax
x, y = gh_imgui.get_item_spacing()
parameters
none
return values
x, y REAL spacing
code sample
x, y = gh_imgui.get_item_spacing()
get_mouse_pos
Gets the mouse position.
syntax
x, y = gh_imgui.get_mouse_pos()
parameters
none
return values
x, y REAL mouse position
code sample
x, y = gh_imgui.get_mouse_pos()
syntax
scroll_x, scroll_y = gh_imgui.get_scroll()
parameters
none
return values
scroll_x, scroll_y REAL scrolling values in X and Y
code sample
scroll_x, scroll_y = gh_imgui.get_scroll()
syntax
scroll_x, scroll_y = gh_imgui.get_scroll_max()
parameters
none
return values
scroll_x, scroll_y REAL scrolling values in X and Y
code sample
scroll_x, scroll_y = gh_imgui.get_scroll_max()
syntax
h = gh_imgui.get_text_line_heigh_with_spacing()
parameters
none
return values
h REAL height
code sample
h = gh_imgui.get_text_line_heigh_with_spacing()
syntax
h = gh_imgui.get_text_line_height()
parameters
none
return values
h REAL line height
code sample
h = gh_imgui.get_text_line_height()
syntax
h = gh_imgui.get_text_line_height_with_spacing()
parameters
none
return values
h REAL line height
code sample
h = gh_imgui.get_text_line_height_with_spacing()
syntax
version = gh_imgui.get_version()
parameters
none
return values
version STRING ImGui version
code sample
version_str = gh_imgui.get_version()
syntax
x, y = gh_imgui.get_window_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_window_pos()
syntax
x, y, width, height = gh_imgui.get_window_pos_size()
parameters
none
return values
x, y, width, height REAL position and size
code sample
x, y, width, height = gh_imgui.get_window_pos_size()
syntax
width, height = gh_imgui.get_window_size()
parameters
none
return values
width, height REAL size
code sample
width, height = gh_imgui.get_window_size()
syntax
gh_imgui.gizmo_begin_frame()
parameters
none
return values
none
code sample
gh_imgui.frame_begin(...)
gh_imgui.gizmo_begin_frame()
...
syntax
tx,ty,tz, rx,ry,rz, sx,sy,sz = gh_imgui.gizmo_decompose_matrix_to_components (
obj_id
)
parameters
obj_id ID object identifier
return values
tx,ty,tz, rx,ry,rz, sx,sy,sz REAL translation vector, rotation vector and scale vector
code sample
tx,ty,tz, rx,ry,rz, sx,sy,sz = gh_imgui.gizmo_decompose_matrix_to_components(obj_id)
syntax
gh_imgui.gizmo_enable (
state
)
parameters
state INTEGER 0 or 1
return values
none
code sample
gh_imgui.gizmo_enable(1)
syntax
state = gh_imgui.gizmo_is_over()
parameters
none
return values
state BOOLEAN 1 (yes) or 0 (no)
code sample
is_over = gh_imgui.gizmo_is_over()
syntax
state = gh_imgui.gizmo_is_using()
parameters
none
return values
state BOOLEAN 1 (yes) or 0 (no)
code sample
is_using = gh_imgui.gizmo_is_using()
syntax
gh_imgui.gizmo_manipulate (
cam_id,
obj_id,
oper_type,
trans_mode
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
oper_type ENUM( imgui_OperationType ) operation type: 'translate', 'rotate' or 'scale'
trans_mode ENUM( imgui_TransformationMode ) transformation mode: 'local' or 'world'
return values
none
code sample
gh_imgui.gizmo_manipulate(cam_id, obj_id, "rotate", "local")
syntax
gh_imgui.gizmo_set_rect (
x, y, width, height
)
parameters
x, y, width, height INTEGER viewport size
return values
none
code sample
gh_imgui.gizmo_set_rect(0, 0, winW, winH)
syntax
gh_imgui.group_begin()
parameters
none
return values
none
code sample
gh_imgui.group_begin()
-- display widgets
...
gh_imgui.group_end()
syntax
gh_imgui.group_end()
parameters
none
return values
none
code sample
gh_imgui.group_begin()
-- display widgets
...
gh_imgui.group_end()
syntax
gh_imgui.image (
tex_id,
width, height
)
parameters
tex_id ID texture identifier as returned by gh_texture.create_xxx() functions
width, height REAL image size
return values
none
code sample
gh_imgui.image(tex0, 200, 200)
syntax
gh_imgui.image_button (
tex_id,
width, height,
frame_padding
)
parameters
tex_id ID texture identifier as returned by gh_texture.create_xxx() functions
width, height REAL image size
frame_padding INTEGER frame padding
return values
none
code sample
gh_imgui.image_button(tex0, 200, 200, 1)
imgui_plot_create
Creates a plotline.
syntax
plot_id = gh_imgui.imgui_plot_create (
label
)
parameters
label STRING name of the plotline
return values
plot_id ID plotline identifier
code sample
plot_id = gh_imgui.imgui_plot_create("myPlotline")
syntax
gh_imgui.imguizmoquat_gizmo3d_v1 (
label,
size,
mode,
object_id
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
object_id REAL object identifier
return values
none
code sample
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
gh_imgui.imguizmoquat_gizmo3d_v1("##gizmo01", 100.0, modeDirection + cubeAtOrigin, torus)
syntax
qx, qy, qz, qw = gh_imgui.imguizmoquat_gizmo3d_v2 (
label,
size,
mode,
q0x, q0y, q0z, q0w
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
q0x, q0y, q0z, q0w REAL initial orientation quaternion
return values
qx, qy, qz, qw REAL orientation quaternion
code sample
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
q0 = {x=0, y=0, z=0, w=0}
qr = {x=0, y=0, z=0, w=0}
qr.x, qr.w, qr.z, qr.w = gh_imgui.imguizmoquat_gizmo3d_v2("##gizmo01", 100.0, modeDirection + cubeAtOrigin, q0.x, q0.y, q0.z, q0.w)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_imgui.imguizmoquat_gizmo3d_v3 (
label,
size,
mode,
q0x, q0y, q0z, q0w
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
q0x, q0y, q0z, q0w REAL initial orientation quaternion
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
q0 = {x=0, y=0, z=0, w=0}
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_imgui.imguizmoquat_gizmo3d_v3("##gizmo01", 100.0, modeDirection + cubeAtOrigin, q0.x, q0.y, q0.z, q0.w)
imnodes_begin_input_attribute
syntax
gh_imgui.imnodes_begin_input_attribute (
input_attr_id,
pin_shape
)
parameters
input_attr_id INTEGER
pin_shape INTEGER
return values
none
code sample
ImNodesPinShape_Circle = 0
ImNodesPinShape_CircleFilled = 1
ImNodesPinShape_Triangle = 2
ImNodesPinShape_TriangleFilled = 3
ImNodesPinShape_Quad = 4
ImNodesPinShape_QuadFilled = 5
pin_shape = ImNodesPinShape_CircleFilled
gh_imgui.imnodes_begin_input_attribute(input_attr_id, pin_shape)
syntax
gh_imgui.imnodes_begin_node (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_begin_node(node_id)
syntax
gh_imgui.imnodes_begin_node_editor()
parameters
none
return values
none
code sample
gh_imgui.imnodes_begin_node_editor()
imnodes_begin_node_title_bar
syntax
gh_imgui.imnodes_begin_node_title_bar()
parameters
none
return values
none
code sample
gh_imgui.imnodes_begin_node_title_bar()
imnodes_begin_output_attribute
syntax
gh_imgui.imnodes_begin_output_attribute (
output_attr_id,
pin_shape
)
parameters
output_attr_id INTEGER
pin_shape INTEGER
return values
none
code sample
ImNodesPinShape_Circle = 0
ImNodesPinShape_CircleFilled = 1
ImNodesPinShape_Triangle = 2
ImNodesPinShape_TriangleFilled = 3
ImNodesPinShape_Quad = 4
ImNodesPinShape_QuadFilled = 5
pin_shape = ImNodesPinShape_CircleFilled
gh_imgui.imnodes_begin_output_attribute(output_attr_id, pin_shape)
imnodes_clear_link_selection
syntax
gh_imgui.imnodes_clear_link_selection (
link_id
)
parameters
link_id INTEGER
return values
none
code sample
gh_imgui.imnodes_clear_link_selection(link_id)
imnodes_clear_links_selection
syntax
gh_imgui.imnodes_clear_links_selection()
parameters
none
return values
none
code sample
gh_imgui.imnodes_clear_links_selection()
imnodes_clear_node_selection
syntax
gh_imgui.imnodes_clear_node_selection (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_clear_node_selection(node_id)
imnodes_clear_nodes_selection
syntax
gh_imgui.imnodes_clear_nodes_selection()
parameters
none
return values
none
code sample
gh_imgui.imnodes_clear_nodes_selection()
syntax
gh_imgui.imnodes_end_node()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node()
syntax
gh_imgui.imnodes_end_node_editor()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node_editor()
imnodes_end_node_title_bar
syntax
gh_imgui.imnodes_end_node_title_bar()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node_title_bar()
imnodes_end_output_attribute_DUP1
syntax
gh_imgui.imnodes_end_output_attribute_DUP1()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_output_attribute()
imnodes_end_output_attribute_DUP2
syntax
gh_imgui.imnodes_end_output_attribute_DUP2()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_output_attribute()
imnodes_get_node_editor_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_editor_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_editor_space_pos(node_id)
imnodes_get_node_grid_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_grid_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_grid_space_pos(node_id)
imnodes_get_node_screen_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_screen_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_screen_space_pos(node_id)
imnodes_get_selected_link
syntax
link_id = gh_imgui.imnodes_get_selected_link (
index
)
parameters
index INTEGER
return values
link_id INTEGER
code sample
link_id = gh_imgui.imnodes_get_selected_link(index)
imnodes_get_selected_node
syntax
node_id = gh_imgui.imnodes_get_selected_node (
index
)
parameters
index INTEGER
return values
node_id INTEGER
code sample
node_id = gh_imgui.imnodes_get_selected_node(index)
imnodes_is_editor_hovered
syntax
state = gh_imgui.imnodes_is_editor_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
code sample
state = gh_imgui.imnodes_is_editor_hovered()
syntax
state, started_at_attribute_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created()
parameters
none
return values
state BOOLEAN
started_at_attribute_id INTEGER
ended_at_attribute_id INTEGER
code sample
state, started_at_attribute_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created()
imnodes_is_link_created_v2
syntax
state, started_at_node_id, started_at_attribute_id, ended_at_node_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created_v2()
parameters
none
return values
state BOOLEAN
started_at_node_id INTEGER
started_at_attribute_id INTEGER
ended_at_node_id INTEGER
ended_at_attribute_id INTEGER
code sample
state, started_at_node_id, started_at_attribute_id, ended_at_node_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created_v2()
imnodes_is_link_destroyed
syntax
state, link_id = gh_imgui.imnodes_is_link_destroyed()
parameters
none
return values
state BOOLEAN
link_id INTEGER
code sample
state, link_id = gh_imgui.imnodes_is_link_destroyed()
syntax
state, started_at_attribute_id = gh_imgui.imnodes_is_link_dropped (
including_detached_links
)
parameters
including_detached_links INTEGER
return values
state BOOLEAN
started_at_attribute_id INTEGER
code sample
state, started_at_attribute_id = gh_imgui.imnodes_is_link_dropped(including_detached_links)
syntax
state, link_id = gh_imgui.imnodes_is_link_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
link_id INTEGER
code sample
state, link_id = gh_imgui.imnodes_is_link_hovered()
syntax
state = gh_imgui.imnodes_is_link_selected (
link_id
)
parameters
link_id INTEGER
return values
state BOOLEAN
code sample
state = gh_imgui.imnodes_is_link_selected(link_id)
syntax
state, started_at_attribute_id = gh_imgui.imnodes_is_link_started()
parameters
none
return values
state BOOLEAN
started_at_attribute_id INTEGER
code sample
state, started_at_attribute_id = gh_imgui.imnodes_is_link_started()
syntax
state, node_id = gh_imgui.imnodes_is_node_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
node_id INTEGER
code sample
state, node_id = gh_imgui.imnodes_is_node_hovered()
syntax
state = gh_imgui.imnodes_is_node_selected (
node_id
)
parameters
node_id INTEGER
return values
state BOOLEAN
code sample
state = gh_imgui.imnodes_is_node_selected(node_id)
syntax
state, pin_id = gh_imgui.imnodes_is_pin_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
pin_id INTEGER
code sample
state, pin_id = gh_imgui.imnodes_is_pin_hovered()
syntax
gh_imgui.imnodes_link (
link_id,
start_attribute_id,
end_attribute_id
)
parameters
link_id INTEGER
start_attribute_id INTEGER
end_attribute_id INTEGER
return values
none
code sample
gh_imgui.imnodes_link(link_id, start_attribute_id, end_attribute_id)
syntax
gh_imgui.imnodes_minimap (
minimap_size_fraction,
minimap_location
)
parameters
minimap_size_fraction REAL
minimap_location INTEGER
return values
none
code sample
ImNodesMiniMapLocation_BottomLeft = 0
ImNodesMiniMapLocation_BottomRight = 1
ImNodesMiniMapLocation_TopLeft = 2
ImNodesMiniMapLocation_TopRight = 3
minimap_size_fraction = 0.2
minimap_location = ImNodesMiniMapLocation_BottomLeft
gh_imgui.imnodes_minimap(minimap_size_fraction, minimap_location)
imnodes_num_selected_links
syntax
n = gh_imgui.imnodes_num_selected_links()
parameters
none
return values
n INTEGER
code sample
n = gh_imgui.imnodes_num_selected_links()
imnodes_num_selected_nodes
syntax
n = gh_imgui.imnodes_num_selected_nodes()
parameters
none
return values
n INTEGER
code sample
n = gh_imgui.imnodes_num_selected_nodes()
syntax
gh_imgui.imnodes_pop_color_style()
parameters
none
return values
none
code sample
gh_imgui.imnodes_pop_color_style()
syntax
gh_imgui.imnodes_pop_style_var()
parameters
none
return values
none
code sample
gh_imgui.imnodes_pop_style_var()
syntax
r, g, b, a = gh_imgui.imnodes_push_color_style (
color_item
)
parameters
color_item INTEGER
return values
r, g, b, a REAL
code sample
ImNodesCol_NodeBackground = 0
ImNodesCol_NodeBackgroundHovered = 1
ImNodesCol_NodeBackgroundSelected = 2
ImNodesCol_NodeOutline = 3
ImNodesCol_TitleBar = 4
ImNodesCol_TitleBarHovered = 5
ImNodesCol_TitleBarSelected = 6
ImNodesCol_Link = 7
ImNodesCol_LinkHovered = 8
ImNodesCol_LinkSelected = 9
ImNodesCol_Pin = 10
ImNodesCol_PinHovered = 11
ImNodesCol_BoxSelector = 12
ImNodesCol_BoxSelectorOutline = 13
ImNodesCol_GridBackground = 14
ImNodesCol_GridLine = 15
ImNodesCol_MiniMapBackground = 16
ImNodesCol_MiniMapBackgroundHovered = 17
ImNodesCol_MiniMapOutline = 18
ImNodesCol_MiniMapOutlineHovered = 19
ImNodesCol_MiniMapNodeBackground = 20
ImNodesCol_MiniMapNodeBackgroundHovered = 21
ImNodesCol_MiniMapNodeBackgroundSelected = 22
ImNodesCol_MiniMapNodeOutline = 23
ImNodesCol_MiniMapLink = 24
ImNodesCol_MiniMapLinkSelected = 25
color_item = ImNodesCol_TitleBar
gh_imgui.imnodes_push_color_style(color_item, r, g, b, a)
syntax
value = gh_imgui.imnodes_push_style_var (
style_item
)
parameters
style_item INTEGER
return values
value REAL
code sample
ImNodesStyleVar_GridSpacing = 0
ImNodesStyleVar_NodeCornerRounding = 1
ImNodesStyleVar_NodePaddingHorizontal = 2
ImNodesStyleVar_NodePaddingVertical = 3
ImNodesStyleVar_NodeBorderThickness = 4
ImNodesStyleVar_LinkThickness = 5
ImNodesStyleVar_LinkLineSegmentsPerLength = 6
ImNodesStyleVar_LinkHoverDistance = 7
ImNodesStyleVar_PinCircleRadius = 8
ImNodesStyleVar_PinQuadSideLength = 9
ImNodesStyleVar_PinTriangleSideLength = 10
ImNodesStyleVar_PinLineThickness = 11
ImNodesStyleVar_PinHoverRadius = 12
ImNodesStyleVar_PinOffset = 13
style_item = ImNodesStyleVar_GridSpacing
value = 24
gh_imgui.imnodes_push_style_var(style_item, value)
imnodes_read_selected_links
syntax
gh_imgui.imnodes_read_selected_links()
parameters
none
return values
none
code sample
gh_imgui.imnodes_read_selected_links()
imnodes_read_selected_nodes
syntax
gh_imgui.imnodes_read_selected_nodes()
parameters
none
return values
none
code sample
gh_imgui.imnodes_read_selected_nodes()
syntax
gh_imgui.imnodes_select_link (
link_id
)
parameters
link_id INTEGER
return values
none
code sample
gh_imgui.imnodes_select_link(link_id)
syntax
gh_imgui.imnodes_select_node (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_select_node(node_id)
imnodes_set_node_draggable
syntax
gh_imgui.imnodes_set_node_draggable (
node_id,
state
)
parameters
node_id INTEGER
state BOOLEAN 1 or 0
return values
none
code sample
gh_imgui.imnodes_set_node_draggable(state)
imnodes_set_node_editor_space_pos
syntax
gh_imgui.imnodes_set_node_editor_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_editor_space_pos(node_id, x, y)
imnodes_set_node_grid_space_pos
syntax
gh_imgui.imnodes_set_node_grid_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_grid_space_pos(node_id, x, y)
imnodes_set_node_screen_space_pos
syntax
gh_imgui.imnodes_set_node_screen_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_screen_space_pos(node_id, x, y)
syntax
gh_imgui.implot_add_data (
plotid,
x, y
)
parameters
plotid INTEGER plot identifier.
x, y REAL plot data.
return values
none
code sample
gh_imgui.implot_add_data(plotid, x, y)
syntax
gh_imgui.implot_begin_plot (
label_DUP1,
x_label,
y_label,
label_DUP2,
x, y,
flags,
x_flags,
y_flags,
y2_flags,
y3_flags
)
parameters
label_DUP1 STRING plot label.
x_label STRING X axis label.
y_label STRING y axis label.
label_DUP2 STRING plot label.
x, y REAL plot size.
flags INTEGER plot flags/options.
x_flags INTEGER X axis flags/options.
y_flags INTEGER Y axis flags/options.
y2_flags INTEGER Y axis additional flags/options.
y3_flags INTEGER Y axis additional flags/options.
return values
none
code sample
gh_imgui.implot_begin_plot(label, x_label, y_label, x_size, y_size, flags, x_flags, y_flags, y2_flags, y3_flags)
gh_imguiimplot_draw_plotline(plotid0, ...)
gh_imguiimplot_draw_plotline(plotid1, ...)
gh_imgui.implot_end_plot()
syntax
plotid = gh_imgui.implot_create_dataplot (
max_points
)
parameters
max_points INTEGER max number of points of the data plot. Can be 0
return values
plotid INTEGER plot identifier.
code sample
plotid = gh_imgui.implot_create_dataplot(max_points)
implot_draw_plotbars
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotbars (
plotid,
label,
count,
offset,
size,
vertical
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
size REAL size.
vertical INTEGER vertical (1) or hozizontal (0) bars.
return values
none
code sample
gh_imgui.implot_draw_plotbars(plotid, label, count, offset, size, vertical)
implot_draw_plotline
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotline (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotline(plotid, label, count, offset)
implot_draw_plotscatter
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotscatter (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotscatter(plotid, label, count, offset)
implot_draw_plotshaded
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotshaded (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotshaded(plotid, label, count, offset)
implot_end_plot
Ends plot rendering.
syntax
gh_imgui.implot_end_plot()
parameters
none
return values
none
code sample
gh_imgui.implot_end_plot()
implot_get_mouse_pos
Gets mouse position
syntax
x, y = gh_imgui.implot_get_mouse_pos()
parameters
none
return values
x, y REAL mouse position.
code sample
x, y = gh_imgui.implot_get_mouse_pos()
syntax
state = gh_imgui.implot_is_hovered()
parameters
none
return values
state INTEGER 1 (hovered) or 0 (not hovered).
code sample
is_hovered = gh_imgui.implot_is_hovered()
implot_kill_dataplot
Destroy a plot data set.
syntax
gh_imgui.implot_kill_dataplot (
plotid
)
parameters
plotid INTEGER plot identifier.
return values
none
code sample
gh_imgui.implot_kill_dataplot(plotid)
syntax
gh_imgui.implot_plottext (
text,
x, y,
vertical,
offset_x, offset_y
)
parameters
text STRING text
x, y REAL text position
vertical INTEGER vertical (1) or horizontal (0) text
offset_x, offset_y REAL offset
return values
none
code sample
gh_imgui.implot_plottext(text, x, y, vertical, offset_x, offset_y)
syntax
gh_imgui.implot_pop_colormap (
count
)
parameters
count INTEGER undo multiple pushes at once by increasing count.
return values
none
code sample
ImPlotColormap_Deep = 0
ImPlotColormap_Dark = 1
ImPlotColormap_Pastel = 2
ImPlotColormap_Paired = 3
ImPlotColormap_Viridis = 4
gh_imgui.implot_push_colormap(ImPlotColormap_Dark)
...
gh_imgui.implot_pop_colormap(1)
implot_pop_style_color
Restores a color
syntax
gh_imgui.implot_pop_style_color (
count
)
parameters
count INTEGER number of colors to restore (default: 1).
return values
none
code sample
gh_imgui.implot_push_style_color(ImPlotCol_Line, r, g, b, a)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_color(1)
syntax
gh_imgui.implot_push_colormap (
colormap_index
)
parameters
colormap_index INTEGER colormap index/identifier.
return values
none
code sample
ImPlotColormap_Deep = 0
ImPlotColormap_Dark = 1
ImPlotColormap_Pastel = 2
ImPlotColormap_Paired = 3
ImPlotColormap_Viridis = 4
ImPlotColormap_Plasma = 5
ImPlotColormap_Hot = 6
ImPlotColormap_Cool = 7
ImPlotColormap_Pink = 8
ImPlotColormap_Jet = 9
ImPlotColormap_Twilight = 10
ImPlotColormap_RdBu = 11
ImPlotColormap_BrBG = 12
ImPlotColormap_PiYG = 13
ImPlotColormap_Spectral = 14
ImPlotColormap_Greys = 15
gh_imgui.implot_push_colormap(ImPlotColormap_Plasma)
...
gh_imgui.implot_pop_colormap(1)
syntax
gh_imgui.implot_push_style_color (
color_index,
r, g, b, a
)
parameters
color_index INTEGER index (identifier) of the color.
r, g, b, a REAL RGBA color.
return values
none
code sample
ImPlotCol_Line = 0
ImPlotCol_Fill = 1
ImPlotCol_MarkerOutline = 2
ImPlotCol_MarkerFill = 3
ImPlotCol_ErrorBar = 4
ImPlotCol_FrameBg = 5
ImPlotCol_PlotBg = 6
ImPlotCol_PlotBorder = 7
ImPlotCol_XAxis = 8
ImPlotCol_YAxis = 9
ImPlotCol_YAxis2 = 10
ImPlotCol_YAxis3 = 11
ImPlotCol_Selection = 12
ImPlotCol_Query = 13
gh_imgui.implot_push_style_color(ImPlotCol_Line, r, g, b, a)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_color(1)
syntax
gh_imgui.implot_push_style_var_1f (
var_id,
x
)
parameters
var_id INTEGER variable identifier.
x REAL value.
return values
none
code sample
ImPlotStyleVar_LineWeight = 0
ImPlotStyleVar_Marker = 1
ImPlotStyleVar_MarkerSize = 2
ImPlotStyleVar_MarkerWeight = 3
ImPlotStyleVar_FillAlpha = 4
ImPlotStyleVar_ErrorBarSize = 5
ImPlotStyleVar_ErrorBarWeight = 6
ImPlotStyleVar_DigitalBitHeight = 7
ImPlotStyleVar_DigitalBitGap = 8
gh_imgui.implot_push_style_var_1i(ImPlotStyleVar_FillAlpha, 0.5)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_var(1)
syntax
gh_imgui.implot_push_style_var_1i (
var_id,
x
)
parameters
var_id INTEGER variable identifier.
x INTEGER value.
return values
none
code sample
ImPlotStyleVar_LineWeight = 0
ImPlotStyleVar_Marker = 1
ImPlotStyleVar_MarkerSize = 2
ImPlotStyleVar_MarkerWeight = 3
ImPlotStyleVar_FillAlpha = 4
ImPlotStyleVar_ErrorBarSize = 5
ImPlotStyleVar_ErrorBarWeight = 6
ImPlotStyleVar_DigitalBitHeight = 7
ImPlotStyleVar_DigitalBitGap = 8
ImPlotMarker_None = 1
ImPlotMarker_Circle = 2
ImPlotMarker_Square = 4
ImPlotMarker_Diamond = 8
ImPlotMarker_Up = 16
ImPlotMarker_Down = 32
ImPlotMarker_Left = 64
ImPlotMarker_Right = 128
ImPlotMarker_Cross = 256
ImPlotMarker_Plus = 512
ImPlotMarker_Asterisk = 1024
gh_imgui.implot_push_style_var_1i(ImPlotStyleVar_Marker, ImPlotMarker_Circle)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_var(1)
syntax
gh_imgui.implot_set_next_plot_limits (
x_min,
x_max,
y_min,
y_max,
cond
)
parameters
x_min INTEGER min limit in a X axis.
x_max INTEGER max limit in a X axis.
y_min INTEGER min limit in a Y axis.
y_max INTEGER max limit in a Y axis.
cond INTEGER
return values
none
code sample
ImGuiCond_None = 0
ImGuiCond_Always = 1
ImGuiCond_Once = 2
ImGuiCond_FirstUseEver = 4
ImGuiCond_Appearing = 8
gh_imgui.implot_set_next_plot_limits(x-10, x, -10, 30, ImGuiCond_Always)
syntax
gh_imgui.implot_show_demo_window (
show_window
)
parameters
show_window INTEGER
return values
none
code sample
gh_imgui.implot_show_demo_window(show_window)
indent
Sets indent spacing.
syntax
gh_imgui.indent (
indent_w
)
parameters
indent_w REAL size
return values
none
code sample
indent_w = 10.0
gh_imgui.indent(indent_w)
syntax
error = gh_imgui.init()
parameters
none
return values
error BOOLEAN 1 (success) or 0 (error)
code sample
ret = gh_imgui.init()
input_text
Allows to type a text.
syntax
state, text = gh_imgui.input_text (
label,
max_text_len,
initial_text,
flags
)
parameters
label STRING name of the input field
max_text_len INTEGER max text lenght in bytes (4096 bytes is the default value if max_text_len is set to 0)
initial_text STRING initial text
flags ENUM( imgui_InputTextFlags ) ImGuiInputTextFlags_xxx options
return values
state BOOLEAN state (1 or 0). Useful with ImGuiInputTextFlags_EnterReturnsTrue
text STRING text
code sample
flags = ImGuiInputTextFlags_None
text, state = gh_imgui.input_text("User name", 128, "", flags)
syntax
gh_imgui.invisible_button (
label,
w, h,
flags
)
parameters
label STRING label
w, h REAL size of the button
flags INTEGER options
return values
none
code sample
ImGuiButtonFlags_None = 0
ImGuiButtonFlags_MouseButtonLeft = 1
ImGuiButtonFlags_MouseButtonRight = 2
ImGuiButtonFlags_MouseButtonMiddle = 4
gh_imgui.invisible_button("canvas", 320, 180, ImGuiButtonFlags_None)
syntax
hovered = gh_imgui.is_any_item_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_any_item_hovered()
syntax
hovered = gh_imgui.is_any_window_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_any_window_hovered()
syntax
clicked = gh_imgui.is_item_clicked (
mouse_button
)
parameters
mouse_button ENUM( imgui_Mouse ) left button (0) or right button (1)
return values
clicked BOOLEAN clicked: 1 (true) or 0 (false)
code sample
clicked = gh_imgui.is_item_clicked(0)
syntax
hovered = gh_imgui.is_item_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_item_hovered()
syntax
state = gh_imgui.is_mouse_clicked (
button
)
parameters
button ENUM( mouse_button ) mouse button: 0 (left), 1 (right) or 2 (middle)
return values
state BOOLEAN clicked: 1 (true) or 0 (false)
code sample
state = gh_imgui.is_mouse_clicked(button)
syntax
hovered = gh_imgui.is_window_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_window_hovered()
syntax
out_value, ret = gh_imgui.knob (
label,
in_value,
v_min, v_max,
speed,
format,
knob_type,
size,
flags,
steps
)
parameters
label STRING label
in_value REAL initial value
v_min, v_max REAL min and max values
speed REAL animation speed
format STRING how the value is displayed.
knob_type INTEGER type of the knob: tick, dot, wiper, ...
size REAL size in pixels of the knob
flags INTEGER flags
steps INTEGER number of steps from start to end
return values
out_value REAL value of the knob between v_min and _vmax
ret INTEGER return code: 1 if OK, 0 if error
code sample
ImGuiKnobVariant_Tick = 1
ImGuiKnobVariant_Dot = 2
ImGuiKnobVariant_Wiper = 4
ImGuiKnobVariant_WiperOnly = 8
ImGuiKnobVariant_WiperDot = 16
ImGuiKnobVariant_Stepped = 32
ImGuiKnobVariant_Space = 64
ImGuiKnobFlags_NoTitle = 1
ImGuiKnobFlags_NoInput = 2
ImGuiKnobFlags_ValueTooltip = 4
ImGuiKnobFlags_DragHorizontal = 8
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_ReadOnlyInput = 16
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_DisableMouse = 32
value, ret = gh_imgui.knob(label, init_value, v_min, v_max, speed, format, type, size, flags, steps)
syntax
ret = gh_imgui.list_box_begin (
cb_index,
w, h
)
parameters
cb_index INTEGER combo box index
w, h REAL size of the list box
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_imgui.list_box_begin(cb_index, 0)
syntax
selected_item = gh_imgui.list_box_draw (
cb_id,
initial_selected_item
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.list_box_draw(cb_id, 0)
syntax
selected_item = gh_imgui.list_box_draw_v2 (
cb_id,
initial_selected_item,
height_in_items
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
height_in_items INTEGER height of the list box in items
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.list_box_draw_v2(cb_id, 0, 20)
list_box_end
Ends a list box header.
syntax
gh_imgui.list_box_end()
parameters
none
return values
none
code sample
gh_imgui.list_box_end()
syntax
start_item, end_item = gh_imgui.list_clipping_begin (
num_items
)
parameters
num_items INTEGER number of items
return values
start_item, end_item INTEGER range coreved by the list clipper
code sample
start_item, end_item = gh_imgui.list_clipping_begin(num_items)
list_clipping_end
Ends the list clipping.
syntax
gh_imgui.list_clipping_end (
num_items,
start_item, end_item
)
parameters
num_items INTEGER number of items
start_item, end_item INTEGER range coreved by the list clipper
return values
none
code sample
gh_imgui.list_clipping_end(num_items, start_item, end_item)
syntax
meid = gh_imgui.memory_editor_create (
size
)
parameters
size INTEGER size of the window
return values
meid ID memory editor identifier
code sample
meid = gh_imgui.memory_editor_create(1024)
syntax
gh_imgui.memory_editor_draw_window_DUP1 (
meid,
title
)
parameters
meid ID memory editor identifier
title STRING title of the window
return values
none
code sample
gh_imgui.memory_editor_draw_window(meid, title)
syntax
gh_imgui.memory_editor_draw_window_DUP2 (
meid
)
parameters
meid ID memory editor identifier
return values
none
code sample
gh_imgui.memory_editor_draw_contents(meid)
syntax
gh_imgui.memory_editor_kill (
meid
)
parameters
meid ID memory editor identifier
return values
none
code sample
gh_imgui.memory_editor_kill(meid)
syntax
gh_imgui.memory_editor_read_data_from_buffer (
meid,
buffer,
buffer_size
)
parameters
meid ID memory editor identifier
buffer POINTER memory buffer. See memory buffer function of gh_utils.
buffer_size INTEGER size in bytes of memory buffer.
return values
none
code sample
gh_imgui.memory_editor_read_data_from_buffer(meid, buffer, buffer_size)
syntax
gh_imgui.memory_editor_read_data_from_file (
meid,
filename
)
parameters
meid ID memory editor identifier
filename STRING absolute path to the file
return values
none
code sample
gh_imgui.memory_editor_read_data_from_file(meid, filename)
syntax
gh_imgui.memory_editor_resize (
meid,
size
)
parameters
meid ID memory editor identifier
size INTEGER size of the window
return values
none
code sample
gh_imgui.memory_editor_resize(meid, 512)
syntax
gh_imgui.memory_editor_set_data_from_texture (
meid,
tid
)
parameters
meid ID memory editor identifier
tid ID texture identifier
return values
none
code sample
gh_imgui.memory_editor_set_data_from_texture(meid, tid)
memory_editor_set_value_1u8
Writes a byte.
syntax
gh_imgui.memory_editor_set_value_1u8 (
meid,
index,
x
)
parameters
meid ID memory editor identifier
index INTEGER index of the value
x INTEGER value
return values
none
code sample
gh_imgui.memory_editor_set_value_1u8(meid, 0, 128)
syntax
gh_imgui.memory_editor_write_data_to_buffer (
meid,
buffer,
buffer_size
)
parameters
meid ID memory editor identifier
buffer POINTER memory buffer. See memory buffer function of gh_utils.
buffer_size INTEGER size in bytes of memory buffer.
return values
none
code sample
gh_imgui.memory_editor_write_data_to_buffer(meid, buffer, buffer_size)
syntax
gh_imgui.memory_editor_write_data_to_file (
meid,
filename
)
parameters
meid ID memory editor identifier
filename STRING absolute path to the file
return values
none
code sample
gh_imgui.memory_editor_write_data_to_file(meid, filename)
syntax
state = gh_imgui.menu_begin_main_bar()
parameters
none
return values
state BOOLEAN 1 or 0 - only call menu_end_main_bar() if this returns 1
code sample
gh_imgui.menu_begin_main_bar()
menu_end_main_bar
Ends the main menu bar.
syntax
gh_imgui.menu_end_main_bar()
parameters
none
return values
none
code sample
gh_imgui.menu_end_main_bar()
syntax
item_index = gh_imgui.plot_add_item (
plot_id,
label,
type
)
parameters
plot_id ID plotline identifier
label STRING label
type INTEGER line: 0, scatter: 1, xbar: 2 or ybar: 3
return values
item_index INTEGER index of the new item
code sample
type_line = 0
type_scatter = 1
type_xbar = 2
type_ybar = 3
item_index = gh_imgui.plot_add_item(plot_id, "myNewItem", type_line)
syntax
gh_imgui.plot_axis_scroll (
plot_id,
axis,
current_time,
history
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0, Y axis: 1
current_time REAL current time
history REAL history seconds
return values
none
code sample
gh_imgui.plot_axis_scroll(plot_id, axis, current_time, history)
plot_draw
Draws a plotline.
syntax
gh_imgui.plot_draw (
plot_id,
label,
num_items,
size_x, size_y
)
parameters
plot_id ID plotline identifier
label STRING name of the plotline
num_items INTEGER number of lines to draw
size_x, size_y REAL plotline frame size
return values
none
code sample
gh_imgui.plot_draw(plot_id, label, num_items, size_x, size_y)
syntax
x, y = gh_imgui.plot_get_mouse_position()
parameters
none
return values
x, y REAL mouse position
code sample
x, y = gh_imgui.plot_get_mouse_position()
syntax
state = gh_imgui.plot_is_hovered()
parameters
none
return values
state INTEGER 1: hovered, 0: not hovered
code sample
state = gh_imgui.plot_is_hovered()
plot_item_add_data
Adds data to an item.
syntax
gh_imgui.plot_item_add_data (
plot_id,
item_index,
x, y
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
return values
none
code sample
gh_imgui.plot_item_add_data(plot_id, item_index, x, y)
syntax
gh_imgui.plot_item_buffer_point (
plot_id,
item_index,
x, y,
max_points
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
max_points INTEGER max number of points
return values
none
code sample
gh_imgui.plot_item_buffer_point(plot_id, item_index, x, y, max_points)
syntax
gh_imgui.plot_item_clear_data_DUP1 (
plot_id,
item_index
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
return values
none
code sample
gh_imgui.plot_item_clear_data(plot_id, item_index)
plot_item_clear_data_DUP2
Resize data of an item.
syntax
gh_imgui.plot_item_clear_data_DUP2 (
plot_id,
item_index,
n
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
n INTEGER data size
return values
none
code sample
gh_imgui.plot_item_resize_data(plot_id, item_index, n)
syntax
n = gh_imgui.plot_item_get_data_size (
plot_id,
item_index
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
return values
n INTEGER data size
code sample
n = gh_imgui.plot_item_get_data_size(plot_id, item_index)
syntax
gh_imgui.plot_item_roll_point (
plot_id,
item_index,
x, y,
span
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
span REAL duration in seconds
return values
none
code sample
gh_imgui.plot_item_roll_point(plot_id, item_index, x, y, span)
syntax
gh_imgui.plot_item_set_color (
plot_id,
item_index,
r, g, b, a
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.plot_item_set_color(plot_id, item_index, r, g, b, a)
plot_item_set_data
Sets data of an item.
syntax
gh_imgui.plot_item_set_data (
plot_id,
item_index,
data_index,
x, y
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
data_index INTEGER index of the data
x, y REAL data - these are the line values in Y and Y
return values
none
code sample
gh_imgui.plot_item_set_data(plot_id, item_index, , data_index, x, y)
plot_item_set_data_begin
Sets the start offset.
syntax
gh_imgui.plot_item_set_data_begin (
plot_id,
item_index,
x
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x INTEGER offset
return values
none
code sample
gh_imgui.plot_item_set_data_begin(plot_id, item_index, 0)
plot_item_set_label
Sets a label of an item.
syntax
gh_imgui.plot_item_set_label (
plot_id,
item_index,
label
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
label STRING label
return values
none
code sample
gh_imgui.plot_add_item(plot_id, item_index, "myItem")
syntax
gh_imgui.plot_item_set_size (
plot_id,
item_index,
size
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
size REAL size (or tickness)
return values
none
code sample
gh_imgui.plot_item_set_size(plot_id, item_index, 2.0)
syntax
gh_imgui.plot_item_set_type (
plot_id,
item_index,
type
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
type INTEGER line: 0, scatter: 1, xbar: 2 or ybar: 3
return values
none
code sample
gh_imgui.plot_item_set_type(plot_id, item_index, type)
plot_kill
Destroys a plotline.
syntax
gh_imgui.plot_kill (
plot_id
)
parameters
plot_id ID plotline identifier
return values
none
code sample
gh_imgui.plot_kill(plot_id)
syntax
gh_imgui.plot_set_axis_color (
plot_id,
axis,
r, g, b, a
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
r, g, b, a REAL RGBA color
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_color(plot_id, axis_y, r, g, b, a)
syntax
gh_imgui.plot_set_axis_label (
plot_id,
axis,
label
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
label STRING label
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_label(plot_id, axis_y, "Y axis")
syntax
gh_imgui.plot_set_axis_param_bool (
plot_id,
axis,
what,
state
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'show_grid', 'show_tick_marks', 'show_tick_labels', 'adaptive', 'lock_max', 'lock_min', 'flip'
state BOOLEAN 0 (disabled) or 1 (enabled)
return values
none
code sample
axis_x = 0
axis_y = 1
state = 1
gh_imgui.plot_set_axis_param_bool(plot_id, axis_x, "show_grid", state)
gh_imgui.plot_set_axis_param_bool(plot_id, axis_y, "show_grid", state)
syntax
gh_imgui.plot_set_axis_param_float (
plot_id,
axis,
what,
x
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'minimum', 'maximum', 'zoom_rate'
x REAL value
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_param_float(plot_id, axis_y, "minimum", -10.0)
gh_imgui.plot_set_axis_param_bool(plot_id, axis_y, "minimum", 10.0)
syntax
gh_imgui.plot_set_axis_param_int (
plot_id,
axis,
what,
x
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'divisions', 'subdivisions'
x INTEGER value
return values
none
code sample
axis_x = 0
gh_imgui.plot_set_axis_param_int(plot_id, axis_x, "divisions", 10)
gh_imgui.plot_set_axis_param_int(plot_id, axis_x, "subdivisions", 4)
syntax
gh_imgui.plot_set_color (
plot_id,
what,
r, g, b, a
)
parameters
plot_id ID plotline identifier
what STRING element name: 'frame', 'background', 'border'
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.plot_set_color(plot_id, "background", 0.4, 0.4, 0.4, 0.85)
syntax
gh_imgui.plot_set_state (
plot_id,
what,
state
)
parameters
plot_id ID plotline identifier
what STRING element name: 'show_crosshairs', 'show_mouse_pos', 'show_legend'
state BOOLEAN 0 (disabled) or 1 (enabled)
return values
none
code sample
gh_imgui.plot_set_state(plot_id, "show_crosshairs", state)
syntax
gh_imgui.plot_set_title (
plot_id,
title
)
parameters
plot_id ID plotline identifier
title STRING title of the plotline
return values
none
code sample
gh_imgui.plot_set_title(plot_id, title)
plotline_create
Creates a plotline.
syntax
index = gh_imgui.plotline_create (
label,
num_points
)
parameters
label STRING label
num_points INTEGER number of points in the plotline
return values
index INTEGER index of the new plotline
code sample
plotline_index = gh_imgui.plotline_create("Curve", 1000)
plotline_draw
Draws a plotline.
syntax
gh_imgui.plotline_draw (
index,
type,
overlay,
values_offset,
scale_min, scale_max,
graph_size_x, graph_size_y
)
parameters
index INTEGER index of the plotline
type ENUM( draw_type ) type: 1 (histogram) or 0 (line)
overlay STRING overlay text
values_offset INTEGER offset
scale_min, scale_max REAL minimal / maximal value
graph_size_x, graph_size_y REAL size of the graph
return values
none
code sample
values_offset = 0
scale_min = 0
scale_max = 100
graph_size_x = 400
graph_size_y = 200
gh_imgui.plotline_draw(plotline_index, type, "overlay!", values_offset, scale_min, scale_max, graph_size_x, graph_size_y)
plotline_draw_v2
Draws a plotline.
syntax
gh_imgui.plotline_draw_v2 (
index,
type,
overlay,
num_values,
values_offset,
scale_min, scale_max,
graph_size_x, graph_size_y
)
parameters
index INTEGER index of the plotline
type ENUM( draw_type ) type: 1 (histogram) or 0 (line)
overlay STRING overlay text
num_values INTEGER number of values to draw
values_offset INTEGER offset
scale_min, scale_max REAL minimal / maximal value
graph_size_x, graph_size_y REAL size of the graph
return values
none
code sample
values_offset = 0
values_count = 1000
scale_min = 0
scale_max = 100
graph_size_x = 400
graph_size_y = 200
gh_imgui.plotline_draw_v2(plotline_index, type, "overlay!", values_count, values_offset, scale_min, scale_max, graph_size_x, graph_size_y)
syntax
x = gh_imgui.plotline_get_value1f (
index,
value_index
)
parameters
index INTEGER index of the plotline
value_index INTEGER index of value in the plotline
return values
x REAL value
code sample
x = gh_imgui.plotline_get_value1f(plotline_index, value_index)
syntax
gh_imgui.plotline_set_value1f (
index,
value_index,
x
)
parameters
index INTEGER index of the plotline
value_index INTEGER index of value in the plotline
x REAL value
return values
none
code sample
gh_imgui.plotline_set_value1f(plotline_index, value_index, x)
syntax
gh_imgui.pop_clip_rect()
parameters
none
return values
none
code sample
gh_imgui.pop_clip_rect()
syntax
gh_imgui.pop_font()
parameters
none
return values
none
code sample
gh_imgui.pop_font()
syntax
gh_imgui.pop_item_width()
parameters
none
return values
none
code sample
local width = gh_imgui.get_content_region_available_width()
gh_imgui.push_item_width(width * 0.8)
...
gh_imgui.pop_item_width()
syntax
gh_imgui.pop_style_color()
parameters
none
return values
none
code sample
gh_imgui.pop_style_color()
progress_bar
Displays a progress bar.
syntax
gh_imgui.progress_bar (
fraction,
width, height,
overlay
)
parameters
fraction REAL progression of the bar: from 0.0 to 1.0
width, height INTEGER size of the bar
overlay STRING overlay text
return values
none
code sample
gh_imgui.progress_bar(0.45, width, height, overlay_str)
syntax
gh_imgui.push_clip_rect (
x_min, y_min,
x_max, y_max
)
parameters
x_min, y_min REAL 2D coordinates or the upper-left bounding rectangle
x_max, y_max REAL 2D coordinates or the lower-right bounding rectangle
return values
none
code sample
x0, y0 = gh_imgui.get_item_rect_min()
x1, y1 = gh_imgui.get_item_rect_max()
gh_imgui.push_clip_rect(x0, y0, x1, y1)
syntax
gh_imgui.push_font (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_imgui.push_font(font_id)
syntax
gh_imgui.push_item_width (
width
)
parameters
width REAL width in pixels of next items
return values
none
code sample
local width = gh_imgui.get_content_region_available_width()
gh_imgui.push_item_width(width * 0.8)
...
gh_imgui.pop_item_width()
syntax
gh_imgui.push_style_color (
item_type,
r, g, b, a
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see complete list in set_color() function)
r, g, b, a REAL new color
return values
none
code sample
element_type = IMGUI_WINDOW_BG_COLOR
gh_imgui.push_style_color(element_type, r, g, b, a)
radio_button
Display a radio button.
syntax
gh_imgui.radio_button (
name,
active
)
parameters
name STRING name
active BOOLEAN active state: 1 (true) or 0 (false)
return values
none
code sample
gh_imgui.radio_button("radio button 1", 0)
gh_imgui.radio_button("radio button 2", 1)
gh_imgui.radio_button("radio button 3", 0)
syntax
gh_imgui.rebuild_all_fonts()
parameters
none
return values
none
code sample
gh_imgui.rebuild_all_fonts()
syntax
gh_imgui.reset_default_font()
parameters
none
return values
none
code sample
gh_imgui.reset_default_font()
syntax
gh_imgui.same_line (
local_pos_x,
spacing_w
)
parameters
local_pos_x REAL default value: 0.0
spacing_w REAL default value: -1.0
return values
none
code sample
gh_imgui.same_line(local_pos_x, spacing_w)
syntax
gh_imgui.select_draw_list (
draw_list
)
parameters
draw_list ENUM( imgui_DrawList ) draw list type
return values
none
code sample
IMGUI_DRAWLIST_WINDOW = 0
IMGUI_DRAWLIST_BACKGROUND = 1
IMGUI_DRAWLIST_FOREGROUND = 2
draw_list = IMGUI_DRAWLIST_WINDOW
gh_imgui.select_draw_list(draw_list)
syntax
ret = gh_imgui.selectable (
text,
selected,
flags
)
parameters
text STRING label
selected BOOLEAN selected state: 1 (yes) or 0 (no)
flags ENUM( imgui_SelectableFlags ) ImGuiSelectableFlags_xxx options
return values
ret INTEGER state
code sample
-- Possible flags
ImGuiSelectableFlags_None = 0
ImGuiSelectableFlags_DontClosePopups = 1 -- // Clicking this don't close parent popup window
ImGuiSelectableFlags_SpanAllColumns = 2 -- Selectable frame can span all columns (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick = 4 -- Generate press events on double clicks too
ImGuiSelectableFlags_Disabled = 8 -- Cannot be selected, display greyed out text
selected = 0
flags = ImGuiSelectableFlags_SpanAllColumns
ret = gh_imgui.selectable(text, selected, flags)
syntax
gh_imgui.separator()
parameters
none
return values
none
code sample
gh_imgui.separator()
syntax
gh_imgui.set_color (
item_type,
r, g, b, a
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see values in the code sample)
r, g, b, a REAL RGBA color of the widget
return values
none
code sample
IMGUI_WINDOW_BG_COLOR = 1
IMGUI_TITLE_BG_COLOR = 2
IMGUI_PLOTLINES_COLOR = 3
IMGUI_FRAME_BG_COLOR = 4
IMGUI_TITLE_BG_ACTIVE_COLOR = 5
IMGUI_TITLE_BG_COLLAPSED_COLOR = 6
IMGUI_PLOTHISTOGRAM_COLOR = 7
IMGUI_COMBO_BG_COLOR = 8
IMGUI_BUTTON_COLOR = 9
IMGUI_SEPARATOR_COLOR = 10
IMGUI_RESIZE_GRIP_COLOR = 11
IMGUI_PLOTLINE_HOVERED_COLOR = 12
IMGUI_PLOTHISTOGRAM_HOVERED_COLOR = 13
IMGUI_BUTTON_HOVERED_COLOR = 14
IMGUI_SEPARATOR_HOVERED_COLOR = 15
IMGUI_RESIZE_GRIP_HOVERED_COLOR = 16
IMGUI_HEADER_COLOR = 17
IMGUI_HEADER_HOVERED_COLOR = 18
IMGUI_SLIDER_GRAB_COLOR = 19
IMGUI_CHECK_MARK_COLOR = 20
IMGUI_SCROLLBAR_BG_COLOR = 21
IMGUI_SCROLLBAR_GRAB_COLOR = 22
IMGUI_SCROLLBAR_GRAB_HOVERED_COLOR = 23
IMGUI_TEXT_COLOR = 24
IMGUI_POPUP_BG_COLOR = 25
IMGUI_TEXT_DISABLED_COLOR = 26
IMGUI_CHILD_BG_COLOR = 27
IMGUI_BORDER_COLOR = 28
IMGUI_BORDER_SHADOW_COLOR = 29
IMGUI_FRAME_BG_HOVERED_COLOR = 30
IMGUI_FRAME_BG_ACTIVE_COLOR = 31
IMGUI_MENU_BAR_BG_COLOR = 32
IMGUI_SCROLLBAR_GRAB_ACTIVE_COLOR = 33
IMGUI_SLIDER_GRAB_ACTIVE_COLOR = 34
IMGUI_BUTTON_ACTIVE_COLOR = 35
IMGUI_HEADER_ACTIVE_COLOR = 36
IMGUI_SEPARATOR_ACTIVE_COLOR = 37
IMGUI_RESIZE_GRIP_ACTIVE_COLOR = 38
IMGUI_CLOSE_BUTTON_COLOR = 39
IMGUI_CLOSE_BUTTON_HOVERED_COLOR = 40
IMGUI_CLOSE_BUTTON_ACTIVE_COLOR = 41
IMGUI_PLOTLINES_HOVERED_COLOR = 42
IMGUI_TEXT_SELECTED_BG_COLOR = 43
IMGUI_MODAL_WINDOW_DARKENING_COLOR = 44
IMGUI_DRAG_DROP_TARGET_COLOR = 45
IMGUI_NAV_HIGHLIGHT_COLOR = 46
IMGUI_NAV_WINDOW_IN_HIGHLIGHT_COLOR = 47
IMGUI_MODAL_WINDOW_DIM_BG_COLOR = 48
IMGUI_TAB_COLOR = 49
IMGUI_TAB_HOVERED_COLOR = 50
IMGUI_TAB_ACTIVE_COLOR = 51
IMGUI_TAB_UNFOCUSED_COLOR = 52
IMGUI_TAB_UNFOCUSED_ACTIVE_COLOR = 53
widget_type = IMGUI_BUTTON_COLOR
gh_imgui.set_color(widget_type, r, g, b, a)
syntax
gh_imgui.set_cur_font_display_offset (
x, y
)
parameters
x, y REAL offsets
return values
none
code sample
gh_imgui.set_cur_font_display_offset(x, y)
set_default_font
Sets the default font.
syntax
gh_imgui.set_default_font (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_imgui.set_default_font(font_id)
syntax
gh_imgui.set_font_glyph_offset (
font_id,
x, y
)
parameters
font_id ID font identifier
x, y INTEGER font offset
return values
none
code sample
gh_imgui.set_font_glyph_offset(font_id, 0, -2)
gh_imgui.rebuild_all_fonts()
syntax
gh_imgui.set_frame_border_size (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_frame_border_size(x)
set_indent_spacing
Sets the indent size.
syntax
gh_imgui.set_indent_spacing (
spacing
)
parameters
spacing REAL indent spacing
return values
none
code sample
gh_imgui.set_indent_spacing(spacing)
syntax
gh_imgui.set_item_default_focus()
parameters
none
return values
none
code sample
gh_imgui.set_item_default_focus()
syntax
gh_imgui.set_item_spacing (
x, y
)
parameters
x, y REAL spacing
return values
none
code sample
gh_imgui.set_item_spacing(x, y)
syntax
gh_imgui.set_keyboard_focus_here (
offset
)
parameters
offset INTEGER offset
return values
none
code sample
gh_imgui.set_keyboard_focus_here(offset)
syntax
gh_imgui.set_next_item_width (
width
)
parameters
width REAL item width
return values
none
code sample
gh_imgui.set_next_item_width(width)
syntax
gh_imgui.set_next_window_content_size (
width, height
)
parameters
width, height REAL size
return values
none
code sample
gh_imgui.set_next_window_content_size(width, height)
syntax
gh_imgui.set_next_window_size (
width, height
)
parameters
width, height INTEGER size of the window
return values
none
code sample
gh_imgui.set_next_window_size(width, height)
syntax
gh_imgui.set_next_window_size_constraints (
min_x, min_y,
max_x, max_y
)
parameters
min_x, min_y INTEGER bottom left corner
max_x, max_y INTEGER top right corner
return values
none
code sample
gh_imgui.set_next_window_size_constraints(min_x, min_y, max_x, max_y)
syntax
gh_imgui.set_rounding (
what,
x
)
parameters
what STRING name of the element: window, child, popup, frame, scrollbar, grab, tab
x REAL size
return values
none
code sample
gh_imgui.set_rounding("frame", x)
syntax
gh_imgui.set_scroll (
scroll_x, scroll_y
)
parameters
scroll_x, scroll_y REAL scrolling values in X and Y
return values
none
code sample
gh_imgui.set_scroll(scroll_x, scroll_y)
syntax
gh_imgui.set_scroll_from_pos_y (
local_y,
center_y_ratio
)
parameters
local_y REAL local y
center_y_ratio REAL y ratio
return values
none
code sample
gh_imgui.set_scroll_from_pos_y(local_y, center_y_ratio)
set_scroll_here_y
Adjusts scrolling amount to make current cursor position visible.
center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
When using to make a default/current item visible, consider using set_item_default_focus() instead.
syntax
gh_imgui.set_scroll_here_y (
center_y_ratio
)
parameters
center_y_ratio REAL y ratio
return values
none
code sample
gh_imgui.set_scroll_here_y(center_y_ratio)
syntax
gh_imgui.set_style_colors (
style
)
parameters
style ENUM( imgui_Style ) name of the style
return values
none
code sample
-- Available sytles:
"classic"
"dark"
"light"
"krosoft"
"maya"
"rayteak"
"fromhue"
"cherry"
"dark2"
"corporate_grey"
style_name = "classic"
gh_imgui.set_style_colors(style_name)
set_tooltip
Sets a tooltip.
syntax
gh_imgui.set_tooltip (
caption
)
parameters
caption STRING tooltip text
return values
none
code sample
gh_imgui.set_tooltip("This is a tooltip!")
syntax
gh_imgui.set_window_border_size (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_window_border_size(x)
syntax
gh_imgui.set_window_focus (
name
)
parameters
name STRING name of the window
return values
none
code sample
gh_imgui.set_window_focus(name)
syntax
gh_imgui.set_window_rounding (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_window_rounding(x)
syntax
gh_imgui.set_window_size (
name,
width, height
)
parameters
name STRING window name
width, height INTEGER size of the window
return values
none
code sample
gh_imgui.set_window_size("Control Panel", width, height)
syntax
gh_imgui.show_demo_window()
parameters
none
return values
none
code sample
gh_imgui.show_demo_window()
syntax
gh_imgui.show_metrics_window()
parameters
none
return values
none
code sample
gh_imgui.show_metrics_window()
syntax
gh_imgui.show_stack_tool_window()
parameters
none
return values
none
code sample
gh_imgui.show_stack_tool_window()
show_test_window
Shows ImGui test window.
syntax
gh_imgui.show_test_window()
parameters
none
return values
none
code sample
gh_imgui.frame_begin(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button)
gh_imgui.show_test_window()
gh_imgui.frame_end()
slider_1f
Displays a 1D slider.
syntax
value = gh_imgui.slider_1f (
label,
initial_value,
v_min, v_max,
power
)
parameters
label STRING name of the slider
initial_value REAL initial value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
value REAL current value
code sample
v = gh_imgui.slider_1f("slider01", initial_value, v_min, v_max, 1.0)
syntax
value = gh_imgui.slider_1i (
label,
initial_value,
v_min, v_max
)
parameters
label STRING name of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
return values
value INTEGER current value
code sample
v = gh_imgui.slider_1i("slider01", initial_value, v_min, v_max)
syntax
value = gh_imgui.slider_1i_v2 (
label,
initial_value,
v_min, v_max,
flags
)
parameters
label STRING name of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
flags INTEGER ImGuiSliderFlags_xxxx flags
return values
value INTEGER current value
code sample
ImGuiSliderFlags_None = 0
ImGuiSliderFlags_ClampOnInput = 16
ImGuiSliderFlags_Logarithmic = 32
ImGuiSliderFlags_NoRoundToFormat = 64
ImGuiSliderFlags_NoInput = 12
v = gh_imgui.slider_1i_v2("slider01", initial_value, v_min, v_max, ImGuiSliderFlags_None)
slider_2f
Displays a 2D slider.
syntax
x, y = gh_imgui.slider_2f (
label,
x0, y0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0 REAL initial 2D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y REAL current 2D value
code sample
x, y = gh_imgui.slider_2f("slider04", x0, y0, v_min, v_max, 1.0)
slider_3f
Displays a 3D slider.
syntax
x, y, z = gh_imgui.slider_3f (
label,
x0, y0, z0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0, z0 REAL initial 3D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y, z REAL current 3D value
code sample
x, y, z = gh_imgui.slider_3f("slider03", x0, y0, z0, v_min, v_max, 1.0)
slider_4f
Displays a 4D slider.
syntax
x, y, z, w = gh_imgui.slider_4f (
label,
x0, y0, z0, w0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0, z0, w0 REAL initial 4D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y, z, w REAL current 4D value
code sample
x, y, z, w = gh_imgui.slider_4f("slider02", x0, y0, z0, w0, v_min, v_max, 1.0)
spacing
Adds a vertical space.
syntax
gh_imgui.spacing()
parameters
none
return values
none
code sample
gh_imgui.spacing()
tab_bar_begin
Begins a tab bar.
syntax
is_opened = gh_imgui.tab_bar_begin (
label
)
parameters
label STRING label
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
ret = gh_imgui.tab_bar_begin("tabbar01")
tab_bar_begin_v2
Begins a tab bar.
syntax
is_opened = gh_imgui.tab_bar_begin_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TabBarFlags ) ImGuiTabBarFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
ImGuiTabBarFlags_None = 0,
ImGuiTabBarFlags_Reorderable = 1
ImGuiTabBarFlags_AutoSelectNewTabs = 2
ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 4
ImGuiTabBarFlags_NoTabListPopupButton = 8
ImGuiTabBarFlags_NoTabListScrollingButtons = 16
ImGuiTabBarFlags_NoTooltip = 32
ImGuiTabBarFlags_FittingPolicyResizeDown = 64
ImGuiTabBarFlags_FittingPolicyScroll = 128
ret = gh_imgui.tab_bar_begin_v2("tabbar01", ImGuiTabBarFlags_Reorderable)
tab_bar_end
Ends a tab bar.
syntax
gh_imgui.tab_bar_end()
parameters
none
return values
none
code sample
ImGuiTabBarFlags_Reorderable = 1
if (gh_imgui.tab_bar_begin_v2("tabbar01", ImGuiTabBarFlags_Reorderable) == 1) then
...
gh_imgui.tab_bar_end()
end
tab_item_begin
Begins a tab bar item.
syntax
is_opened = gh_imgui.tab_item_begin (
label,
show_tab,
flags
)
parameters
label STRING label
show_tab BOOLEAN 1 (show) or 0 (hide)
flags ENUM( imgui_TabItemFlags ) ImGuiTabItemFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
flags = ImGuiTabItemFlags_None -- 0
show_tab = 1
if (gh_imgui.tab_bar_begin("tabbar01", show_tab, flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 0, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
tab_item_begin_v2
Begins a tab bar item.
syntax
is_opened = gh_imgui.tab_item_begin_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TabItemFlags ) ImGuiTabItemFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
if (gh_imgui.tab_bar_begin_v2("tabbar01", flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 1, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
tab_item_end
Ends a tab bar item.
syntax
gh_imgui.tab_item_end()
parameters
none
return values
none
code sample
flags = 0
if (gh_imgui.tab_bar_begin_v2("tabbar01", flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 1, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
table_begin
Begins a table.
syntax
ret = gh_imgui.table_begin (
label,
num_columns,
flags,
outer_size_x, outer_size_y,
inner_width
)
parameters
label STRING label
num_columns INTEGER number of columns
flags INTEGER options. See all ImGuiTableFlags_xxxx constants in imgui.lua
outer_size_x, outer_size_y REAL outer size
inner_width REAL inner width
return values
ret INTEGER 1 if success or 0 if error
code sample
flags = ImGuiTableFlags_Resizable + ImGuiTableFlags_Borders
num_columns = 2
if (gh_imgui.table_begin("Table1", num_columns, flags, 0,0, 0) == 1) then
...
...
gh_imgui.table_end()
end
syntax
gh_imgui.table_end()
parameters
none
return values
none
code sample
flags = ImGuiTableFlags_Resizable + ImGuiTableFlags_Borders
num_columns = 2
if (gh_imgui.table_begin("Table1", num_columns, flags, 0,0, 0) == 1) then
...
...
gh_imgui.table_end()
end
syntax
count = gh_imgui.table_get_column_count()
parameters
none
return values
count INTEGER
code sample
count = gh_imgui.table_get_column_count()
syntax
flags = gh_imgui.table_get_column_flags (
column_n
)
parameters
column_n INTEGER column index
return values
flags INTEGER See the ImGuiTableColumnFlags_xxxxx constants in imgui.lua
code sample
flags = gh_imgui.table_get_column_flags(column_n)
syntax
index = gh_imgui.table_get_column_index()
parameters
none
return values
index INTEGER
code sample
index = gh_imgui.table_get_column_index()
syntax
name = gh_imgui.table_get_column_name (
column_n
)
parameters
column_n INTEGER column index
return values
name STRING
code sample
name = gh_imgui.table_get_column_name(column_n)
syntax
index = gh_imgui.table_get_row_index()
parameters
none
return values
index INTEGER
code sample
index = gh_imgui.table_get_row_index()
syntax
ret = gh_imgui.table_next_column()
parameters
none
return values
ret INTEGER 1 if visible or 0 if not
code sample
ret = gh_imgui.table_next_column()
syntax
gh_imgui.table_next_row_DUP1 (
row_flags,
min_row_height
)
parameters
row_flags INTEGER See ImGuiTableRowFlags_xxxx in imgui.lua
min_row_height INTEGER
return values
none
code sample
gh_imgui.table_next_row(row_flags, min_row_height)
syntax
gh_imgui.table_next_row_DUP2 (
row_flags,
min_row_height
)
parameters
row_flags INTEGER See ImGuiTableRowFlags_xxxx in imgui.lua
min_row_height INTEGER
return values
none
code sample
gh_imgui.table_next_row(row_flags, min_row_height)
syntax
gh_imgui.table_set_bg_color (
target,
r, g, b, a,
column_n
)
parameters
target INTEGER
r, g, b, a REAL RGBA color
column_n INTEGER column index
return values
none
code sample
gh_imgui.table_set_bg_color(target, r, g, b, a, column_n)
syntax
gh_imgui.table_set_column_enabled (
column_n,
state
)
parameters
column_n INTEGER
state BOOLEAN 0 or 1
return values
none
code sample
gh_imgui.table_set_column_enabled(column_n, state)
syntax
ret = gh_imgui.table_set_column_index (
column_n
)
parameters
column_n INTEGER column index
return values
ret INTEGER 1 if success or 0 if error
code sample
ret = gh_imgui.table_set_column_index(column_n)
table_setup_column
Allows to to specify label, resizing policy, default width/weight, id, various other flags etc.
syntax
gh_imgui.table_setup_column (
label,
flags,
init_width_or_weight,
user_id
)
parameters
label STRING
flags INTEGER
init_width_or_weight REAL
user_id INTEGER
return values
none
code sample
gh_imgui.table_setup_column(label, flags, init_width_or_weight, user_id)
syntax
gh_imgui.table_setup_scroll_freeze (
cols,
rows
)
parameters
cols INTEGER
rows INTEGER
return values
none
code sample
gh_imgui.table_setup_scroll_freeze(cols, rows)
syntax
gh_imgui.terminate()
parameters
none
return values
none
code sample
gh_imgui.terminate()
text
Displays a simple text.
syntax
gh_imgui.text (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text("GeeXLab is powerful!")
text_rgba
Displays a colored text.
syntax
gh_imgui.text_rgba (
text,
r, g, b, a
)
parameters
text STRING text to display
r, g, b, a REAL color of the text
return values
none
code sample
gh_imgui.text_rgba("GeeXLab is powerful!", 1.0, 1.0, 0.0, 1.0)
syntax
gh_imgui.text_unformatted_v1 (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text_unformatted_v1("GeeXLab is powerful!")
syntax
gh_imgui.text_unformatted_v2 (
text,
text_end
)
parameters
text STRING text to display
text_end STRING XX euh...
return values
none
code sample
gh_imgui.text_unformatted_v2("GeeXLab is powerful!")
text_wrapped
Displays a wrapped text.
syntax
gh_imgui.text_wrapped (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text_wrapped("GeeXLab is powerful!")
syntax
out_value = gh_imgui.toggle (
label,
in_value,
size_x, size_y,
flags,
animation_duration,
frame_rounding,
knob_rounding
)
parameters
label STRING label
in_value BOOLEAN initial value
size_x, size_y REAL size in pixels of the toggle
flags INTEGER flags
animation_duration REAL animation duration
frame_rounding REAL frame rounding - from 0.0 to 1.0
knob_rounding REAL knob rounding - from 0.0 to 1.0
return values
out_value REAL value of the toggle: 0 or 1
code sample
ImGuiToggleFlags_None = 0
ImGuiToggleFlags_Animated = 1
ImGuiToggleFlags_BorderedFrame = 8
ImGuiToggleFlags_BorderedKnob = 16
ImGuiToggleFlags_ShadowedFrame = 32
ImGuiToggleFlags_ShadowedKnob = 64
ImGuiToggleFlags_A11y = 256
size_x = 40
size_y = 20
flags = ImGuiToggleFlags_Animated
animation_duration = 0.1
frame_rounding = 1.0
knob_rounding = 1.0
label = "Horizontal drag"
out_value = gh_imgui.toggle(label, in_value, size_x, size_y, flags, animation_duration, frame_rounding, knob_rounding)
syntax
state = gh_imgui.tree_node (
label
)
parameters
label STRING label
return values
state BOOLEAN tree opened: 1 (true) or 0 (false)
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_ex
Starts a tree.
syntax
state = gh_imgui.tree_node_ex (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TreeNodeFlags ) ImGuiTreeNodeFlags_xxx options
return values
state BOOLEAN tree opened: 1 (true) or 0 (false)
code sample
flags = ImGuiTreeNodeFlags_Selected
node_open = gh_imgui.tree_node_ex("Root", flags)
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_leaf
Display a tree leaf.
syntax
gh_imgui.tree_node_leaf (
label
)
parameters
label STRING label
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_leaf_v2
Display a tree leaf.
syntax
gh_imgui.tree_node_leaf_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TreeNodeFlags ) tree options - see ImGuiTreeNodeFlags_xxx constants in libs/lua/imgui.lua
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
local ImGuiTreeNodeFlags_Bullet = 512
gh_imgui.tree_node_leaf_v2("Child 1", ImGuiTreeNodeFlags_Bullet)
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
syntax
gh_imgui.tree_pop()
parameters
none
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
syntax
gh_imgui.underline (
r, g, b, a
)
parameters
r, g, b, a REAL color
return values
none
code sample
gh_imgui.underline(r, g, b, a)
unindent
Sets unindent spacing.
syntax
gh_imgui.unindent (
indent_w
)
parameters
indent_w REAL size
return values
none
code sample
gh_imgui.unindent(indent_w)
url
Draw a clickable url.
syntax
clicked = gh_imgui.url (
link_caption,
link_url,
tooltip_text
)
parameters
link_caption STRING caption
link_url STRING url (https://....) - Link can be empty to work like a button
tooltip_text STRING tool tip (can be empty)
return values
clicked INTEGER 1 if clicked, 0 otherwise.
code sample
clicked = gh_imgui.url(link_caption, link_url, tooltip_text)
syntax
value = gh_imgui.vslider_1f (
label,
width, height,
initial_value,
v_min, v_max,
power
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value REAL initial value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
value REAL current value
code sample
v = gh_imgui.vslider_1f("vslider01", 20, 100, initial_value, v_min, v_max, 1.0)
syntax
value = gh_imgui.vslider_1i (
label,
width, height,
initial_value,
v_min, v_max
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
return values
value INTEGER current value
code sample
v = gh_imgui.vslider_1i("slider01", 20, 100, initial_value, v_min, v_max)
syntax
value = gh_imgui.vslider_1i_v2 (
label,
width, height,
initial_value,
v_min, v_max,
flags
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
flags INTEGER ImGuiSliderFlags_xxxx flags
return values
value INTEGER current value
code sample
ImGuiSliderFlags_None = 0
ImGuiSliderFlags_ClampOnInput = 16
ImGuiSliderFlags_Logarithmic = 32
ImGuiSliderFlags_NoRoundToFormat = 64
ImGuiSliderFlags_NoInput = 128
v = gh_imgui.vslider_1i_v2("slider01", 20, 100, initial_value, v_min, v_max, ImGuiSliderFlags_None)
syntax
gh_imgui.widget (
widget_type
)
parameters
widget_type ENUM( imgui_Widget ) type of the widget
return values
none
code sample
IMGUI_WIDGET_SEPARATOR = 1
IMGUI_WIDGET_SAME_LINE = 2
IMGUI_WIDGET_BULLET = 3
IMGUI_WIDGET_VERTICAL_SPACING = 4
IMGUI_WIDGET_NEW_LINE = 5
gh_imgui.widget(IMGUI_WIDGET_SEPARATOR)
syntax
is_open = gh_imgui.window_begin (
name,
width, height,
pos_x, pos_y,
win_flags,
pos_flags,
size_flags
)
parameters
name STRING name of the window
width, height REAL size of the window
pos_x, pos_y REAL position of the window
win_flags ENUM( imgui_WindowFlags ) window options: set to 0 for default options. Options can be OR-ed.
pos_flags ENUM( imgui_PosSizeFlags ) window position options: set to 4 for default options
size_flags ENUM( imgui_PosSizeFlags ) window size options: set to 4 for default options
return values
is_open BOOLEAN window: 1 (opened) or 0 (collapsed)
code sample
-- Window options
local window_default = 0
local window_no_resize = 2
local window_no_move = 4
local window_no_collapse = 32
local window_show_border = 128
local window_no_save_settings = 256
-- Position or size options
local pos_size_flag_always = 1 -- Always set the pos and/or size
local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed)
local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file)
local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time)
-- window_flags = window_no_move | window_no_save_settings
window_flags = 0
pos_flags = pos_size_flag_first_use_ever
size_flags = pos_size_flag_first_use_ever
is_open = gh_imgui.window_begin("GeeXLab ImGui demo", 300, 200, 20, 20, window_flags, pos_flags, size_flags)
if (is_open == 1) then
gh_imgui.text("GeeXLab is powerful!")
end
gh_imgui.window_end()
syntax
is_open, show_window = gh_imgui.window_begin_v2 (
name,
width, height,
pos_x, pos_y,
win_flags,
pos_flags,
size_flags,
show_window
)
parameters
name STRING name of the window
width, height REAL size of the window
pos_x, pos_y REAL position of the window
win_flags ENUM( imgui_WindowFlags ) window options: set to 0 for default options. Options can be OR-ed.
pos_flags ENUM( imgui_PosSizeFlags ) window position options: set to 4 for default options
size_flags ENUM( imgui_PosSizeFlags ) window size options: set to 4 for default options
show_window BOOLEAN initial open state of the window: 1 (show) or 0 (hide)
return values
is_open, show_window BOOLEAN is_open: 1 (window opened) or 0 (window collapsed) - show_window: 0 (the user has clicked on the close button)
code sample
-- Window options
local window_default = 0
local window_no_resize = 2
local window_no_move = 4
local window_no_collapse = 32
local window_show_border = 128
local window_no_save_settings = 256
-- Position or size options
local pos_size_flag_always = 1 -- Always set the pos and/or size
local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed)
local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file)
local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time)
-- window_flags = window_no_move | window_no_save_settings
window_flags = 0
pos_flags = pos_size_flag_first_use_ever
size_flags = pos_size_flag_first_use_ever
if (show_window == 1) then
window_flags = 0
show = show_window
is_open, show_window = gh_imgui.window_begin_v2("GeeXLab information", 300, 200, 20, 20, window_flags, pos_flags, size_flags, show)
if (is_open == 1) then
gh_imgui.text("GeeXLab is powerful!")
end
gh_imgui.window_end()
end
syntax
gh_imgui.window_end()
parameters
none
return values
none
code sample
window_flags = 0
gh_imgui.window_begin("GeeXLab information", 300, 200, 20, 20, window_flags)
gh_imgui.text("GeeXLab is powerful!")
gh_imgui.window_end()
gh_mesh
Mesh module
gh_mesh is the module that manages the meshes.
A mesh is a set of triangular faces that can be used to represent any type of 3D shape: starting from the basic built-in shapes (plane, torus, sphere) to complex shapes created with modeling softwares such as 3D Studio Max or Blender.
syntax
gh_mesh.alloc_mesh_data (
mesh_id,
num_vertices,
num_faces
)
parameters
mesh_id ID mesh identifier
num_vertices INTEGER number of vertices
num_faces INTEGER number of faces
return values
none
code sample
mesh_triangle = gh_mesh.create()
gh_mesh.alloc_mesh_data(mesh_triangle, 3, 1)
create_box
Creates a mesh box.
syntax
mesh_id = gh_mesh.create_box (
width, height, depth,
wsegs, hsegs, dsegs
)
parameters
width, height, depth REAL size of the box
wsegs, hsegs, dsegs INTEGER number of subdivisions along X, Y and Z axis
return values
mesh_id ID mesh identifier
code sample
mesh_box = gh_mesh.create_box(10.0, 10.0, 10.0, 4, 4, 4)
syntax
mesh_id = gh_mesh.create_box_8v (
width, height, depth
)
parameters
width, height, depth REAL size of the box
return values
mesh_id ID mesh identifier
code sample
mesh_box = gh_mesh.create_box_8v(10.0, 10.0, 10.0)
create_cylinder
Creates a mesh cylinder.
syntax
mesh_id = gh_mesh.create_cylinder (
radius,
height,
stacks,
slices
)
parameters
radius REAL radius of the cylinder
height REAL height of the cylinder
stacks INTEGER number of subdivisions along the height
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
mesh_cyl = gh_mesh.create_cylinder(radius, height, stacks, slices)
create_cylinder_xyz
Creates a mesh cylinder.
syntax
mesh_id = gh_mesh.create_cylinder_xyz (
central_axis,
radius,
height,
stacks,
slices
)
parameters
central_axis ENUM( along_axis ) direction of the central axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
radius REAL radius of the cylinder
height REAL height of the cylinder
stacks INTEGER number of subdivisions along the height
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
central_axis = 1 -- a Y-axis oriented cylinder
mesh_cyl = gh_mesh.create_cylinder_xyz(central_axis, radius, height, stacks, slices)
create_disc
Creates a mesh disc.
syntax
mesh_id = gh_mesh.create_disc (
radius,
thickness,
slices
)
parameters
radius REAL radius of the disc
thickness REAL thickness of the disc
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
mesh_disc = gh_mesh.create_disc(radius, thickness, slices)
create_ellipse
Creates a mesh ellipse.
syntax
mesh_id = gh_mesh.create_ellipse (
major_radius,
minor_radius,
slices,
radius_segments,
opening_angle
)
parameters
major_radius REAL major radius of the ellipse
minor_radius REAL minor radius of the ellipse
slices INTEGER number of subdivisions along the perimeter
radius_segments INTEGER number of subdivisions along the radius
opening_angle REAL opening angle. If 0, the ellipse is close
return values
mesh_id ID mesh identifier
code sample
mesh_ellipse = gh_mesh.create_ellipse(major_radius, minor_radius, slices, radius_segments, opening_angle)
mesh_disc = gh_mesh.create_ellipse(radius, radius, 20, 20, 0)
create_gear
Creates a mesh gear.
syntax
mesh_id = gh_mesh.create_gear (
inner_radius,
outer_radius,
tooth_depth,
num_teeth,
width
)
parameters
inner_radius REAL inner radius
outer_radius REAL outer radius
tooth_depth REAL depth of a tooth
num_teeth INTEGER number of teeth of the gear
width REAL width of the gear
return values
mesh_id ID mesh identifier
code sample
mesh_gear = gh_mesh.create_gear(1.0, 4.0, 1.0, 10, 2.0)
syntax
mesh_id = gh_mesh.create_icosphere (
radius,
recursion_level
)
parameters
radius REAL sphere radius
recursion_level INTEGER level of detail
return values
mesh_id ID mesh identifier
code sample
mesh_icosphere = gh_mesh.create_icosphere(10.0, 2)
create_plane
Creates a mesh plane.
syntax
mesh_id = gh_mesh.create_plane (
width, height,
wsegs, hsegs
)
parameters
width, height REAL size of the plane in the XZ plane
wsegs, hsegs INTEGER number of subdivisions along the X and Z axis
return values
mesh_id ID mesh identifier
code sample
mesh_plane = gh_mesh.create_plane(20.0, 10.0, 4, 4)
syntax
mesh_id = gh_mesh.create_plane_v3 (
width, height,
wsegs, hsegs,
pitch, yaw, roll
)
parameters
width, height REAL size of the plane in the XZ plane
wsegs, hsegs INTEGER number of subdivisions along the X and Z axis
pitch, yaw, roll REAL initial orientation of the vertices using Euler's angles
return values
mesh_id ID mesh identifier
code sample
mesh_plane = gh_mesh.create_plane_v3(20.0, 10.0, 4, 4, 45.0, 0, 0)
syntax
mesh_id = gh_mesh.create_quad (
width, height
)
parameters
width, height REAL size of the quad in the XY plane
return values
mesh_id ID mesh identifier
code sample
mesh_quad = gh_mesh.create_quad(20.0, 10.0)
create_sphere
Creates a mesh sphere.
syntax
mesh_id = gh_mesh.create_sphere (
radius,
stacks, slices
)
parameters
radius REAL radius of the sphere
stacks, slices INTEGER number of subdivisions along the X and Y axis.
return values
mesh_id ID mesh identifier
code sample
mesh_sphere = gh_mesh.create_sphere(10.0, 20, 20)
syntax
mesh_id = gh_mesh.create_terrain (
tex_id,
num_subdivisions,
vertical_scale,
terrain_size,
height_threshold
)
parameters
tex_id ID terrain texture identifier (height map)
num_subdivisions INTEGER number of subdivisions
vertical_scale REAL vertical scale factor
terrain_size REAL size of the terrain (the terrain is a square patch)
height_threshold REAL height threshold
return values
mesh_id ID mesh identifier
code sample
mesh_terrain = gh_mesh.create_terrain(tex_id, num_subdivisions, vertical_scale, terrain_size, height_threshold)
create_torus
Creates a mesh torus.
syntax
mesh_id = gh_mesh.create_torus (
outer_radius,
inner_radius,
slices
)
parameters
outer_radius REAL outer radius of the torus
inner_radius REAL inner radius of the torus
slices INTEGER number of subdivisions or sections
return values
mesh_id ID mesh identifier
code sample
mesh_torus = gh_mesh.create_torus(10.0, 4.0, 20)
syntax
mesh_id = gh_mesh.create_triangle()
parameters
none
return values
mesh_id ID mesh identifier
code sample
mesh_triangle = gh_mesh.create_triangle()
create_v2
Creates a mesh.
syntax
mesh_id = gh_mesh.create_v2()
parameters
none
return values
mesh_id ID mesh identifier
code sample
mesh_id = gh_mesh.create_v2()
syntax
x, y, z = gh_mesh.get_face_normal (
mesh_id,
face_index
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face between 0 and gh_object.get_num_faces()-1
return values
x, y, z REAL normal vector
code sample
x, y, z = gh_mesh.get_face_normal(mesh_id, face_index)
syntax
a, b, c = gh_mesh.get_face_vertex_indices (
mesh_id,
face_index
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face between 0 and gh_object.get_num_faces()-1
return values
a, b, c INTEGER vertex indices
code sample
a, b, c = gh_mesh.get_face_vertex_indices(mesh_id, face_index)
syntax
x, y, z = gh_mesh.get_vertex_absolute_position (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z REAL 3D position
code sample
vertex_index = 0
x, y, z = gh_mesh.get_vertex_absolute_position(mesh_id, vertex_index)
syntax
r, g, b, a = gh_mesh.get_vertex_color (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
r, g, b, a REAL RGBA color of the vertex
code sample
vertex_index = 0
r, g, b, a = gh_mesh.get_vertex_color(mesh_id, vertex_index)
syntax
x, y, z = gh_mesh.get_vertex_normal (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z REAL normal vector
code sample
vertex_index = 0
x, y, z = gh_mesh.get_vertex_normal(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_position (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z, w REAL 4D position
code sample
vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_position(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_tangent (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z, w REAL tangent vector
code sample
vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_tangent(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_uv (
mesh_id,
vertex_index,
tex_unit
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
tex_unit INTEGER texture unit of the texcoord set. Only two sets are supported
return values
x, y, z, w REAL tangent vector
code sample
vertex_index = 0
tex_unit = 0
x, y, z, w = gh_mesh.get_vertex_uv(mesh_id, vertex_index, tex_unit)
syntax
buff_ptr, buff_size = gh_mesh.instancing_attrib_buffer_get (
mesh_id,
va_index
)
parameters
mesh_id ID mesh identifier
va_index INTEGER vertex attrib index
return values
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
code sample
va_index = 0
position_ptr, size = gh_mesh.instancing_attrib_buffer_get(mesh_id, va_index)
syntax
gh_mesh.instancing_attrib_buffer_update_needed (
mesh_id,
va_index
)
parameters
mesh_id ID mesh identifier
va_index INTEGER vertex attrib index
return values
none
code sample
va_index = 0
gh_mesh.instancing_attrib_buffer_update_needed(mesh_id, va_index)
syntax
r, g, b, a = gh_mesh.instancing_get_color (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
r, g, b, a REAL RGBA color of the instance
code sample
r, g, b, a = gh_mesh.instancing_get_color(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_orientation (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL orientation of the instance (quaternion)
code sample
x, y, z, w = gh_mesh.instancing_get_orientation(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_position (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL position of the instance
code sample
x, y, z, w = gh_mesh.instancing_get_position(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_scale (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL scale of the instance
code sample
x, y, z, w = gh_mesh.instancing_get_scale(mesh_id, instance)
syntax
gh_mesh.instancing_init (
mesh_id,
num_instances
)
parameters
mesh_id ID mesh identifier
num_instances INTEGER number of instances
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
separate_vertex_arrays = 1
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances-1 do
x = math.random(-100, 100)
y = math.random(-50, 50)
z = 0.0
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_axis_angle (
mesh_id,
index,
x, y, z,
angle
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL rotation axis
angle REAL rotation angle
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_axis_angle(mesh_id, i, 0.0, 0.0, 1.0, 60.0)
gh_mesh.instancing_set_color(mesh_id, i, 1.0, 1.0, 1.0, 1.0)
end
syntax
gh_mesh.instancing_set_color (
mesh_id,
index,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
r, g, b, a REAL RGBA color of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_color(mesh_id, i, 1.0, 1.0, 1.0, 1.0)
end
syntax
gh_mesh.instancing_set_orientation (
mesh_id,
index,
pitch, yaw, roll
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
pitch, yaw, roll REAL angles of rotation around X, Y and Z axis
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_orientation_v2 (
mesh_id,
index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z, w REAL rotation quaternion
return values
none
code sample
local num_instances = 1000
gh_mesh.instancing_init(mesh, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
qx = ...
qy = ...
qz = ...
qw = ...
gh_mesh.instancing_set_orientation_v2(mesh_id, i, qx, qy, qz, qw)
end
syntax
gh_mesh.instancing_set_position (
mesh_id,
index,
x, y, z
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL position of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_position_v2 (
mesh_id,
index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z, w REAL position of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position_v2(mesh_id, i, x, y, z, 1.0)
end
syntax
gh_mesh.instancing_set_scale (
mesh_id,
index,
x, y, z
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL scaling factors along the 3 axis
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_scale(mesh_id, i, 1.0, 1.0, 1.0)
end
syntax
ret = gh_mesh.meshlet_generate (
mesh_id,
max_vertices,
max_indices
)
parameters
mesh_id ID mesh identifier
max_vertices INTEGER max vertices of a meshlet
max_indices INTEGER max indices of a meshlet. 3 indices make a triangular face.
return values
ret INTEGER 1 if ok, 0 if error.
code sample
ret = gh_mesh.meshlet_generate(mesh_id, 64, 126)
syntax
n = gh_mesh.meshlet_get_count (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
n INTEGER number of meshlets
code sample
n = gh_mesh.meshlet_get_count(mesh_id)
syntax
mesh_face_index = gh_mesh.meshlet_get_index (
mesh_id,
meshlet_index,
meshlet_primitive_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
meshlet_primitive_index INTEGER index in the meshlet indices list (0 to num_meshlet_indices-1)
return values
mesh_face_index INTEGER index relative to the meshlet indices list
code sample
mesh_face_index = gh_mesh.meshlet_get_index(mesh_id, meshlet_index, meshlet_primitive_index)
syntax
num_meshlet_indices = gh_mesh.meshlet_get_index_count (
mesh_id,
meshlet_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
return values
num_meshlet_indices INTEGER number of indices
code sample
num_meshlet_indices = gh_mesh.meshlet_get_index_count(mesh_id)
syntax
mesh_vertex_index = gh_mesh.meshlet_get_vertex (
mesh_id,
meshlet_index,
meshlet_vertex_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
meshlet_vertex_index INTEGER vertex in the meshlet vertices list (0 to num_meshlet_vertices-1)
return values
mesh_vertex_index INTEGER index relative to the mesh vertices list
code sample
mesh_vertex_index = gh_mesh.meshlet_get_vertex(mesh_id, meshlet_index, meshlet_vertex_index)
syntax
num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count (
mesh_id,
meshlet_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
return values
num_meshlet_vertices INTEGER number of vertices
code sample
num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count(mesh_id)
syntax
gh_mesh.resize_box (
width, height, depth,
mesh_id
)
parameters
width, height, depth REAL size of the box
mesh_id ID mesh identifier
return values
none
code sample
gh_mesh.resize_box(mesh_id, 10.0, 10.0, 10.0)
syntax
gh_mesh.resize_plane (
mesh_id,
width, height
)
parameters
mesh_id ID mesh identifier
width, height REAL size of the quad in the XY plane
return values
none
code sample
gh_mesh.resize_plane(mesh_id, 20.0, 15.0)
syntax
gh_mesh.resize_quad (
mesh_id,
width, height
)
parameters
mesh_id ID mesh identifier
width, height REAL size of the quad in the XY plane
return values
none
code sample
gh_mesh.resize_quad(mesh_id, 20.0, 15.0)
syntax
gh_mesh.ribbon_add_point (
mesh_id,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
x, y, z, w REAL position of the new point
return values
none
code sample
gh_mesh.ribbon_add_point(mesh_id, x, y, z, 1.0)
syntax
mesh_id = gh_mesh.ribbon_create (
thickness
)
parameters
thickness REAL thickness of ribbon
return values
mesh_id ID mesh identifier
code sample
mesh_id = gh_mesh.ribbon_create(2.0)
syntax
gh_mesh.ribbon_set_cross_vector (
mesh_id,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
x, y, z, w REAL vector coordinates
return values
none
code sample
gh_mesh.ribbon_set_cross_vector(mesh_id, x, y, z)
syntax
gh_mesh.set_face_vertex_indices (
mesh_id,
face_index,
a, b, c
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face
a, b, c INTEGER vertex indices
return values
none
code sample
gh_mesh.set_face_vertex_indices(mesh_id, face_index, a, b, c)
syntax
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays (
state
)
parameters
state INTEGER 1 (separate vertex arrays) or 0 (interleaved vertex array) - Default is separate vertex arrays.
return values
none
code sample
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(0)
...
mesh = gh_mesh.create_plane(128, 128, 10, 10)
...
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(1)
syntax
gh_mesh.set_vertex_color (
mesh_id,
vertex_index,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
r, g, b, a REAL RGBA color of the vertex
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_color(mesh_id, vertex_index, r, g, b, a)
syntax
gh_mesh.set_vertex_normal (
mesh_id,
vertex_index,
x, y, z
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z REAL normal vector
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_normal(mesh_id, vertex_index, x, y, z)
syntax
gh_mesh.set_vertex_position (
mesh_id,
vertex_index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL 3D position
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_position(mesh_id, vertex_index, x, y, z, 1.0)
syntax
gh_mesh.set_vertex_source (
mesh_id,
gpu_buffer_id
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
return values
none
code sample
gh_mesh.set_vertex_source(mesh_id, gpu_buffer_id)
syntax
gh_mesh.set_vertex_tangent (
mesh_id,
vertex_index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL tangent vector
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_tangent(mesh_id, vertex_index, x, y, z, w)
syntax
gh_mesh.set_vertex_uv (
mesh_id,
vertex_index,
x, y, z, w,
tex_unit
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL texcoord
tex_unit INTEGER texture unit of the texcoord set. Only two sets are supported
return values
none
code sample
vertex_index = 0
tex_unit = 0
gh_mesh.set_vertex_uv(mesh_id, vertex_index, x, y, z, w, tex_unit)
syntax
gh_mesh.set_vertices_color (
mesh_id,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
r, g, b, a REAL RGBA color of the vertex
return values
none
code sample
gh_mesh.set_vertices_color(mesh_id, r, g, b, a)
syntax
gh_mesh.vertices_from_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
size,
update_cpu,
update_gpu
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
size INTEGER size of the copy in bytes
update_cpu BOOLEAN update the mesh vertex array in CPU memory: 1 (YES) or 0 (NO)
update_gpu BOOLEAN update the mesh vertex array in GPU memory: 1 (YES) or 0 (NO)
return values
none
code sample
gh_mesh.vertices_from_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, size, update_cpu, update_gpu)
syntax
gh_mesh.vertices_position_from_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
gpu_buffer_stride,
size,
update_cpu,
update_gpu
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
gpu_buffer_stride INTEGER stride value: size in bytes between to consecutive positions in the gpu buffer
size INTEGER size of the copy in bytes
update_cpu BOOLEAN update the mesh vertex array in CPU memory: 1 (YES) or 0 (NO)
update_gpu BOOLEAN update the mesh vertex array in GPU memory: 1 (YES) or 0 (NO)
return values
none
code sample
gpu_buffer_stride = 16 # 16 bytes = size of a vec4.
gpu_buffer_offset = 0
gh_mesh.vertices_position_from_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, gpu_buffer_stride, size, update_cpu, update_gpu)
syntax
gh_mesh.vertices_position_to_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
gpu_buffer_stride
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
gpu_buffer_stride INTEGER stride value: size in bytes between to consecutive positions in the gpu buffer
return values
none
code sample
gpu_buffer_stride = 16 # 16 bytes = size of a vec4.
gpu_buffer_offset = 0
gh_mesh.vertices_position_to_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, gpu_buffer_stride)
syntax
gh_mesh.vertices_to_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
return values
none
code sample
gh_mesh.vertices_to_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset)
voxelize
Voxelizes a mesh.
syntax
gh_mesh.voxelize (
mesh_id,
voxelsizex,
voxelsizey,
voxelsizez
)
parameters
mesh_id ID mesh identifier
voxelsizex REAL width of a voxel
voxelsizey REAL height of a voxel
voxelsizez REAL depth of a voxel
return values
none
code sample
gh_mesh.voxelize(mesh_id, 4, 4, 4)
gh_physx3 windowslinuxmacos
NVIDIA PhysX 3 module
gh_physx3 is the module that manages NVIDIA PhysX 3 engine.
Thanks to gh_physx3, you will be able to create rigid bodies and do collisions, create particles and fluids, creates clothes and joints.
syntax
gh_physx3.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_physx3.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx3.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_physx3.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx3.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_physx3.actor_apply_transform(actor_id, object)
syntax
gh_physx3.actor_clear_forces (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_clear_forces(actor_id)
syntax
s = gh_physx3.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
s REAL squared speed
code sample
s = gh_physx3.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx3.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_physx3.actor_get_angular_velocity(actor_id)
syntax
s = gh_physx3.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
s REAL squared speed
code sample
s = gh_physx3.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx3.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = ggh_physx3.actor_get_linear_velocity(actor_id)
syntax
x, y, z, w = gh_physx3.actor_get_orientation (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z, w REAL orientation
code sample
x, y, z, w = gh_physx3.actor_get_orientation(actor_id)
syntax
x, y, z = gh_physx3.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_physx3.actor_get_position(actor_id)
syntax
thres = gh_physx3.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
t = gh_physx3.actor_get_sleep_threshold(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx3.actor_get_transform_mat16 (
actor_id
)
parameters
actor_id ID actor identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx3.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx3.actor_get_transform_pos_qrot (
actor_id
)
parameters
actor_id ID actor identifier
return values
px, py, pz REAL position
qx, qy, qz, qw REAL rotation quaternion
code sample
px, py, pz, qx, qy, qz, qw = gh_physx3.actor_get_transform_pos_qrot(actor_id)
syntax
state = gh_physx3.actor_is_sleeping (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
is_sleeping = gh_physx3.actor_is_sleeping(actor_id)
actor_kill
Destroys an actor.
syntax
gh_physx3.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_kill(actor_id)
syntax
gh_physx3.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_put_to_sleep(actor_id)
syntax
gh_physx3.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID PhysX actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_physx3.actor_set_3d_object(actor_id, oid)
syntax
gh_physx3.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx3.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx3.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx3.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx3.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_physx3.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx3.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx3.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx3.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_physx3.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx3.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx3.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx3.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx3.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx3.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID PhysX actor identifier
mat_id ID material identifier
return values
none
code sample
gh_physx3.actor_set_material(actor_id, mat_id)
syntax
gh_physx3.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_physx3.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx3.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_physx3.actor_set_position(actor_id, x, y, z)
syntax
gh_physx3.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_physx3.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx3.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx3.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx3.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID PhysX actor identifier
density REAL density
return values
none
code sample
gh_physx3.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx3.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_physx3.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx3.check_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN available: 1 (true) or 0 (false)
code sample
if (can_run_sim) then
gh_physx3.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_physx3.check_results(scene_id) == 1) then
gh_physx3.fetch_results(scene_id)
can_run_sim = true
end
syntax
actor_id = gh_physx3.cloth_create_from_mesh (
scene_id,
mesh_id,
gpu_cloth,
x, y, z,
pitch, yaw, roll,
gx, gy, gz
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
gpu_cloth BOOLEAN run on GPU: 1 (true) or 0 (false)
x, y, z REAL position
pitch, yaw, roll REAL Euler's angles
gx, gy, gz REAL gravity vector
return values
actor_id ID identifier of the cloth actor
code sample
actor_id = gh_physx3.cloth_create_from_mesh(scene_id, mesh_id, gpu_cloth, x, y, z, pitch. yaw, roll, gravity_x, gravity_y, gravity_z)
syntax
state = gh_physx3.cloth_is_running_on_gpu (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
state = gh_physx3.cloth_is_running_on_gpu(actor_id)
syntax
gh_physx3.cloth_set_external_acceleration (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL acceleration vector
return values
none
code sample
gh_physx3.cloth_set_external_acceleration(actor_id, x, y, z)
syntax
gh_physx3.cloth_set_gpu_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.cloth_set_gpu_state(actor_id, state)
syntax
gh_physx3.cloth_set_stiffness (
actor_id,
stiffness
)
parameters
actor_id ID PhysX actor identifier
stiffness REAL stiffness
return values
none
code sample
gh_physx3.cloth_set_stiffness(actor_id, stiffness)
syntax
gh_physx3.cloth_update_mesh_vertex_data (
actor_id,
mesh_id,
update_position,
update_normals
)
parameters
actor_id ID PhysX actor identifier
mesh_id ID mesh identifier
update_position BOOLEAN updates positions: 1 (true) or 0 (false)
update_normals BOOLEAN updates normals: 1 (true) or 0 (false)
return values
none
code sample
gh_physx3.cloth_update_mesh_vertex_data(actor_id, mesh_id, 1, 0)
syntax
gh_physx3.cloth_update_particles_from_mesh_particles (
actor_id,
mesh_id
)
parameters
actor_id ID PhysX actor identifier
mesh_id ID mesh identifier
return values
none
code sample
gh_physx3.cloth_update_particles_from_mesh_particles(actor_id, mesh_id)
create_actor_box
Creates a box actor.
syntax
actor_id = gh_physx3.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
w, h, d REAL width, height and depth
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Creates a capsule actor.
syntax
actor_id = gh_physx3.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius of the capsule (actually the cylinder)
half_height REAL half height of the cylinder
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_id_capsule = gh_physx3.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx3.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_id_mesh = gh_physx3.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx3.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
convex BOOLEAN convex state: 1 (yes) or 0 (no)
return values
actor_id ID PhysX actor identifier
code sample
convex = 1
actor_id_mesh = gh_physx3.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Creates a plane actor.
syntax
actor_id = gh_physx3.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
parameters
scene_id ID PhysX scene identifier
nx, ny, nz, d REAL plane equation
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_id_plane = gh_physx3.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Creates a sphere actor.
syntax
actor_id = gh_physx3.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_id_plane = gh_physx3.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
syntax
mat_id = gh_physx3.create_material (
static_friction,
dynamic_friction,
resilience
)
parameters
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience
return values
mat_id ID PhysX material identifier
code sample
mat_id = gh_physx3.create_material(0.5, 0.5, 0.5)
syntax
scene_id = gh_physx3.create_scene (
gpu_physx,
bounce_threshold_velocity
)
parameters
gpu_physx BOOLEAN 1 (GPU) or 0 (CPU)
bounce_threshold_velocity REAL bounce threshold velocity
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
scene_id = gh_physx3.create_scene(1, bounce_threshold_velocity)
syntax
scene_id = gh_physx3.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx3.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx3.create_scene_broadphase_mbp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
minX, minY, minZ REAL world minimal dimension
maxX, maxY, maxZ REAL world maximal dimension
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
minX = -100
minY = 0
minZ = -100
maxX = 100,
maxY = 100
maxZ = 100
scene_id = gh_physx3.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
syntax
scene_id = gh_physx3.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx3.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
ret = gh_physx3.fetch_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.run_simulation_step(scene_id, time_step)
gh_physx3.fetch_results(scene_id)
syntax
clock = gh_physx3.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_physx3.gpu_get_clock_frequency_khz()
syntax
name = gh_physx3.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_physx3.gpu_get_name()
syntax
num_sm = gh_physx3.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_physx3.gpu_get_num_multiprocessors()
syntax
size = gh_physx3.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_physx3.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx3.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_physx3.gpu_is_supported()
syntax
joint_id = gh_physx3.joint_create (
scene_id,
joint_type,
actor_id1,
x1, y1, z1,
pitch1, yaw1, roll1,
actor_id2,
x2, y2, z2,
pitch2, yaw2, roll2
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
actor_id1 ID PhysX first actor identifier
x1, y1, z1 REAL position of the joint related to the first actor
pitch1, yaw1, roll1 REAL orientation of the joint related to the first actor
actor_id2 ID PhysX second actor identifier
x2, y2, z2 REAL position of the joint related to the second actor
pitch2, yaw2, roll2 REAL orientation of the joint related to the second actor
return values
joint_id ID PhysX joint identifier
code sample
joint_id = gh_physx3.joint_create(scene_id, joint_type, actor_id1, x1, y1, z1, pitch1, yaw1, roll1, actor_id2, x2, y2, z2, pitch2, yaw2, roll2)
syntax
gh_physx3.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_physx3.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx3.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_physx3.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx3.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_physx3.joint_kill(joint_id)
syntax
gh_physx3.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_physx3.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx3.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
damping REAL damping of the limit spring
stiffness REAL if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
restitution REAL controls the amount of bounce when the joint hits a limit
bounce_threshold REAL determines the minimum impact velocity which will cause the joint to bounce
return values
none
code sample
gh_physx3.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx3.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_physx3.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx3.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_physx3.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx3.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
parameters
joint_id ID PhysX joint identifier
velocity, max_force REAL parameters
drive_enabled, free_spin_enabled BOOLEAN drive and free spin parameters: 1 (enabled) or 0 (disabled)
return values
none
code sample
gh_physx3.joint_set_motor_params(px_joint, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx3.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_physx3.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx3.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_physx3.kill_material(mat_id)
syntax
px_ps_id = gh_physx3.particle_system_create (
scene_id,
max_particles,
run_on_gpu,
init_particles
)
parameters
scene_id ID PhysX scene identifier
max_particles INTEGER max number of particles
run_on_gpu BOOLEAN 1 (GPU) or 0 (CPU)
init_particles BOOLEAN initializes particles positions: 1 (true) or 0 (false)
return values
px_ps_id ID PhysX particle system actor identifier
code sample
px_ps_id = gh_physx3.particle_system_create(scene_id, max_particles, run_on_gpu, 0)
syntax
px_ps_id = gh_physx3.particle_system_create_fluid (
scene_id,
max_particles,
particle_size,
viscosity,
stiffness,
run_on_gpu,
init_particles
)
parameters
scene_id ID PhysX scene identifier
max_particles INTEGER max number of particles
particle_size REAL size of a particle
viscosity REAL fluid viscosity
stiffness REAL fluid stiffness
run_on_gpu BOOLEAN 1 (GPU) or 0 (CPU)
init_particles BOOLEAN initializes particles positions: 1 (true) or 0 (false)
return values
px_ps_id ID PhysX particle system actor identifier
code sample
px_ps_id = gh_physx3.particle_system_create_fluid(scene_id, max_particles, particle_size, viscosity, stiffness, run_on_gpu, 0)
syntax
gh_physx3.particle_system_from_gxc_ps (
px_ps_id,
gxc_ps_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
gxc_ps_id ID gxc particle system identifier
return values
none
code sample
gh_physx3.particle_system_from_gxc_ps(px_ps_id, gxc_ps_id)
syntax
gh_physx3.particle_system_position_from_vertex_pool (
px_ps_id,
vp_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
vp_id ID vertex pool identifier
return values
none
code sample
gh_physx3.particle_system_position_from_vertex_pool(px_ps_id, vp_id)
syntax
gh_physx3.particle_system_position_to_vertex_pool (
px_ps_id,
vp_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
vp_id ID vertex pool identifier
return values
none
code sample
gh_physx3.particle_system_position_to_vertex_pool(px_ps_id, vp_id)
syntax
gh_physx3.particle_system_to_gxc_ps (
px_ps_id,
gxc_ps_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
gxc_ps_id ID gxc particle system identifier
return values
none
code sample
gh_physx3.particle_system_to_gxc_ps(px_ps_id, gxc_ps_id)
run_simulation
Runs a simulation.
syntax
ret = gh_physx3.run_simulation (
scene_id,
dt,
time_step
)
parameters
scene_id ID PhysX scene identifier
dt REAL detla time
time_step REAL simulation time step
return values
ret BOOLEAN simulation done: 1 (true) or 0 (false)
code sample
ret = gh_physx3.run_simulation(scene_id, dt, time_step)
run_simulation_step
Runs a simulation step.
syntax
ret = gh_physx3.run_simulation_step (
scene_id,
time_step
)
parameters
scene_id ID PhysX scene identifier
time_step REAL simulation time step
return values
ret BOOLEAN simulation: 1 (started) or 0 (error)
code sample
ret = gh_physx3.run_simulation_step(scene_id, time_step)
syntax
gh_physx3.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx3.scene_sync_3d_objects(sid)
syntax
gh_physx3.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
code sample
velocity = 3.0
gh_physx3.set_max_depenetration_velocity(velocity)
...
actor_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
syntax
gh_physx3.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_physx3.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx3.set_simulation_scales (
size,
mass,
speed
)
parameters
size REAL the approximate size of objects in the simulation (default: 1.0)
mass REAL the approximate mass of a size * size * size block (default: 1000)
speed REAL the approximate velocities of objects in simulation (default: 10)
return values
none
code sample
gh_physx3.set_simulation_scales(1, 1000, 10)
syntax
gh_physx3.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx3.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Starts the PhysX engine.
syntax
ret = gh_physx3.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx3.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.stop()
syntax
gh_physx3.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_physx3.update_material(mat_id, static_friction, dynamic_friction, resilience)
gh_physx4 windowslinuxmacos
NVIDIA PhysX 4 module
gh_physx4 is the module that manages NVIDIA PhysX 4 engine.
Thanks to gh_physx4, you will be able to play with rigid body collisions, and handling joints.
Clothes and particles are no longer part of PhysX 4.
syntax
gh_physx4.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_physx4.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx4.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_physx4.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx4.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_physx4.actor_apply_transform(actor_id, obj_id)
syntax
gh_physx4.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_physx4.actor_clear_forces(actor_id)
syntax
s = gh_physx4.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_physx4.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx4.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_physx4.actor_get_angular_velocity(actor_id)
syntax
speed = gh_physx4.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
speed REAL squared speed
code sample
speed = gh_physx4.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx4.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = ggh_physx4.actor_get_linear_velocity(actor_id)
syntax
x, y, z, w = gh_physx4.actor_get_orientation (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z, w REAL orientation
code sample
x, y, z, w = gh_physx4.actor_get_orientation(actor_id)
syntax
x, y, z = gh_physx4.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_physx4.actor_get_position(actor_id)
syntax
thres = gh_physx4.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
thres = gh_physx4.actor_get_sleep_threshold(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx4.actor_get_transform_mat16 (
actor_id
)
parameters
actor_id ID actor identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx4.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx4.actor_get_transform_pos_qrot (
actor_id
)
parameters
actor_id ID actor identifier
return values
px, py, pz REAL position
qx, qy, qz, qw REAL rotation quaternion
code sample
px, py, pz, qx, qy, qz, qw = gh_physx4.actor_get_transform_pos_qrot(actor_id)
syntax
state = gh_physx4.actor_is_sleeping (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
is_sleeping = gh_physx4.actor_is_sleeping(actor_id)
actor_kill
Destroys an actor.
syntax
gh_physx4.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx4.actor_kill(actor_id)
syntax
gh_physx4.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx4.actor_put_to_sleep(actor_id)
syntax
gh_physx4.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_physx4.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_physx4.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx4.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx4.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx4.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx4.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_physx4.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx4.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx4.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx4.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx4.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx4.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_physx4.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx4.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx4.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx4.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx4.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx4.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_physx4.actor_set_material(actor_id, mat_id)
syntax
gh_physx4.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_physx4.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx4.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_physx4.actor_set_position(actor_id, x, y, z)
syntax
gh_physx4.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_physx4.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx4.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx4.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx4.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID actor identifier
density REAL density
return values
none
code sample
gh_physx4.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx4.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_physx4.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx4.check_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN available: 1 (true) or 0 (false)
code sample
if (can_run_sim) then
gh_physx4.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_physx4.check_results(scene_id) == 1) then
gh_physx4.fetch_results(scene_id)
can_run_sim = true
end
create_actor_box
Creates a box actor.
syntax
actor_id = gh_physx4.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
w, h, d REAL width, height and depth
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_box = gh_physx4.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Creates a capsule actor.
syntax
actor_id = gh_physx4.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius of the capsule (actually the cylinder)
half_height REAL half height of the cylinder
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_capsule = gh_physx4.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx4.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_mesh = gh_physx4.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx4.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
convex BOOLEAN convex state: 1 (yes) or 0 (no)
return values
actor_id ID PhysX actor identifier
code sample
convex = 1
actor_mesh = gh_physx4.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Creates a plane actor.
syntax
actor_id = gh_physx4.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
parameters
scene_id ID PhysX scene identifier
nx, ny, nz, d REAL plane equation
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_plane = gh_physx4.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Creates a sphere actor.
syntax
actor_id = gh_physx4.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_sphere = gh_physx4.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
syntax
mat_id = gh_physx4.create_material (
static_friction,
dynamic_friction,
resilience
)
parameters
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience
return values
mat_id ID PhysX material identifier
code sample
mat_id = gh_physx4.create_material(0.5, 0.5, 0.5)
syntax
scene_id = gh_physx4.create_scene (
gpu_physx,
bounce_threshold_velocity
)
parameters
gpu_physx BOOLEAN 1 (GPU) or 0 (CPU)
bounce_threshold_velocity REAL bounce threshold velocity
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
scene_id = gh_physx4.create_scene(1, bounce_threshold_velocity)
syntax
scene_id = gh_physx4.create_scene_broadphase_abp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_abp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx4.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx4.create_scene_broadphase_mbp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
minX, minY, minZ REAL world minimal dimension
maxX, maxY, maxZ REAL world maximal dimension
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
minX = -100
minY = 0
minZ = -100
maxX = 100,
maxY = 100
maxZ = 100
scene_id = gh_physx4.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
syntax
scene_id = gh_physx4.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
create_scene_set_solver_type
Set the solver that will be used to create a PhysX scene.Synchronizes physics and graphics objects.
A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine).
If used, create_scene_set_solver_type() must be called before any scene creation function.
syntax
gh_physx4.create_scene_set_solver_type (
solver_type
)
parameters
solver_type ENUM( physx_solver_type ) solver type
return values
none
code sample
gh_physx4.create_scene_set_solver_type(solver_type)
syntax
ret = gh_physx4.fetch_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx4.run_simulation_step(scene_id, time_step)
ret = gh_physx4.fetch_results(scene_id)
syntax
clock = gh_physx4.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_physx4.gpu_get_clock_frequency_khz()
syntax
name = gh_physx4.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_physx4.gpu_get_name()
syntax
num_sm = gh_physx4.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_physx4.gpu_get_num_multiprocessors()
syntax
size = gh_physx4.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_physx4.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx4.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_physx4.gpu_is_supported()
syntax
joint_id = gh_physx4.joint_create (
scene_id,
joint_type,
actor1_id,
x1, y1, z1,
pitch1, yaw1, roll1,
actor2_id,
x2, y2, z2,
pitch2, yaw2, roll2
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
actor1_id ID PhysX first actor identifier
x1, y1, z1 REAL position of the joint related to the first actor
pitch1, yaw1, roll1 REAL orientation of the joint related to the first actor
actor2_id ID PhysX second actor identifier
x2, y2, z2 REAL position of the joint related to the second actor
pitch2, yaw2, roll2 REAL orientation of the joint related to the second actor
return values
joint_id ID PhysX joint identifier
code sample
joint_id = gh_physx4.joint_create(scene_id, joint_type, actor1, x1, y1, z1, pitch1, yaw1, roll1, actor2, x2, y2, z2, pitch2, yaw2, roll2)
syntax
gh_physx4.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_physx4.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx4.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_physx4.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx4.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_physx4.joint_kill(joint_id)
syntax
gh_physx4.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_physx4.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx4.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
damping REAL damping of the limit spring
stiffness REAL if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
restitution REAL controls the amount of bounce when the joint hits a limit
bounce_threshold REAL determines the minimum impact velocity which will cause the joint to bounce
return values
none
code sample
gh_physx4.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx4.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_physx4.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx4.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_physx4.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx4.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
parameters
joint_id ID PhysX joint identifier
velocity, max_force REAL parameters
drive_enabled, free_spin_enabled BOOLEAN drive and free spin parameters: 1 (enabled) or 0 (disabled)
return values
none
code sample
gh_physx4.joint_set_motor_params(joint_id, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx4.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_physx4.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx4.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_physx4.kill_material(mat_id)
syntax
ret = gh_physx4.run_simulation (
scene_id,
dt,
time_step
)
parameters
scene_id ID PhysX scene identifier
dt REAL detla time
time_step REAL simulation time step
return values
ret BOOLEAN simulation done: 1 (true) or 0 (false)
code sample
ret = gh_physx4.run_simulation(scene_id, dt, time_step)
run_simulation_step
Runs a simulation step.
syntax
ret = gh_physx4.run_simulation_step (
scene_id,
time_step
)
parameters
scene_id ID PhysX scene identifier
time_step REAL simulation time step
return values
ret BOOLEAN simulation: 1 (started) or 0 (error)
code sample
ret = gh_physx4.run_simulation_step(scene_id, time_step)
syntax
n = gh_physx4.scene_get_num_active_actors (
scene_id
)
parameters
scene_id ID scene identifier
return values
n INTEGER number of active actors
code sample
n = gh_physx4.scene_get_num_active_actors(scene_id)
syntax
gh_physx4.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx4.scene_sync_3d_objects(scene_id)
scene_sync_3d_objects_v2
Synchronizes physics and graphics objects.
A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine).
syntax
gh_physx4.scene_sync_3d_objects_v2 (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx4.scene_sync_3d_objects_v2(scene_id)
syntax
gh_physx4.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
code sample
velocity = 3.0
gh_physx4.set_max_depenetration_velocity(velocity)
...
actor_box = gh_physx4.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
syntax
gh_physx4.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_physx4.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx4.set_simulation_scales (
size,
mass,
speed
)
parameters
size REAL the approximate size of objects in the simulation (default: 1.0)
mass REAL the approximate mass of a size * size * size block (default: 1000)
speed REAL the approximate velocities of objects in simulation (default: 10)
return values
none
code sample
gh_physx4.set_simulation_scales(1, 1000, 10)
syntax
gh_physx4.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx4.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_box = gh_physx4.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Starts the PhysX engine.
syntax
ret = gh_physx4.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx4.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx4.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx4.stop()
syntax
gh_physx4.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_physx4.update_material(mat_id, static_friction, dynamic_friction, resilience)
gh_physx5 windowslinuxmacos
NVIDIA PhysX 5 module
gh_physx5 is the module that manages NVIDIA PhysX 5 engine.
Thanks to gh_physx5, you will be able to play with rigid body collisions, joints and particles.
syntax
gh_physx5.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_phys5.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx5.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_phys5.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx5.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_phys5.actor_apply_transform(actor_id, obj_id)
syntax
gh_physx5.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_phys5.actor_clear_forces(actor_id)
syntax
s = gh_physx5.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_phys5.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx5.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_phys5.actor_get_angular_velocity(actor_id)
syntax
speed = gh_physx5.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
speed REAL squared speed
code sample
speed = gh_phys5.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx5.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = ggh_phys5.actor_get_linear_velocity(actor_id)
syntax
x, y, z, w = gh_physx5.actor_get_orientation (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z, w REAL orientation
code sample
x, y, z, w = gh_phys5.actor_get_orientation(actor_id)
syntax
x, y, z = gh_physx5.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_phys5.actor_get_position(actor_id)
syntax
thres = gh_physx5.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
thres = gh_phys5.actor_get_sleep_threshold(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx5.actor_get_transform_mat16 (
actor_id
)
parameters
actor_id ID actor identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_phys5.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx5.actor_get_transform_pos_qrot (
actor_id
)
parameters
actor_id ID actor identifier
return values
px, py, pz REAL position
qx, qy, qz, qw REAL rotation quaternion
code sample
px, py, pz, qx, qy, qz, qw = gh_phys5.actor_get_transform_pos_qrot(actor_id)
syntax
state = gh_physx5.actor_is_sleeping (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
is_sleeping = gh_phys5.actor_is_sleeping(actor_id)
actor_kill
Destroys an actor.
syntax
gh_physx5.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_phys5.actor_kill(actor_id)
syntax
gh_physx5.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_phys5.actor_put_to_sleep(actor_id)
syntax
gh_physx5.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_phys5.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_physx5.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_phys5.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx5.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_phys5.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx5.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_phys5.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx5.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_phys5.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx5.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_phys5.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx5.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_phys5.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx5.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_phys5.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx5.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_phys5.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx5.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_phys5.actor_set_material(actor_id, mat_id)
syntax
gh_physx5.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_phys5.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx5.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_phys5.actor_set_position(actor_id, x, y, z)
syntax
gh_physx5.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_phys5.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx5.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_phys5.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx5.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID actor identifier
density REAL density
return values
none
code sample
gh_phys5.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx5.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_phys5.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx5.check_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN available: 1 (true) or 0 (false)
code sample
if (can_run_sim) then
gh_phys5.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_phys5.check_results(scene_id) == 1) then
gh_phys5.fetch_results(scene_id)
can_run_sim = true
end
create_actor_box
Creates a box actor.
syntax
actor_id = gh_physx5.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
w, h, d REAL width, height and depth
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_box = gh_phys5.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Creates a capsule actor.
syntax
actor_id = gh_physx5.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius of the capsule (actually the cylinder)
half_height REAL half height of the cylinder
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_capsule = gh_phys5.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx5.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_mesh = gh_phys5.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx5.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
px, py, pz REAL position
density REAL density
mat_id ID material identifier
convex BOOLEAN convex state: 1 (yes) or 0 (no)
return values
actor_id ID PhysX actor identifier
code sample
convex = 1
actor_mesh = gh_phys5.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Creates a plane actor.
syntax
actor_id = gh_physx5.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
parameters
scene_id ID PhysX scene identifier
nx, ny, nz, d REAL plane equation
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_plane = gh_phys5.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Creates a sphere actor.
syntax
actor_id = gh_physx5.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
parameters
scene_id ID PhysX scene identifier
radius REAL radius
px, py, pz REAL position
density REAL density
mat_id ID material identifier
return values
actor_id ID PhysX actor identifier
code sample
actor_sphere = gh_phys5.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
syntax
mat_id = gh_physx5.create_material (
static_friction,
dynamic_friction,
resilience
)
parameters
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience
return values
mat_id ID PhysX material identifier
code sample
mat_id = gh_phys5.create_material(0.5, 0.5, 0.5)
syntax
scene_id = gh_physx5.create_scene (
gpu_physx,
bounce_threshold_velocity
)
parameters
gpu_physx BOOLEAN 1 (GPU) or 0 (CPU)
bounce_threshold_velocity REAL bounce threshold velocity
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
scene_id = gh_phys5.create_scene(1, bounce_threshold_velocity)
syntax
scene_id = gh_physx5.create_scene_broadphase_abp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_phys5.create_scene_broadphase_abp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx5.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_phys5.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx5.create_scene_broadphase_mbp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
minX, minY, minZ REAL world minimal dimension
maxX, maxY, maxZ REAL world maximal dimension
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
minX = -100
minY = 0
minZ = -100
maxX = 100,
maxY = 100
maxZ = 100
scene_id = gh_phys5.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
syntax
scene_id = gh_physx5.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
parameters
bounce_threshold_velocity REAL bounce threshold velocity
enable_ccd BOOLEAN CCD: 1 (enabled) or 0 (disabled)
enable_contact_reporting BOOLEAN contact reporting: 1 (enabled) or 0 (disabled)
enable_stabilization BOOLEAN stabilization: 1 (enabled) or 0 (disabled)
return values
scene_id ID PhysX scene identifier
code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_phys5.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
create_scene_set_solver_type
Set the solver that will be used to create a PhysX scene.Synchronizes physics and graphics objects.
A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine).
If used, create_scene_set_solver_type() must be called before any scene creation function.
syntax
gh_physx5.create_scene_set_solver_type (
solver_type
)
parameters
solver_type ENUM( physx_solver_type ) solver type
return values
none
code sample
gh_phys5.create_scene_set_solver_type(solver_type)
syntax
ret = gh_physx5.fetch_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.run_simulation_step(scene_id, time_step)
ret = gh_phys5.fetch_results(scene_id)
syntax
clock = gh_physx5.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_phys5.gpu_get_clock_frequency_khz()
syntax
name = gh_physx5.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_phys5.gpu_get_name()
syntax
num_sm = gh_physx5.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_phys5.gpu_get_num_multiprocessors()
syntax
size = gh_physx5.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_phys5.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx5.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_phys5.gpu_is_supported()
syntax
joint_id = gh_physx5.joint_create (
scene_id,
joint_type,
actor1_id,
x1, y1, z1,
pitch1, yaw1, roll1,
actor2_id,
x2, y2, z2,
pitch2, yaw2, roll2
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
actor1_id ID PhysX first actor identifier
x1, y1, z1 REAL position of the joint related to the first actor
pitch1, yaw1, roll1 REAL orientation of the joint related to the first actor
actor2_id ID PhysX second actor identifier
x2, y2, z2 REAL position of the joint related to the second actor
pitch2, yaw2, roll2 REAL orientation of the joint related to the second actor
return values
joint_id ID PhysX joint identifier
code sample
joint_id = gh_phys5.joint_create(scene_id, joint_type, actor1, x1, y1, z1, pitch1, yaw1, roll1, actor2, x2, y2, z2, pitch2, yaw2, roll2)
syntax
gh_physx5.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_phys5.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx5.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_phys5.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx5.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_phys5.joint_kill(joint_id)
syntax
gh_physx5.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_phys5.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx5.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
damping REAL damping of the limit spring
stiffness REAL if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
restitution REAL controls the amount of bounce when the joint hits a limit
bounce_threshold REAL determines the minimum impact velocity which will cause the joint to bounce
return values
none
code sample
gh_phys5.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx5.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
lower_limit, upper_limit REAL the range of the limit. The upper limit must be no lower than the lower limit.
limit_contact_distance REAL the distance inside the limit value at which the limit will be considered to be active by the solver
return values
none
code sample
gh_phys5.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx5.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_phys5.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx5.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
parameters
joint_id ID PhysX joint identifier
velocity, max_force REAL parameters
drive_enabled, free_spin_enabled BOOLEAN drive and free spin parameters: 1 (enabled) or 0 (disabled)
return values
none
code sample
gh_phys5.joint_set_motor_params(joint_id, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx5.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_phys5.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx5.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_phys5.kill_material(mat_id)
syntax
ret = gh_physx5.run_simulation (
scene_id,
dt,
time_step
)
parameters
scene_id ID PhysX scene identifier
dt REAL detla time
time_step REAL simulation time step
return values
ret BOOLEAN simulation done: 1 (true) or 0 (false)
code sample
ret = gh_phys5.run_simulation(scene_id, dt, time_step)
run_simulation_step
Runs a simulation step.
syntax
ret = gh_physx5.run_simulation_step (
scene_id,
time_step
)
parameters
scene_id ID PhysX scene identifier
time_step REAL simulation time step
return values
ret BOOLEAN simulation: 1 (started) or 0 (error)
code sample
ret = gh_phys5.run_simulation_step(scene_id, time_step)
syntax
n = gh_physx5.scene_get_num_active_actors (
scene_id
)
parameters
scene_id ID scene identifier
return values
n INTEGER number of active actors
code sample
n = gh_phys5.scene_get_num_active_actors(scene_id)
syntax
gh_physx5.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_phys5.scene_sync_3d_objects(scene_id)
scene_sync_3d_objects_v2
Synchronizes physics and graphics objects.
A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine).
syntax
gh_physx5.scene_sync_3d_objects_v2 (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_phys5.scene_sync_3d_objects_v2(scene_id)
syntax
gh_physx5.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
code sample
velocity = 3.0
gh_phys5.set_max_depenetration_velocity(velocity)
...
actor_box = gh_phys5.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
syntax
gh_physx5.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_phys5.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx5.set_simulation_scales (
size,
mass,
speed
)
parameters
size REAL the approximate size of objects in the simulation (default: 1.0)
mass REAL the approximate mass of a size * size * size block (default: 1000)
speed REAL the approximate velocities of objects in simulation (default: 10)
return values
none
code sample
gh_phys5.set_simulation_scales(1, 1000, 10)
syntax
gh_physx5.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_phys5.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_box = gh_phys5.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Starts the PhysX engine.
syntax
ret = gh_physx5.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx5.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.stop()
syntax
gh_physx5.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_phys5.update_material(mat_id, static_friction, dynamic_friction, resilience)
syntax
aligned = gh_utils.align_down (
x,
a
)
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)
syntax
aligned = gh_utils.align_up (
x,
a
)
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)
box_create
Creates a simple box.
syntax
box_id = gh_utils.box_create (
w, h, d,
r, g, b, a
)
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)
syntax
gh_utils.box_update_size (
box_id,
w, h, d
)
parameters
box_id ID box identifier
w, h, d REAL width, height and depth of the box
return values
none
code sample
gh_utils.box_update_size(box_id, 12.0, 12.0, 12.0)
syntax
gh_utils.buffer_copy (
src_buff_ptr,
src_offset,
dst_buff_ptr,
dst_offset,
num_bytes
)
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
none
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)
...
syntax
hashcode = gh_utils.buffer_crc32 (
buff_ptr,
offset
)
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)
syntax
buff_ptr, buff_size = gh_utils.buffer_create (
size
)
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)
syntax
gh_utils.buffer_kill (
buff_ptr
)
parameters
buff_ptr POINTER pointer to the buffer
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
...
gh_utils.buffer_kill(buffer_ptr)
syntax
hashcode = gh_utils.buffer_md5 (
buff_ptr,
offset
)
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)
syntax
x, y = gh_utils.buffer_read_1f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y REAL value
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)
syntax
x, y = gh_utils.buffer_read_2f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y REAL value
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)
syntax
x, y, z = gh_utils.buffer_read_3f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y, z REAL value
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)
syntax
x, y, z, w = gh_utils.buffer_read_4f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y, z, w REAL value
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)
syntax
x = gh_utils.buffer_read_byte (
buff_ptr,
offset
)
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)
syntax
line, line_size = gh_utils.buffer_read_line (
buff_ptr,
buff_size,
offset
)
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)
syntax
hashcode = gh_utils.buffer_sha1 (
buff_ptr,
offset
)
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)
syntax
hashcode = gh_utils.buffer_sha256 (
buff_ptr,
offset
)
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)
syntax
hashcode = gh_utils.buffer_sha512 (
buff_ptr,
offset
)
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)
syntax
ret = gh_utils.buffer_to_file (
buff_ptr,
buff_size,
dst_filename
)
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
syntax
gh_utils.buffer_write_1f (
buff_ptr,
offset,
x
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x REAL value
return values
none
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)
syntax
gh_utils.buffer_write_2f (
buff_ptr,
offset,
x, y
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x, y REAL value
return values
none
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)
syntax
gh_utils.buffer_write_3f (
buff_ptr,
offset,
x, y, z
)
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
none
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)
syntax
gh_utils.buffer_write_4f (
buff_ptr,
offset,
x, y, z, w
)
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
none
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)
syntax
gh_utils.buffer_write_byte (
buff_ptr,
offset,
x
)
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
none
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)
syntax
circle_id = gh_utils.circle_create (
radius,
subdivisions,
r, g, b, a
)
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
Creates a simple circle.
syntax
circle_id = gh_utils.circle_create_v2 (
plane_type,
radius,
subdivisions,
r, g, b, a
)
parameters
plane_type ENUM( plane_type ) 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)
syntax
gh_utils.circle_update_radius (
circle_id,
radius
)
parameters
circle_id ID circle identifier
radius REAL radius
return values
none
code sample
gh_utils.circle_update_radius(circle_id, 12.0)
syntax
text, text_len = gh_utils.clipboard_get_text()
parameters
none
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()
syntax
gh_utils.clipboard_set_text (
text
)
parameters
text STRING text to be copied in the clipboard
return values
none
code sample
gh_utils.clipboard_set_text("Hello!")
syntax
size = gh_utils.cpu_get_mem_available_size_mb()
parameters
none
return values
size INTEGER size in MB
code sample
mem_size_mb = gh_utils.cpu_get_mem_available_size_mb()
syntax
size = gh_utils.cpu_get_mem_size_mb()
parameters
none
return values
size INTEGER size in MB
code sample
mem_size_mb = gh_utils.cpu_get_mem_size_mb()
syntax
str = gh_utils.cpu_get_name()
parameters
none
return values
str STRING CPU name
code sample
local cpu_name = gh_utils.cpu_get_name()
syntax
speed = gh_utils.cpu_get_speed_mhz()
parameters
none
return values
speed REAL CPU speed
code sample
local cpu_speed = gh_utils.cpu_get_speed_mhz()
syntax
gh_utils.cpu_usage_cleanup()
parameters
none
return values
none
code sample
gh_utils.cpu_usage_cleanup()
syntax
num_cores = gh_utils.cpu_usage_get_core_count()
parameters
none
return values
num_cores INTEGER number of cores
code sample
local cores = gh_utils.cpu_usage_get_core_count()
syntax
usage = gh_utils.cpu_usage_get_core_usage (
index
)
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)
syntax
ret = gh_utils.cpu_usage_init()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
local ret = gh_utils.cpu_usage_init()
syntax
gh_utils.cpu_usage_update()
parameters
none
return values
none
code sample
gh_utils.cpu_usage_update()
syntax
hashcode = gh_utils.crc32 (
str
)
parameters
str STRING string
return values
hashcode STRING hashcode of the file
code sample
hashcode = gh_utils.crc32("hello")
curl_download_file_in_buffer
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
)
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)
syntax
gh_utils.curl_download_file_v1 (
curl_lib,
url,
local_file
)
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
none
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_get_file_time_and_size
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
)
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)
syntax
gh_utils.dnd_set_check_scene_file (
state
)
parameters
state BOOLEAN state (0 or 1).
return values
none
code sample
gh_utils.dnd_set_check_scene_file(0)
syntax
ret = gh_utils.do_file_from_sqlite3_blob (
db_id,
column
)
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)
syntax
ret = gh_utils.do_file_from_zip (
zip_filename,
filename
)
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")
syntax
gh_utils.do_screenshot (
filename,
absolute_path
)
parameters
filename STRING relative path of the screenshot file
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
none
code sample
gh_utils.do_screenshot("image.jpg", 0)
syntax
gh_utils.do_screenshot_v2 (
filename,
flip_image
)
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
none
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)
syntax
gh_utils.do_screenshot_v3 (
filename,
x, y, width, height,
flip_image
)
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
none
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)
syntax
gh_utils.do_screenshot_v4 (
filename,
x, y, width, height,
flip_image,
format,
saving_options
)
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
none
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)
syntax
gh_utils.do_screenshot_v5 (
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
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
none
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)
syntax
gh_utils.do_screenshot_v6 (
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
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
none
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)
syntax
filename = gh_utils.drop_files_get_file_by_index (
index
)
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
syntax
filename = gh_utils.drop_files_get_file_by_index_w (
index
)
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
syntax
num_dropped = gh_utils.drop_files_get_num_files()
parameters
none
return values
num_dropped INTEGER number of dropped files
code sample
num_files = gh_utils.drop_files_get_num_files()
syntax
gh_utils.dylib_frame (
dylib_id,
elapsed_time,
data
)
parameters
dylib_id ID dylib identifier
elapsed_time REAL elapsed time in seconds
data STRING user data
return values
none
code sample
gh_utils.dylib_frame(dylib_id, elapsed_time, "")
syntax
message = gh_utils.dylib_get_message (
dylib_id
)
parameters
dylib_id ID dylib identifier
return values
message STRING message
code sample
message = gh_utils.dylib_get_message(dylib_id)
syntax
dylib_id = gh_utils.dylib_load (
dylib_filename
)
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")
syntax
gh_utils.dylib_resize (
dylib_id,
width, height,
data
)
parameters
dylib_id ID dylib identifier
width, height INTEGER width and height of the 3D window
data STRING user data
return values
none
code sample
gh_utils.dylib_resize(dylib_id, width, height, "")
syntax
gh_utils.dylib_set_message (
dylib_id,
message
)
parameters
dylib_id ID dylib identifier
message STRING message
return values
none
code sample
message = "....."
gh_utils.dylib_set_message(dylib_id, message)
syntax
gh_utils.dylib_start (
dylib_id,
width, height,
data
)
parameters
dylib_id ID dylib identifier
width, height INTEGER width and height of the 3D window
data STRING user data
return values
none
code sample
gh_utils.dylib_start(dylib_id, width, height, "")
syntax
gh_utils.dylib_stop (
dylib_id,
data
)
parameters
dylib_id ID dylib identifier
data STRING user data
return values
none
code sample
gh_utils.dylib_stop(dylib_id, "")
syntax
gh_utils.dylib_unload (
dylib_id
)
parameters
dylib_id ID dylib identifier
return values
none
code sample
gh_utils.dylib_unload(dylib_id)
syntax
ret = gh_utils.exe_from_buffer (
buff_ptr,
buff_size
)
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
Executes a script.
syntax
gh_utils.exe_script (
name,
threaded
)
parameters
name STRING name of the script
threaded BOOLEAN runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
return values
none
code sample
local threaded = 0
gh_utils.exe_script("init_meshes", threaded)
exe_script_v2
Executes a script.
syntax
gh_utils.exe_script_v2 (
name,
threaded,
create_worker_wind3d
)
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
none
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
Executes a script.
syntax
gh_utils.exe_script_v3 (
name,
threaded,
create_worker_wind3d,
thread_affinity_mask
)
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
none
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
Executes a script.
syntax
ret = gh_utils.exe_string (
lua_python_commands
)
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)
syntax
buff_ptr, buff_size = gh_utils.file_buffer_create (
filename
)
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)
syntax
crc32, crc32_str = gh_utils.file_crc32 (
zip_filename,
filename
)
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)
syntax
hashcode = gh_utils.file_md5 (
zip_filename,
filename
)
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)
syntax
data, data_size = gh_utils.file_read (
zip_filename,
filename
)
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)
syntax
hashcode = gh_utils.file_sha1 (
zip_filename,
filename
)
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)
syntax
hashcode = gh_utils.file_sha256 (
zip_filename,
filename
)
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)
syntax
hashcode = gh_utils.file_sha512 (
zip_filename,
filename
)
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)
syntax
size = gh_utils.file_size_DUP1 (
zip_filename,
filename
)
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)
syntax
size = gh_utils.file_size_DUP2 (
zip_filename,
filename
)
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)
file_write
Writes data to a file.
syntax
ret = gh_utils.file_write (
filename,
data
)
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)
font_create
Creates a new font.
syntax
font_id = gh_utils.font_create (
font_name,
height
)
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
Renders (draws) a text.
syntax
gh_utils.font_render (
font_id,
x, y,
r, g, b, a,
text
)
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
none
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))
syntax
gh_utils.font_render3d (
font_id,
x, y, z,
r, g, b, a,
text
)
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
none
code sample
gh_utils.font_render3d(font_id, 0, 20.0, -20.0, 0.2, 1.0, 0.0, 1.0, "V1")
syntax
gh_utils.font_set_viewport_info (
font_id,
x, y,
width, height
)
parameters
font_id ID font identifier
x, y INTEGER viewport offsets
width, height INTEGER viewport size
return values
none
code sample
gh_utils.font_set_viewport_info(font_id, 0, 0, width, height)
syntax
gh_utils.ftgl_font_add_text2d (
font_id,
x, y,
r, g, b, a,
text
)
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
none
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")
syntax
gh_utils.ftgl_font_add_text3d (
font_id,
x, y, z,
r, g, b, a,
text
)
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
none
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")
syntax
gh_utils.ftgl_font_clear (
font_id
)
parameters
font_id ID font identifier
return values
none
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)
syntax
font_id = gh_utils.ftgl_font_create (
font_tex_id
)
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)
syntax
gh_utils.ftgl_font_kill (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_utils.ftgl_font_kill(font_id)
ftgl_font_render
Renders a 2D font.
syntax
gh_utils.ftgl_font_render (
font_id
)
parameters
font_id ID font identifier
return values
none
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)
syntax
gh_utils.ftgl_font_texture_kill (
font_tex_id
)
parameters
font_tex_id ID font texture identifier
return values
none
code sample
gh_utils.ftgl_font_texture_kill(font_tex_id)
syntax
font_tex_id = gh_utils.ftgl_font_texture_load (
filename,
height,
tex_width, tex_height,
_5, _6
)
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)
syntax
gh_utils.get_app_build_date()
parameters
none
return values
none
code sample
build_date = gh_utils.get_app_build_date()
syntax
dir = gh_utils.get_app_dir()
parameters
none
return values
dir STRING directory
code sample
app_dir = gh_utils.get_app_dir()
syntax
name = gh_utils.get_app_name()
parameters
none
return values
name STRING name of the host application
code sample
app_name = gh_utils.get_app_name()
syntax
text = gh_utils.get_app_title_bar()
parameters
none
return values
text STRING title
code sample
text = gh_utils.get_app_title_bar()
syntax
major, minor, patch, build = gh_utils.get_app_version()
parameters
none
return values
major, minor, patch, build INTEGER version of GeeXLab
code sample
major, minor, patch, build = gh_utils.get_app_version()
syntax
command_line = gh_utils.get_command_line()
parameters
none
return values
command_line STRING command line
code sample
command_line = gh_utils.get_command_line()
syntax
date = gh_utils.get_date_str()
parameters
none
return values
date STRING date (Y.M.D.h.m.s)
code sample
date = gh_utils.get_date_str()
syntax
date = gh_utils.get_date_str_v2 (
format
)
parameters
format INTEGER 0 (Y.M.D.h.m.s) or 1 (Y.M.D@h:m:s)
return values
date STRING date
code sample
date = gh_utils.get_date_str_v2(1)
syntax
dir = gh_utils.get_demo_dir()
parameters
none
return values
dir STRING directory of the current scene file
code sample
demo_dir = gh_utils.get_demo_dir()
syntax
demo_zip_filename = gh_utils.get_demo_zip_filename()
parameters
none
return values
demo_zip_filename STRING filename of the main zip archive
code sample
main_zip_filename = gh_utils.get_demo_zip_filename()
get_desktop_resolution
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()
parameters
none
return values
width, height STRING resolution of the desktop in pixels
code sample
width, height = gh_utils.get_desktop_resolution()
syntax
elapsed_time = gh_utils.get_elapsed_time()
parameters
none
return values
elapsed_time REAL elapsed time in seconds
code sample
local elapsed_time = gh_utils.get_elapsed_time()
syntax
dir = gh_utils.get_lib_dir()
parameters
none
return values
dir STRING directory
code sample
lib_dir = gh_utils.get_lib_dir()
syntax
gh_utils.get_lua_version()
parameters
none
return values
none
code sample
major, minor, patch = gh_utils.get_lua_version()
syntax
major, minor, build, name, codename = gh_utils.get_os_info()
parameters
none
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
Returns the platform: 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
syntax
platform = gh_utils.get_platform()
parameters
none
return values
platform ENUM( platform ) 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
code sample
platform = gh_utils.get_platform()
get_platform_name
Returns the platform name: Windows xx-bit, macOS 10.x, Linux xx-bit, Raspberry Pi.
syntax
platform_name = gh_utils.get_platform_name()
parameters
none
return values
platform_name STRING the name of the platform
code sample
platform_name = gh_utils.get_platform_name()
syntax
time = gh_utils.get_time()
parameters
none
return values
time REAL elapsed time in seconds
code sample
local curr_time = gh_utils.get_time()
syntax
time = gh_utils.get_time_microseconds()
parameters
none
return values
time INTEGER elapsed time in micro-seconds
code sample
local curr_time_us = gh_utils.get_time_microseconds()
syntax
dt = gh_utils.get_time_step()
parameters
none
return values
dt REAL time step in seconds
code sample
local dt = gh_utils.get_time_step()
syntax
uptime = gh_utils.get_uptime()
parameters
none
return values
uptime REAL up time in seconds
code sample
local uptime = gh_utils.get_uptime()
syntax
gh_utils.global_array_char_alloc (
num_elements,
max_string_len
)
parameters
num_elements INTEGER number of elements
max_string_len INTEGER max length of a string in a the array
return values
none
code sample
num_elements = 256
max_string_len = 1024
gh_utils.global_array_char_alloc(num_elements, max_string_len)
syntax
value = gh_utils.global_array_char_get (
index
)
parameters
index INTEGER index in the array
return values
value STRING value
code sample
index = 2
value = gh_utils.global_array_char_get(index)
syntax
gh_utils.global_array_char_set (
index,
value
)
parameters
index INTEGER index in the array
value STRING value
return values
none
code sample
index = 2
value = "Hello"
gh_utils.global_array_char_set(index, value)
syntax
gh_utils.global_array_float_alloc (
num_elements
)
parameters
num_elements INTEGER number of elements
return values
none
code sample
num_elements = 256
gh_utils.global_array_float_alloc(num_elements)
syntax
value = gh_utils.global_array_float_get (
index
)
parameters
index INTEGER index in the array
return values
value REAL value
code sample
index = 2
value = gh_utils.global_array_float_get(index)
syntax
gh_utils.global_array_float_set (
index,
value
)
parameters
index INTEGER index in the array
value REAL value
return values
none
code sample
index = 2
value = 3.14
gh_utils.global_array_float_set(index, value)
syntax
gh_utils.global_array_int_alloc (
num_elements
)
parameters
num_elements INTEGER number of elements
return values
none
code sample
num_elements = 256
gh_utils.global_array_int_alloc(num_elements)
syntax
value = gh_utils.global_array_int_get (
index
)
parameters
index INTEGER index in the array
return values
value INTEGER value
code sample
index = 2
value = gh_utils.global_array_int_get(index)
syntax
gh_utils.global_array_int_set (
index,
value
)
parameters
index INTEGER index in the array
value INTEGER value
return values
none
code sample
index = 2
value = 10
gh_utils.global_array_int_set(index, value)
grid_create
Creates a grid object.
syntax
grid_id = gh_utils.grid_create()
parameters
none
return values
grid_id ID grid identifier
code sample
grid_id = gh_utils.grid_create()
syntax
gh_utils.grid_set_display_lines_options (
grid_id,
display_main_lines,
display_lines
)
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
none
code sample
gh_utils.grid_set_display_lines_options(grid_id, 1, 1)
syntax
gh_utils.grid_set_geometry_params (
grid_id,
x_size, z_size,
x_div, z_div
)
parameters
grid_id ID grid identifier
x_size, z_size REAL size
x_div, z_div INTEGER subdivisions
return values
none
code sample
gh_utils.grid_set_geometry_params(grid_id, 20, 20, 10, 10)
grid_set_lines_color
Sets grid color.
syntax
gh_utils.grid_set_lines_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_lines_color(grid_id, 0.7, 0.7, 0.7, 1)
syntax
gh_utils.grid_set_main_lines_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_lines_color(grid_id, 1.0, 1.0, 0.0, 1)
syntax
gh_utils.grid_set_main_x_axis_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_x_axis_color(grid_id, 1.0, 0.0, 0.0, 1)
syntax
gh_utils.grid_set_main_z_axis_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_z_axis_color(grid_id, 0.0, 0.0, 1.0, 1)
syntax
r, g, b = gh_utils.hex_color_to_rgb (
html_color
)
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")
syntax
state = gh_utils.is_64bit()
parameters
none
return values
state BOOLEAN 1 (64-bit) or 0 (otherwise)
code sample
app_64bit = gh_utils.is_64bit()
syntax
state = gh_utils.is_luajit()
parameters
none
return values
state BOOLEAN 1 (LuaJIT) or 0 (otherwise)
code sample
is_luajit = gh_utils.is_luajit()
syntax
state = gh_utils.is_rpi()
parameters
none
return values
state BOOLEAN 1 if RPi and 0 otherwise
code sample
rpi = gh_utils.is_rpi()
line_create
Creates a simple line.
syntax
line_id = gh_utils.line_create()
parameters
none
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)
syntax
gh_utils.line_set_end_color (
line_id,
r, g, b, a
)
parameters
line_id ID line identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.line_set_end_color(line_id, 1, 1, 0, 1)
syntax
gh_utils.line_set_end_position (
line_id,
x, y, z
)
parameters
line_id ID line identifier
x, y, z REAL position
return values
none
code sample
gh_utils.line_set_end_position(line_id, 10, 10, 0.0)
syntax
gh_utils.line_set_start_color (
line_id,
r, g, b, a
)
parameters
line_id ID line identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.line_set_start_color(line_id, 1, 1, 0, 1)
syntax
gh_utils.line_set_start_position (
line_id,
x, y, z
)
parameters
line_id ID line identifier
x, y, z REAL position
return values
none
code sample
gh_utils.line_set_start_position(line_id, -10, -10, 0.0)
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
)
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)
syntax
len = gh_utils.math_length_vec3 (
x, y, z
)
parameters
x, y, z REAL vector
return values
len REAL length
code sample
len = gh_utils.math_length_vec3(x, y, z)
syntax
vx, vy, vz = gh_utils.math_normalize_vec3 (
x, y, z
)
parameters
x, y, z REAL vector
return values
vx, vy, vz REAL normalized vector
code sample
vx, vy, vz = gh_utils.math_normalize_vec3(x, y, z)
syntax
qx, qy, qz, qw = gh_utils.math_quat_from_euler_angles (
pitch, yaw, roll
)
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)
syntax
qx, qy, qz, qw = gh_utils.math_quat_from_lookat (
px, py, pz,
tx, ty, tz,
ux, uy, uz
)
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)
syntax
qx, qy, qz, qw = gh_utils.math_quat_from_vectors_rotation (
x0, y0, z0,
x1, y1, z1
)
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)
syntax
hashcode = gh_utils.md5 (
str
)
parameters
str STRING string
return values
hashcode STRING hashcode of the file
code sample
hashcode = gh_utils.md5("hello")
nfd_open_dialog
macos ✘
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
)
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
macos ✘
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
)
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
macos ✘
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
)
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", "")
syntax
gh_utils.open_url (
str
)
parameters
str STRING url
return values
none
code sample
gh_utils.open_url("https://geeks3d.com")
syntax
rgba = gh_utils.pack_rgba_u8 (
r, g, b, a
)
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)
syntax
gh_utils.printc (
text
)
parameters
text STRING text
return values
none
code sample
gh_utils.printc(text)
progress_bar_inc
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
)
parameters
percent_inc REAL increment in percent
caption STRING caption of the progress bar
return values
none
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
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
)
parameters
percent REAL percent
caption STRING caption of the progress bar
return values
none
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.")
syntax
px, py = gh_utils.project_3d_to_2d_v1 (
cam_id,
obj_id,
x, y, z, w
)
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)
syntax
px, py = gh_utils.project_3d_to_2d_v2 (
cam_id,
x, y, z, w
)
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)
syntax
texture_id = gh_utils.qr_code_gen (
payload,
err_correction_level
)
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)
syntax
payload, payload_len, corner0, corner1, corner2, ... corner7 = gh_utils.qr_code_scan (
texture_id,
bthreshold
)
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)
syntax
x = gh_utils.random()
parameters
none
return values
x REAL random number
code sample
local x = gh_utils.random()
local y = gh_utils.random()
local z = gh_utils.random()
syntax
x = gh_utils.random16 (
a, b
)
parameters
a, b REAL random number range: a must be smaller than b
return values
x REAL random number
code sample
a = 0
b = 2.0
x = gh_utils.random16(a, b)
syntax
x = gh_utils.random32 (
a, b
)
parameters
a, b REAL random number range: a must be smaller than b
return values
x REAL random number
code sample
a = 0
b = 2.0
x = gh_utils.random32(a, b)
random_init
Initializes the random number generator (random_uniform_real, random_uniform_int, random_poisson and random_normal).
syntax
gh_utils.random_init (
s
)
parameters
s INTEGER seed
return values
none
code sample
s = 123456789
gh_utils.random_init(s)
syntax
x = gh_utils.random_normal (
mean,
deviation
)
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)
random_poisson
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
)
parameters
mean REAL distribution parameter
return values
x INTEGER random number
code sample
mean = 4.1
x = gh_utils.random_poisson(mean)
random_uniform_int
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
)
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)
syntax
x = gh_utils.random_uniform_real (
a, b
)
parameters
a, b REAL random number range: a must be smaller than b
return values
x REAL random number
code sample
a = 0
b = 2.0
x = gh_utils.random_uniform_real(a, b)
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
)
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)
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
)
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)
syntax
ro_x, ro_y, ro_z, rd_x, rd_y, rd_z = gh_utils.raycast_get_ray (
screen_x, screen_y,
cam_id
)
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)
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
)
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
Sanitize a string.
syntax
gh_utils.sanitize_string (
text,
filter_type
)
parameters
text STRING str
filter_type ENUM( filter_type ) 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
none
code sample
sanitized_text = gh_utils.sanitize_string(text, 0)
syntax
gh_utils.screenshot_kill_image_saving_thread()
parameters
none
return values
none
code sample
gh_utils.screenshot_kill_image_saving_thread()
syntax
num_saved_images, num_queued_images = gh_utils.screenshot_threaded_get_stats()
parameters
none
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()
syntax
gh_utils.set_app_title_bar (
text
)
parameters
text STRING title
return values
none
code sample
gh_utils.set_app_title_bar("GeeXLab!")
syntax
gh_utils.set_new_scene_data (
filename,
width, height,
fullscreen,
msaa
)
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
none
code sample
gh_utils.set_new_scene_data(filename, -1, -1, 0, "Off")
syntax
hashcode = gh_utils.sha1 (
str
)
parameters
str STRING string
return values
hashcode STRING hashcode of the file
code sample
hashcode = gh_utils.sha1("hello")
syntax
hashcode = gh_utils.sha256 (
str
)
parameters
str STRING string
return values
hashcode STRING hashcode of the file
code sample
hashcode = gh_utils.sha256("hello")
syntax
hashcode = gh_utils.sha512 (
str
)
parameters
str STRING string
return values
hashcode STRING hashcode of the file
code sample
hashcode = gh_utils.sha512("hello")
syntax
sv_id = gh_utils.shared_variable_create (
name
)
parameters
name STRING name
return values
sv_id ID shared variable identifier
code sample
sv_name = "sv1"
sv_id = gh_utils.shared_variable_create(sv_name)
syntax
sv_id = gh_utils.shared_variable_create_array (
sv_name,
sv_type,
num_elements
)
parameters
sv_name STRING shared var name
sv_type ENUM( shared_var_elem_type ) 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)
syntax
elem_value = gh_utils.shared_variable_get_array_value_1f (
sv_name,
elem_index
)
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)
syntax
elem_value = gh_utils.shared_variable_get_array_value_1i (
sv_name,
elem_index
)
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)
syntax
elem_value = gh_utils.shared_variable_get_array_value_str (
sv_name,
elem_index
)
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
Gets a 4D value.
syntax
x, y, z, w = gh_utils.shared_variable_get_value_4f (
sv_name
)
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_buffer_DUP1
Gets a string value.
syntax
str = gh_utils.shared_variable_get_value_buffer_DUP1 (
sv_name
)
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)
syntax
buffer_ptr, buffer_size = gh_utils.shared_variable_get_value_buffer_DUP2 (
sv_name
)
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
Gets a pointer value.
syntax
ptr = gh_utils.shared_variable_get_value_ptr (
sv_name
)
parameters
sv_name STRING shared var name
return values
ptr POINTER pointer
code sample
ptr = gh_utils.shared_variable_get_value_ptr(sv_name)
shared_variable_get_value_str
Gets a string value.
syntax
str = gh_utils.shared_variable_get_value_str (
sv_name
)
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)
syntax
is_exist = gh_utils.shared_variable_is_exist (
sv_name
)
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)
syntax
gh_utils.shared_variable_kill (
sv_name
)
parameters
sv_name STRING shared var name
return values
none
code sample
gh_utils.shared_variable_kill(sv1_name)
syntax
gh_utils.shared_variable_set_array_value_1f (
sv_name,
elem_index,
elem_value
)
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
none
code sample
gh_utils.shared_variable_set_array_value_1f("texture_ids", 0, 16.0)
syntax
gh_utils.shared_variable_set_array_value_1i (
sv_name,
elem_index,
elem_value
)
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
none
code sample
gh_utils.shared_variable_set_array_value_1i("texture_ids", 0, 2)
syntax
gh_utils.shared_variable_set_array_value_str (
sv_name,
elem_index,
elem_value
)
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
none
code sample
gh_utils.shared_variable_set_array_value_str("texture_ids", 0, "abcd")
shared_variable_set_value_4f
Sets a 4D value.
syntax
gh_utils.shared_variable_set_value_4f (
sv_name,
x, y, z, w
)
parameters
sv_name STRING shared var name
x, y, z, w REAL 4D value
return values
none
code sample
gh_utils.shared_variable_set_value_4f(sv_name, 0.2, 0.3, 0.4, 1.0)
syntax
gh_utils.shared_variable_set_value_buffer (
sv_name,
buffer_ptr,
buffer_size
)
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
none
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
Sets a pointer value.
syntax
gh_utils.shared_variable_set_value_ptr (
sv_name,
ptr
)
parameters
sv_name STRING shared var name
ptr POINTER pointer
return values
none
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)
shared_variable_set_value_str
Sets a string value.
syntax
gh_utils.shared_variable_set_value_str (
sv_name,
str
)
parameters
sv_name STRING shared var name
str STRING string value
return values
none
code sample
gh_utils.shared_variable_set_value_str(sv_name, str)
syntax
gh_utils.shell_exe (
command,
parameters,
exe_dir
)
parameters
command STRING command
parameters STRING command parameters
exe_dir STRING command execution folder
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
gh_utils.shell_exe("firefox", "/new-window https://www.geeks3d.com/geexlab/", demo_dir)
syntax
gh_utils.shell_exe_v2 (
command,
parameters,
exe_dir,
show_mode,
mask,
run_as_admin
)
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
none
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)
syntax
ret = gh_utils.shmem_create (
shmem_name,
shmem_size
)
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)
syntax
ret = gh_utils.shmem_is_available (
shmem_name,
shmem_size
)
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)
syntax
gh_utils.shmem_kill (
shmem_name
)
parameters
shmem_name STRING shared memory name. The name is the shared memory identifier used by all other functions.
return values
none
code sample
gh_utils.shmem_kill(shmem_name)
syntax
buffer_ptr = gh_utils.shmem_map (
shmem_name,
shmem_size
)
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)
syntax
gh_utils.shmem_unmap (
shmem_name
)
parameters
shmem_name STRING shared memory name. The name is the shared memory identifier used by all other functions.
return values
none
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)
syntax
ret = gh_utils.smolv_to_spirv (
smolv_filename,
spirv_filename
)
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)
syntax
sphere_id = gh_utils.sphere_create (
radius,
subdivisions,
r, g, b, a
)
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)
syntax
gh_utils.sphere_update_radius (
sphere_id,
radius
)
parameters
sphere_id ID sphere identifier
radius REAL radius
return values
none
code sample
gh_utils.sphere_update_radius(sphere_id, 12.0)
syntax
ret = gh_utils.spirv_to_smolv (
spirv_filename,
smolv_filename,
flags
)
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)
spout_create_sender
Creates a Spout sender.
syntax
sender_id = gh_utils.spout_create_sender (
sender_name,
texture_id
)
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
Destroys a Spout sender.
syntax
gh_utils.spout_kill_sender (
sender_id
)
parameters
sender_id ID sender identifier
return values
none
code sample
gh_utils.spout_kill_sender(senderid)
syntax
gh_utils.spout_register_directshow_filter (
state
)
parameters
state INTEGER 0 or 1
return values
none
code sample
gh_utils.spout_register_directshow_filter(1)
syntax
gh_utils.spout_send_texture (
sender_id,
texture_id
)
parameters
sender_id ID sender identifier
texture_id ID texture identifier
return values
none
code sample
gh_utils.spout_send_texture(senderid, texture_id)
syntax
gh_utils.spout_send_texture_rt (
sender_id,
rt_id,
color_index,
width, height
)
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
none
code sample
gh_utils.spout_send_texture_rt(senderid, rt_id, color_index, width, height)
syntax
gh_utils.srandom (
seed
)
parameters
seed INTEGER seed
return values
none
code sample
s = 1234321
gh_utils.srandom(s)
syntax
gh_utils.stop_demo()
parameters
none
return values
none
code sample
gh_utils.stop_demo()
syntax
gh_utils.sys_exec (
command,
parameters,
exe_dir
)
parameters
command STRING command
parameters STRING command parameters
exe_dir STRING command execution folder
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
gh_utils.sys_exec("ffmpeg", "-i input.mp4 output.avi", demo_dir)
syntax
temp_folder = gh_utils.temp_directory_path()
parameters
none
return values
temp_folder STRING absolute path of the temp folder
code sample
temp_folder = gh_utils.temp_directory_path()
syntax
gh_utils.thread_lock_acquire (
index
)
parameters
index INTEGER index of the thread lock object.
return values
none
code sample
gh_utils.thread_lock_acquire(tl)
...
gh_utils.thread_lock_release(tl)
syntax
index = gh_utils.thread_lock_create()
parameters
none
return values
index INTEGER index of the thread lock object.
code sample
tl1 = gh_utils.thread_lock_create()
syntax
gh_utils.thread_lock_kill_all()
parameters
none
return values
none
code sample
gh_utils.thread_lock_kill_all()
syntax
gh_utils.thread_lock_release (
index
)
parameters
index INTEGER index of the thread lock object.
return values
none
code sample
gh_utils.thread_lock_acquire(tl)
...
gh_utils.thread_lock_release(tl)
syntax
gh_utils.thread_sleep (
delay
)
parameters
delay INTEGER pause delay in milliseconds
return values
none
code sample
gh_utils.thread_sleep(2000)
syntax
gh_utils.trace (
str
)
parameters
str STRING trace to write
return values
none
code sample
gh_utils.trace("Hello world!")
syntax
x, y, z, w = gh_utils.trackball_get_orientation (
x, y,
prev_x, prev_y
)
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)
syntax
gh_utils.trackball_init (
radius,
x, y
)
parameters
radius REAL radius of the trackball. The radius is in screen space.
x, y INTEGER size of the screen
return values
none
code sample
gh_utils.trackball_init(radius, w, h)
syntax
gh_utils.tripod_visualizer_camera_render (
cam_id,
x_offset, y_offset, width, height
)
parameters
cam_id ID camera identifier
x_offset, y_offset, width, height INTEGER viewport size
return values
none
code sample
gh_utils.tripod_visualizer_camera_render(cam_id, 0, 0, 100, 100)
syntax
r, g, b, a = gh_utils.unpack_rgba_u8 (
rgba
)
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)
syntax
date = gh_utils.vendor_name_from_vendor_id (
vendorID
)
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
syntax
webcam_id = gh_utils.webcam_create()
parameters
none
return values
webcam_id ID webcam identifier
code sample
webcam_id = gh_utils.webcam_create()
syntax
width, height = gh_utils.webcam_get_frame_size (
webcam_id
)
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)
syntax
gh_utils.webcam_get_name (
webcam_id
)
parameters
webcam_id ID webcam identifier
return values
none
code sample
name = gh_utils.webcam_get_name(webcam_id)
syntax
num_webcams = gh_utils.webcam_get_num()
parameters
none
return values
num_webcams ID number of webcams
code sample
num_webcam = gh_utils.webcam_get_num()
syntax
gh_utils.webcam_grab_frame (
webcam_id
)
parameters
webcam_id ID webcam identifier
return values
none
code sample
gh_utils.webcam_grab_frame(webcam_id)
syntax
gh_utils.webcam_kill (
webcam_id
)
parameters
webcam_id ID webcam identifier
return values
none
code sample
gh_utils.webcam_kill(webcam_id)
syntax
ret = gh_utils.webcam_start (
webcam_id,
webcam_number
)
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
syntax
ret = gh_utils.webcam_start_v2 (
webcam_id,
webcam_number,
capture_width, capture_height
)
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
syntax
gh_utils.webcam_stop (
webcam_id
)
parameters
webcam_id ID webcam identifier
return values
none
code sample
gh_utils.webcam_stop(webcam_id)
syntax
gh_utils.webcam_update_texture (
webcam_id,
tex_id
)
parameters
webcam_id ID webcam identifier
tex_id ID texture identifier
return values
none
code sample
gh_utils.webcam_update_texture(webcam_id, tex_id)
syntax
gh_utils.win32_audio_volume_control (
command
)
parameters
command STRING command. Possible values: mute, up and down
return values
none
code sample
local command0 = "mute"
local command1 = "up"
local command2 = "down"
gh_utils.win32_audio_volume_control(command1)
syntax
ret = gh_utils.win_registry_create_key (
key_name,
subkey_name,
options
)
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)
syntax
ret = gh_utils.win_registry_delete_key (
key_name,
subkey_name
)
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)
syntax
ret, x = gh_utils.win_registry_read_value_dword (
key_name,
subkey_name,
value_name
)
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)
syntax
ret, str = gh_utils.win_registry_read_value_string (
key_name,
subkey_name,
value_name
)
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)
syntax
ret = gh_utils.win_registry_write_value_dword (
key_name,
subkey_name,
value_name,
x
)
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)
syntax
ret = gh_utils.win_registry_write_value_string (
key_name,
subkey_name,
value_name,
str
)
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.")
syntax
buff_ptr, buff_size = gh_utils.zip_buffer_create (
zip_filename,
filename
)
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)
syntax
ret = gh_utils.zip_to_file (
zip_filename,
src_filename,
dst_filename
)
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
syntax
gh_vk.clear_color_depth_buffers (
r, g, b, a,
z
)
parameters
r, g, b, a REAL color buffer clear value.
z REAL depth buffer clear value.
return values
none
code sample
gh_vk.clear_color_depth_buffers(0, 0, 0, 1.0, 1.0)
syntax
gh_vk.command_buffer_begin (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.command_buffer_begin(cmdbuf_id)
syntax
cmdbuf_id = gh_vk.command_buffer_create (
type
)
parameters
type INTEGER type of the command buffer: 0 (primary) or 1 (secondary)
return values
cmdbuf_id INTEGER command buffer identifier
code sample
cmdbuf_id = gh_vk.command_buffer_create(0)
syntax
gh_vk.command_buffer_end (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.command_buffer_end(cmdbuf_id)
syntax
gh_vk.command_buffer_execute (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.command_buffer_execute(cmdbuf_id)
syntax
gh_vk.command_buffer_execute_secondary_cmd (
main_cmdbuf_id,
secd_cmdbuf_id
)
parameters
main_cmdbuf_id INTEGER main command buffer identifier
secd_cmdbuf_id INTEGER second command buffer identifier
return values
none
code sample
gh_vk.command_buffer_execute_secondary_cmd(main_cmdbuf_id, secd_cmdbuf_id)
syntax
gh_vk.command_buffer_kill (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.command_buffer_kill(cmdbuf_id)
syntax
gh_vk.command_buffer_op (
command_buffer,
op
)
parameters
command_buffer INTEGER command buffer identifier
op STRING operation on the command buffer: begin, end or submit
return values
none
code sample
# INIT
command_buffer = gh_vk.command_buffer_create(0)
# FRAME
gh_vk.command_buffer_op(command_buffer, "begin")
...
gh_vk.command_buffer_op(command_buffer, "end")
gh_vk.command_buffer_op(command_buffer, "submit")
command_buffer_reset
Resets a command buffer.
syntax
gh_vk.command_buffer_reset (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.command_buffer_reset(cmdbuf_id)
create_storage_image
Creates a storage image.
syntax
storage_image_id = gh_vk.create_storage_image (
width, height,
pixel_format
)
parameters
width, height INTEGER size of the storage image
pixel_format INTEGER pixel format
return values
storage_image_id INTEGER storage image identifier
code sample
PF_U8_RGB = 1
PF_U8_RGBA = 3
PF_F32_RGBA = 6
storage_image_id = gh_vk.create_storage_image(1024, 1024, PF_F32_RGBA)
syntax
gh_vk.create_storage_kill (
storage_image_id
)
parameters
storage_image_id INTEGER storage image identifier
return values
none
code sample
gh_vk.create_storage_image(storage_image_id)
descriptorset_add_geometry
Adds a geometry (a mesh) to a descriptor set.
Several meshes can be added.
Once all meshes have been added, call descriptorset_add_all_geometry_cores_vertices() and descriptorset_add_all_geometry_cores_indices() to build the vertices and indices arrays that will be visible by shaders.
Deprecated name: descriptorset_push_geometry_core
syntax
gh_vk.descriptorset_add_geometry (
ds_id,
mesh_id
)
parameters
ds_id INTEGER descriptor set identifier
mesh_id INTEGER mesh identifier
return values
none
code sample
gh_vk.descriptorset_add_geometry(ds_id, mesh0)
gh_vk.descriptorset_add_geometry(ds_id, mesh1)
gh_vk.descriptorset_add_geometry(ds_id, mesh2)
binding_point = 2
gh_vk.descriptorset_build_geometries_vertices_arrays(ds_id, binding_point, shader_stages)
binding_point = 3
gh_vk.descriptorset_build_geometries_indices_arrays(ds_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_add_push_constant_range (
ds_id,
size,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
size INTEGER size of the push constant in bytes
offset INTEGER offset of the push constant in bytes relative to the whole push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
size = 20
offset = 0
gh_vk.descriptorset_add_push_constant_range(ds_id, size, offset, shader_stages)
syntax
resource_index = gh_vk.descriptorset_add_resource_empty_texture_array (
ds_id,
texture_count,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
texture_count INTEGER number of textures
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
resource_index INTEGER index of the resource in the descriptor set
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
texture_count = 2
shader_stages = SHADER_STAGE_FRAGMENT
binding_point = 0
resource_index = gh_vk.descriptorset_add_resource_empty_texture_array(ds_id, texture_count, binding_point, shader_stages)
syntax
resource_index = gh_vk.descriptorset_add_resource_gpu_buffer (
ds_id,
gpubuffer_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
gpubuffer_id INTEGER GPU buffer identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
resource_index INTEGER index of the resource in the descriptor set
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
binding_point = 0
resource_index = gh_vk.descriptorset_add_resource_gpu_buffer(ds_id, gpubuffer_id, binding_point, shader_stages)
syntax
resource_index = gh_vk.descriptorset_add_resource_rt_color (
ds_id,
rt_id,
color_index,
sampler_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
rt_id INTEGER render target identifier
color_index INTEGER texture index in the render target
sampler_id INTEGER sampler identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
resource_index INTEGER index of the resource in the descriptor set
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_FRAGMENT
binding_point = 0
color_index = 0
resource_index = gh_vk.descriptorset_add_resource_rt_color(ds_id, rt_id, color_index, sampler_id, binding_point, shader_stages)
syntax
resource_index = gh_vk.descriptorset_add_resource_storage_image (
ds_id,
storage_image_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
storage_image_id INTEGER storage image identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
resource_index INTEGER index of the resource in the descriptor set
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
SHADER_STAGE_RAYGEN = 256
SHADER_STAGE_ANY_HIT = 512
SHADER_STAGE_CLOSEST_HIT = 1024
SHADER_STAGE_MISS = 2048
SHADER_STAGE_INTERSECTION = 4096
shader_stages = SHADER_STAGE_RAYGEN
binding_point = 0
resource_index = gh_vk.descriptorset_add_resource_storage_image(ds_id, storage_image_id, binding_point, shader_stages)
syntax
resource_index = gh_vk.descriptorset_add_resource_texture (
ds_id,
texture_id,
sampler_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
texture_id INTEGER texture identifier
sampler_id INTEGER sampler identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
resource_index INTEGER index of the resource in the descriptor set
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_FRAGMENT + SHADER_STAGE_VERTEX
binding_point = 0
resource_index = gh_vk.descriptorset_add_resource_texture(ds_id, texture_id, sampler_id, binding_point, shader_stages)
descriptorset_bind
Binds a descriptor set.
syntax
gh_vk.descriptorset_bind (
ds_id
)
parameters
ds_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.descriptorset_bind(ds_id)
descriptorset_build
Builds a descriptor set.
syntax
gh_vk.descriptorset_build (
ds_id
)
parameters
ds_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.descriptorset_build(ds_id)
syntax
gh_vk.descriptorset_build_geometries_indices_arrays (
ds_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
gh_vk.descriptorset_add_geometry(ds_id, mesh0)
gh_vk.descriptorset_add_geometry(ds_id, mesh1)
gh_vk.descriptorset_add_geometry(ds_id, mesh2)
binding_point = 2
gh_vk.descriptorset_build_geometries_vertices_arrays(ds_id, binding_point, shader_stages)
binding_point = 3
gh_vk.descriptorset_build_geometries_indices_arrays(ds_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_build_geometries_vertices_arrays (
ds_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
gh_vk.descriptorset_add_geometry(ds_id, mesh0)
gh_vk.descriptorset_add_geometry(ds_id, mesh1)
gh_vk.descriptorset_add_geometry(ds_id, mesh2)
binding_point = 2
gh_vk.descriptorset_build_geometries_vertices_arrays(ds_id, binding_point, shader_stages)
binding_point = 3
gh_vk.descriptorset_build_geometries_indices_arrays(ds_id, binding_point, shader_stages)
syntax
ds_id = gh_vk.descriptorset_create()
parameters
none
return values
ds_id INTEGER descriptor set identifier
code sample
ds_id = gh_vk.descriptorset_create()
syntax
gh_vk.descriptorset_kill (
ds_id
)
parameters
ds_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.descriptorset_kill(ds_id)
syntax
gh_vk.descriptorset_push_constant_1f (
ds_id,
x,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
x REAL value of the constant
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
x = 0.25
offset = 0
gh_vk.descriptorset_push_constant_1f(ds_id, x, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_1i (
ds_id,
x,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
x INTEGER value of the constant
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
x = 2
offset = 0
gh_vk.descriptorset_push_constant_1i(ds_id, x, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_4f (
ds_id,
x, y, z, w,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
x, y, z, w REAL value of the constant
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
x = 0.25
y = 0.15
z = 0.0
w = 1.0
offset = 4
gh_vk.descriptorset_push_constant_4f(ds_id, x, y, z, w, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_4i (
ds_id,
x, y, z, w,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
x, y, z, w INTEGER value of the constant
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
x = 1
y = 2
z = 4
w = 8
offset = 4
gh_vk.descriptorset_push_constant_4i(ds_id, x, y, z, w, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_4x4f (
ds_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the 16 floats that make the 4x4 matrix
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
offset = 0
gh_vk.descriptorset_push_constant_4x4f(ds_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_camera_projection_matrix (
ds_id,
camera_id,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
camera_id INTEGER camera identifier
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
offset = 36
gh_vk.descriptorset_push_constant_camera_projection_matrix(ds_id, camera, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_camera_view_matrix (
ds_id,
camera_id,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
camera_id INTEGER camera identifier
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
offset = 20
gh_vk.descriptorset_push_constant_camera_view_matrix(ds_id, camera, offset, shader_stages)
syntax
gh_vk.descriptorset_push_constant_object_matrix (
ds_id,
object_id,
offset,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
object_id INTEGER object identifier
offset INTEGER offset of the value in bytes in the push constant buffer
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
offset = 20
gh_vk.descriptorset_push_constant_object_matrix(ds_id, mesh, offset, shader_stages)
syntax
gh_vk.descriptorset_update (
ds_id
)
parameters
ds_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.descriptorset_update(ds_id)
syntax
gh_vk.descriptorset_update_resource_gpu_buffer (
ds_id,
resource_index,
gpubuffer_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
resource_index INTEGER index of the resource in the descriptor set
gpubuffer_id INTEGER GPU buffer identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_VERTEX
binding_point = 0
gh_vk.descriptorset_update_resource_gpu_buffer(ds_id, resource_index, gpubuffer_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_update_resource_rt_color (
ds_id,
resource_index,
rt_id,
color_index,
sampler_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
resource_index INTEGER index of the resource in the descriptor set
rt_id INTEGER render target identifier
color_index INTEGER texture index in the render target
sampler_id INTEGER sampler identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_FRAGMENT
binding_point = 0
color_index = 0
gh_vk.descriptorset_update_resource_rt_color(ds_id, resource_index, rt_id, color_index, sampler_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_update_resource_storage_image (
ds_id,
resource_index,
storage_image_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
resource_index INTEGER index of the resource in the descriptor set
storage_image_id INTEGER storage image identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
SHADER_STAGE_RAYGEN = 256
SHADER_STAGE_ANY_HIT = 512
SHADER_STAGE_CLOSEST_HIT = 1024
SHADER_STAGE_MISS = 2048
SHADER_STAGE_INTERSECTION = 4096
shader_stages = SHADER_STAGE_RAYGEN
binding_point = 0
gh_vk.descriptorset_update_resource_storage_image(ds_id, resource_index, storage_image_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_update_resource_texture (
ds_id,
resource_index,
texture_id,
sampler_id,
binding_point,
shader_stages
)
parameters
ds_id INTEGER descriptor set identifier
resource_index INTEGER index of the resource in the descriptor set
texture_id INTEGER texture identifier
sampler_id INTEGER sampler identifier
binding_point INTEGER resource binding point in the shader
shader_stages INTEGER shader stages that must access to the resource
return values
none
code sample
SHADER_STAGE_VERTEX = 1
SHADER_STAGE_TESSELLATION_CONTROL = 2
SHADER_STAGE_TESSELLATION_EVALUATION = 4
SHADER_STAGE_GEOMETRY = 8
SHADER_STAGE_FRAGMENT = 16
SHADER_STAGE_COMPUTE = 32
SHADER_STAGE_TASK = 64
SHADER_STAGE_MESH = 128
shader_stages = SHADER_STAGE_FRAGMENT + SHADER_STAGE_VERTEX
binding_point = 0
gh_vk.descriptorset_update_resource_texture(ds_id, resource_index, texture_id, sampler_id, binding_point, shader_stages)
syntax
gh_vk.descriptorset_update_resource_texture_array (
ds_id,
resource_index,
texture_index,
texture_id,
sampler_id
)
parameters
ds_id INTEGER descriptor set identifier
resource_index INTEGER index of the resource in the descriptor set
texture_index INTEGER index of the texture in the texture array
texture_id INTEGER texture identifier
sampler_id INTEGER sampler identifier
return values
none
code sample
texture_count = 2
shader_stages = SHADER_STAGE_FRAGMENT
binding_point = 0
resource_index = gh_vk.descriptorset_add_resource_empty_texture_array(ds_id, texture_count, binding_point, shader_stages)
texture_index = 0
gh_vk.descriptorset_update_resource_texture_array(ds_id, resource_index, texture_index, texture1_id, sampler_id)
texture_index = 1
gh_vk.descriptorset_update_resource_texture_array(ds_id, resource_index, texture_index, texture2_id, sampler_id)
syntax
gh_vk.draw_mesh_tasks (
first_task,
task_count
)
parameters
first_task INTEGER first task - usually 0.
task_count INTEGER number of tasks to launch.
return values
none
code sample
gh_vk.draw_mesh_tasks(first_task, task_count)
syntax
x = gh_vk.driver_properties_khr_get_value_1i (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING property name: driverID, conformanceVersion_major, conformanceVersion_minor, conformanceVersion_patch, conformanceVersion_subminor
return values
x INTEGER value of the property
code sample
x = gh_vk.driver_properties_khr_get_value_1i(gpu_index, "driverID")
syntax
s = gh_vk.driver_properties_khr_get_value_str (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING property name: driverName, driverID_str, driverInfo
return values
s STRING value of the property
code sample
s = gh_vk.driver_properties_khr_get_value_str(gpu_index, "driverName")
syntax
num_gpus = gh_vk.get_num_gpus()
parameters
none
return values
num_gpus INTEGER number of GPUs.
code sample
num_gpus = gh_vk.get_num_gpus()
syntax
num_features = gh_vk.get_num_physical_device_features (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
num_features INTEGER number of features.
code sample
num_features = gh_vk.get_num_physical_device_features(gpu_index)
syntax
num_limits = gh_vk.get_num_physical_device_limits (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
num_limits INTEGER number of limits.
code sample
num_limits = gh_vk.get_num_physical_device_limits(gpu_index)
syntax
feature_index = gh_vk.get_physical_device_feature_index (
gpu_index,
name
)
parameters
gpu_index INTEGER index of the GPU.
name STRING name of a feature.
return values
feature_index INTEGER index of the feature.
code sample
feature_index = gh_vk.get_physical_device_feature_index(gpu_index, name)
syntax
name = gh_vk.get_physical_device_feature_name (
gpu_index,
feature_index
)
parameters
gpu_index INTEGER index of the GPU.
feature_index INTEGER index of the feature.
return values
name STRING name of a feature.
code sample
name = gh_vk.get_physical_device_feature_name(gpu_index, feature_index)
syntax
state = gh_vk.get_physical_device_feature_state (
gpu_index,
feature_index
)
parameters
gpu_index INTEGER index of the GPU.
feature_index INTEGER index of the feature.
return values
state INTEGER state of feature (0 or 1).
code sample
state = gh_vk.get_physical_device_feature_state(gpu_index, feature_index)
syntax
x, y, z = gh_vk.get_physical_device_limit_f32 (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
x, y, z REAL limit value
code sample
x, y, z = gh_vk.get_physical_device_limit_f32(gpu_index, limit_index)
syntax
limit_index = gh_vk.get_physical_device_limit_index (
gpu_index,
name
)
parameters
gpu_index INTEGER index of the GPU.
name STRING name of the limit
return values
limit_index INTEGER index of the limit.
code sample
limit_index = gh_vk.get_physical_device_limit_index(gpu_index, name)
syntax
name = gh_vk.get_physical_device_limit_name (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
name STRING name of the limit
code sample
name = gh_vk.get_physical_device_limit_name(gpu_index, limit_index)
syntax
x, y, z = gh_vk.get_physical_device_limit_s32 (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
x, y, z INTEGER signed integer limit value
code sample
x, y, z = gh_vk.get_physical_device_limit_s32(gpu_index, limit_index)
syntax
type = gh_vk.get_physical_device_limit_type (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
type STRING type of the limit: 1u32, 1s32, 1u64, 1f32, 3u32, 2u32, 2f32
code sample
type = gh_vk.get_physical_device_limit_type(gpu_index, limit_index)
syntax
x, y, z = gh_vk.get_physical_device_limit_u32 (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
x, y, z INTEGER unsigned integer limit value
code sample
x, y, z = gh_vk.get_physical_device_limit_u32(gpu_index, limit_index)
syntax
x, y, z = gh_vk.get_physical_device_limit_u64 (
gpu_index,
limit_index
)
parameters
gpu_index INTEGER index of the GPU.
limit_index INTEGER index of the limit.
return values
x, y, z INTEGER unsigned integer limit value
code sample
x, y, z = gh_vk.get_physical_device_limit_u64(gpu_index, limit_index)
syntax
major, minor, patch = gh_vk.gpu_get_api_version (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
major, minor, patch INTEGER version of the Vulkan API.
code sample
major, minor, patch = gh_vk.gpu_get_api_version(gpu_index)
syntax
vendor_id, device_id = gh_vk.gpu_get_device_id (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
vendor_id, device_id INTEGER vendor and device ID
code sample
vendor_id, device_id = gh_vk.gpu_get_device_id(gpu_index)
syntax
type = gh_vk.gpu_get_device_type (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
type INTEGER type of the Vulkan device
code sample
VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2
VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3
VK_PHYSICAL_DEVICE_TYPE_CPU = 4
type = gh_vk.gpu_get_device_type(gpu_index)
if (type == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) then
print("- device type: DISCRETE GPU")
end
syntax
extension_name = gh_vk.gpu_get_extension_name (
gpu_index,
extension_index
)
parameters
gpu_index INTEGER index of the GPU.
extension_index INTEGER index of the extension.
return values
extension_name STRING name of the extension.
code sample
name = gh_vk.gpu_get_extension_name(gpu_index, extension_index)
syntax
heap_size = gh_vk.gpu_get_heap_size (
gpu_index,
memory_heap_index
)
parameters
gpu_index INTEGER index of the GPU.
memory_heap_index INTEGER index of the memory heap.
return values
heap_size INTEGER size of the memory heap in bytes
code sample
heap_size = gh_vk.gpu_get_heap_size(gpu_index, memory_heap_index)
syntax
layer_name = gh_vk.gpu_get_layer_name (
gpu_index,
layer_index
)
parameters
gpu_index INTEGER index of the GPU.
layer_index INTEGER index of the layer.
return values
layer_name STRING name of the layer.
code sample
name = gh_vk.gpu_get_layer_name(gpu_index, layer_index)
syntax
num_gpus = gh_vk.gpu_get_name (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
num_gpus INTEGER number of GPUs.
code sample
name = gh_vk.gpu_get_name(gpu_index)
syntax
num_extensions = gh_vk.gpu_get_num_extensions (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
num_extensions INTEGER number of extensions.
code sample
num_extensions = gh_vk.gpu_get_num_extensions(gpu_index)
syntax
vendor_id, device_id = gh_vk.gpu_get_num_layers (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
vendor_id, device_id INTEGER vendor and device ID
code sample
num_layers = gh_vk.gpu_get_num_layers(gpu_index)
syntax
num_memory_heaps = gh_vk.gpu_get_num_memory_heaps (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
num_memory_heaps INTEGER number of memory heaps
code sample
num_memory_heaps = gh_vk.gpu_get_num_memory_heaps(gpu_index)
syntax
major, minor, patch, build = gh_vk.gpu_get_nvidia_driver_version (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
major, minor, patch, build INTEGER version of driver.
code sample
major, minor, patch, build = gh_vk.gpu_get_nvidia_driver_version(gpu_index)
syntax
is_supported = gh_vk.gpu_is_extension_supported (
gpu_index,
extension_name
)
parameters
gpu_index INTEGER index of the GPU.
extension_name STRING name of the extension.
return values
is_supported INTEGER 1 if supported, 0 if not.
code sample
is_supported = gh_vk.gpu_is_extension_supported(gpu_index, extension_name)
syntax
extension_name = gh_vk.instance_get_extension_name (
extension_index
)
parameters
extension_index INTEGER index of the extension.
return values
extension_name STRING name of the extension.
code sample
name = gh_vk.instance_get_extension_name(extension_index)
syntax
layer_name = gh_vk.instance_get_layer_name (
layer_index
)
parameters
layer_index INTEGER index of the layer.
return values
layer_name STRING name of the layer.
code sample
name = gh_vk.instance_get_layer_name(layer_index)
syntax
num_extensions = gh_vk.instance_get_num_extensions()
parameters
none
return values
num_extensions INTEGER number of extensions.
code sample
num_extensions = gh_vk.instance_get_num_extensions()
syntax
num_layers = gh_vk.instance_get_num_layers()
parameters
none
return values
num_layers INTEGER number of layers.
code sample
num_layers = gh_vk.instance_get_num_layers()
syntax
x, y, z = gh_vk.mesh_shader_get_property_value_nv (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING name of the property.
return values
x, y, z INTEGER value of the property
code sample
Possible properties:
"maxDrawMeshTasksCount" - return value: x, 0, 0
"maxTaskWorkGroupInvocations" - return value: x, 0, 0
"maxTaskWorkGroupSize" - return value: x,y, z
"maxTaskTotalMemorySize" - return value: x, 0, 0
"maxTaskOutputCount" - return value: x, 0, 0
"maxMeshWorkGroupInvocations" - return value: x, 0, 0
"maxMeshWorkGroupSize" - return value: x,y, z
"maxMeshTotalMemorySize" - return value: x, 0, 0
"maxMeshOutputVertices" - return value: x, 0, 0
"maxMeshOutputPrimitives" - return value: x, 0, 0
"maxMeshMultiviewViewCount" - return value: x, 0, 0
"meshOutputPerVertexGranularity" - return value: x, 0, 0
"meshOutputPerPrimitiveGranularity" - return value: x, 0, 0
x, y, z = gh_vk.mesh_shader_get_property_value_nv(gpu_index, "maxDrawMeshTasksCount")
pipeline_bind
Binds a pipeline.
syntax
gh_vk.pipeline_bind (
pipeline_id
)
parameters
pipeline_id INTEGER pipeline identifier
return values
none
code sample
gh_vk.pipeline_bind(pipeline)
pipeline_build
Builds a pipeline.
syntax
gh_vk.pipeline_build (
pipeline_id,
ds_id
)
parameters
pipeline_id INTEGER pipeline identifier
ds_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.pipeline_build(pipeline, ds_id)
pipeline_build_v2
Builds a pipeline.
syntax
gh_vk.pipeline_build_v2 (
pipeline_id,
ds_id,
rt_id
)
parameters
pipeline_id INTEGER pipeline identifier
ds_id INTEGER descriptor set identifier
rt_id INTEGER render target identifier
return values
none
code sample
gh_vk.pipeline_build_v2(pipeline, ds_id, rt_id)
pipeline_create
Creates a pipeline.
syntax
pipeline_id = gh_vk.pipeline_create (
pipeline_name,
gpu_program_id,
render_states_descr
)
parameters
pipeline_name STRING name of the pipeline
gpu_program_id INTEGER gpu program identifier
render_states_descr STRING reserved
return values
pipeline_id INTEGER pipeline identifier
code sample
pipeline = gh_vk.pipeline_create("phong_pipeline", phong_gpu_prog, "")
pipeline_kill
Destroys a pipeline.
syntax
gh_vk.pipeline_kill (
pipeline_id
)
parameters
pipeline_id INTEGER pipeline identifier
return values
none
code sample
gh_vk.pipeline_kill(pipeline)
syntax
gh_vk.pipeline_set_attrib_4f (
pipeline_id,
attrib_name,
x, y, z, w
)
parameters
pipeline_id INTEGER pipeline identifier
attrib_name STRING name of the atttribute - Possible values: DEPTH_BIAS, DEPTH_BIAS_CLAMP, DEPTH_BIAS_SLOPE_SCALED, LINE_WIDTH
x, y, z, w REAL value of the attribute
return values
none
code sample
gh_vk.pipeline_set_attrib_4f(pipeline, "LINE_WIDTH", 2.0, 0, 0, 0)
syntax
gh_vk.pipeline_set_attrib_4i (
pipeline_id,
attrib_name,
x, y, z, w
)
parameters
pipeline_id INTEGER pipeline identifier
attrib_name STRING name of the atttribute - Possible values: DEPTH_TEST, DEPTH_READ_ONLY, BLENDING, BLENDING_FACTORS_COLOR, FILL_MODE, PRIMITIVE_TYPE, CULL_MODE, CCW
x, y, z, w INTEGER value of the attribute
return values
none
code sample
local lib_dir = gh_utils.get_lib_dir()
dofile(lib_dir .. "lua/vk.lua")
...
gh_vk.pipeline_set_attrib_4i(pipeline, "DEPTH_TEST", 1, 0, 0, 0)
gh_vk.pipeline_set_attrib_4i(pipeline, "FILL_MODE", POLYGON_MODE_SOLID, 0, 0, 0)
gh_vk.pipeline_set_attrib_4i(pipeline, "PRIMITIVE_TYPE", PRIMITIVE_TRIANGLE, 0, 0, 0)
gh_vk.pipeline_set_attrib_4i(pipeline, "CULL_MODE", POLYGON_FACE_NONE, 0, 0, 0)
...
syntax
x = gh_vk.raytracing_acceleration_structure_get_property_value_u32 (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING name of the property.
return values
x INTEGER value of the property
code sample
Possible properties:
"maxPerStageDescriptorAccelerationStructures"
"maxPerStageDescriptorUpdateAfterBindAccelerationStructures"
"maxDescriptorSetAccelerationStructures"
"maxDescriptorSetUpdateAfterBindAccelerationStructures"
"minAccelerationStructureScratchOffsetAlignment"
x = gh_vk.raytracing_acceleration_structure_get_property_value_u32(gpu_index, "maxDescriptorSetAccelerationStructures")
syntax
x = gh_vk.raytracing_acceleration_structure_get_property_value_u64 (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING name of the property.
return values
x INTEGER value of the property
code sample
Possible properties:
"maxGeometryCount"
"maxInstanceCount"
"maxPrimitiveCount"
x = gh_vk.raytracing_acceleration_structure_get_property_value_u64(gpu_index, "maxGeometryCount")
raytracing_blas_add_geometry
syntax
blas_index = gh_vk.raytracing_blas_add_geometry (
rt_index,
mesh_id
)
parameters
rt_index INTEGER index of the raytracing opaque object
mesh_id INTEGER identifier of a mesh.
return values
blas_index INTEGER index of the blas
code sample
blas_index = gh_vk.raytracing_blas_add_geometry(rt_index, mesh_id)
syntax
ret = gh_vk.raytracing_build_blas (
rt_index
)
parameters
rt_index INTEGER index of the raytracing opaque object
return values
ret INTEGER 1 if ok or 0 if error
code sample
ret = gh_vk.raytracing_build_blas(rt_index)
syntax
gh_vk.raytracing_build_tlas (
rt_index
)
parameters
rt_index INTEGER index of the raytracing opaque object
return values
none
code sample
gh_vk.raytracing_build_tlas(rt_index)
raytracing_descriptorset_bind
syntax
gh_vk.raytracing_descriptorset_bind (
command_buffer,
descriptor_set_id
)
parameters
command_buffer INTEGER command buffer identifier
descriptor_set_id INTEGER descriptor set identifier
return values
none
code sample
gh_vk.raytracing_descriptorset_bind(command_buffer, descriptor_set_id)
syntax
rt_index = gh_vk.raytracing_new (
gpu_index
)
parameters
gpu_index INTEGER index of the GPU.
return values
rt_index INTEGER index of the new raytracing opaque object
code sample
gpu_index = gh_vk.get_current_gpu()
rt_index = gh_vk.raytracing_new()
syntax
gh_vk.raytracing_pipeline_bind (
command_buffer,
pipeline_id
)
parameters
command_buffer INTEGER command buffer identifier
pipeline_id INTEGER pipeline identifier
return values
none
code sample
gh_vk.raytracing_pipeline_bind(command_buffer, pipeline_id)
raytracing_pipeline_build
syntax
gh_vk.raytracing_pipeline_build (
rt_index,
pipeline_id,
rt_ds,
render_target_id
)
parameters
rt_index INTEGER index of the raytracing opaque object
pipeline_id INTEGER pipeline identifier
rt_ds INTEGER descriptor set identifier
render_target_id INTEGER render target identifier. Can be 0 if not used.
return values
none
code sample
rt_pipeline = gh_vk.pipeline_create("rt_pipeline", raytracing_prog, "")
rt_pipeline_ok = gh_vk.raytracing_pipeline_build(rt_index, rt_pipeline, rt_ds, 0)
syntax
x = gh_vk.raytracing_pipeline_get_property_value_u32 (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING name of the property.
return values
x INTEGER value of the property
code sample
Possible properties:
"shaderGroupHandleSize"
"maxRayRecursionDepth"
"maxShaderGroupStride"
"shaderGroupBaseAlignment"
"shaderGroupHandleCaptureReplaySize"
"maxRayDispatchInvocationCount"
"shaderGroupHandleAlignment"
"maxRayHitAttributeSize"
x = gh_vk.raytracing_pipeline_get_property_value_u32(gpu_index, "maxRayRecursionDepth")
syntax
gh_vk.raytracing_raytrace (
rt_index,
width, height,
render_target_id,
color_target_index
)
parameters
rt_index INTEGER index of the raytracing opaque object
width, height INTEGER
render_target_id INTEGER render target identifier. Can be 0 if not used.
color_target_index INTEGER index of the color target in the render target.
return values
none
code sample
gh_vk.raytracing_raytrace(rt_index, width, height, 0, 0)
raytracing_set_ray_recursion_depth
syntax
gh_vk.raytracing_set_ray_recursion_depth (
rt_index,
recursion_depth
)
parameters
rt_index INTEGER index of the raytracing opaque object
recursion_depth INTEGER recursion depth
return values
none
code sample
gh_vk.raytracing_set_ray_recursion_depth(rt_index, recursion_depth)
raytracing_shader_binding_table_build
syntax
gh_vk.raytracing_shader_binding_table_build (
rt_index,
pipeline_id
)
parameters
rt_index INTEGER index of the raytracing opaque object
pipeline_id INTEGER pipeline identifier
return values
none
code sample
gh_vk.raytracing_shader_binding_table_build(rt_index, pipeline_id)
raytracing_tlas_add_instance_data
syntax
instance_index = gh_vk.raytracing_tlas_add_instance_data (
rt_index,
mesh_id,
blas_index,
hit_group_index,
visibility_mask
)
parameters
rt_index INTEGER index of the raytracing opaque object
mesh_id INTEGER identifier of a mesh.
blas_index INTEGER index of the blas.
hit_group_index INTEGER
visibility_mask INTEGER
return values
instance_index INTEGER index of the new instance
code sample
instance_index = gh_vk.raytracing_tlas_add_instance_data(rt_index, mesh_id, blas_index, hit_group_index, visibility_mask)
raytracing_tlas_add_instance_data_v2
syntax
instance_index = gh_vk.raytracing_tlas_add_instance_data_v2 (
rt_index,
pos_x, pos_y, pos_z,
pitch, yaw, roll,
scale_x, scale_y, scale_z,
transform_order,
blas_index,
hit_group_index,
visibility_mask
)
parameters
rt_index INTEGER index of the raytracing opaque object
pos_x, pos_y, pos_z REAL position.
pitch, yaw, roll REAL orientation using Euler's angles.
scale_x, scale_y, scale_z REAL scale.
transform_order INTEGER transformatzion order to build the transformation matrix.
blas_index INTEGER index of the blas.
hit_group_index INTEGER
visibility_mask INTEGER
return values
instance_index INTEGER index of the new instance
code sample
TRANSFORM_ORDER_TRS = 0 --default.
TRANSFORM_ORDER_RTS = 1
TRANSFORM_ORDER_TSR = 2
TRANSFORM_ORDER_RST = 3
instance_index = gh_vk.raytracing_tlas_add_instance_data_v2(rt_index, pos_x, pos_y, pos_z, pitch, yaw, roll, scale_x, scale_y, scale_z, TRANSFORM_ORDER_TRS, blas_index, hit_group_index, visibility_mask)
raytracing_tlas_add_instance_data_v3
syntax
instance_index = gh_vk.raytracing_tlas_add_instance_data_v3 (
rt_index,
pos_x, pos_y, pos_z,
qx, qy, qz, qw,
scale_x, scale_y, scale_z,
transform_order,
blas_index,
hit_group_index,
visibility_mask
)
parameters
rt_index INTEGER index of the raytracing opaque object
pos_x, pos_y, pos_z REAL position.
qx, qy, qz, qw REAL orientation using a quaternion.
scale_x, scale_y, scale_z REAL scale.
transform_order INTEGER transformation order to build the transformation matrix.
blas_index INTEGER index of the blas.
hit_group_index INTEGER
visibility_mask INTEGER
return values
instance_index INTEGER index of the new instance
code sample
TRANSFORM_ORDER_TRS = 0 --default.
TRANSFORM_ORDER_RTS = 1
TRANSFORM_ORDER_TSR = 2
TRANSFORM_ORDER_RST = 3
instance_index = gh_vk.raytracing_tlas_add_instance_data_v3(rt_index, pos_x, pos_y, pos_z, qx, qy, qz, qw, scale_x, scale_y, scale_z, TRANSFORM_ORDER_TRS, blas_index, hit_group_index, visibility_mask)
raytracing_tlas_add_instance_data_v4
syntax
instance_index = gh_vk.raytracing_tlas_add_instance_data_v4 (
rt_index,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,
blas_index,
hit_group_index,
visibility_mask
)
parameters
rt_index INTEGER index of the raytracing opaque object
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL transformation matrix
blas_index INTEGER index of the blas.
hit_group_index INTEGER
visibility_mask INTEGER
return values
instance_index INTEGER index of the new instance
code sample
instance_index = gh_vk.raytracing_tlas_add_instance_data_v4(rt_index, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15, blas_index, hit_group_index, visibility_mask)
raytracing_tlas_update_instance_transform
syntax
gh_vk.raytracing_tlas_update_instance_transform (
rt_index,
instance_index,
mesh_id
)
parameters
rt_index INTEGER index of the raytracing opaque object
instance_index INTEGER index of the instance
mesh_id INTEGER identifier of a mesh.
return values
none
code sample
gh_vk.raytracing_tlas_update_instance_transform(rt_index, instance_index, mesh_id)
raytracing_tlas_update_instance_transform_v2
syntax
gh_vk.raytracing_tlas_update_instance_transform_v2 (
rt_index,
instance_index,
pos_x, pos_y, pos_z,
pitch, yaw, roll,
scale_x, scale_y, scale_z,
transform_order
)
parameters
rt_index INTEGER index of the raytracing opaque object
instance_index INTEGER index of the instance
pos_x, pos_y, pos_z REAL position.
pitch, yaw, roll REAL orientation using Euler's angles.
scale_x, scale_y, scale_z REAL scale.
transform_order INTEGER transformation order to build the transformation matrix.
return values
none
code sample
TRANSFORM_ORDER_TRS = 0 --default.
TRANSFORM_ORDER_RTS = 1
TRANSFORM_ORDER_TSR = 2
TRANSFORM_ORDER_RST = 3
gh_vk.raytracing_tlas_update_instance_transform_v2(rt_index, instance_index, pos_x, pos_y, pos_z, pitch, yaw, roll, scale_x, scale_y, scale_z, TRANSFORM_ORDER_TRS)
raytracing_tlas_update_instance_transform_v3
syntax
gh_vk.raytracing_tlas_update_instance_transform_v3 (
rt_index,
instance_index,
pos_x, pos_y, pos_z,
qx, qy, qz, qw,
scale_x, scale_y, scale_z,
transform_order
)
parameters
rt_index INTEGER index of the raytracing opaque object
instance_index INTEGER index of the instance
pos_x, pos_y, pos_z REAL position.
qx, qy, qz, qw REAL orientation using a quaternion.
scale_x, scale_y, scale_z REAL scale.
transform_order INTEGER transformation order to build the transformation matrix.
return values
none
code sample
TRANSFORM_ORDER_TRS = 0 --default.
TRANSFORM_ORDER_RTS = 1
TRANSFORM_ORDER_TSR = 2
TRANSFORM_ORDER_RST = 3
gh_vk.raytracing_tlas_update_instance_transform_v3(rt_index, instance_index, pos_x, pos_y, pos_z, qx, qy, qz, qw, scale_x, scale_y, scale_z, TRANSFORM_ORDER_TRS)
raytracing_tlas_update_instance_transform_v4
syntax
gh_vk.raytracing_tlas_update_instance_transform_v4 (
rt_index,
instance_index,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
rt_index INTEGER index of the raytracing opaque object
instance_index INTEGER index of the instance
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL transformation matrix
return values
none
code sample
gh_vk.raytracing_tlas_update_instance_transform_v4(rt_index, instance_index, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_vk.raytracing_update_tlas (
rt_index
)
parameters
rt_index INTEGER index of the raytracing opaque object
return values
none
code sample
gh_vk.raytracing_update_tlas(rt_index)
render_pass_begin
Begins a render pass.
syntax
gh_vk.render_pass_begin (
cmdbuf_id,
is_secondary_cmd
)
parameters
cmdbuf_id INTEGER command buffer identifier
is_secondary_cmd INTEGER 1 if secondary command buffer or 0 otherwise (main command buffer).
return values
none
code sample
gh_vk.render_pass_begin(cmdbuf_id, 0)
render_pass_begin_v2
Begins a render pass.
syntax
gh_vk.render_pass_begin_v2 (
cmdbuf_id,
swapchain_buffer_index,
is_secondary_cmd
)
parameters
cmdbuf_id INTEGER command buffer identifier
swapchain_buffer_index INTEGER index of a swapchain buffer
is_secondary_cmd INTEGER 1 if secondary command buffer or 0 otherwise (main command buffer).
return values
none
code sample
gh_vk.render_pass_begin_v2(cmdbuf_id, swapchain_buffer_index, 0)
render_pass_begin_v3
Begins a render pass.
syntax
gh_vk.render_pass_begin_v3 (
cmdbuf_id,
r, g, b, a,
z,
swapchain_buffer_index,
is_secondary_cmd
)
parameters
cmdbuf_id INTEGER command buffer identifier
r, g, b, a REAL color buffer clear value
z REAL depth buffer clear value
swapchain_buffer_index INTEGER index of a swapchain buffer
is_secondary_cmd INTEGER 1 if secondary command buffer or 0 otherwise (main command buffer).
return values
none
code sample
gh_vk.render_pass_begin_v3(cmdbuf_id, 0, 0, 0, 1, 1, swapchain_buffer_index, 0)
render_pass_end
Ends a render pass.
syntax
gh_vk.render_pass_end (
cmdbuf_id
)
parameters
cmdbuf_id INTEGER command buffer identifier
return values
none
code sample
gh_vk.render_pass_end(cmdbuf_id)
syntax
sampler_id = gh_vk.sampler_create (
filtering_mode,
addressing_mode,
anisotropy,
_reserved_
)
parameters
filtering_mode STRING filtering mode: NONE, LINEAR, TRILINEAR
addressing_mode STRING filtering mode: WRAP (or REPEAT), MIRROR, CLAMP
anisotropy REAL anisotropy value (1.0 ; 16.0)
_reserved_ INTEGER reserved - set it to 0
return values
sampler_id INTEGER sampler identifier
code sample
anisotropy = 1.0
sampler_id = gh_vk.sampler_create("LINEAR", "REPEAT", anisotropy, 0)
sampler_kill
Kills a texture sampler.
syntax
gh_vk.sampler_kill (
sampler_id
)
parameters
sampler_id INTEGER sampler identifier
return values
none
code sample
gh_vk.sampler_kill(sampler_id)
syntax
gh_vk.set_viewport_scissor (
x, y, w, h
)
parameters
x, y, w, h INTEGER position (x, y) and size (w, h) of the current viewport. This information is recorded in the current command buffer (see command_buffer_begin).
return values
none
code sample
gh_vk.set_viewport_scissor(0, 0, winW, winH)
syntax
x = gh_vk.shader_core_properties_amd_get_value (
gpu_index,
property_name
)
parameters
gpu_index INTEGER index of the GPU.
property_name STRING property name: shaderEngineCount, shaderArraysPerEngineCount, computeUnitsPerShaderArray, simdPerComputeUnit, wavefrontsPerSimd, wavefrontSize, sgprsPerSimd, minSgprAllocation, maxSgprAllocation, sgprAllocationGranularity, vgprsPerSimd, minVgprAllocation, maxVgprAllocation, vgprAllocationGranularity
return values
x INTEGER value of the property
code sample
x = gh_vk.shader_core_properties_amd_get_value(gpu_index, "shaderEngineCount")
syntax
cur_image = gh_vk.swapchain_get_current_image_index()
parameters
none
return values
cur_image INTEGER index of the current image
code sample
cur_image = gh_vk.swapchain_get_current_image_index()
syntax
num_images = gh_vk.swapchain_get_image_count()
parameters
none
return values
num_images INTEGER number of images
code sample
num_images = gh_vk.swapchain_get_image_count()
syntax
has_changed = gh_vk.swapchain_has_changed()
parameters
none
return values
has_changed INTEGER 1 if swapchain has changed, 0 if not
code sample
has_changed = gh_vk.swapchain_has_changed()
syntax
gh_vk.wait_for_gpu()
parameters
none
return values
none
code sample
gh_vk.wait_for_gpu()