Quick Links
- Homepage
- Downloads
- Code Sample Pack
- Gallery
- Forum

Documentation
- Overview
- GLSL Programs
- Live Coding
- Hack your first
  GLSL program

- Reference guide

Follow GLSL Hacker

GLSL Hacker @ Twitter

GLSL Hacker

Reference Guide
Host-API Lua / Python



» Back to Homepage
» Back to Developer's 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: 10

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

    Alias: vertex_setpos

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

    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

    Alias: vertex_setcol

    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.

    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_index [INTEGER]: index of first vertex. Sets it to 0 to render all vertices.

    Code sample :

    gh_vertex_pool.render(vp, 0)


    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.

    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.

    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.

    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.

    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)






  • (C)2012 Geeks3D