GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



» 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: 17



gh_vertex_pool.create

Description

Creates a vertex pool.

Languages

Lua - Python

Parameters

  • num_vertices [INTEGER]: number of vertices in the vertex pool.

    Return Values

  • vp_id [INTEGER]: vertex pool identifier

    Code sample


    vp = gh_vertex_pool.create(1000)



    gh_vertex_pool.vertex_set_position

    Description

    Sets the position of a particular vertex.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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, index, x, y, z, 1.0)



    gh_vertex_pool.vertex_set_color

    Description

    Sets the color of a particular vertex.

    Languages

    Lua - Python

    Parameters

  • 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.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.vertex_set_color(vp, index, r, g, b, a)



    gh_vertex_pool.render

    Description

    Renders a vertex pool.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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, 0, -1)



    gh_vertex_pool.vb_map

    Description

    Maps the GPU memory of the vertex buffer into CPU address space.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.vb_map(vp)



    gh_vertex_pool.vb_unmap

    Description

    Unmaps the GPU memory of the vertex buffer.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.vb_unmap(vp)



    gh_vertex_pool.vb_set_vertex_position

    Description

    Sets the position of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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)
    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

    Description

    Gets the position of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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, offset)



    gh_vertex_pool.vb_set_vertex_color

    Description

    Sets the color of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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)
    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

    Description

    Gets the color of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.
  • index [INTEGER]: vertex index.

    Return Values

  • r, g, b, a [REAL]: RGBA color.

    Code sample


    r, g, b, a = gh_vertex_pool.vb_get_vertex_color(vp, offset)



    gh_vertex_pool.vb_set_vertex_normal

    Description

    Sets the normal of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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)
    gh_vertex_pool.vb_set_vertex_normal(vp, vertex_index, x, y, z, w)
    gh_vertex_pool.vb_unmap(vp)



    gh_vertex_pool.vb_get_vertex_normal

    Description

    Gets the normal of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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, offset)



    gh_vertex_pool.vb_set_vertex_tangent

    Description

    Sets the tangent of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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)
    gh_vertex_pool.vb_set_vertex_tangent(vp, vertex_index, x, y, z, w)
    gh_vertex_pool.vb_unmap(vp)



    gh_vertex_pool.vb_get_vertex_tangent

    Description

    Gets the tangent of a vertex in a mapped GPU memory.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: 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, offset)



    gh_vertex_pool.vertices_to_gpu_buffer

    Description

    Copies all vertices to a GPU buffer.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.
  • gpu_buffer_id [INTEGER]: GPU buffer identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.vertices_to_gpu_buffer(vp, gpu_buffer_id)



    gh_vertex_pool.vertices_from_gpu_buffer

    Description

    Copies all vertices from a GPU buffer to a vertex pool.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.
  • gpu_buffer_id [INTEGER]: GPU buffer identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.vertices_from_gpu_buffer(vp, gpu_buffer_id)



    gh_vertex_pool.set_vertex_source

    Description

    Set the source of the vertices of a vertex pool.

    Languages

    Lua - Python

    Parameters

  • vp [INTEGER]: vertex pool identifier.
  • gpu_buffer_id [INTEGER]: GPU buffer identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_vertex_pool.set_vertex_source(vp, gpu_buffer_id)





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.