 Reference Guide Host-API Lua / Python
» Back to Homepage
» Back to Developer's Guide Index
gh_vertex_pool Library
gh_vertex_pool is the module that manages a pool of vertices (or an array of vertices).
Number of functions: 10
gh_vertex_pool.create
Creates a vertex pool.
: Lua - Python
num_vertices [INTEGER]: number of vertices in the vertex pool.
vp_id [INTEGER]: vertex pool identifier
:
vp = gh_vertex_pool.create(1000)
gh_vertex_pool.vertex_set_position
Sets the position of a particular vertex.
: Lua - Python
: vertex_setpos
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: index of the vertex from 0 to num_vertices-1.
x, y, z, w [REAL]: 3D position of the vertex.
:
gh_vertex_pool.vertex_set_position(vp, index, x, y, z, 1.0)
gh_vertex_pool.vertex_set_color
Sets the color of a particular vertex.
: Lua - Python
: vertex_setcol
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: index of the vertex from 0 to num_vertices-1.
r, g, b, a [REAL]: RGBA color of the vertex.
:
gh_vertex_pool.vertex_set_color(vp, index, r, g, b, a)
gh_vertex_pool.render
Renders a vertex pool.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
start_index [INTEGER]: index of first vertex. Sets it to 0 to render all vertices.
:
gh_vertex_pool.render(vp, 0)
gh_vertex_pool.vb_map
Maps the GPU memory of the vertex buffer into CPU address space.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
:
gh_vertex_pool.vb_map(vp)
gh_vertex_pool.vb_unmap
Unmaps the GPU memory of the vertex buffer.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
:
gh_vertex_pool.vb_unmap(vp)
gh_vertex_pool.vb_set_vertex_position
Sets the position of a vertex in a mapped GPU memory.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: vertex index.
x, y, z, w [REAL]: 4D position.
:
gh_vertex_pool.vb_map(vp)
for i=0, z_max-1 do
for j=0, x_max-1 do
local offset = i*z_max + j
x, y, z, w = gh_vertex_pool.vb_get_vertex_position(vp, offset)
y1 = 2.0 * math.cos(elapsed_time + x * 0.1) + math.sin(elapsed_time + z * 0.1);
y2 = 2.0 * math.sin(elapsed_time + x * 0.1) + math.cos(elapsed_time + z * 0.1);
gh_vertex_pool.vb_set_vertex_position(vp, offset, x, y1+y2, z, w)
end
end
gh_vertex_pool.vb_unmap(vp)
gh_vertex_pool.vb_get_vertex_position
Gets the position of a vertex in a mapped GPU memory.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: vertex index.
x, y, z, w [REAL]: 4D position.
:
x, y, z, w = gh_vertex_pool.vb_get_vertex_position(vp, offset)
gh_vertex_pool.vb_set_vertex_color
Sets the color of a vertex in a mapped GPU memory.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: vertex index.
r, g, b, a [REAL]: RGBA color.
:
gh_vertex_pool.vb_map(vp)
for i=0, z_max-1 do
for j=0, x_max-1 do
local offset = i*z_max + j
r, g, b, a = gh_vertex_pool.vb_get_vertex_color(vp, offset)
-- Do some stuff with r, g, b, a.
-- ...
gh_vertex_pool.vb_set_vertex_color(vp, offset, r, g, b, a)
end
end
gh_vertex_pool.vb_unmap(vp)
gh_vertex_pool.vb_get_vertex_color
Gets the color of a vertex in a mapped GPU memory.
: Lua - Python
vp [INTEGER]: vertex pool identifier.
index [INTEGER]: vertex index.
r, g, b, a [REAL]: RGBA color.
:
r, g, b, a = gh_vertex_pool.vb_get_vertex_color(vp, offset)
|