From bfdc713b68dd6f8d61e7b26fc2cff15caf24b44d Mon Sep 17 00:00:00 2001 From: majortom6 Date: Sun, 19 Feb 2017 11:31:57 -0600 Subject: -finished formatting all of the includes, at least for now --- README.md | 2 +- inc/constants.hpp | 6 ++-- inc/opengl/spritebatch.hpp | 72 ++++++++++++++++-------------------------- inc/opengl/transform.hpp | 78 +++++++++++++++++++++++----------------------- inc/sdl/event.hpp | 4 +-- inc/sdl/timer.hpp | 30 +++++++++--------- 6 files changed, 88 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index f5cfca8..6968a39 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ nature's course for librarys ~ -apt install libsdl2-dev libglm-dev +apt install libsdl2-dev libglm-dev libglew-dev ideas - make code compilable on various distrobutions (maybe wangblows if not too big of changes) diff --git a/inc/constants.hpp b/inc/constants.hpp index 8cf4edd..fbcb454 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -2,9 +2,9 @@ #define constants_h // General -const int CREATURES = 10; -const int RESOURCES = 100; -const int MINIMUM_RESOURCES = 80; +const int CREATURES = 100; +const int RESOURCES = 1000; +const int MINIMUM_RESOURCES = 800; const int WINDOW_X = 1000; const int WINDOW_Y = 1000; 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 _gfxPtr; ///< This is for sorting - std::vector _gfx; ///< These are the actual glyphs - std::vector _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 _gfxPtr; ///< This is for sorting + std::vector _gfx; ///< These are the actual glyphs + std::vector _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 diff --git a/inc/sdl/event.hpp b/inc/sdl/event.hpp index 3a0a868..c3536cc 100644 --- a/inc/sdl/event.hpp +++ b/inc/sdl/event.hpp @@ -15,8 +15,8 @@ class Event int gEventType(); private: - bool run; - SDL_Event v; + bool run; + SDL_Event v; }; #endif diff --git a/inc/sdl/timer.hpp b/inc/sdl/timer.hpp index d4e46e8..3bcaaaa 100644 --- a/inc/sdl/timer.hpp +++ b/inc/sdl/timer.hpp @@ -5,21 +5,23 @@ class Timer { - public: - Timer(); - void Start(); - void Stop(); - void Pause(); - void unPause(); - int getTicks(); - bool isStarted(){return started;}; - bool isPaused(){return paused;}; + public: + Timer(); - private: - int startTicks; - int pausedTicks; - bool paused; - bool started; + void Start(); + void Stop(); + void Pause(); + void unPause(); + + int getTicks(); + bool getStarted(){return started;}; + bool getPaused(){return paused;}; + + private: + int startTicks; + int pausedTicks; + bool paused; + bool started; }; #endif -- cgit v1.2.3