From 31317175d72c62994b98a93e1b827633b4de9cb2 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 1 Aug 2017 23:47:35 +0100 Subject: Fixing constructors and destructors --- include/YAGE/Math/matrix.hpp | 9 --------- include/YAGE/Physics/body.hpp | 2 -- include/YAGE/Physics/collider.hpp | 3 --- include/YAGE/camera2d.hpp | 1 - include/YAGE/glslprogram.hpp | 21 +++++++++++++-------- include/YAGE/sprite.hpp | 5 +++++ include/YAGE/spritebatch.hpp | 23 ++++++++++++++--------- include/YAGE/texturecache.hpp | 1 - include/YAGE/window.hpp | 23 +++++++++++++---------- issues.org | 38 -------------------------------------- src/body.cpp | 3 --- src/camera2d.cpp | 3 --- src/glslprogram.cpp | 3 --- src/texturecache.cpp | 3 --- todolist.org | 38 ++++++++++++++++++++++++++++++++++++++ 15 files changed, 83 insertions(+), 93 deletions(-) delete mode 100644 issues.org create mode 100644 todolist.org diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index 388e9535..2aca04db 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -183,15 +183,6 @@ public: return detail::Row((Matrix*)this, row); } - Matrix& operator=(const Matrix &other) - { - if(this!=&other) - { - data_=other.data_; - } - return *this; - } - Matrix& operator+=(const Matrix &rhs) { std::vector out; diff --git a/include/YAGE/Physics/body.hpp b/include/YAGE/Physics/body.hpp index 8fb7aaf6..b0869779 100644 --- a/include/YAGE/Physics/body.hpp +++ b/include/YAGE/Physics/body.hpp @@ -39,8 +39,6 @@ protected: Vector2d force_=Vector2d(0, 0); public: - virtual ~Body(); - // apply force to the object and update the velocity virtual void applyForce(const Vector2d &force)=0; virtual void update()=0; diff --git a/include/YAGE/Physics/collider.hpp b/include/YAGE/Physics/collider.hpp index fc5d38d5..716b7d4c 100644 --- a/include/YAGE/Physics/collider.hpp +++ b/include/YAGE/Physics/collider.hpp @@ -28,9 +28,6 @@ protected: public: Collider(const glm::vec2 &position, const glm::vec2 &size) : position_(position), size_(size) {} - // virtual deconstructor for classes that inherits - virtual ~Collider() {} - // function that checks if two colliders are colliding virtual bool collides(const Collider &collider) const=0; diff --git a/include/YAGE/camera2d.hpp b/include/YAGE/camera2d.hpp index 400cfe02..4c44ccaf 100644 --- a/include/YAGE/camera2d.hpp +++ b/include/YAGE/camera2d.hpp @@ -28,7 +28,6 @@ private: public: Camera2D(int screen_width=1280, int screen_height=720); - virtual ~Camera2D(); // update camera location void update(GlslProgram &program); diff --git a/include/YAGE/glslprogram.hpp b/include/YAGE/glslprogram.hpp index 28222ede..70f30b73 100644 --- a/include/YAGE/glslprogram.hpp +++ b/include/YAGE/glslprogram.hpp @@ -19,19 +19,24 @@ namespace yage 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; + /// 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 + /// compiles one shader void compileShader(const GLuint &shader, const std::string &file_path); public: - GlslProgram(); + GlslProgram()=default; + GlslProgram(const GlslProgram&)=delete; + GlslProgram(GlslProgram&&)=delete; ~GlslProgram(); - // compiles vertex and fragment shader + GlslProgram& operator=(const GlslProgram&)=delete; + GlslProgram& operator=(GlslProgram&&)=delete; + + /// 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); diff --git a/include/YAGE/sprite.hpp b/include/YAGE/sprite.hpp index 9e5aca8b..cddc0e26 100644 --- a/include/YAGE/sprite.hpp +++ b/include/YAGE/sprite.hpp @@ -29,8 +29,13 @@ private: Texture texture_; public: Sprite(); + Sprite(const Sprite&)=delete; + Sprite(Sprite&&)=delete; ~Sprite(); + Sprite& operator=(const Sprite&)=delete; + Sprite& operator=(Sprite&&)=delete; + void init(float x, float y, float width, float height, const std::string &texture_path); void draw(); }; diff --git a/include/YAGE/spritebatch.hpp b/include/YAGE/spritebatch.hpp index 61efd0aa..a3007bbf 100644 --- a/include/YAGE/spritebatch.hpp +++ b/include/YAGE/spritebatch.hpp @@ -36,12 +36,12 @@ private: public: Glyph(GLuint texture, float depth, const Vertex &top_left, const Vertex &top_right, const Vertex &bottom_right, const Vertex &bottom_left); - inline GLuint texture() const { return texture_; } - inline float depth() const { return depth_; } - inline Vertex top_left() const { return top_left_; } - inline Vertex top_right() const { return top_right_; } - inline Vertex bottom_right() const { return bottom_right_; } - inline Vertex bottom_left() const { return bottom_left_; } + GLuint texture() const { return texture_; } + float depth() const { return depth_; } + Vertex top_left() const { return top_left_; } + Vertex top_right() const { return top_right_; } + Vertex bottom_right() const { return bottom_right_; } + Vertex bottom_left() const { return bottom_left_; } }; class RenderBatch @@ -58,9 +58,9 @@ public: RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture); // getters - inline GLint offset() const { return offset_; } - inline GLsizei num_vertices() const { return num_vertices_; } - inline GLuint texture() const { return texture_; } + GLint offset() const { return offset_; } + GLsizei num_vertices() const { return num_vertices_; } + GLuint texture() const { return texture_; } }; class SpriteBatch @@ -78,8 +78,13 @@ private: // member functions public: SpriteBatch(); + SpriteBatch(const SpriteBatch&)=delete; + SpriteBatch(SpriteBatch&&)=delete; ~SpriteBatch(); + SpriteBatch& operator=(const SpriteBatch&)=delete; + SpriteBatch& operator=(SpriteBatch&&)=delete; + // initialize vaos and vbos void init(); void begin(); diff --git a/include/YAGE/texturecache.hpp b/include/YAGE/texturecache.hpp index 158f81ee..ac318230 100644 --- a/include/YAGE/texturecache.hpp +++ b/include/YAGE/texturecache.hpp @@ -22,7 +22,6 @@ private: std::unordered_map texture_map_; public: TextureCache(); - ~TextureCache(); Texture getTexture(const std::string &texture_path); }; diff --git a/include/YAGE/window.hpp b/include/YAGE/window.hpp index 98ba2592..beefae3d 100644 --- a/include/YAGE/window.hpp +++ b/include/YAGE/window.hpp @@ -28,25 +28,28 @@ enum WindowFlags : unsigned // window wrapper around SDL_Window pointer class Window { -public: // member variables private: - // window handle + /// window handle SDL_Window *window_=nullptr; -public: // member functions +public: Window(); - // destroys the window handle - ~Window(); + Window(const Window&)=delete; + Window(Window&&)=delete; + /// destroys the window handle + ~Window(); - // create the window, initialize the handle and update the width and height + Window& operator=(const Window&)=delete; + Window& operator=(Window&&)=delete; + + /// create the window, initialize the handle and update the width and height void create(const std::string &window_name, int width, int height, unsigned flags=WindowFlags::SHOWN); - // swap the buffer + /// swap the buffer void swapBuffer(); - // clear buffer + /// clear buffer void clearBuffer(); -private: }; -} // yage +} // namespace yage #endif diff --git a/issues.org b/issues.org deleted file mode 100644 index c0b1c287..00000000 --- a/issues.org +++ /dev/null @@ -1,38 +0,0 @@ -#+TITLE: Issues -#+DATE: <2017-07-27 Thu> -#+AUTHOR: Yann Herklotz -#+EMAIL: ymherklotz@gmail.com -#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline -#+OPTIONS: author:t c:nil creator:comment d:(not "LOGBOOK") date:t -#+OPTIONS: e:t email:nil f:t inline:t num:t p:nil pri:nil stat:t -#+OPTIONS: tags:t tasks:t tex:t timestamp:t toc:t todo:t |:t -#+CREATOR: Emacs 25.2.1 (Org mode 8.2.10) -#+DESCRIPTION: This is a todo list for yage. -#+EXCLUDE_TAGS: noexport -#+KEYWORDS: todo list -#+LANGUAGE: en -#+SELECT_TAGS: export - -* General - -** TODO Add comments - -*** Reason - Currently there are no comments in the code. They should be added so that in the future the code - can be edited easily and improved without having to know the exact implementation of every function. - -*** Requirements - - It should follow the doxygen API so that documentation can easily be generated. - - -* Graphics - -** TODO Switch GPU API - -*** Reason - Vulkan is much more straight forward and it should be easier to understand OpenGL from it. I - also the newest API that will be used in the newest games and is supported by quite a few - graphics cards. - -*** Requirements - - yage shouldn't depend on GL anymore and exclusively use Vulkan libraries. diff --git a/src/body.cpp b/src/body.cpp index 524a92ee..ad92b0ca 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -13,9 +13,6 @@ namespace yage const double Body::GRAVITY=-9.81; -Body::~Body() -{} - double Body::xPosition() const { return position_[0]; diff --git a/src/camera2d.cpp b/src/camera2d.cpp index 0b60b7c6..88b468de 100644 --- a/src/camera2d.cpp +++ b/src/camera2d.cpp @@ -19,9 +19,6 @@ Camera2D::Camera2D(int screen_width, int screen_height) : ortho_matrix_(glm::ortho(0.f, (float)screen_width, 0.f, (float)screen_height)) {} -Camera2D::~Camera2D() -{} - void Camera2D::update(GlslProgram &program) { if(matrix_needs_update_) diff --git a/src/glslprogram.cpp b/src/glslprogram.cpp index acb81f56..18fee54e 100644 --- a/src/glslprogram.cpp +++ b/src/glslprogram.cpp @@ -15,9 +15,6 @@ namespace yage { -GlslProgram::GlslProgram() -{} - GlslProgram::~GlslProgram() { // cleanup all the shaders and the program diff --git a/src/texturecache.cpp b/src/texturecache.cpp index bc48c4e0..6d10b209 100644 --- a/src/texturecache.cpp +++ b/src/texturecache.cpp @@ -15,9 +15,6 @@ namespace yage TextureCache::TextureCache() {} -TextureCache::~TextureCache() -{} - Texture TextureCache::getTexture(const std::string &texture_path) { auto itr = texture_map_.find(texture_path); diff --git a/todolist.org b/todolist.org new file mode 100644 index 00000000..c0b1c287 --- /dev/null +++ b/todolist.org @@ -0,0 +1,38 @@ +#+TITLE: Issues +#+DATE: <2017-07-27 Thu> +#+AUTHOR: Yann Herklotz +#+EMAIL: ymherklotz@gmail.com +#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline +#+OPTIONS: author:t c:nil creator:comment d:(not "LOGBOOK") date:t +#+OPTIONS: e:t email:nil f:t inline:t num:t p:nil pri:nil stat:t +#+OPTIONS: tags:t tasks:t tex:t timestamp:t toc:t todo:t |:t +#+CREATOR: Emacs 25.2.1 (Org mode 8.2.10) +#+DESCRIPTION: This is a todo list for yage. +#+EXCLUDE_TAGS: noexport +#+KEYWORDS: todo list +#+LANGUAGE: en +#+SELECT_TAGS: export + +* General + +** TODO Add comments + +*** Reason + Currently there are no comments in the code. They should be added so that in the future the code + can be edited easily and improved without having to know the exact implementation of every function. + +*** Requirements + - It should follow the doxygen API so that documentation can easily be generated. + + +* Graphics + +** TODO Switch GPU API + +*** Reason + Vulkan is much more straight forward and it should be easier to understand OpenGL from it. I + also the newest API that will be used in the newest games and is supported by quite a few + graphics cards. + +*** Requirements + - yage shouldn't depend on GL anymore and exclusively use Vulkan libraries. -- cgit