summaryrefslogtreecommitdiff
path: root/inc/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'inc/opengl')
-rw-r--r--inc/opengl/spritebatch.hpp72
-rw-r--r--inc/opengl/transform.hpp78
2 files changed, 66 insertions, 84 deletions
diff --git a/inc/opengl/spritebatch.hpp b/inc/opengl/spritebatch.hpp
index 3ece593..94ca97c 100644
--- a/inc/opengl/spritebatch.hpp
+++ b/inc/opengl/spritebatch.hpp
@@ -9,55 +9,37 @@
class RenderBatch {
-public:
- RenderBatch(GLuint Offset, GLuint NumVertices) : offset(Offset),
- numVertices(NumVertices){
- }
- GLuint offset;
- GLuint numVertices;
- //GLuint texture;
+ public:
+ RenderBatch(GLuint Offset, GLuint NumVertices) : offset(Offset),
+ numVertices(NumVertices){}
+ GLuint offset;
+ GLuint numVertices;
};
-
class SpriteBatch
{
- public:
- SpriteBatch(GeoShader theshader);
- ~SpriteBatch();
- // Initializes the spritebatch
- void init();
- // Begins the spritebatch
- void begin();
- // Ends the spritebatch
- void end();
- // Adds a glyph to the spritebatch
- void draw(const GraphicsData& gfxData);
- // Renders the entire SpriteBatch to the screen
- void renderBatch();
-
- private:
- // Creates all the needed RenderBatches
- void createRenderBatches();
- // Generates our VAO and VBO
- void createVertexArray();
- // Sorts glyphs according to _sortType
- //void sortGlyphs();
- // Comparators used by sortGlyphs()
- //static bool compareFrontToBack(Glyph* a, Glyph* b);
- //static bool compareBackToFront(Glyph* a, Glyph* b);
- //static bool compareTexture(Glyph* a, Glyph* b);
-
- GLuint _vbo;
- GLuint _vao;
-
- //GlyphSortType _sortType;
-
- std::vector<GraphicsData*> _gfxPtr; ///< This is for sorting
- std::vector<GraphicsData> _gfx; ///< These are the actual glyphs
- std::vector<RenderBatch> _renderBatches;
-
- GeoShader shader;
-
+ public:
+ SpriteBatch(GeoShader theshader);
+ ~SpriteBatch();
+
+ void init();
+ void begin();
+ void end();
+ void draw(const GraphicsData& gfxData);
+ void renderBatch();
+
+ private:
+ void createRenderBatches();
+ void createVertexArray();
+
+ GLuint _vbo;
+ GLuint _vao;
+
+ std::vector<GraphicsData*> _gfxPtr; ///< This is for sorting
+ std::vector<GraphicsData> _gfx; ///< These are the actual glyphs
+ std::vector<RenderBatch> _renderBatches;
+
+ GeoShader shader;
};
#endif
diff --git a/inc/opengl/transform.hpp b/inc/opengl/transform.hpp
index 9d0988c..c2adb03 100644
--- a/inc/opengl/transform.hpp
+++ b/inc/opengl/transform.hpp
@@ -8,45 +8,45 @@
struct Transform
{
-public:
- Transform(const glm::vec3& pos = glm::vec3(), const glm::vec3& rot = glm::vec3(), const glm::vec3& scale = glm::vec3(1.0f, 1.0f, 1.0f))
- {
- this->pos = pos;
- this->rot = rot;
- this->scale = scale;
- }
-
- inline glm::mat4 GetModel() const
- {
- glm::mat4 posMat = glm::translate(pos);
- glm::mat4 scaleMat = glm::scale(scale);
- glm::mat4 rotX = glm::rotate(rot.x, glm::vec3(1.0, 0.0, 0.0));
- glm::mat4 rotY = glm::rotate(rot.y, glm::vec3(0.0, 1.0, 0.0));
- glm::mat4 rotZ = glm::rotate(rot.z, glm::vec3(0.0, 0.0, 1.0));
- glm::mat4 rotMat = rotX * rotY * rotZ;
-
- return posMat * rotMat * scaleMat;
- }
-
- inline glm::mat4 GetMVP(const Camera& camera) const
- {
- glm::mat4 VP = camera.GetViewProjection();
- glm::mat4 M = GetModel();
-
- return VP * M;
- }
-
- inline glm::vec3* GetPos() { return &pos; }
- inline glm::vec3* GetRot() { return &rot; }
- inline glm::vec3* GetScale() { return &scale; }
-
- inline void SetPos(glm::vec3& pos) { this->pos = pos; }
- inline void SetRot(glm::vec3& rot) { this->rot = rot; }
- inline void SetScale(glm::vec3& scale) { this->scale = scale; }
-private:
- glm::vec3 pos;
- glm::vec3 rot;
- glm::vec3 scale;
+ public:
+ Transform(const glm::vec3& pos = glm::vec3(), const glm::vec3& rot = glm::vec3(), const glm::vec3& scale = glm::vec3(1.0f, 1.0f, 1.0f))
+ {
+ this->pos = pos;
+ this->rot = rot;
+ this->scale = scale;
+ }
+
+ inline glm::mat4 GetModel() const {
+ glm::mat4 posMat = glm::translate(pos);
+ glm::mat4 scaleMat = glm::scale(scale);
+ glm::mat4 rotX = glm::rotate(rot.x, glm::vec3(1.0, 0.0, 0.0));
+ glm::mat4 rotY = glm::rotate(rot.y, glm::vec3(0.0, 1.0, 0.0));
+ glm::mat4 rotZ = glm::rotate(rot.z, glm::vec3(0.0, 0.0, 1.0));
+ glm::mat4 rotMat = rotX * rotY * rotZ;
+
+ return posMat * rotMat * scaleMat;
+ }
+
+ inline glm::mat4 GetMVP(const Camera& camera) const
+ {
+ glm::mat4 VP = camera.GetViewProjection();
+ glm::mat4 M = GetModel();
+
+ return VP * M;
+ }
+
+ inline glm::vec3* GetPos() { return &pos; }
+ inline glm::vec3* GetRot() { return &rot; }
+ inline glm::vec3* GetScale() { return &scale; }
+
+ inline void SetPos(glm::vec3& pos) { this->pos = pos; }
+ inline void SetRot(glm::vec3& rot) { this->rot = rot; }
+ inline void SetScale(glm::vec3& scale) { this->scale = scale; }
+
+ private:
+ glm::vec3 pos;
+ glm::vec3 rot;
+ glm::vec3 scale;
};
#endif