From ab92d8abc2484671eccd633b8cfdd65598eb51a1 Mon Sep 17 00:00:00 2001 From: Light3039 Date: Thu, 27 May 2021 18:55:30 +0430 Subject: [PATCH] Maintenance --- Engine/premake5.lua | 2 +- Engine/src/Engine/Base.h | 2 +- Engine/src/Engine/Core/Application.cpp | 25 ++++++++--- Engine/src/Engine/Core/Application.h | 9 ++-- Engine/src/Engine/Core/Logger.cpp | 4 +- Engine/src/Engine/Core/Logger.h | 5 ++- Engine/src/Engine/Core/Window.h | 16 ++++--- Engine/src/Engine/EntryPoint.h | 2 +- Engine/src/Engine/Events/Event.h | 8 +--- Engine/src/Engine/Events/KeyboardEvents.h | 1 - Engine/src/Engine/Events/MouseEvents.h | 1 - Engine/src/Engine/Events/WindowEvents.h | 1 - .../src/Engine/Graphics/GraphicsContext.cpp | 28 +++++++++--- Engine/src/Engine/Graphics/GraphicsContext.h | 17 +++++--- Engine/src/Engine/Graphics/RenderCommand.cpp | 3 +- Engine/src/Engine/Graphics/RenderCommand.h | 12 +++++- Engine/src/Engine/Graphics/Shader.cpp | 7 +++ Engine/src/Engine/Graphics/Shader.h | 20 +++++++++ Engine/src/Engine/Layer/Layer.h | 43 ++++++------------- Engine/src/Engine/Layer/LayerStack.cpp | 7 ++- Engine/src/Engine/Layer/LayerStack.h | 10 ++--- .../Engine/UserInterface/UserInterface.cpp | 7 +-- .../src/Engine/UserInterface/UserInterface.h | 14 ++++-- Engine/src/LightEngine.h | 25 +++++++++-- .../GraphicsAPI/OpenGL/glGraphicsContext.cpp | 4 ++ .../GraphicsAPI/OpenGL/glRenderCommand.h | 3 +- .../GraphicsAPI/OpenGL/glUserInterface.cpp | 3 -- .../GraphicsAPI/OpenGL/glUserInterface.h | 3 -- Engine/src/Platform/OS/Windows/wWindow.cpp | 5 ++- Engine/src/Platform/OS/Windows/wWindow.h | 12 +++--- Sandbox/imgui.ini | 4 +- Sandbox/premake5.lua | 2 +- Sandbox/src/SandboxApp.cpp | 1 + 33 files changed, 193 insertions(+), 113 deletions(-) create mode 100644 Engine/src/Engine/Graphics/Shader.cpp create mode 100644 Engine/src/Engine/Graphics/Shader.h diff --git a/Engine/premake5.lua b/Engine/premake5.lua index 1c330e2..1587989 100644 --- a/Engine/premake5.lua +++ b/Engine/premake5.lua @@ -50,7 +50,7 @@ project "Engine" --- Filters --- -- windows filter "system:windows" - defines "LT_PLATFORM_WINDOWS" + defines "LIGHT_PLATFORM_WINDOWS" systemversion "latest" staticruntime "On" diff --git a/Engine/src/Engine/Base.h b/Engine/src/Engine/Base.h index 51b8005..e06aa7a 100644 --- a/Engine/src/Engine/Base.h +++ b/Engine/src/Engine/Base.h @@ -2,7 +2,7 @@ #include "Core/Logger.h" -#if defined(LT_PLATFORM_WINDOWS) +#if defined(LIGHT_PLATFORM_WINDOWS) #define LT_BUILD_PLATFORM "Windows" #elif defined(LT_PLATFORM_LINUX) #error "Unsupported platform: UNIX" diff --git a/Engine/src/Engine/Core/Application.cpp b/Engine/src/Engine/Core/Application.cpp index 7dd213f..d669b87 100644 --- a/Engine/src/Engine/Core/Application.cpp +++ b/Engine/src/Engine/Core/Application.cpp @@ -4,49 +4,60 @@ #include "Logger.h" #include "Window.h" -#include "Events/MouseEvents.h" +#include "Events/Event.h" -#include -#include +#include "Graphics/GraphicsContext.h" +#include "Graphics/RenderCommand.h" + +#include "UserInterface/UserInterface.h" namespace Light { Application::Application() { Logger::Initialize(); - m_Window = std::unique_ptr(Window::Create({ "Title", 800u, 600u, false }, std::bind(&Application::OnEvent, this , std::placeholders::_1))); - - LT_ENGINE_INFO("Initialized Logger"); } Application::~Application() { + LT_ENGINE_INFO("Application::~Application: Terminating Application"); } void Application::GameLoop() { while (m_Window->IsOpen()) { + // Events m_Window->PollEvents(); + // Rendering m_Window->GetGfxContext()->GetRenderCommand()->SwapBuffers(); m_Window->GetGfxContext()->GetRenderCommand()->ClearBackBuffer(); - m_Window->GetGfxContext()->GetUserInterface()->Begin(); + // Update + // ... + // UserInterface + m_Window->GetGfxContext()->GetUserInterface()->Begin(); m_Window->GetGfxContext()->GetUserInterface()->End(); } } void Application::OnEvent(const Event& event) { + // Window if (event.HasCategory(WindowEventCategory)) m_Window->OnEvent(event); + // UserInterface if (event.HasCategory(InputEventCategory)) m_Window->GetGfxContext()->GetUserInterface()->OnInput(event); + // Input + // ... + + // Layers m_LayerStack.OnEvent(event); } diff --git a/Engine/src/Engine/Core/Application.h b/Engine/src/Engine/Core/Application.h index 7a9833e..b7a32e4 100644 --- a/Engine/src/Engine/Core/Application.h +++ b/Engine/src/Engine/Core/Application.h @@ -2,22 +2,23 @@ #include "Base.h" -#include "Events/Event.h" - #include "Layer/LayerStack.h" -#include - namespace Light { class Window; + class Event; class Application { private: std::unique_ptr m_Window = nullptr; LayerStack m_LayerStack; + public: + Application(const Application&) = delete; + Application& operator=(const Application&) = delete; + virtual ~Application(); void GameLoop(); diff --git a/Engine/src/Engine/Core/Logger.cpp b/Engine/src/Engine/Core/Logger.cpp index 50736e0..76765c2 100644 --- a/Engine/src/Engine/Core/Logger.cpp +++ b/Engine/src/Engine/Core/Logger.cpp @@ -5,8 +5,8 @@ namespace Light { - std::shared_ptr Logger::s_EngineLogger; - std::shared_ptr Logger::s_ClientLogger; + std::shared_ptr Logger::s_EngineLogger = nullptr; + std::shared_ptr Logger::s_ClientLogger = nullptr; void Light::Logger::Initialize() { diff --git a/Engine/src/Engine/Core/Logger.h b/Engine/src/Engine/Core/Logger.h index 2fdf97d..517144b 100644 --- a/Engine/src/Engine/Core/Logger.h +++ b/Engine/src/Engine/Core/Logger.h @@ -1,6 +1,4 @@ #pragma once -// TODO: File logger -// #include "Base.h" @@ -40,7 +38,10 @@ namespace Light { { private: static std::shared_ptr s_EngineLogger, s_ClientLogger; + public: + Logger() = delete; + static void Initialize(); static inline std::shared_ptr GetEngineLogger() { return s_EngineLogger; } diff --git a/Engine/src/Engine/Core/Window.h b/Engine/src/Engine/Core/Window.h index bf133e1..7188a4b 100644 --- a/Engine/src/Engine/Core/Window.h +++ b/Engine/src/Engine/Core/Window.h @@ -2,14 +2,11 @@ #include "Base.h" -#include "Events/Event.h" - -#include "Graphics/GraphicsContext.h" - -#include - namespace Light { + class Event; + class GraphicsContext; + struct WindowProperties { std::string title; @@ -22,7 +19,11 @@ namespace Light { protected: std::unique_ptr m_GraphicsContext; bool b_Open; + public: + Window(const Window&) = delete; + Window& operator=(const Window&) = delete; + virtual ~Window() = default; inline GraphicsContext* GetGfxContext() { return m_GraphicsContext.get(); } @@ -38,6 +39,9 @@ namespace Light { virtual inline void* GetNativeHandle() = 0; static Window* Create(const WindowProperties& properties, std::function callback); + + protected: + Window() = default; }; } \ No newline at end of file diff --git a/Engine/src/Engine/EntryPoint.h b/Engine/src/Engine/EntryPoint.h index 8c2b948..08f9117 100644 --- a/Engine/src/Engine/EntryPoint.h +++ b/Engine/src/Engine/EntryPoint.h @@ -1,6 +1,6 @@ #pragma once -#ifdef LT_PLATFORM_WINDOWS +#ifdef LIGHT_PLATFORM_WINDOWS // To be defined in client project extern Light::Application* Light::CreateApplication(); diff --git a/Engine/src/Engine/Events/Event.h b/Engine/src/Engine/Events/Event.h index 9eaf948..7828cf1 100644 --- a/Engine/src/Engine/Events/Event.h +++ b/Engine/src/Engine/Events/Event.h @@ -2,10 +2,6 @@ #include "Base.h" -#include - -#include - namespace Light { enum class EventType @@ -13,8 +9,8 @@ namespace Light { None = 0, // input - MouseMoved, WheelScrolled, ButtonPressed, ButtonReleased, // mouse - KeyPressed, KeyReleased, // keyboard + MouseMoved, WheelScrolled, ButtonPressed, ButtonReleased, + KeyPressed, KeyReleased, // window WindowMoved, WindowResized, WindowClosed, WindowLostFocus, WindowGainFocus, diff --git a/Engine/src/Engine/Events/KeyboardEvents.h b/Engine/src/Engine/Events/KeyboardEvents.h index b9ddb6e..8c3e20a 100644 --- a/Engine/src/Engine/Events/KeyboardEvents.h +++ b/Engine/src/Engine/Events/KeyboardEvents.h @@ -1,7 +1,6 @@ #pragma once #include "Base.h" - #include "Event.h" #include diff --git a/Engine/src/Engine/Events/MouseEvents.h b/Engine/src/Engine/Events/MouseEvents.h index fda8e4c..8dc96c3 100644 --- a/Engine/src/Engine/Events/MouseEvents.h +++ b/Engine/src/Engine/Events/MouseEvents.h @@ -1,7 +1,6 @@ #pragma once #include "Base.h" - #include "Event.h" #include diff --git a/Engine/src/Engine/Events/WindowEvents.h b/Engine/src/Engine/Events/WindowEvents.h index 9ce43fb..ba6ca1e 100644 --- a/Engine/src/Engine/Events/WindowEvents.h +++ b/Engine/src/Engine/Events/WindowEvents.h @@ -1,7 +1,6 @@ #pragma once #include "Base.h" - #include "Event.h" #include diff --git a/Engine/src/Engine/Graphics/GraphicsContext.cpp b/Engine/src/Engine/Graphics/GraphicsContext.cpp index 2958639..70006bd 100644 --- a/Engine/src/Engine/Graphics/GraphicsContext.cpp +++ b/Engine/src/Engine/Graphics/GraphicsContext.cpp @@ -1,29 +1,45 @@ #include "ltpch.h" #include "GraphicsContext.h" - #include "OpenGL/glGraphicsContext.h" +#include "RenderCommand.h" +#include "UserInterface/UserInterface.h" + namespace Light { GraphicsContext* GraphicsContext::s_Context = nullptr; GraphicsContext* GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle) { + // terminate gfx context dependent classes + if (s_Context) + { + s_Context->m_RenderCommand.reset(); + s_Context->m_UserInterface.reset(); + } + + // create gfx context switch (api) { case Light::GraphicsAPI::Default: case Light::GraphicsAPI::OpenGL: s_Context = new glGraphicsContext(windowHandle); + break; + default: + break; + // TODO: ASSERT + } + + // create gfx context dependent classes + if (s_Context) + { s_Context->m_RenderCommand = std::unique_ptr(RenderCommand::Create(windowHandle)); s_Context->m_UserInterface = std::unique_ptr(UserInterface::Create(windowHandle)); // ...Renderer // ...UserInterface... - - return s_Context; - - default: - return nullptr; // TODO: Add ASSERT } + + return s_Context; } } \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/GraphicsContext.h b/Engine/src/Engine/Graphics/GraphicsContext.h index 552a705..d5ebeda 100644 --- a/Engine/src/Engine/Graphics/GraphicsContext.h +++ b/Engine/src/Engine/Graphics/GraphicsContext.h @@ -2,14 +2,14 @@ #include "Base.h" -#include "RenderCommand.h" -#include "UserInterface/UserInterface.h" - -struct GLFWwindow {}; +struct GLFWwindow; namespace Light { + class RenderCommand; + class UserInterface; + enum class GraphicsAPI { Default, OpenGL // TODO: Add DirectX, Vulkan, Metal. @@ -22,18 +22,25 @@ namespace Light { std::unique_ptr m_RenderCommand; std::unique_ptr m_UserInterface; + protected: GraphicsAPI m_GraphicsAPI; public: - virtual ~GraphicsContext() = default; + GraphicsContext(const GraphicsContext&) = delete; + GraphicsContext& operator=(const GraphicsContext&) = delete; + virtual ~GraphicsContext() = default; + static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle); static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; } inline RenderCommand* GetRenderCommand() { return m_RenderCommand.get(); } inline UserInterface* GetUserInterface() { return m_UserInterface.get(); } + + protected: + GraphicsContext() = default; }; } \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RenderCommand.cpp b/Engine/src/Engine/Graphics/RenderCommand.cpp index 32de053..1aa0877 100644 --- a/Engine/src/Engine/Graphics/RenderCommand.cpp +++ b/Engine/src/Engine/Graphics/RenderCommand.cpp @@ -1,10 +1,9 @@ #include "ltpch.h" #include "RenderCommand.h" +#include "OpenGL/glRenderCommand.h" #include "GraphicsContext.h" -#include "OpenGL/glRenderCommand.h" - namespace Light { RenderCommand* RenderCommand::Create(GLFWwindow* windowHandle) diff --git a/Engine/src/Engine/Graphics/RenderCommand.h b/Engine/src/Engine/Graphics/RenderCommand.h index 285134d..3636624 100644 --- a/Engine/src/Engine/Graphics/RenderCommand.h +++ b/Engine/src/Engine/Graphics/RenderCommand.h @@ -1,5 +1,7 @@ #pragma once +#include "Base.h" + struct GLFWwindow; namespace Light { @@ -8,13 +10,21 @@ namespace Light { { private: public: - static RenderCommand* Create(GLFWwindow* windowHandle); + RenderCommand(const RenderCommand&) = delete; + RenderCommand& operator=(const RenderCommand&) = delete; + + virtual ~RenderCommand() = default; virtual void SwapBuffers() = 0; virtual void ClearBackBuffer() = 0; virtual void Draw(unsigned int count) = 0; virtual void DrawIndexed(unsigned int count) = 0; + + static RenderCommand* Create(GLFWwindow* windowHandle); + + protected: + RenderCommand() = default; }; } \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Shader.cpp b/Engine/src/Engine/Graphics/Shader.cpp new file mode 100644 index 0000000..80022d1 --- /dev/null +++ b/Engine/src/Engine/Graphics/Shader.cpp @@ -0,0 +1,7 @@ +#include "ltpch.h" +#include "Shader.h" + +namespace Light { + + +} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Shader.h b/Engine/src/Engine/Graphics/Shader.h new file mode 100644 index 0000000..eb99c6b --- /dev/null +++ b/Engine/src/Engine/Graphics/Shader.h @@ -0,0 +1,20 @@ +#pragma once + +namespace Light { + + class Shader + { + private: + public: + static Shader* Create(); + + virtual ~Shader() = default; + + virtual void Bind() = 0; + virtual void UnBind() = 0; + + protected: + Shader() = default; + }; + +} \ No newline at end of file diff --git a/Engine/src/Engine/Layer/Layer.h b/Engine/src/Engine/Layer/Layer.h index 2041994..b536b46 100644 --- a/Engine/src/Engine/Layer/Layer.h +++ b/Engine/src/Engine/Layer/Layer.h @@ -2,14 +2,22 @@ #include "Base.h" -#include "Events/MouseEvents.h" -#include "Events/KeyboardEvents.h" -#include "Events/WindowEvents.h" - -#include - namespace Light { + class MouseMovedEvent; + class ButtonPressedEvent; + class ButtonReleasedEvent; + class WheelScrolledEvent; + + class KeyPressedEvent; + class KeyReleasedEvent; + + class WindowClosedEvent; + class WindowResizedEvent; + class WindowMovedEvent; + class WindowLostFocusEvent; + class WindowGainFocusEvent; + class Layer { private: @@ -43,27 +51,4 @@ namespace Light { virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; } }; - class TestLayer : public Layer - { - public: - TestLayer(const std::string& name): Layer(name) {} - - // Mouse events - virtual bool OnMouseMoved(const MouseMovedEvent& event) override { LT_ENGINE_TRACE("{}", event.GetInfoLog()); return false; } - virtual bool OnButtonPressed(const ButtonPressedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnButtonReleased(const ButtonReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnWheelScrolled(const WheelScrolledEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - - // Keyboard events - virtual bool OnKeyPressed(const KeyPressedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnKeyReleased(const KeyReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - - // Window events - virtual bool OnWindowClosed(const WindowClosedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnWindowResized(const WindowResizedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnWindowMoved(const WindowMovedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnWindowLostFocus(const WindowLostFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; } - }; - } \ No newline at end of file diff --git a/Engine/src/Engine/Layer/LayerStack.cpp b/Engine/src/Engine/Layer/LayerStack.cpp index 880db1d..1a27660 100644 --- a/Engine/src/Engine/Layer/LayerStack.cpp +++ b/Engine/src/Engine/Layer/LayerStack.cpp @@ -1,7 +1,12 @@ #include "ltpch.h" #include "LayerStack.h" -#include +#include "Layer.h" + +#include "Events/Event.h" +#include "Events/MouseEvents.h" +#include "Events/KeyboardEvents.h" +#include "Events/WindowEvents.h" namespace Light { diff --git a/Engine/src/Engine/Layer/LayerStack.h b/Engine/src/Engine/Layer/LayerStack.h index d2db61e..7dd3814 100644 --- a/Engine/src/Engine/Layer/LayerStack.h +++ b/Engine/src/Engine/Layer/LayerStack.h @@ -2,14 +2,11 @@ #include "Base.h" -#include "Layer.h" - -#include "Events/Event.h" - -#include - namespace Light { + class Layer; + class Event; + class LayerStack { private: @@ -38,7 +35,6 @@ namespace Light { private: void AttachLayerImpl(Layer* layer); void DetatchLayerImpl(Layer* layer); - }; } \ No newline at end of file diff --git a/Engine/src/Engine/UserInterface/UserInterface.cpp b/Engine/src/Engine/UserInterface/UserInterface.cpp index a9b1707..7a95071 100644 --- a/Engine/src/Engine/UserInterface/UserInterface.cpp +++ b/Engine/src/Engine/UserInterface/UserInterface.cpp @@ -1,11 +1,12 @@ #include "ltpch.h" #include "UserInterface.h" - -#include "Graphics/GraphicsContext.h" #include "OpenGL/glUserInterface.h" -#include "Events/KeyboardEvents.h" +#include "Graphics/GraphicsContext.h" + +#include "Events/Event.h" #include "Events/MouseEvents.h" +#include "Events/KeyboardEvents.h" #include diff --git a/Engine/src/Engine/UserInterface/UserInterface.h b/Engine/src/Engine/UserInterface/UserInterface.h index b43ca38..9ae1088 100644 --- a/Engine/src/Engine/UserInterface/UserInterface.h +++ b/Engine/src/Engine/UserInterface/UserInterface.h @@ -2,22 +2,28 @@ #include "Base.h" -#include "Events/Event.h" - struct GLFWwindow; namespace Light { + class Event; + class UserInterface { - private: public: - static UserInterface* Create(GLFWwindow* windowHandle); + UserInterface(const UserInterface&) = delete; + UserInterface operator=(const UserInterface&) = delete; + + virtual ~UserInterface() = default; void OnInput(const Event& inputEvent); virtual void Begin() = 0; virtual void End() = 0; + + static UserInterface* Create(GLFWwindow* windowHandle); + protected: + UserInterface() = default; }; } \ No newline at end of file diff --git a/Engine/src/LightEngine.h b/Engine/src/LightEngine.h index 0183dfd..1c47bc1 100644 --- a/Engine/src/LightEngine.h +++ b/Engine/src/LightEngine.h @@ -1,11 +1,30 @@ #pragma once +// Core +#include "Core/Application.h" +#include "Core/Window.h" +#include "Core/Logger.h" + +// Events #include "Events/Event.h" #include "Events/KeyboardEvents.h" #include "Events/MouseEvents.h" +#include "Events/WindowEvents.h" -#include "Core/Application.h" -#include "Core/Logger.h" +// Graphics +#include "Graphics/GraphicsContext.h" +#include "Graphics/RenderCommand.h" +// Layer +#include "Layer/Layer.h" +#include "Layer/LayerStack.h" + +// UserInterface +#include "UserInterface/UserInterface.h" + +// Base #include "Base.h" -#include "EntryPoint.h" \ No newline at end of file + +#ifdef LIGHT_ENTRY_POINT + #include "EntryPoint.h" +#endif \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp index 448ef64..b3e588b 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp @@ -1,6 +1,10 @@ #include "ltpch.h" #include "glGraphicsContext.h" +// Required for forward declaration +#include "Graphics/RenderCommand.h" +#include "UserInterface/UserInterface.h" + #include #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h index 789992b..e66f6b1 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h @@ -3,13 +3,13 @@ #include "Base.h" #include "Graphics/RenderCommand.h" - namespace Light { class glRenderCommand : public RenderCommand { private: GLFWwindow* m_WindowHandle; + public: glRenderCommand(GLFWwindow* windowHandle); @@ -20,5 +20,4 @@ namespace Light { void DrawIndexed(unsigned int count) override; }; - } \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp index 7149f34..398ce37 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp @@ -1,9 +1,6 @@ #include "ltpch.h" #include "glUserInterface.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" - #include #include #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h index 28bd89b..85685ed 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h @@ -3,13 +3,10 @@ #include "Base.h" #include "UserInterface/UserInterface.h" -#include "Events/Event.h" - namespace Light { class glUserInterface : public UserInterface { - private: public: glUserInterface(GLFWwindow* windowHandle); ~glUserInterface(); diff --git a/Engine/src/Platform/OS/Windows/wWindow.cpp b/Engine/src/Platform/OS/Windows/wWindow.cpp index 0d8a1db..3a0f193 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.cpp +++ b/Engine/src/Platform/OS/Windows/wWindow.cpp @@ -1,12 +1,15 @@ #include "ltpch.h" #include "wWindow.h" -#include "Events/KeyboardEvents.h" +#include "Events/Event.h" #include "Events/MouseEvents.h" +#include "Events/KeyboardEvents.h" #include "Events/WindowEvents.h" #include "Graphics/GraphicsContext.h" +#include + namespace Light { Window* Window::Create(const WindowProperties& properties, std::function callback) diff --git a/Engine/src/Platform/OS/Windows/wWindow.h b/Engine/src/Platform/OS/Windows/wWindow.h index 7a0fd26..cd03cb2 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.h +++ b/Engine/src/Platform/OS/Windows/wWindow.h @@ -1,18 +1,14 @@ #pragma once -#define GLFW_INCLUDE_NONE #include "Base.h" - #include "Core/Window.h" -#include "Events/Event.h" -#include - -#include - +struct GLFWwindow; namespace Light { + class Event; + class wWindow : public Window { private: @@ -20,6 +16,7 @@ namespace Light { WindowProperties m_Properties; std::function m_EventCallback; + public: wWindow(const WindowProperties& properties, std::function callback); @@ -32,6 +29,7 @@ namespace Light { virtual unsigned int GetHeight() override; virtual inline void* GetNativeHandle() override { return m_Handle; } + private: void BindGlfwEvents(); }; diff --git a/Sandbox/imgui.ini b/Sandbox/imgui.ini index c404be8..b8157e5 100644 --- a/Sandbox/imgui.ini +++ b/Sandbox/imgui.ini @@ -4,8 +4,8 @@ Size=400,400 Collapsed=0 [Window][Dear ImGui Demo] -Pos=248,45 -Size=550,536 +Pos=276,-1 +Size=521,536 Collapsed=0 [Table][0xC9935533,3] diff --git a/Sandbox/premake5.lua b/Sandbox/premake5.lua index d0a0a45..b111012 100644 --- a/Sandbox/premake5.lua +++ b/Sandbox/premake5.lua @@ -47,7 +47,7 @@ project "Sandbox" --- Filters --- -- windows filter "system:windows" - defines "LT_PLATFORM_WINDOWS" + defines "LIGHT_PLATFORM_WINDOWS" systemversion "latest" staticruntime "On" diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/SandboxApp.cpp index 80f8f7c..8745c47 100644 --- a/Sandbox/src/SandboxApp.cpp +++ b/Sandbox/src/SandboxApp.cpp @@ -1,3 +1,4 @@ +#define LIGHT_ENTRY_POINT #include #include "SandboxLayer.h"