diff --git a/CMakeLists.txt b/CMakeLists.txt index bef597c..daa6558 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ add_library(lol STATIC "src/Shader.cpp" "src/VertexArrayObject.cpp" "vendor/glad/src/glad.c" -) + "include/lol/Texture.hpp" "src/Texture.cpp" "include/lol/util/Factory.hpp" ) target_include_directories(lol PUBLIC ${GLM_INCLUDE_DIRS} diff --git a/include/lol/Shader.hpp b/include/lol/Shader.hpp index 47b21eb..872d218 100644 --- a/include/lol/Shader.hpp +++ b/include/lol/Shader.hpp @@ -6,14 +6,16 @@ #include -#include +#include +#include +#include namespace lol { class AbstractShader : public NonCopyable { - friend class ShaderFactory; + PRODUCT(AbstractShader); public: AbstractShader(const std::string& vertexShader, const std::string& fragmentShader); @@ -32,14 +34,6 @@ namespace lol }; typedef std::shared_ptr Shader; - - class ShaderFactory - { - public: - inline static Shader Produce(const std::string& vertexShader, const std::string& fragmentShader) - { - return std::make_shared(vertexShader, fragmentShader); - } - }; - + typedef Factory ShaderFactory; + typedef ObjectManager ShaderManager; } \ No newline at end of file diff --git a/include/lol/Texture.hpp b/include/lol/Texture.hpp new file mode 100644 index 0000000..e486d2d --- /dev/null +++ b/include/lol/Texture.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace lol +{ + class Texture2D : public NonCopyable + { + public: + Texture2D(); + + private: + unsigned int textureID; + }; +} \ No newline at end of file diff --git a/include/lol/VertexArrayObject.hpp b/include/lol/VertexArrayObject.hpp index 42104e2..ded5277 100644 --- a/include/lol/VertexArrayObject.hpp +++ b/include/lol/VertexArrayObject.hpp @@ -3,7 +3,9 @@ #include #include -#include +#include +#include +#include namespace lol { @@ -30,17 +32,20 @@ namespace lol }; // VAO structure that sets up the buffers and deletes them at the end of the lifecycle - class AbstractVertexArrayObject : public NonCopyable + class AbstractVertexArrayObject : + public NonCopyable { - friend class VAOFactory; + PRODUCT(AbstractVertexArrayObject); public: AbstractVertexArrayObject() = delete; - AbstractVertexArrayObject(const VertexArray& vertices, const IndexArray& indices, const Layout& layout, Usage usage); ~AbstractVertexArrayObject(); void Render(unsigned int mode = 4); + private: + AbstractVertexArrayObject(const VertexArray& vertices, const IndexArray& indices, const Layout& layout, Usage usage = Usage::Static); + private: unsigned int vao, vbo, ebo; size_t indexCount; @@ -53,13 +58,9 @@ namespace lol typedef std::shared_ptr VertexArrayObject; // Factory for creating said shared pointers. - class VAOFactory - { - public: - static VertexArrayObject Produce(const VertexArray& vertices, const IndexArray& indices, const Layout& layout, Usage usage = Usage::Static) - { - return std::make_shared(vertices, indices, layout, usage); - } - }; + typedef Factory VAOFactory; + + // Object manager for managing said shared pointers + typedef ObjectManager VAOManager; } \ No newline at end of file diff --git a/include/lol/lol.hpp b/include/lol/lol.hpp index cac1228..5118de0 100644 --- a/include/lol/lol.hpp +++ b/include/lol/lol.hpp @@ -2,8 +2,7 @@ #include #include -#include #include #include -#include -#include \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/include/lol/BoundingBox.hpp b/include/lol/util/BoundingBox.hpp similarity index 100% rename from include/lol/BoundingBox.hpp rename to include/lol/util/BoundingBox.hpp diff --git a/include/lol/util/Factory.hpp b/include/lol/util/Factory.hpp new file mode 100644 index 0000000..14f3ad6 --- /dev/null +++ b/include/lol/util/Factory.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#define PRODUCT(type) friend class Factory + +namespace lol +{ + + template + class Factory : public NonCopyable + { + public: + ~Factory() {} + + template + inline static std::shared_ptr Produce(Args&&... args) + { + return std::shared_ptr(new Type(args...)); + } + + private: + Factory() {} + }; + +} \ No newline at end of file diff --git a/include/lol/NonCopyable.hpp b/include/lol/util/NonCopyable.hpp similarity index 100% rename from include/lol/NonCopyable.hpp rename to include/lol/util/NonCopyable.hpp diff --git a/include/lol/ObjectManager.hpp b/include/lol/util/ObjectManager.hpp similarity index 89% rename from include/lol/ObjectManager.hpp rename to include/lol/util/ObjectManager.hpp index 845d7d6..4de1438 100644 --- a/include/lol/ObjectManager.hpp +++ b/include/lol/util/ObjectManager.hpp @@ -63,10 +63,4 @@ namespace lol std::map> objects; }; - class AbstractShader; - class AbstractVertexArrayObject; - - typedef ObjectManager VAOManager; - typedef ObjectManager ShaderManager; - } \ No newline at end of file diff --git a/src/Texture.cpp b/src/Texture.cpp new file mode 100644 index 0000000..daa3bc9 --- /dev/null +++ b/src/Texture.cpp @@ -0,0 +1,11 @@ +#include + +#include + +namespace lol +{ + Texture2D::Texture2D() + { + + } +} \ No newline at end of file diff --git a/src/VertexArrayObject.cpp b/src/VertexArrayObject.cpp index a10e250..6fd8c49 100644 --- a/src/VertexArrayObject.cpp +++ b/src/VertexArrayObject.cpp @@ -61,5 +61,4 @@ namespace lol index++; } } - } \ No newline at end of file