Class GL.GLSLUtils.VertexBuffer

Description

This class defines a vertex buffer. This is a chunk of memory defining vertex attributes for future drawing. Any number of vertex buffers (up to a hardware specific limit) can be added to any GLSLProgram.

Vertex buffers are generally speaking stored on the graphic card for fast access, making it possible to draw huge amounts of primitives without using all available CPU->GPU memory bandwidth.

Normal usage of this class is to create it, then call add_[type] for each vertex attribute (add_float, add_vec2 etc) defined in your program, then call set_size or set_data to set the size of the buffer, add the VertexBuffer to any relevant GLSLProgram instances, and then optionally call pwrite, vertex or stream_vertex() to update the data.

The add_* functions can not be called once the VertexBuffer has been added to a GLSLProgram. set_size, set_data or recalc must be called before the VertexBuffer is added to a GLSLProgram.


Variable current_size

int GL.GLSLUtils.VertexBuffer.current_size

Description

The maximum offset ever written using stream


Variable id

int GL.GLSLUtils.VertexBuffer.id

Description

The vertexbuffer id (the object id passed to glBindBuffer).


Variable offset

int GL.GLSLUtils.VertexBuffer.offset

Description

The index of the last vertex that was written using stream


Variable size

int GL.GLSLUtils.VertexBuffer.size

Description

The total size of the VertexBuffer, counted in vertices


Variable stride

int GL.GLSLUtils.VertexBuffer.stride

Description

The size of a single vertex, in bytes


Variable vertex_size

int GL.GLSLUtils.VertexBuffer.vertex_size

Description

The size of a single vertex, in floats


Method create

GL.GLSLUtils.VertexBuffer GL.GLSLUtils.VertexBuffer(int draw_mode)

Description

Create a new vertex buffer, draw_mode is a usage hint.

GL_STREAM_DRAW: Draw multiple times, updating the data ocassionally GL_STATIC_DRAW: Set the data once, then draw multiple times GL_DYNAMIC_DRAW: Draw and update all the time

The mode is only a hint, it does not really affect the functionality of the buffer.