From afe623ba793f9f4c51f94abe6464020d22387c9d Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 6 Apr 2017 16:16:59 +0100 Subject: Improved files --- include/YAGE/camera2d.hpp | 9 +++------ include/YAGE/gltexture.hpp | 18 ------------------ include/YAGE/imageloader.hpp | 4 ++-- include/YAGE/resourcemanager.hpp | 4 ++-- include/YAGE/sprite.hpp | 4 ++-- include/YAGE/texture.hpp | 18 ++++++++++++++++++ include/YAGE/texturecache.hpp | 6 +++--- include/YAGE/vertex.hpp | 28 ++++++++++++++++++++++++++++ 8 files changed, 58 insertions(+), 33 deletions(-) delete mode 100644 include/YAGE/gltexture.hpp create mode 100644 include/YAGE/texture.hpp (limited to 'include') diff --git a/include/YAGE/camera2d.hpp b/include/YAGE/camera2d.hpp index 0c86fc31..4c035ba3 100644 --- a/include/YAGE/camera2d.hpp +++ b/include/YAGE/camera2d.hpp @@ -1,6 +1,8 @@ #ifndef CAMERA_2D_HPP #define CAMERA_2D_HPP +#include "glslprogram.hpp" + #include #include @@ -23,14 +25,9 @@ public: virtual ~Camera2D(); // update camera location - void update(); + void update(GlslProgram &program); // camera movement void move(const glm::vec2 &direction); - - // getters - float getScale() { return scale_; } - glm::vec2 getPosition() { return position_; } - glm::mat4 getCameraMatrix() { return camera_matrix_; } }; } // yage diff --git a/include/YAGE/gltexture.hpp b/include/YAGE/gltexture.hpp deleted file mode 100644 index 7446d560..00000000 --- a/include/YAGE/gltexture.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef GL_TEXTURE_HPP -#define GL_TEXTURE_HPP - -#include - -namespace yage -{ - -struct GlTexture -{ - GLuint id; - int width; - int height; -}; - -} // yage - -#endif diff --git a/include/YAGE/imageloader.hpp b/include/YAGE/imageloader.hpp index 632897dc..de190ea4 100644 --- a/include/YAGE/imageloader.hpp +++ b/include/YAGE/imageloader.hpp @@ -1,7 +1,7 @@ #ifndef IMAGE_LOADER_HPP #define IMAGE_LOADER_HPP -#include "gltexture.hpp" +#include "texture.hpp" #include @@ -11,7 +11,7 @@ namespace yage class ImageLoader { public: - static GlTexture loadPng(const std::string &file_path); + static Texture loadPng(const std::string &file_path); }; } // yage diff --git a/include/YAGE/resourcemanager.hpp b/include/YAGE/resourcemanager.hpp index 08ab31e0..61642caf 100644 --- a/include/YAGE/resourcemanager.hpp +++ b/include/YAGE/resourcemanager.hpp @@ -1,7 +1,7 @@ #ifndef RESOURCE_MANAGER_HPP #define RESOURCE_MANAGER_HPP -#include "gltexture.hpp" +#include "texture.hpp" #include "texturecache.hpp" #include @@ -14,7 +14,7 @@ class ResourceManager private: static TextureCache texture_cache_; public: - static GlTexture getTexture(const std::string &texture_path); + static Texture getTexture(const std::string &texture_path); }; } // yage diff --git a/include/YAGE/sprite.hpp b/include/YAGE/sprite.hpp index 8abc339a..fa214686 100644 --- a/include/YAGE/sprite.hpp +++ b/include/YAGE/sprite.hpp @@ -1,7 +1,7 @@ #ifndef SPRITE_HPP #define SPRITE_HPP -#include "gltexture.hpp" +#include "texture.hpp" #include @@ -18,7 +18,7 @@ private: float width_; float height_; GLuint vbo_id_ = 0; - GlTexture texture_; + Texture texture_; public: Sprite(); ~Sprite(); diff --git a/include/YAGE/texture.hpp b/include/YAGE/texture.hpp new file mode 100644 index 00000000..c72c80d7 --- /dev/null +++ b/include/YAGE/texture.hpp @@ -0,0 +1,18 @@ +#ifndef GL_TEXTURE_HPP +#define GL_TEXTURE_HPP + +#include + +namespace yage +{ + +struct Texture +{ + GLuint id; + int width; + int height; +}; + +} // yage + +#endif diff --git a/include/YAGE/texturecache.hpp b/include/YAGE/texturecache.hpp index 43266ee9..4969b27b 100644 --- a/include/YAGE/texturecache.hpp +++ b/include/YAGE/texturecache.hpp @@ -1,7 +1,7 @@ #ifndef TEXTURE_CACHE_HPP #define TEXTURE_CACHE_HPP -#include "gltexture.hpp" +#include "texture.hpp" #include @@ -11,12 +11,12 @@ namespace yage class TextureCache { private: - std::unordered_map texture_map_; + std::unordered_map texture_map_; public: TextureCache(); ~TextureCache(); - GlTexture getTexture(const std::string &texture_path); + Texture getTexture(const std::string &texture_path); }; } // yage diff --git a/include/YAGE/vertex.hpp b/include/YAGE/vertex.hpp index 5826aeee..bbf8a7d3 100644 --- a/include/YAGE/vertex.hpp +++ b/include/YAGE/vertex.hpp @@ -10,6 +10,13 @@ struct Position { float x; float y; + + Position() + {} + + Position(float x_, float y_) : + x(x_), y(y_) + {} }; struct Color @@ -18,12 +25,26 @@ struct Color GLubyte g; GLubyte b; GLubyte a; + + Color() + {} + + Color(GLubyte r_, GLubyte g_, GLubyte b_, GLubyte a_) : + r(r_), g(g_), b(b_), a(a_) + {} }; struct UV { float u; float v; + + UV() + {} + + UV(float u_, float v_) : + u(u_), v(v_) + {} }; struct Vertex @@ -32,6 +53,13 @@ struct Vertex Color color; UV uv; + Vertex() + {} + + Vertex(const Position &position_, const Color &color_, const UV &uv_) : + position(position_), color(color_), uv(uv_) + {} + void setPosition(float x, float y) { position.x = x; -- cgit