SLGLVertexBuffer encapsulates an OpenGL buffer for vertex attributes.
More...
#include <SLGLVertexBuffer.h>
SLGLVertexBuffer encapsulates an OpenGL buffer for vertex attributes.
SLGLVertexBuffer is only meant to be used within the SLGLVertexArray class. Attributes can be either be in sequential order (first all positions, then all normals, etc.) or interleaved (all attributes together for one vertex). See SLGLVertexBuffer::generate for more information.
Vertex index buffer are not handled in this class. They are generated in SLGLVertexArray.
◆ SLGLVertexBuffer()
SLGLVertexBuffer::SLGLVertexBuffer |
( |
| ) |
|
Constructor initializing with default values.
◆ ~SLGLVertexBuffer()
SLGLVertexBuffer::~SLGLVertexBuffer |
( |
| ) |
|
|
inline |
◆ attribIndex()
Returns the vector index if a vertex attribute exists otherwise -1.
◆ attribs()
◆ bindAndEnableAttrib()
void SLGLVertexBuffer::bindAndEnableAttrib |
( |
| ) |
|
Binds & enables the vertex attribute for OpenGL < 3.0.
This method is only used by SLGLVertexArray drawing methods for OpenGL contexts prior to 3.0 where vertex array objects did not exist. This is the additional overhead that had to be done per draw call.
◆ clear()
void SLGLVertexBuffer::clear |
( |
| ) |
|
Calls deleteGL & clears the attributes.
◆ deleteGL()
void SLGLVertexBuffer::deleteGL |
( |
| ) |
|
Deletes all vertex array & vertex buffer objects.
Deletes the OpenGL objects for the vertex array and the vertex buffer. The vector _attribs with the attribute information is not cleared.
◆ disableAttrib()
void SLGLVertexBuffer::disableAttrib |
( |
| ) |
|
disables the vertex attribute for OpenGL < 3.0
This method is only used by SLGLVertexArray drawing methods for OpenGL contexts prior to 3.0 where vertex array objects did not exist. This is the additional overhead that had to be done per draw call.
◆ generate()
Generates the VBO.
Generates the OpenGL VBO for one or more vertex attributes. If the input data is an interleaved array (all attribute data pointer where identical) also the output buffer will be generated as an interleaved array. Vertex arrays with attributes that are updated can not be interleaved. Vertex attributes with separate arrays can generate an interleaved or a sequential vertex buffer.
Sequential attribute layout:
| Positions | Normals | TexCoords |
Attribs: | Position0 | Position1 | Normal0 | Normal1 |TexCoord0|TexCoord1|
Elements: | PX | PY | PZ | PX | PY | PZ | NX | NY | NZ | NX | NY | NZ | TX | TY | TX | TY |
Bytes: |#### #### ####|#### #### ####|#### #### ####|#### #### ####|#### ####|#### ####|
| | |
|<------ offset Normals ----->| |
|<-------------------- offset TexCoords ------------------->|
Interleaved attribute layout:
| Vertex 0 | Vertex 1 |
Attribs: | Position0 | Normal0 |TexCoord0| Position1 | Normal1 |TexCoord1|
Elements: | PX | PY | PZ | NX | NY | NZ | TX | TY | PX | PY | PZ | NX | NY | NZ | TX | TY |
Bytes: |#### #### ####|#### #### ####|#### ####|#### #### ####|#### #### ####|#### ####|
| | | |
|<-offsetN=32->| | |
|<------- offsetTC=32 ------->| |
| |
|<---------- strideBytes=32 ----------->|
◆ id()
SLuint SLGLVertexBuffer::id |
( |
| ) |
const |
|
inline |
◆ outputInterleaved()
SLbool SLGLVertexBuffer::outputInterleaved |
( |
| ) |
const |
|
inline |
◆ size()
SLuint SLGLVertexBuffer::size |
( |
| ) |
const |
|
inline |
◆ sizeOfType()
static total size of all buffers in bytes
Returns the size in byte depending off the buffer type.
Returns the size of a buffer data type
◆ updateAttrib() [1/6]
Updates a specific vertex attribute in the VBO.
Updates the specified vertex attribute. This works only for sequential attributes and not for interleaved attributes. This is used e.g. for meshes with vertex skinning. See SLMesh::draw where we have joint attributes.
◆ updateAttrib() [2/6]
Updates a specific vertex attribute in the VBO.
◆ updateAttrib() [3/6]
Updates a specific vertex attribute in the VBO.
◆ updateAttrib() [4/6]
Updates a specific vertex attribute in the VBO.
◆ updateAttrib() [5/6]
Updates a specific vertex attribute in the VBO.
◆ updateAttrib() [6/6]
Updates a specific vertex attribute in the VBO.
◆ _attribs
NO. of vertices in array.
◆ _id
◆ _numVertices
SLuint SLGLVertexBuffer::_numVertices |
|
protected |
OpenGL id of vertex buffer object.
◆ _outputInterleaved
SLbool SLGLVertexBuffer::_outputInterleaved |
|
protected |
Vector of vertex attributes.
◆ _sizeBytes
SLuint SLGLVertexBuffer::_sizeBytes |
|
protected |
Distance for interleaved attributes in bytes.
◆ _strideBytes
SLuint SLGLVertexBuffer::_strideBytes |
|
protected |
Flag if VBO should be generated interleaved.
◆ _usage
Total size of float VBO in bytes.
◆ totalBufferCount
SLuint SLGLVertexBuffer::totalBufferCount = 0 |
|
static |
◆ totalBufferSize
SLuint SLGLVertexBuffer::totalBufferSize = 0 |
|
static |
static total no. of buffers in use
The documentation for this class was generated from the following files: