SimpleGL
1.1.0
A framework for platform independent rendering
|
This class is used for batch rendering with OpenGL. More...
#include <batching_gl.hpp>
Public Member Functions | |
BatchGL (int capacity=1024 *1024) | |
Creates a new batch with specified capacity. More... | |
~BatchGL (void) | |
Destroys a batch. More... | |
void | begin () override |
Starts drawing with TRIANGLES mode. More... | |
void | begin (Primitive mode) |
Starts drawing with specified mode. More... | |
void | flush () override |
Flushes the batch, could be used if the batch would overflow. More... | |
void | specifyVertexAttributes () |
Specifies the vertex attributes. More... | |
void | applyTransform () |
Applies the MVP transformation if necessary. More... | |
void | resetShaderProgram () |
Resets to the default shader program. More... | |
ShaderProgram * | getShaderProgram () |
Gets the current shader program of the batch. More... | |
void | setShaderProgram (ShaderProgram *program) |
Sets the current shader program of the batch. More... | |
Public Member Functions inherited from sgl::Batch | |
~Batch (void) | |
Destroys a batch. More... | |
virtual void | end () |
Ends the drawing, this should also flush the batch. More... | |
void | vertex (float x, float y) |
Defines a new vertex at specified coordinates. More... | |
void | vertex (float x, float y, float z) |
Defines a new vertex at specified coordinates. More... | |
void | vertex (glm::vec2 vertex) |
Defines a new vertex at specified coordinates. More... | |
void | vertex (glm::vec3 vertex) |
Defines a new vertex at specified coordinates. More... | |
void | color (float r, float g, float b) |
Defines a new color with specified components. More... | |
void | color (float r, float g, float b, float a) |
Defines a new color with specified components. More... | |
void | color (glm::vec3 color) |
Defines a new color with specified components. More... | |
void | color (glm::vec4 color) |
Defines a new color with specified components. More... | |
void | texCoord (float s, float t) |
Defines a new texture coordinate with specified values. More... | |
void | texCoord (glm::vec2 texCoord) |
Defines a new texture coordinate with specified values. More... | |
void | normal (float nx, float ny, float nz) |
Defines a new normal with specified values. More... | |
void | normal (glm::vec3 normal) |
Defines a new normal with specified values. More... | |
void | setModel (glm::mat4 model) |
Sets the model matrix. More... | |
glm::mat4 | getModel () |
Gets the model matrix. More... | |
void | setView (glm::mat4 view) |
Sets the view matrix. More... | |
glm::mat4 | getView () |
Gets the view matrix. More... | |
void | setProjection (glm::mat4 projection) |
Sets the projection matrix. More... | |
glm::mat4 | getProjection () |
Gets the projection matrix. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from sgl::Batch | |
Batch (void) | |
Initializes a new batch. More... | |
Protected Attributes inherited from sgl::Batch | |
Transformation | transformation |
The transformation for the batch. More... | |
bool | drawing |
Tells if the batch is drawing. More... | |
int | numVertices |
The counter for the number of vertices. More... | |
std::vector< glm::vec3 > | vertices |
The storage for vertices. More... | |
std::vector< glm::vec4 > | colors |
The storage for colors. More... | |
std::vector< glm::vec2 > | texCoords |
The storage for texture coordinates. More... | |
std::vector< glm::vec3 > | normals |
The storage for normals. More... | |
This class is used for batch rendering with OpenGL.
Definition at line 30 of file batching_gl.hpp.
sgl::BatchGL::BatchGL | ( | int | capacity = 1024 * 1024 | ) |
Creates a new batch with specified capacity.
If no capacity is specified it will use a default capacity of 1048576 vertices.
capacity | The capacity of this batch. |
Definition at line 57 of file batching_gl.cpp.
sgl::BatchGL::~BatchGL | ( | void | ) |
Destroys a batch.
Definition at line 139 of file batching_gl.cpp.
void sgl::BatchGL::applyTransform | ( | ) |
Applies the MVP transformation if necessary.
Definition at line 257 of file batching_gl.cpp.
|
overridevirtual |
Starts drawing with TRIANGLES mode.
Reimplemented from sgl::Batch.
Definition at line 153 of file batching_gl.cpp.
void sgl::BatchGL::begin | ( | Primitive | mode | ) |
Starts drawing with specified mode.
mode | The mode to use for drawing. |
Definition at line 157 of file batching_gl.cpp.
|
overridevirtual |
Flushes the batch, could be used if the batch would overflow.
Implements sgl::Batch.
Definition at line 166 of file batching_gl.cpp.
ShaderProgram * sgl::BatchGL::getShaderProgram | ( | ) |
Gets the current shader program of the batch.
Definition at line 278 of file batching_gl.cpp.
void sgl::BatchGL::resetShaderProgram | ( | ) |
Resets to the default shader program.
Definition at line 274 of file batching_gl.cpp.
void sgl::BatchGL::setShaderProgram | ( | ShaderProgram * | program | ) |
Sets the current shader program of the batch.
program | The new shader program. |
Definition at line 282 of file batching_gl.cpp.
void sgl::BatchGL::specifyVertexAttributes | ( | ) |
Specifies the vertex attributes.
Definition at line 231 of file batching_gl.cpp.