< 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

  1. gh_vertex_pool.create ()
  2. gh_vertex_pool.render ()
  3. gh_vertex_pool.set_vertex_source ()
  4. gh_vertex_pool.vb_get_vertex_color ()
  5. gh_vertex_pool.vb_get_vertex_normal ()
  6. gh_vertex_pool.vb_get_vertex_position ()
  7. gh_vertex_pool.vb_get_vertex_tangent ()
  8. gh_vertex_pool.vb_map ()
  9. gh_vertex_pool.vb_set_vertex_color ()
  10. gh_vertex_pool.vb_set_vertex_normal ()
  11. gh_vertex_pool.vb_set_vertex_position ()
  12. gh_vertex_pool.vb_set_vertex_tangent ()
  13. gh_vertex_pool.vb_unmap ()
  14. gh_vertex_pool.vertex_get_color ()
  15. gh_vertex_pool.vertex_get_position ()
  16. gh_vertex_pool.vertex_set_color ()
  17. gh_vertex_pool.vertex_set_position ()
  18. gh_vertex_pool.vertices_from_gpu_buffer ()
  19. gh_vertex_pool.vertices_to_gpu_buffer ()



create

Description

Creates a vertex pool.


Syntax

vp_id = gh_vertex_pool.create(
 num_vertices
)

Languages


Parameters


Return Values


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


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


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


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


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


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


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


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


Return Values


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


Return Values


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


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


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


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


Return Values

This function has no return value(s).


Code sample


gh_vertex_pool.vertices_to_gpu_buffer(vp_id, gpu_buffer_id)
			






GeeXLab Rootard Guide | Downloads | Contact