41         glDeleteVertexArrays(1, &
_vaoID);
 
   76         SL_EXIT_MSG(
"The position attribute has no variable location.");
 
  110                                  void*          indexDataElements,
 
  112                                  void*          indexDataEdges)
 
  115     assert(indexDataElements);
 
  137     assert(dataPointer && 
"No data pointer passed");
 
  138     assert(elementSize > 0 && elementSize < 5 && 
"Element size invalid");
 
  143         SL_EXIT_MSG(
"Attribute type does not exist in VAO.");
 
  146         glGenVertexArrays(1, &
_vaoID);
 
  147     glBindVertexArray(
_vaoID);
 
  153     glBindVertexArray(0);
 
  202     glGenVertexArrays(1, &
_vaoID);
 
  203     glBindVertexArray(
_vaoID);
 
  241         glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
 
  243         glBufferData(GL_ELEMENT_ARRAY_BUFFER,
 
  256         glBufferData(GL_ELEMENT_ARRAY_BUFFER,
 
  265     glBindVertexArray(0);
 
  283     glGenTransformFeedbacks(1, &
_tfoID);
 
  286     glGenVertexArrays(1, &
_vaoID);
 
  287     glBindVertexArray(
_vaoID);
 
  310     glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 
_tfoID);
 
  311     glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 
_vbo.
id());
 
  334         glBufferData(GL_ELEMENT_ARRAY_BUFFER,
 
  347         glBufferData(GL_ELEMENT_ARRAY_BUFFER,
 
  356     glBindVertexArray(0);
 
  367     glEnable(GL_RASTERIZER_DISCARD);
 
  370     glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 
tfoID);
 
  373     glBeginTransformFeedback(GL_POINTS);
 
  382     glEndTransformFeedback();
 
  385     glDisable(GL_RASTERIZER_DISCARD);
 
  388     glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
 
  402     glBindVertexArray(
_vaoID);
 
  412     glDrawElements(primitiveType,
 
  415                    (
void*)(
size_t)(indexOffset * (
SLuint)indexTypeSize));
 
  420     switch (primitiveType)
 
  434     glBindVertexArray(0);
 
  446     assert((
_vbo.
id()) && 
"No VBO generated for VAO.");
 
  448     glBindVertexArray(
_vaoID);
 
  450     if (countVertices == 0)
 
  454     glDrawArrays(primitiveType,
 
  462     switch (primitiveType)
 
  476     glBindVertexArray(0);
 
  492            "No index VBO generated for VAO");
 
  496     glBindVertexArray(
_vaoID);
 
  506     glDrawElementsInstanced(primitiveType,
 
  509                             (
void*)(
size_t)(indexOffset * (
SLuint)indexTypeSize),
 
  510                             (GLsizei)countInstances);
 
  517     switch (primitiveType)
 
  530     glBindVertexArray(0);
 
  544         SL_EXIT_MSG(
"No VBO generated for VAO in drawArrayAsColored.");
 
  559 #if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN) 
  560     if (lineWidth != 1.0f)
 
  561         glLineWidth(lineWidth);
 
  570 #if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN) 
  571     if (lineWidth != 1.0f)
 
#define SL_EXIT_MSG(message)
 
SLGLAttributeType
Enumeration for float vertex attribute types.
 
@ AT_position
Vertex position as a 2, 3 or 4 component vectors.
 
SLGLBufferUsage
Enumeration for buffer usage types also supported by OpenGL ES.
 
SLGLBufferType
Enumeration for buffer data types.
 
@ BT_ubyte
vertex index type (0-2^8)
 
@ BT_ushort
vertex index type (0-2^16)
 
Singleton class for global render state.
 
Wrapper class around OpenGL Vertex Array Objects (VAO)
 
Encapsulation of an OpenGL shader program object.
 
SLint uniformMatrix4fv(const SLchar *name, SLsizei count, const SLfloat *value, GLboolean transpose=false) const
Passes a 4x4 float matrix values py pointer to the uniform variable "name".
 
SLint uniform1f(const SLchar *name, SLfloat v0) const
Passes the float value v0 to the uniform variable "name".
 
SLint getUniformLocation(const SLchar *name) const
 
static SLGLProgramGeneric * get(SLStdShaderProg id)
Get program reference for given id.
 
Singleton class holding all OpenGL states.
 
SLMat4f modelMatrix
Init all states.
 
static SLGLState * instance()
Public static instance getter for singleton pattern.
 
SLMat4f viewMatrix
matrix for the active cameras view transform
 
SLMat4f projectionMatrix
matrix for projection transform
 
void currentMaterial(SLMaterial *mat)
 
SLGLVertexBuffer _vbo
NO. of vertices in array.
 
size_t _numIndicesEdges
Pointer to index data for elements.
 
void beginTF(SLuint tfoID)
Begin transform feedback.
 
SLGLVertexBuffer * _instanceVbo
index data type (ubyte, ushort, uint)
 
SLuint numVertices() const
 
SLuint _idVBOIndices
Vertex buffer object for float attributes.
 
void setInstanceVBO(SLGLVertexBuffer *vbo, SLuint divisor=0)
Attach a VBO that has been created outside of this VAO.
 
void * _indexDataEdges
NO. of vertex indices in array for hard edges.
 
void endTF()
End transform feedback.
 
SLuint tfoID() const
Returns the TFO id.
 
size_t _numIndicesElements
OpenGL id of index vbo.
 
SLuint _vaoID
Number of instances of drawing.
 
SLuint _tfoID
OpenGL id of vertex array object.
 
static SLuint totalDrawCalls
 
void updateAttrib(SLGLAttributeType type, SLint elementSize, void *dataPointer)
Updates a specific vertex attribute in the VBO.
 
void drawElementsAs(SLGLPrimitiveType primitiveType, SLuint numIndexes=0, SLuint indexOffsetBytes=0)
Draws the VAO by element indices with a primitive type.
 
void setAttrib(SLGLAttributeType type, SLint elementSize, SLint location, void *dataPointer, SLGLBufferType dataType=BT_float)
Adds a vertex attribute with data pointer and an element size.
 
static SLuint totalPrimitivesRendered
static total no. of draw calls
 
SLGLBufferType _indexDataType
Pointer to index data for hard edges.
 
SLuint _instanceDivisor
Vertex buffer object containing the positions for instanced drawing.
 
SLuint _numVertices
OpenGL id of transform feedback object.
 
void generateTF(SLuint numVertices, SLGLBufferUsage usage=BU_static, SLbool outputInterleaved=true, SLuint divisor=0)
Generates the VA & VB & TF objects.
 
void drawArrayAs(SLGLPrimitiveType primitiveType, SLint firstVertex=0, SLsizei countVertices=0)
Draws the VAO as an array with a primitive type.
 
SLuint numIndicesElements() const
 
void drawElementsInstanced(SLGLPrimitiveType primitiveType, SLuint countInstance=0, SLuint numIndexes=0, SLuint indexOffset=0)
Draws the VAO as an array with instance primitive type.
 
void * _indexDataElements
NO. of vertex indices in array for triangles, lines or points.
 
void setIndices(SLuint numIndicesElements, SLGLBufferType indexDataType, void *indexDataElements, SLuint numIndicesEdges=0, void *indexDataEdges=nullptr)
Adds the index array for indexed element drawing.
 
void generate(SLuint numVertices, SLGLBufferUsage usage=BU_static, SLbool outputInterleaved=true, SLuint divisor=0)
Generates the VA & VB objects for a NO. of vertices.
 
void drawEdges(SLCol4f color, SLfloat lineWidth=1.0f)
Draws the hard edges of the VAO with the edge indices.
 
void deleteGL()
Deletes all vertex array & vertex buffer objects.
 
SLuint numIndicesEdges() const
 
SLGLVertexBuffer encapsulates an OpenGL buffer for vertex attributes.
 
SLint attribIndex(SLGLAttributeType type)
Returns the vector index if a vertex attribute exists otherwise -1.
 
void generate(SLuint numVertices, SLGLBufferUsage usage=BU_static, SLbool outputInterleaved=true)
Generates the VBO.
 
static SLuint totalBufferSize
static total no. of buffers in use
 
static SLuint totalBufferCount
 
void clear()
Calls deleteGL & clears the attributes.
 
static SLuint sizeOfType(SLGLBufferType type)
static total size of all buffers in bytes
 
SLVVertexAttrib & attribs()
 
void bindAndEnableAttrib(SLuint divisor=0) const
Binds & enables the vertex attribute for OpenGL < 3.0 and during VAO creation.
 
void updateAttrib(SLGLAttributeType type, SLint elementSize, void *dataPointer)
Updates a specific vertex attribute in the VBO.
 
Struct for vertex attribute information.
 
SLGLAttributeType type
type of vertex attribute
 
SLint location
GLSL input variable location index.
 
SLint elementSize
size of attribute element (SLVec3f has 3)
 
SLuint bufferSizeBytes
size of the attribute part in the buffer
 
void * dataPointer
pointer to the attributes source data