diff --git a/Escape-the-Dawn/Components/Input.h b/Escape-the-Dawn/Components/Input.h index f5c9e2a..ca7dfe6 100644 --- a/Escape-the-Dawn/Components/Input.h +++ b/Escape-the-Dawn/Components/Input.h @@ -10,7 +10,7 @@ namespace Components struct Input : Component { int KeyState[GLFW_KEY_LAST]; - float MouseState[2]; + int MouseState[GLFW_MOUSE_BUTTON_LAST]; float dX, dY; }; diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj b/Escape-the-Dawn/Escape-the-Dawn.vcxproj index 22a9e55..6dd87d1 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj @@ -132,7 +132,7 @@ - + diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters index 99a8f67..a27572c 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters @@ -30,7 +30,6 @@ - @@ -107,6 +106,7 @@ Util + diff --git a/Escape-the-Dawn/Renderer.h b/Escape-the-Dawn/Renderer.h index 4dc117b..3280816 100644 --- a/Escape-the-Dawn/Renderer.h +++ b/Escape-the-Dawn/Renderer.h @@ -1,3 +1,6 @@ +#ifndef Renderer_h__ +#define Renderer_h__ + #include #include #include @@ -16,19 +19,32 @@ #include #include "glerror.h" - +#include "ShaderProgram.h" class Renderer { public: - GLuint shaderProgram; + std::shared_ptr m_ShaderProgram; GLuint VAO; + std::vector> Vertices; + std::vector> Normals; + std::vector> TextureCoords; + Renderer(); - + void Draw(); void DrawText(); - GLuint CompileShader(GLenum, std::string); + void AddObjectToDraw(); + void AddTextToDraw(); -}; \ No newline at end of file + void LoadContent(); + + GLFWwindow* GetWindow() const { return m_Window; } + +private: + GLFWwindow* m_Window; +}; + +#endif // Renderer_h__ \ No newline at end of file diff --git a/Escape-the-Dawn/Renderer/Renderer.h b/Escape-the-Dawn/Renderer/Renderer.h deleted file mode 100644 index 77f37f5..0000000 --- a/Escape-the-Dawn/Renderer/Renderer.h +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#define GLFW_INCLUDE_GLU -#include -#include -#define GLM_FORCE_RADIANS -#include -#include -#include -#include - -#include "glerror.h" -#include "ShaderProgram.h" - -class Renderer -{ -public: - std::shared_ptr m_ShaderProgram; - GLuint VAO; - - std::vector> Vertices; - std::vector> Normals; - std::vector> TextureCoords; - - Renderer(); - - void Draw(); - void DrawText(); - - void AddObjectToDraw(); - void AddTextToDraw(); - - void LoadContent(); - GLuint CompileShader(GLenum, std::string); - -}; \ No newline at end of file diff --git a/Escape-the-Dawn/Systems/InputSystem.cpp b/Escape-the-Dawn/Systems/InputSystem.cpp index 15f0790..c0d6822 100644 --- a/Escape-the-Dawn/Systems/InputSystem.cpp +++ b/Escape-the-Dawn/Systems/InputSystem.cpp @@ -7,6 +7,12 @@ void Systems::InputSystem::Update(double dt, EntityID entity, EntityID parent) if (input == nullptr) return; + for (int i = 0; i <= GLFW_KEY_LAST; ++i) { + input->KeyState[i] = glfwGetKey(m_Renderer->GetWindow(), i); + } + for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; ++i) { + input->MouseState[i] = glfwGetMouseButton(m_Renderer->GetWindow(), i); + } } diff --git a/Escape-the-Dawn/Systems/InputSystem.h b/Escape-the-Dawn/Systems/InputSystem.h index 951a75f..ff51ec2 100644 --- a/Escape-the-Dawn/Systems/InputSystem.h +++ b/Escape-the-Dawn/Systems/InputSystem.h @@ -1,10 +1,8 @@ #ifndef InputSystem_h__ #define InputSystem_h__ -#include - #include "System.h" - +#include "Renderer.h" #include "Components/Input.h" namespace Systems @@ -13,13 +11,14 @@ namespace Systems class InputSystem : public System { public: - InputSystem(World* world) - : System(world) - { - - } + InputSystem(World* world, Renderer* renderer) + : System(world), m_Renderer(renderer) { } void Update(double dt, EntityID entity, EntityID parent) override; + +private: + Renderer* m_Renderer; + float m_LastMouseX, m_LastMouseY; }; } diff --git a/Escape-the-Dawn/World.h b/Escape-the-Dawn/World.h index 921c273..5ff403d 100644 --- a/Escape-the-Dawn/World.h +++ b/Escape-the-Dawn/World.h @@ -6,6 +6,8 @@ #include #include +#include "Renderer.h" + #include "Entity.h" #include "Component.h" #include "Factory.h" @@ -64,7 +66,6 @@ public: // Recursively update through the scene graph void Update(double dt); - void RecursiveUpdate(std::shared_ptr system, double dt, EntityID parentEntity); private: