|
KGLLib
|
Collection of geometry data. More...
#include <geometrybuffer.h>
Classes | |
| struct | AttributeData |
Public Member Functions | |
| virtual | ~GeometryBuffer () |
| virtual void | render () |
| virtual void | renderIndexed (int indices, int offset)=0 |
| virtual void | render (int vertices, int offset)=0 |
| virtual bool | bind () |
| virtual bool | unbind () |
| void | addVertices (void *vertices, int count, int offset=0) |
| void | addColors (void *colors, int count, int offset=0) |
| void | addNormals (void *normals, int count, int offset=0) |
| void | addTexCoords (void *texcoords, int count, int offset=0) |
| virtual void | addIndices (unsigned int *indices, int count, int offset=0)=0 |
| virtual void | setPrimitiveType (GLenum type) |
| GLenum | primitiveType () const |
| const GeometryBufferFormat & | format () const |
Static Public Member Functions | |
| static GeometryBuffer * | createBuffer (const GeometryBufferFormat &format) |
| static GeometryBuffer * | createBuffer (GeometryBufferFormat::Format format, int vertexCount, int indexCount=0) |
Protected Member Functions | |
| GeometryBuffer (const GeometryBufferFormat &format) | |
| virtual void | init (const GeometryBufferFormat &format) |
| int | bufferSize () const |
| int | indexBufferSize () const |
| virtual void | addData (void *data, int size, int offset)=0 |
Protected Attributes | |
| GLenum | mPrimitiveType |
| GeometryBufferFormat | mFormat |
| AttributeData | mVertexData |
| AttributeData | mColorData |
| AttributeData | mNormalData |
| AttributeData | mTexCoordData |
Collection of geometry data.
GeometryBuffer object holds vertex and index data and is able to render it. It tries to use the most efficient way for rendering.
Usually you needn't use GeometryBuffer directly: it is used by Batch to store its data.
If you want to create a shared GeometryBuffer and use it for multiple Batch objects, the easiest way is to use Batch::createSharedBuffer() method.
When you specify data for the buffer then an internal copy is made of that data. Thus you can safely delete the data after you have specified it.
| KGLLib::GeometryBuffer::~GeometryBuffer | ( | ) | [virtual] |
Deletes this buffer and frees all allocated resources.
| KGLLib::GeometryBuffer::GeometryBuffer | ( | const GeometryBufferFormat & | format | ) | [protected] |
| virtual void KGLLib::GeometryBuffer::addData | ( | void * | data, |
| int | size, | ||
| int | offset | ||
| ) | [protected, pure virtual] |
Writes data to the internal buffer.
| data | pointer to the data |
| size | size of the data in bytes |
| offset | offset of the internal buffer in bytes |
Implemented in KGLLib::GeometryBufferVertexArray, and KGLLib::GeometryBufferVBO.
Referenced by addVertices().
| virtual void KGLLib::GeometryBuffer::addIndices | ( | unsigned int * | indices, |
| int | count, | ||
| int | offset = 0 |
||
| ) | [pure virtual] |
Sets the indices array to indices. The array must contain at least count entries (if it contains more, then the remaining ones will be unused).
Implemented in KGLLib::GeometryBufferVertexArray, and KGLLib::GeometryBufferVBO.
| void KGLLib::GeometryBuffer::addVertices | ( | void * | vertices, |
| int | count, | ||
| int | offset = 0 |
||
| ) |
Specifies vertex data to be used by this buffer.
| vertices | pointer to the array of vertices. |
| count | number of elements in the specified array. |
| offset | offset of the first element in the buffer. |
This copies count elements from the specified array into the buffer. The first element of the array will be copied to position offset in the buffer.
Each element of the specified array must consist of the same number of floats as specified in the format (GeometryBufferFormat::vertexSize()).
References addData().
| virtual bool KGLLib::GeometryBuffer::bind | ( | ) | [inline, virtual] |
Binds the buffer. The buffer must be bound before you can use any of the render methods.
Reimplemented in KGLLib::GeometryBufferVertexArray, and KGLLib::GeometryBufferVBO.
| int KGLLib::GeometryBuffer::bufferSize | ( | ) | const [protected] |
Calculates size of the buffer (in bytes) according to current format.
References KGLLib::GeometryBufferFormat::colorSize(), format(), KGLLib::GeometryBufferFormat::normalSize(), KGLLib::GeometryBufferFormat::texCoordSize(), KGLLib::GeometryBufferFormat::vertexCount(), and KGLLib::GeometryBufferFormat::vertexSize().
| GeometryBuffer * KGLLib::GeometryBuffer::createBuffer | ( | GeometryBufferFormat::Format | format, |
| int | vertexCount, | ||
| int | indexCount = 0 |
||
| ) | [static] |
Creates new GeometryBuffer object, using the specified format and vertex/index counts. This is a convenience method that can be used to avoid creation of the temporary GeometryBufferFormat object.
References createBuffer().
| GeometryBuffer * KGLLib::GeometryBuffer::createBuffer | ( | const GeometryBufferFormat & | format | ) | [static] |
Creates new GeometryBuffer object, using the specified format.
The GeometryBuffer type (subclass) that is used is chosen automatically depending on hardware features.
Static buffer creation helper methods
Referenced by createBuffer().
| const GeometryBufferFormat& KGLLib::GeometryBuffer::format | ( | ) | const [inline] |
Referenced by KGLLib::GeometryBufferVBO::bind(), bufferSize(), indexBufferSize(), render(), and KGLLib::GeometryBufferVBO::unbind().
| int KGLLib::GeometryBuffer::indexBufferSize | ( | ) | const [protected] |
Calculates size of the index buffer (in bytes) according to current format.
References format(), and KGLLib::GeometryBufferFormat::indexCount().
| GLenum KGLLib::GeometryBuffer::primitiveType | ( | ) | const [inline] |
| void KGLLib::GeometryBuffer::render | ( | ) | [virtual] |
Renders entire contents of the buffer. The buffer must be bound (by calling the bind() method) before it can be used.
References format(), and renderIndexed().
| virtual void KGLLib::GeometryBuffer::render | ( | int | vertices, |
| int | offset | ||
| ) | [pure virtual] |
Renders a subset of non-indexed buffer data. The buffer must be bound (by calling the bind() method) before it can be used.
| indices | number of vertices to use. |
| offset | array index of the first vertex to use. |
Implemented in KGLLib::GeometryBufferVertexArray.
| virtual void KGLLib::GeometryBuffer::renderIndexed | ( | int | indices, |
| int | offset | ||
| ) | [pure virtual] |
Renders a subset of indexed buffer data. The buffer must be bound (by calling the bind() method) before it can be used.
| indices | number of indices to use. |
| offset | array index of the first index to use. |
Implemented in KGLLib::GeometryBufferVertexArray.
Referenced by render().
| void KGLLib::GeometryBuffer::setPrimitiveType | ( | GLenum | type | ) | [virtual] |
Sets the primitive type used to render this batch (e.g. GL_QUADS).
Default value is GL_TRIANGLES.
| virtual bool KGLLib::GeometryBuffer::unbind | ( | ) | [inline, virtual] |
Unbinds the buffer.
Reimplemented in KGLLib::GeometryBufferVertexArray, and KGLLib::GeometryBufferVBO.
1.7.4