From aa67c8bb56cb750ac83ecbd361439f5ecb5e12d9 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 2 Apr 2017 09:19:32 +0100 Subject: Renamed includes --- include/YAGE/gl_texture.hpp | 13 ++++++++++ include/YAGE/glsl_program.hpp | 33 ++++++++++++++++++++++++ include/YAGE/image_loader.hpp | 15 +++++++++++ include/YAGE/io_manager.hpp | 14 +++++++++++ include/YAGE/logger.hpp | 24 ++++++++++++++++++ include/YAGE/pico_png.hpp | 4 +++ include/YAGE/resource_manager.hpp | 18 +++++++++++++ include/YAGE/sprite.hpp | 27 ++++++++++++++++++++ include/YAGE/texture_cache.hpp | 20 +++++++++++++++ include/YAGE/vertex.hpp | 53 +++++++++++++++++++++++++++++++++++++++ include/YAGE/window.hpp | 30 ++++++++++++++++++++++ include/yage/gl_texture.hpp | 13 ---------- include/yage/glsl_program.hpp | 33 ------------------------ include/yage/image_loader.hpp | 15 ----------- include/yage/io_manager.hpp | 14 ----------- include/yage/logger.hpp | 24 ------------------ include/yage/pico_png.hpp | 4 --- include/yage/resource_manager.hpp | 18 ------------- include/yage/sprite.hpp | 27 -------------------- include/yage/texture_cache.hpp | 20 --------------- include/yage/vertex.hpp | 53 --------------------------------------- include/yage/window.hpp | 30 ---------------------- 22 files changed, 251 insertions(+), 251 deletions(-) create mode 100644 include/YAGE/gl_texture.hpp create mode 100644 include/YAGE/glsl_program.hpp create mode 100644 include/YAGE/image_loader.hpp create mode 100644 include/YAGE/io_manager.hpp create mode 100644 include/YAGE/logger.hpp create mode 100644 include/YAGE/pico_png.hpp create mode 100644 include/YAGE/resource_manager.hpp create mode 100644 include/YAGE/sprite.hpp create mode 100644 include/YAGE/texture_cache.hpp create mode 100644 include/YAGE/vertex.hpp create mode 100644 include/YAGE/window.hpp delete mode 100644 include/yage/gl_texture.hpp delete mode 100644 include/yage/glsl_program.hpp delete mode 100644 include/yage/image_loader.hpp delete mode 100644 include/yage/io_manager.hpp delete mode 100644 include/yage/logger.hpp delete mode 100644 include/yage/pico_png.hpp delete mode 100644 include/yage/resource_manager.hpp delete mode 100644 include/yage/sprite.hpp delete mode 100644 include/yage/texture_cache.hpp delete mode 100644 include/yage/vertex.hpp delete mode 100644 include/yage/window.hpp (limited to 'include') diff --git a/include/YAGE/gl_texture.hpp b/include/YAGE/gl_texture.hpp new file mode 100644 index 00000000..808d86b1 --- /dev/null +++ b/include/YAGE/gl_texture.hpp @@ -0,0 +1,13 @@ +#ifndef GL_TEXTURE_HPP +#define GL_TEXTURE_HPP + +#include + +struct GlTexture +{ + GLuint id; + int width; + int height; +}; + +#endif diff --git a/include/YAGE/glsl_program.hpp b/include/YAGE/glsl_program.hpp new file mode 100644 index 00000000..cef38a8e --- /dev/null +++ b/include/YAGE/glsl_program.hpp @@ -0,0 +1,33 @@ +#ifndef GLSL_PROGRAM_HPP +#define GLSL_PROGRAM_HPP + +#include + +#include + +class GlslProgram +{ +private: + // compiled shader program id + GLuint program_id_ = 0; + GLuint vertex_shader_id_ = 0; + GLuint fragment_shader_id_ = 0; + int attribute_index_ = 0; + + // compiles one shader + void compileShader(const GLuint &shader, const std::string &file_path); +public: + GlslProgram(); + ~GlslProgram(); + + // compiles vertex and fragment shader + void compileShaders(const std::string &vertex_shader_path, const std::string &fragment_shader_path); + void linkShaders(); + void addAttribute(const std::string &attribute_name); + GLint getUniformLocation(const std::string &uniform_name); + void use(); + void unuse(); +}; + + +#endif diff --git a/include/YAGE/image_loader.hpp b/include/YAGE/image_loader.hpp new file mode 100644 index 00000000..5f7b97f0 --- /dev/null +++ b/include/YAGE/image_loader.hpp @@ -0,0 +1,15 @@ +#ifndef IMAGE_LOADER_HPP +#define IMAGE_LOADER_HPP + +#include "gl_texture.hpp" + +#include + +class ImageLoader +{ +public: + static GlTexture loadPng(const std::string &file_path); +}; + + +#endif diff --git a/include/YAGE/io_manager.hpp b/include/YAGE/io_manager.hpp new file mode 100644 index 00000000..05d288b5 --- /dev/null +++ b/include/YAGE/io_manager.hpp @@ -0,0 +1,14 @@ +#ifndef IO_MANAGER_HPP +#define IO_MANAGER_HPP + +#include +#include + +class IoManager +{ +public: + static bool readFileToBuffer(const std::string &file_path, std::vector &buffer); +}; + + +#endif diff --git a/include/YAGE/logger.hpp b/include/YAGE/logger.hpp new file mode 100644 index 00000000..36c7b9b3 --- /dev/null +++ b/include/YAGE/logger.hpp @@ -0,0 +1,24 @@ +#ifndef LOGGER_HPP +#define LOGGER_HPP + +#include + +class Logger +{ +public: + template + static std::string log(std::ostream &out, Tail &&tail) + { + out< + static std::string log(std::ostream &out, Head &&head, Tail &&...tail) + { + out<(head); + log(out, std::forward(tail)...); + } +}; + + +#endif diff --git a/include/YAGE/pico_png.hpp b/include/YAGE/pico_png.hpp new file mode 100644 index 00000000..ef123573 --- /dev/null +++ b/include/YAGE/pico_png.hpp @@ -0,0 +1,4 @@ +#include +#include + +extern int decodePNG(std::vector &out_image, unsigned long &image_width, unsigned long &image_height, const unsigned char *in_png, size_t in_size, bool convert_to_rgba32 = true); diff --git a/include/YAGE/resource_manager.hpp b/include/YAGE/resource_manager.hpp new file mode 100644 index 00000000..155515a3 --- /dev/null +++ b/include/YAGE/resource_manager.hpp @@ -0,0 +1,18 @@ +#ifndef RESOURCE_MANAGER_HPP +#define RESOURCE_MANAGER_HPP + +#include "gl_texture.hpp" +#include "texture_cache.hpp" + +#include + +class ResourceManager +{ +private: + static TextureCache texture_cache_; +public: + static GlTexture getTexture(const std::string &texture_path); +}; + + +#endif diff --git a/include/YAGE/sprite.hpp b/include/YAGE/sprite.hpp new file mode 100644 index 00000000..9f765c7d --- /dev/null +++ b/include/YAGE/sprite.hpp @@ -0,0 +1,27 @@ +#ifndef SPRITE_HPP +#define SPRITE_HPP + +#include "gl_texture.hpp" + +#include + +#include + +class Sprite +{ +private: + float x_; + float y_; + float width_; + float height_; + GLuint vbo_id_ = 0; + GlTexture texture_; +public: + Sprite(); + ~Sprite(); + + void init(float x, float y, float width, float height, const std::string &texture_path); + void draw(); +}; + +#endif diff --git a/include/YAGE/texture_cache.hpp b/include/YAGE/texture_cache.hpp new file mode 100644 index 00000000..44dba2f8 --- /dev/null +++ b/include/YAGE/texture_cache.hpp @@ -0,0 +1,20 @@ +#ifndef TEXTURE_CACHE_HPP +#define TEXTURE_CACHE_HPP + +#include "gl_texture.hpp" + +#include + +class TextureCache +{ +private: + std::unordered_map texture_map_; +public: + TextureCache(); + ~TextureCache(); + + GlTexture getTexture(const std::string &texture_path); +}; + + +#endif diff --git a/include/YAGE/vertex.hpp b/include/YAGE/vertex.hpp new file mode 100644 index 00000000..d9ab1138 --- /dev/null +++ b/include/YAGE/vertex.hpp @@ -0,0 +1,53 @@ +#ifndef VERTEX_HPP +#define VERTEX_HPP + +#include + +struct Position +{ + float x; + float y; +}; + +struct Color +{ + GLubyte r; + GLubyte g; + GLubyte b; + GLubyte a; +}; + +struct UV +{ + float u; + float v; +}; + +struct Vertex +{ + Position position; + Color color; + UV uv; + + void setPosition(float x, float y) + { + position.x = x; + position.y = y; + } + + void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) + { + color.r = r; + color.g = g; + color.b = b; + color.a = a; + } + + void setUv(float u, float v) + { + uv.u = u; + uv.v = v; + } +}; + +#endif diff --git a/include/YAGE/window.hpp b/include/YAGE/window.hpp new file mode 100644 index 00000000..6f3058e9 --- /dev/null +++ b/include/YAGE/window.hpp @@ -0,0 +1,30 @@ +#ifndef WINDOW_HPP +#define WINDOW_HPP + +#include + +#include + +enum class WindowFlags +{ + SHOWN=0x1, + HIDDEN=0x2, + FULLSCREEN=0x4, + BORDERLESS=0x8, +}; + +class Window +{ +private: + SDL_Window *window_=nullptr; + int width_=1280; + int height_=720; + +public: + Window(); + ~Window(); + + void create(const std::string &window_name, int width, int height, WindowFlags flags=WindowFlags::SHOWN); +}; + +#endif diff --git a/include/yage/gl_texture.hpp b/include/yage/gl_texture.hpp deleted file mode 100644 index 808d86b1..00000000 --- a/include/yage/gl_texture.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef GL_TEXTURE_HPP -#define GL_TEXTURE_HPP - -#include - -struct GlTexture -{ - GLuint id; - int width; - int height; -}; - -#endif diff --git a/include/yage/glsl_program.hpp b/include/yage/glsl_program.hpp deleted file mode 100644 index cef38a8e..00000000 --- a/include/yage/glsl_program.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef GLSL_PROGRAM_HPP -#define GLSL_PROGRAM_HPP - -#include - -#include - -class GlslProgram -{ -private: - // compiled shader program id - GLuint program_id_ = 0; - GLuint vertex_shader_id_ = 0; - GLuint fragment_shader_id_ = 0; - int attribute_index_ = 0; - - // compiles one shader - void compileShader(const GLuint &shader, const std::string &file_path); -public: - GlslProgram(); - ~GlslProgram(); - - // compiles vertex and fragment shader - void compileShaders(const std::string &vertex_shader_path, const std::string &fragment_shader_path); - void linkShaders(); - void addAttribute(const std::string &attribute_name); - GLint getUniformLocation(const std::string &uniform_name); - void use(); - void unuse(); -}; - - -#endif diff --git a/include/yage/image_loader.hpp b/include/yage/image_loader.hpp deleted file mode 100644 index 5f7b97f0..00000000 --- a/include/yage/image_loader.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef IMAGE_LOADER_HPP -#define IMAGE_LOADER_HPP - -#include "gl_texture.hpp" - -#include - -class ImageLoader -{ -public: - static GlTexture loadPng(const std::string &file_path); -}; - - -#endif diff --git a/include/yage/io_manager.hpp b/include/yage/io_manager.hpp deleted file mode 100644 index 05d288b5..00000000 --- a/include/yage/io_manager.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef IO_MANAGER_HPP -#define IO_MANAGER_HPP - -#include -#include - -class IoManager -{ -public: - static bool readFileToBuffer(const std::string &file_path, std::vector &buffer); -}; - - -#endif diff --git a/include/yage/logger.hpp b/include/yage/logger.hpp deleted file mode 100644 index 36c7b9b3..00000000 --- a/include/yage/logger.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef LOGGER_HPP -#define LOGGER_HPP - -#include - -class Logger -{ -public: - template - static std::string log(std::ostream &out, Tail &&tail) - { - out< - static std::string log(std::ostream &out, Head &&head, Tail &&...tail) - { - out<(head); - log(out, std::forward(tail)...); - } -}; - - -#endif diff --git a/include/yage/pico_png.hpp b/include/yage/pico_png.hpp deleted file mode 100644 index ef123573..00000000 --- a/include/yage/pico_png.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include - -extern int decodePNG(std::vector &out_image, unsigned long &image_width, unsigned long &image_height, const unsigned char *in_png, size_t in_size, bool convert_to_rgba32 = true); diff --git a/include/yage/resource_manager.hpp b/include/yage/resource_manager.hpp deleted file mode 100644 index 155515a3..00000000 --- a/include/yage/resource_manager.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef RESOURCE_MANAGER_HPP -#define RESOURCE_MANAGER_HPP - -#include "gl_texture.hpp" -#include "texture_cache.hpp" - -#include - -class ResourceManager -{ -private: - static TextureCache texture_cache_; -public: - static GlTexture getTexture(const std::string &texture_path); -}; - - -#endif diff --git a/include/yage/sprite.hpp b/include/yage/sprite.hpp deleted file mode 100644 index 9f765c7d..00000000 --- a/include/yage/sprite.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SPRITE_HPP -#define SPRITE_HPP - -#include "gl_texture.hpp" - -#include - -#include - -class Sprite -{ -private: - float x_; - float y_; - float width_; - float height_; - GLuint vbo_id_ = 0; - GlTexture texture_; -public: - Sprite(); - ~Sprite(); - - void init(float x, float y, float width, float height, const std::string &texture_path); - void draw(); -}; - -#endif diff --git a/include/yage/texture_cache.hpp b/include/yage/texture_cache.hpp deleted file mode 100644 index 44dba2f8..00000000 --- a/include/yage/texture_cache.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TEXTURE_CACHE_HPP -#define TEXTURE_CACHE_HPP - -#include "gl_texture.hpp" - -#include - -class TextureCache -{ -private: - std::unordered_map texture_map_; -public: - TextureCache(); - ~TextureCache(); - - GlTexture getTexture(const std::string &texture_path); -}; - - -#endif diff --git a/include/yage/vertex.hpp b/include/yage/vertex.hpp deleted file mode 100644 index d9ab1138..00000000 --- a/include/yage/vertex.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef VERTEX_HPP -#define VERTEX_HPP - -#include - -struct Position -{ - float x; - float y; -}; - -struct Color -{ - GLubyte r; - GLubyte g; - GLubyte b; - GLubyte a; -}; - -struct UV -{ - float u; - float v; -}; - -struct Vertex -{ - Position position; - Color color; - UV uv; - - void setPosition(float x, float y) - { - position.x = x; - position.y = y; - } - - void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) - { - color.r = r; - color.g = g; - color.b = b; - color.a = a; - } - - void setUv(float u, float v) - { - uv.u = u; - uv.v = v; - } -}; - -#endif diff --git a/include/yage/window.hpp b/include/yage/window.hpp deleted file mode 100644 index 6f3058e9..00000000 --- a/include/yage/window.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef WINDOW_HPP -#define WINDOW_HPP - -#include - -#include - -enum class WindowFlags -{ - SHOWN=0x1, - HIDDEN=0x2, - FULLSCREEN=0x4, - BORDERLESS=0x8, -}; - -class Window -{ -private: - SDL_Window *window_=nullptr; - int width_=1280; - int height_=720; - -public: - Window(); - ~Window(); - - void create(const std::string &window_name, int width, int height, WindowFlags flags=WindowFlags::SHOWN); -}; - -#endif -- cgit