< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_vertex_pool library
Description
gh_vertex_pool is the module that manages a pool of vertices (or an array of vertices).
Number of functions: 19
- gh_vertex_pool.create ()
- gh_vertex_pool.render ()
- gh_vertex_pool.set_vertex_source ()
- gh_vertex_pool.vb_get_vertex_color ()
- gh_vertex_pool.vb_get_vertex_normal ()
- gh_vertex_pool.vb_get_vertex_position ()
- gh_vertex_pool.vb_get_vertex_tangent ()
- gh_vertex_pool.vb_map ()
- gh_vertex_pool.vb_set_vertex_color ()
- gh_vertex_pool.vb_set_vertex_normal ()
- gh_vertex_pool.vb_set_vertex_position ()
- gh_vertex_pool.vb_set_vertex_tangent ()
- gh_vertex_pool.vb_unmap ()
- gh_vertex_pool.vertex_get_color ()
- gh_vertex_pool.vertex_get_position ()
- gh_vertex_pool.vertex_set_color ()
- gh_vertex_pool.vertex_set_position ()
- gh_vertex_pool.vertices_from_gpu_buffer ()
- gh_vertex_pool.vertices_to_gpu_buffer ()
create
Description
Creates a vertex pool.
Syntax
vp_id = gh_vertex_pool.create(
num_vertices
)
Languages
Parameters
- num_vertices [INTEGER]: number of vertices in the vertex pool
Return Values
- vp_id [ID]: vertex pool identifier
Code sample
vp_id = gh_vertex_pool.create(1000)
render
Description
Renders a vertex pool.
Syntax
gh_vertex_pool.render(
vp_id,
start_vertex,
num_vertices
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- start_vertex [INTEGER]: index of first vertex. Usually = 0
- num_vertices [INTEGER]: number of vertices to render. Set it to -1 to render from start_vertex to the last vertex.
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.render(vp_id, 0, -1)
set_vertex_source
Description
Set the source of the vertices of a vertex pool.
Syntax
gh_vertex_pool.set_vertex_source(
vp_id,
gpubuff_id
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.set_vertex_source(vp_id, gpu_buffer_id)
vb_get_vertex_color
Description
Gets the color of a vertex in a mapped GPU memory.
Syntax
r, g, b, a = gh_vertex_pool.vb_get_vertex_color(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
Return Values
- r, g, b, a [REAL]: RGBA color value
Code sample
r, g, b, a = gh_vertex_pool.vb_get_vertex_color(vp_id, index)
vb_get_vertex_normal
Description
Gets the normal of a vertex in a mapped GPU memory.
Syntax
x, y, z, w = gh_vertex_pool.vb_get_vertex_normal(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
Return Values
- x, y, z, w [REAL]: 4D vector
Code sample
x, y, z, w = gh_vertex_pool.vb_get_vertex_normal(vp_id, index)
vb_get_vertex_position
Description
Gets the position of a vertex in a mapped GPU memory.
Syntax
x, y, z, w = gh_vertex_pool.vb_get_vertex_position(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
Return Values
- x, y, z, w [REAL]: 4D position
Code sample
x, y, z, w = gh_vertex_pool.vb_get_vertex_position(vp_id, index)
vb_get_vertex_tangent
Description
Gets the tangent of a vertex in a mapped GPU memory.
Syntax
x, y, z, w = gh_vertex_pool.vb_get_vertex_tangent(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
Return Values
- x, y, z, w [REAL]: 4D vector
Code sample
x, y, z, w = gh_vertex_pool.vb_get_vertex_tangent(vp_id, index)
vb_map
Description
Maps the GPU memory of the vertex buffer into CPU address space. Once the vertex buffer is mapped, you can use gh_vertex_pool functions for reading and writing or you can use memory buffer functions of the gh_utils library.
Syntax
buff_ptr, buff_size = gh_vertex_pool.vb_map(
vp_id
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
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_vertex_pool.vb_map(vp_id)
if (buffer_size > 0) then
--
-- do read/write ops with the buffer.
--
index = 0
x, y, z, w = gh_utils.buffer_read_4f(buffer_ptr, index)
z = z * 2.0
gh_utils.buffer_write_4f(buffer_ptr, 0, x, y, z, w)
end
gh_vertex_pool.vb_unmap(vp_id)
vb_set_vertex_color
Description
Sets the color of a vertex in a mapped GPU memory.
Syntax
gh_vertex_pool.vb_set_vertex_color(
vp_id,
index,
r, g, b, a
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vb_map(vp_id)
for i=0, z_max-1 do
for j=0, x_max-1 do
local index = i*z_max + j
r, g, b, a = gh_vertex_pool.vb_get_vertex_color(vp_id, index)
...
... do some stuff with r, g, b, a.
...
gh_vertex_pool.vb_set_vertex_color(vp_id, index, r, g, b, a)
end
end
gh_vertex_pool.vb_unmap(vp_id)
vb_set_vertex_normal
Description
Sets the normal of a vertex in a mapped GPU memory.
Syntax
gh_vertex_pool.vb_set_vertex_normal(
vp_id,
index,
x, y, z, w
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
- x, y, z, w [REAL]: 4D vector
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vb_map(vp_id)
gh_vertex_pool.vb_set_vertex_normal(vp_id, index, x, y, z, w)
gh_vertex_pool.vb_unmap(vp_id)
vb_set_vertex_position
Description
Sets the position of a vertex in a mapped GPU memory.
Syntax
gh_vertex_pool.vb_set_vertex_position(
vp_id,
index,
x, y, z, w
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
- x, y, z, w [REAL]: 4D position
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vb_map(vp_id)
for i=0, z_max-1 do
for j=0, x_max-1 do
local index = i*z_max + j
x, y, z, w = gh_vertex_pool.vb_get_vertex_position(vp_id, index)
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_id, index, x, y1+y2, z, w)
end
end
gh_vertex_pool.vb_unmap(vp_id)
vb_set_vertex_tangent
Description
Sets the tangent of a vertex in a mapped GPU memory.
Syntax
gh_vertex_pool.vb_set_vertex_tangent(
vp_id,
index,
x, y, z, w
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: vertex index
- x, y, z, w [REAL]: 4D vector
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vb_map(vp_id)
gh_vertex_pool.vb_set_vertex_tangent(vp_id, index, x, y, z, w)
gh_vertex_pool.vb_unmap(vp_id)
vb_unmap
Description
Unmaps the GPU memory of the vertex buffer.
Syntax
gh_vertex_pool.vb_unmap(
vp_id
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vb_unmap(vp_id)
vertex_get_color
Description
Gets the color of a particular vertex.
Syntax
r, g, b, a = gh_vertex_pool.vertex_get_color(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: index of the vertex from 0 to num_vertices-1
Return Values
- r, g, b, a [REAL]: RGBA color of the vertex
Code sample
r, g, b, a = gh_vertex_pool.vertex_get_color(vp_id, index)
vertex_get_position
Description
Gets the position of a particular vertex.
Syntax
x, y, z, w = gh_vertex_pool.vertex_get_position(
vp_id,
index
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: index of the vertex from 0 to num_vertices-1
Return Values
- x, y, z, w [REAL]: 4D position of the vertex
Code sample
x, y, z, w = gh_vertex_pool.vertex_get_position(vp_id, index)
vertex_set_color
Description
Sets the color of a particular vertex.
Syntax
gh_vertex_pool.vertex_set_color(
vp_id,
index,
r, g, b, a
)
Languages
Parameters
- vp_id [ID]: 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
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vertex_set_color(vp_id, index, r, g, b, a)
vertex_set_position
Description
Sets the position of a particular vertex.
Syntax
gh_vertex_pool.vertex_set_position(
vp_id,
index,
x, y, z, w
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- index [INTEGER]: index of the vertex from 0 to num_vertices-1
- x, y, z, w [REAL]: 4D position of the vertex
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vertex_set_position(vp_id, index, x, y, z, 1.0)
vertices_from_gpu_buffer
Description
Copies all vertices from a GPU buffer to a vertex pool.
Syntax
gh_vertex_pool.vertices_from_gpu_buffer(
vp_id,
gpubuff_id
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vertices_from_gpu_buffer(vp_id, gpu_buffer_id)
vertices_to_gpu_buffer
Description
Copies all vertices to a GPU buffer.
Syntax
gh_vertex_pool.vertices_to_gpu_buffer(
vp_id,
gpubuff_id
)
Languages
Parameters
- vp_id [ID]: vertex pool identifier
- gpubuff_id [ID]: gpu buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vertex_pool.vertices_to_gpu_buffer(vp_id, gpu_buffer_id)
| |