< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_vb library
Description
gh_vb is a module that manages OpenGL vertex buffers. gh_vb allows to create, set values and render simple vertex buffers.
Number of functions: 16
- gh_vb.bind ()
- gh_vb.create ()
- gh_vb.draw_lines ()
- gh_vb.draw_points ()
- gh_vb.draw_triangles ()
- gh_vb.kill ()
- gh_vb.map ()
- gh_vb.set_value_1f ()
- gh_vb.set_value_1ui ()
- gh_vb.set_value_2f ()
- gh_vb.set_value_3f ()
- gh_vb.set_value_4f ()
- gh_vb.set_value_4x4f ()
- gh_vb.set_vertex_attrib_data ()
- gh_vb.unbind ()
- gh_vb.unmap ()
bind
Description
Binds a vertex buffer.
Syntax
gh_vb.bind(
vb_id
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vb.bind(vb_id)
create
Description
Creates a vertex buffer.
Syntax
vb_id = gh_vb.create(
buff_size,
num_vertex_attribs
)
Languages
Parameters
- buff_size [INTEGER]: size of the vertex buffer in bytes
- num_vertex_attribs [INTEGER]: number of vertex attribs
Return Values
- vb_id [ID]: vertex buffer identifier
Code sample
vb_id = gh_vb.create(buffer_size, num_vertex_attribs)
draw_lines
Description
Draws lines from a vertex buffer.
Syntax
gh_vb.draw_lines(
vb_id,
count,
start,
render_mode
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- count [INTEGER]: number of vertices that must be drawn
- start [INTEGER]: index of the first vertex
- render_mode [ENUM]: render mode: 0 (LINE_RENDER_DEFAULT), 1 (LINE_RENDER_STRIP), 2 (LINE_RENDER_LOOP)
Return Values
This function has no return value(s).
Code sample
-- Draws the first 100 vertices as lines.
LINE_RENDER_DEFAULT = 0
LINE_RENDER_STRIP = 1
LINE_RENDER_LOOP = 2
gh_vb.draw_lines(vb_id, 100, 0, LINE_RENDER_STRIP)
draw_points
Description
Draws points from a vertex buffer.
Syntax
gh_vb.draw_points(
vb_id,
count,
start
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- count [INTEGER]: number of points that must be drawn
- start [INTEGER]: index of the first point
Return Values
This function has no return value(s).
Code sample
-- Draws the first 100 points.
gh_vb.draw_points(vb_id, 100, 0)
draw_triangles
Description
Draws triangles from a vertex buffer.
Syntax
gh_vb.draw_triangles(
vb_id,
count,
start,
triangle_mode
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- count [INTEGER]: number of vertices that must be drawn
- start [INTEGER]: index of the first vertex
- triangle_mode [ENUM]: triangle mode
Return Values
This function has no return value(s).
Code sample
-- triangle modes:
TRIANGLE = 0
TRIANGLE_STRIP = 1
TRIANGLE_FAN = 9
-- Draws the first 90 vertices as triangles (30 triangles).
gh_vb.draw_triangles(vb_id, 90, 0, TRIANGLE)
kill
Description
Kills a vertex buffer.
Syntax
gh_vb.kill(
vb_id
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vb.kill(vb_id)
map
Description
Maps the vertex buffer to CPU memory. The buffer pointer returned by map() is valid until the next call to unmap.
Syntax
buff_ptr, buff_size = gh_vb.map(
vb_id,
access_mode
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- access_mode [STRING]: XX
Return Values
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
Code sample
buffer, buffer_size = gh_vb.map(vb_id, "")
set_value_1f
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_1f(
vb_id,
buff_offset_bytes,
x
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- x [REAL]: value
Return Values
This function has no return value(s).
Code sample
offset = 4
gh_vb.set_value_1f(vb_id, offset, x)
set_value_1ui
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_1ui(
vb_id,
buff_offset_bytes,
x
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- x [INTEGER]: value
Return Values
This function has no return value(s).
Code sample
offset = 4
gh_vb.set_value_1ui(vb_id, offset, x)
set_value_2f
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_2f(
vb_id,
buff_offset_bytes,
x, y
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- x, y [REAL]: value
Return Values
This function has no return value(s).
Code sample
offset = 8
gh_vb.set_value_2f(vb_id, offset, x, y)
set_value_3f
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_3f(
vb_id,
buff_offset_bytes,
x, y, z
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- x, y, z [REAL]: value
Return Values
This function has no return value(s).
Code sample
offset = 12
gh_vb.set_value_3f(vb_id, offset, x, y, z)
set_value_4f
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_4f(
vb_id,
buff_offset_bytes,
x, y, z, w
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- x, y, z, w [REAL]: value
Return Values
This function has no return value(s).
Code sample
offset = 16
gh_vb.set_value_4f(vb_id, offset, x, y, z, w)
set_value_4x4f
Description
Sets a value in the vertex buffer.
Syntax
gh_vb.set_value_4x4f(
vb_id,
buff_offset_bytes,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- buff_offset_bytes [INTEGER]: offset in bytes
- m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 [REAL]: the 16 floats that make the 4x4 matrix
Return Values
This function has no return value(s).
Code sample
offset = 64
gh_vb.set_value_4x4f(vb_id, offset, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
set_vertex_attrib_data
Description
Specifies the description of a vertex attibute. This description will be used to render the vertex array.
Syntax
gh_vb.set_vertex_attrib_data(
vb_id,
vertex_attrib_index,
attrib_location,
type,
dim,
stride,
offset
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
- vertex_attrib_index [INTEGER]: XX
- attrib_location [INTEGER]: XX
- type [INTEGER]: XX
- dim [INTEGER]: XX
- stride [INTEGER]: XX
- offset [INTEGER]: XX
Return Values
This function has no return value(s).
Code sample
gh_vb.set_vertex_attrib_data(vb_id, vertex_attrib_index, attrib_location, type, dim, stride, offset)
unbind
Description
Unbinds a vertex buffer.
Syntax
gh_vb.unbind(
vb_id
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vb.unbind(vb_id)
unmap
Description
Unmaps the vertex buffer.
Syntax
gh_vb.unmap(
vb_id
)
Languages
Parameters
- vb_id [ID]: vertex buffer identifier
Return Values
This function has no return value(s).
Code sample
gh_vb.unmap(vb_id)
| |