From acbed604bbead6e1625aecad151a2617a011d9e2 Mon Sep 17 00:00:00 2001 From: Light Date: Tue, 8 Mar 2022 21:19:19 +0330 Subject: [PATCH] Style: Rename *.h -> *.hpp --- CMakeLists.txt | 2 +- Engine/src/Engine/Base/{Base.h => Base.hpp} | 10 +- .../src/Engine/Base/{Config.h => Config.hpp} | 0 .../Base/{EntryPoint.h => EntryPoint.hpp} | 4 +- .../Portables/{DebugTrap.h => DebugTrap.hpp} | 2 +- Engine/src/Engine/Camera/Camera.cpp | 2 +- Engine/src/Engine/Camera/Camera.h | 27 --- Engine/src/Engine/Camera/Camera.hpp | 27 +++ .../src/Engine/Camera/OrthographicCamera.cpp | 62 +++--- Engine/src/Engine/Camera/OrthographicCamera.h | 41 ---- .../src/Engine/Camera/OrthographicCamera.hpp | 41 ++++ Engine/src/Engine/Camera/SceneCamera.cpp | 131 ++++++------- Engine/src/Engine/Camera/SceneCamera.h | 65 ------ Engine/src/Engine/Camera/SceneCamera.hpp | 65 ++++++ Engine/src/Engine/Core/Application.cpp | 20 +- Engine/src/Engine/Core/Application.h | 58 ------ Engine/src/Engine/Core/Application.hpp | 54 +++++ Engine/src/Engine/Core/UUID.cpp | 19 +- Engine/src/Engine/Core/{UUID.h => UUID.hpp} | 0 Engine/src/Engine/Core/Window.h | 75 ------- Engine/src/Engine/Core/Window.hpp | 73 +++++++ Engine/src/Engine/Debug/Exceptions.cpp | 4 +- .../Debug/{Exceptions.h => Exceptions.hpp} | 0 Engine/src/Engine/Debug/Instrumentor.cpp | 2 +- Engine/src/Engine/Debug/Instrumentor.h | 70 ------- Engine/src/Engine/Debug/Instrumentor.hpp | 70 +++++++ Engine/src/Engine/Debug/Logger.cpp | 2 +- .../src/Engine/Debug/{Logger.h => Logger.hpp} | 2 +- Engine/src/Engine/Events/CharEvent.h | 34 ---- Engine/src/Engine/Events/CharEvent.hpp | 33 ++++ Engine/src/Engine/Events/Event.h | 46 ----- Engine/src/Engine/Events/Event.hpp | 57 ++++++ Engine/src/Engine/Events/KeyboardEvents.h | 80 -------- Engine/src/Engine/Events/KeyboardEvents.hpp | 79 ++++++++ Engine/src/Engine/Events/MouseEvents.h | 108 ---------- Engine/src/Engine/Events/MouseEvents.hpp | 106 ++++++++++ Engine/src/Engine/Events/WindowEvents.h | 92 --------- Engine/src/Engine/Events/WindowEvents.hpp | 91 +++++++++ Engine/src/Engine/Graphics/Blender.cpp | 10 +- Engine/src/Engine/Graphics/Blender.h | 48 ----- Engine/src/Engine/Graphics/Blender.hpp | 49 +++++ Engine/src/Engine/Graphics/Buffers.cpp | 12 +- Engine/src/Engine/Graphics/Buffers.h | 62 ------ Engine/src/Engine/Graphics/Buffers.hpp | 62 ++++++ Engine/src/Engine/Graphics/Framebuffer.cpp | 10 +- Engine/src/Engine/Graphics/Framebuffer.h | 33 ---- Engine/src/Engine/Graphics/Framebuffer.hpp | 33 ++++ .../src/Engine/Graphics/GraphicsContext.cpp | 20 +- Engine/src/Engine/Graphics/GraphicsContext.h | 60 ------ .../src/Engine/Graphics/GraphicsContext.hpp | 59 ++++++ Engine/src/Engine/Graphics/RenderCommand.cpp | 10 +- Engine/src/Engine/Graphics/RenderCommand.h | 37 ---- Engine/src/Engine/Graphics/RenderCommand.hpp | 37 ++++ Engine/src/Engine/Graphics/Renderer.cpp | 16 +- Engine/src/Engine/Graphics/Renderer.h | 85 -------- Engine/src/Engine/Graphics/Renderer.hpp | 84 ++++++++ .../RendererPrograms/QuadRendererProgram.cpp | 12 +- .../RendererPrograms/QuadRendererProgram.h | 56 ------ .../RendererPrograms/QuadRendererProgram.hpp | 55 ++++++ .../RendererPrograms/RendererProgram.h | 17 -- .../RendererPrograms/RendererProgram.hpp | 17 ++ .../TextureRendererProgram.cpp | 12 +- .../RendererPrograms/TextureRendererProgram.h | 58 ------ .../TextureRendererProgram.hpp | 57 ++++++ .../TintedTextureRendererProgram.cpp | 12 +- .../TintedTextureRendererProgram.h | 59 ------ .../TintedTextureRendererProgram.hpp | 58 ++++++ Engine/src/Engine/Graphics/Shader.cpp | 10 +- Engine/src/Engine/Graphics/Shader.h | 36 ---- Engine/src/Engine/Graphics/Shader.hpp | 35 ++++ Engine/src/Engine/Graphics/SharedContext.h | 13 -- Engine/src/Engine/Graphics/SharedContext.hpp | 13 ++ Engine/src/Engine/Graphics/Texture.cpp | 10 +- .../Graphics/{Texture.h => Texture.hpp} | 2 +- Engine/src/Engine/Graphics/VertexLayout.cpp | 10 +- Engine/src/Engine/Graphics/VertexLayout.h | 35 ---- Engine/src/Engine/Graphics/VertexLayout.hpp | 49 +++++ Engine/src/Engine/Input/Input.cpp | 14 +- Engine/src/Engine/Input/Input.h | 55 ------ Engine/src/Engine/Input/Input.hpp | 53 +++++ Engine/src/Engine/Input/KeyCodes.h | 185 ------------------ Engine/src/Engine/Input/KeyCodes.hpp | 184 +++++++++++++++++ Engine/src/Engine/Input/MouseCodes.h | 28 --- Engine/src/Engine/Input/MouseCodes.hpp | 27 +++ Engine/src/Engine/Layer/Layer.cpp | 112 +++++------ Engine/src/Engine/Layer/Layer.h | 78 -------- Engine/src/Engine/Layer/Layer.hpp | 78 ++++++++ Engine/src/Engine/Layer/LayerStack.cpp | 12 +- Engine/src/Engine/Layer/LayerStack.h | 49 ----- Engine/src/Engine/Layer/LayerStack.hpp | 51 +++++ Engine/src/Engine/LightEngine.h | 60 ------ Engine/src/Engine/LightEngine.hpp | 60 ++++++ Engine/src/Engine/Math/Random.cpp | 60 +++--- .../src/Engine/Math/{Random.h => Random.hpp} | 0 Engine/src/Engine/Scene/Components.h | 9 - Engine/src/Engine/Scene/Components.hpp | 8 + .../Engine/Scene/Components/CameraComponent.h | 28 --- .../Scene/Components/CameraComponent.hpp | 26 +++ .../Scene/Components/NativeScriptComponent.h | 24 --- .../Components/NativeScriptComponent.hpp | 28 +++ .../Scene/Components/ScriptableEntity.h | 30 --- .../Scene/Components/ScriptableEntity.hpp | 34 ++++ .../Components/SpriteRendererComponent.h | 26 --- .../Components/SpriteRendererComponent.hpp | 25 +++ .../Engine/Scene/Components/TagComponent.h | 24 --- .../Engine/Scene/Components/TagComponent.hpp | 23 +++ .../Scene/Components/TransformComponent.h | 34 ---- .../Scene/Components/TransformComponent.hpp | 32 +++ .../Engine/Scene/Components/UUIDComponent.h | 17 -- .../Engine/Scene/Components/UUIDComponent.hpp | 17 ++ Engine/src/Engine/Scene/Entity.cpp | 20 +- Engine/src/Engine/Scene/Entity.h | 54 ----- Engine/src/Engine/Scene/Entity.hpp | 52 +++++ Engine/src/Engine/Scene/Scene.cpp | 8 +- Engine/src/Engine/Scene/Scene.h | 46 ----- Engine/src/Engine/Scene/Scene.hpp | 43 ++++ Engine/src/Engine/Time/Timer.cpp | 33 ++-- Engine/src/Engine/Time/Timer.h | 38 ---- Engine/src/Engine/Time/Timer.hpp | 38 ++++ .../Engine/UserInterface/UserInterface.cpp | 20 +- .../src/Engine/UserInterface/UserInterface.h | 52 ----- .../Engine/UserInterface/UserInterface.hpp | 51 +++++ Engine/src/Engine/Utility/FileManager.cpp | 2 +- Engine/src/Engine/Utility/FileManager.h | 86 -------- Engine/src/Engine/Utility/FileManager.hpp | 81 ++++++++ Engine/src/Engine/Utility/ResourceManager.cpp | 10 +- Engine/src/Engine/Utility/ResourceManager.h | 44 ----- Engine/src/Engine/Utility/ResourceManager.hpp | 44 +++++ Engine/src/Engine/Utility/Serializer.cpp | 8 +- Engine/src/Engine/Utility/Serializer.h | 30 --- Engine/src/Engine/Utility/Serializer.hpp | 30 +++ Engine/src/Engine/Utility/Stringifier.cpp | 131 ++++++------- Engine/src/Engine/Utility/Stringifier.h | 25 --- Engine/src/Engine/Utility/Stringifier.hpp | 25 +++ Engine/src/Engine/ltpch.cpp | 2 +- Engine/src/Engine/{ltpch.h => ltpch.hpp} | 16 +- .../GraphicsAPI/DirectX/dxBlender.cpp | 139 ++++++------- .../Platform/GraphicsAPI/DirectX/dxBlender.h | 32 --- .../GraphicsAPI/DirectX/dxBlender.hpp | 31 +++ .../GraphicsAPI/DirectX/dxBuffers.cpp | 4 +- .../Platform/GraphicsAPI/DirectX/dxBuffers.h | 72 ------- .../GraphicsAPI/DirectX/dxBuffers.hpp | 71 +++++++ .../GraphicsAPI/DirectX/dxFramebuffer.cpp | 4 +- .../GraphicsAPI/DirectX/dxFramebuffer.h | 38 ---- .../GraphicsAPI/DirectX/dxFramebuffer.hpp | 37 ++++ .../GraphicsAPI/DirectX/dxGraphicsContext.cpp | 18 +- .../GraphicsAPI/DirectX/dxGraphicsContext.h | 32 --- .../GraphicsAPI/DirectX/dxGraphicsContext.hpp | 31 +++ .../GraphicsAPI/DirectX/dxRenderCommand.cpp | 4 +- .../GraphicsAPI/DirectX/dxRenderCommand.h | 36 ---- .../GraphicsAPI/DirectX/dxRenderCommand.hpp | 35 ++++ .../Platform/GraphicsAPI/DirectX/dxShader.cpp | 4 +- .../Platform/GraphicsAPI/DirectX/dxShader.h | 36 ---- .../Platform/GraphicsAPI/DirectX/dxShader.hpp | 34 ++++ .../GraphicsAPI/DirectX/dxSharedContext.h | 31 --- .../GraphicsAPI/DirectX/dxSharedContext.hpp | 31 +++ .../GraphicsAPI/DirectX/dxTexture.cpp | 115 ++++++----- .../Platform/GraphicsAPI/DirectX/dxTexture.h | 29 --- .../GraphicsAPI/DirectX/dxTexture.hpp | 28 +++ .../GraphicsAPI/DirectX/dxUserInterface.cpp | 6 +- .../GraphicsAPI/DirectX/dxUserInterface.h | 30 --- .../GraphicsAPI/DirectX/dxUserInterface.hpp | 29 +++ .../GraphicsAPI/DirectX/dxVertexLayout.cpp | 6 +- .../GraphicsAPI/DirectX/dxVertexLayout.h | 34 ---- .../GraphicsAPI/DirectX/dxVertexLayout.hpp | 33 ++++ .../Platform/GraphicsAPI/OpenGL/glBlender.cpp | 77 ++++---- .../Platform/GraphicsAPI/OpenGL/glBlender.h | 21 -- .../Platform/GraphicsAPI/OpenGL/glBlender.hpp | 20 ++ .../Platform/GraphicsAPI/OpenGL/glBuffers.cpp | 2 +- .../Platform/GraphicsAPI/OpenGL/glBuffers.h | 57 ------ .../Platform/GraphicsAPI/OpenGL/glBuffers.hpp | 56 ++++++ .../GraphicsAPI/OpenGL/glFramebuffer.cpp | 2 +- .../GraphicsAPI/OpenGL/glFramebuffer.h | 29 --- .../GraphicsAPI/OpenGL/glFramebuffer.hpp | 28 +++ .../GraphicsAPI/OpenGL/glGraphicsContext.cpp | 16 +- .../GraphicsAPI/OpenGL/glGraphicsContext.h | 25 --- .../GraphicsAPI/OpenGL/glGraphicsContext.hpp | 24 +++ .../GraphicsAPI/OpenGL/glRenderCommand.cpp | 66 ++++--- .../GraphicsAPI/OpenGL/glRenderCommand.h | 30 --- .../GraphicsAPI/OpenGL/glRenderCommand.hpp | 29 +++ .../Platform/GraphicsAPI/OpenGL/glShader.cpp | 2 +- .../OpenGL/{glShader.h => glShader.hpp} | 8 +- .../GraphicsAPI/OpenGL/glSharedContext.h | 13 -- .../GraphicsAPI/OpenGL/glSharedContext.hpp | 12 ++ .../Platform/GraphicsAPI/OpenGL/glTexture.cpp | 2 +- .../OpenGL/{glTexture.h => glTexture.hpp} | 4 +- .../GraphicsAPI/OpenGL/glUserInterface.cpp | 4 +- .../GraphicsAPI/OpenGL/glUserInterface.h | 28 --- .../GraphicsAPI/OpenGL/glUserInterface.hpp | 27 +++ .../GraphicsAPI/OpenGL/glVertexLayout.cpp | 4 +- .../GraphicsAPI/OpenGL/glVertexLayout.h | 35 ---- .../GraphicsAPI/OpenGL/glVertexLayout.hpp | 34 ++++ Engine/src/Platform/OS/Linux/lWindow.cpp | 14 +- Engine/src/Platform/OS/Linux/lWindow.h | 46 ----- Engine/src/Platform/OS/Linux/lWindow.hpp | 45 +++++ Engine/src/Platform/OS/Windows/wWindow.cpp | 14 +- Engine/src/Platform/OS/Windows/wWindow.h | 46 ----- Engine/src/Platform/OS/Windows/wWindow.hpp | 45 +++++ Engine/src/renameall.sh | 5 + Mirror/src/EditorLayer.cpp | 4 +- Mirror/src/EditorLayer.cpp~ | 102 ---------- Mirror/src/{EditorLayer.h => EditorLayer.hpp} | 8 +- Mirror/src/MirrorApp.cpp | 42 ++-- Mirror/src/Panels/ContentBrowser.cpp | 4 +- .../{ContentBrowser.h => ContentBrowser.hpp} | 4 +- Mirror/src/Panels/{Panel.h => Panel.hpp} | 0 Mirror/src/Panels/PropertiesPanel.cpp | 6 +- ...{PropertiesPanel.h => PropertiesPanel.hpp} | 4 +- Mirror/src/Panels/SceneHierarchyPanel.cpp | 115 +++++------ Mirror/src/Panels/SceneHierarchyPanel.h | 33 ---- Mirror/src/Panels/SceneHierarchyPanel.hpp | 31 +++ 211 files changed, 3803 insertions(+), 3937 deletions(-) rename Engine/src/Engine/Base/{Base.h => Base.hpp} (94%) rename Engine/src/Engine/Base/{Config.h => Config.hpp} (100%) rename Engine/src/Engine/Base/{EntryPoint.h => EntryPoint.hpp} (97%) rename Engine/src/Engine/Base/Portables/{DebugTrap.h => DebugTrap.hpp} (99%) delete mode 100644 Engine/src/Engine/Camera/Camera.h create mode 100644 Engine/src/Engine/Camera/Camera.hpp delete mode 100644 Engine/src/Engine/Camera/OrthographicCamera.h create mode 100644 Engine/src/Engine/Camera/OrthographicCamera.hpp delete mode 100644 Engine/src/Engine/Camera/SceneCamera.h create mode 100644 Engine/src/Engine/Camera/SceneCamera.hpp delete mode 100644 Engine/src/Engine/Core/Application.h create mode 100644 Engine/src/Engine/Core/Application.hpp rename Engine/src/Engine/Core/{UUID.h => UUID.hpp} (100%) delete mode 100644 Engine/src/Engine/Core/Window.h create mode 100644 Engine/src/Engine/Core/Window.hpp rename Engine/src/Engine/Debug/{Exceptions.h => Exceptions.hpp} (100%) delete mode 100644 Engine/src/Engine/Debug/Instrumentor.h create mode 100644 Engine/src/Engine/Debug/Instrumentor.hpp rename Engine/src/Engine/Debug/{Logger.h => Logger.hpp} (97%) delete mode 100644 Engine/src/Engine/Events/CharEvent.h create mode 100644 Engine/src/Engine/Events/CharEvent.hpp delete mode 100644 Engine/src/Engine/Events/Event.h create mode 100644 Engine/src/Engine/Events/Event.hpp delete mode 100644 Engine/src/Engine/Events/KeyboardEvents.h create mode 100644 Engine/src/Engine/Events/KeyboardEvents.hpp delete mode 100644 Engine/src/Engine/Events/MouseEvents.h create mode 100644 Engine/src/Engine/Events/MouseEvents.hpp delete mode 100644 Engine/src/Engine/Events/WindowEvents.h create mode 100644 Engine/src/Engine/Events/WindowEvents.hpp delete mode 100644 Engine/src/Engine/Graphics/Blender.h create mode 100644 Engine/src/Engine/Graphics/Blender.hpp delete mode 100644 Engine/src/Engine/Graphics/Buffers.h create mode 100644 Engine/src/Engine/Graphics/Buffers.hpp delete mode 100644 Engine/src/Engine/Graphics/Framebuffer.h create mode 100644 Engine/src/Engine/Graphics/Framebuffer.hpp delete mode 100644 Engine/src/Engine/Graphics/GraphicsContext.h create mode 100644 Engine/src/Engine/Graphics/GraphicsContext.hpp delete mode 100644 Engine/src/Engine/Graphics/RenderCommand.h create mode 100644 Engine/src/Engine/Graphics/RenderCommand.hpp delete mode 100644 Engine/src/Engine/Graphics/Renderer.h create mode 100644 Engine/src/Engine/Graphics/Renderer.hpp delete mode 100644 Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h create mode 100644 Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.hpp delete mode 100644 Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.h create mode 100644 Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.hpp delete mode 100644 Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h create mode 100644 Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.hpp delete mode 100644 Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.h create mode 100644 Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.hpp delete mode 100644 Engine/src/Engine/Graphics/Shader.h create mode 100644 Engine/src/Engine/Graphics/Shader.hpp delete mode 100644 Engine/src/Engine/Graphics/SharedContext.h create mode 100644 Engine/src/Engine/Graphics/SharedContext.hpp rename Engine/src/Engine/Graphics/{Texture.h => Texture.hpp} (96%) delete mode 100644 Engine/src/Engine/Graphics/VertexLayout.h create mode 100644 Engine/src/Engine/Graphics/VertexLayout.hpp delete mode 100644 Engine/src/Engine/Input/Input.h create mode 100644 Engine/src/Engine/Input/Input.hpp delete mode 100644 Engine/src/Engine/Input/KeyCodes.h create mode 100644 Engine/src/Engine/Input/KeyCodes.hpp delete mode 100644 Engine/src/Engine/Input/MouseCodes.h create mode 100644 Engine/src/Engine/Input/MouseCodes.hpp delete mode 100644 Engine/src/Engine/Layer/Layer.h create mode 100644 Engine/src/Engine/Layer/Layer.hpp delete mode 100644 Engine/src/Engine/Layer/LayerStack.h create mode 100644 Engine/src/Engine/Layer/LayerStack.hpp delete mode 100644 Engine/src/Engine/LightEngine.h create mode 100644 Engine/src/Engine/LightEngine.hpp rename Engine/src/Engine/Math/{Random.h => Random.hpp} (100%) delete mode 100644 Engine/src/Engine/Scene/Components.h create mode 100644 Engine/src/Engine/Scene/Components.hpp delete mode 100644 Engine/src/Engine/Scene/Components/CameraComponent.h create mode 100644 Engine/src/Engine/Scene/Components/CameraComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Components/NativeScriptComponent.h create mode 100644 Engine/src/Engine/Scene/Components/NativeScriptComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Components/ScriptableEntity.h create mode 100644 Engine/src/Engine/Scene/Components/ScriptableEntity.hpp delete mode 100644 Engine/src/Engine/Scene/Components/SpriteRendererComponent.h create mode 100644 Engine/src/Engine/Scene/Components/SpriteRendererComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Components/TagComponent.h create mode 100644 Engine/src/Engine/Scene/Components/TagComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Components/TransformComponent.h create mode 100644 Engine/src/Engine/Scene/Components/TransformComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Components/UUIDComponent.h create mode 100644 Engine/src/Engine/Scene/Components/UUIDComponent.hpp delete mode 100644 Engine/src/Engine/Scene/Entity.h create mode 100644 Engine/src/Engine/Scene/Entity.hpp delete mode 100644 Engine/src/Engine/Scene/Scene.h create mode 100644 Engine/src/Engine/Scene/Scene.hpp delete mode 100644 Engine/src/Engine/Time/Timer.h create mode 100644 Engine/src/Engine/Time/Timer.hpp delete mode 100644 Engine/src/Engine/UserInterface/UserInterface.h create mode 100644 Engine/src/Engine/UserInterface/UserInterface.hpp delete mode 100644 Engine/src/Engine/Utility/FileManager.h create mode 100644 Engine/src/Engine/Utility/FileManager.hpp delete mode 100644 Engine/src/Engine/Utility/ResourceManager.h create mode 100644 Engine/src/Engine/Utility/ResourceManager.hpp delete mode 100644 Engine/src/Engine/Utility/Serializer.h create mode 100644 Engine/src/Engine/Utility/Serializer.hpp delete mode 100644 Engine/src/Engine/Utility/Stringifier.h create mode 100644 Engine/src/Engine/Utility/Stringifier.hpp rename Engine/src/Engine/{ltpch.h => ltpch.hpp} (91%) delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxShader.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h create mode 100644 Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.hpp rename Engine/src/Platform/GraphicsAPI/OpenGL/{glShader.h => glShader.hpp} (83%) delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.hpp rename Engine/src/Platform/GraphicsAPI/OpenGL/{glTexture.h => glTexture.hpp} (86%) delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.hpp delete mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h create mode 100644 Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.hpp delete mode 100644 Engine/src/Platform/OS/Linux/lWindow.h create mode 100644 Engine/src/Platform/OS/Linux/lWindow.hpp delete mode 100644 Engine/src/Platform/OS/Windows/wWindow.h create mode 100644 Engine/src/Platform/OS/Windows/wWindow.hpp create mode 100755 Engine/src/renameall.sh delete mode 100644 Mirror/src/EditorLayer.cpp~ rename Mirror/src/{EditorLayer.h => EditorLayer.hpp} (83%) rename Mirror/src/Panels/{ContentBrowser.h => ContentBrowser.hpp} (91%) rename Mirror/src/Panels/{Panel.h => Panel.hpp} (100%) rename Mirror/src/Panels/{PropertiesPanel.h => PropertiesPanel.hpp} (91%) delete mode 100644 Mirror/src/Panels/SceneHierarchyPanel.h create mode 100644 Mirror/src/Panels/SceneHierarchyPanel.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 988b550..339b4d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ target_link_libraries( PRIVATE imgui) # Precompiled headers -target_precompile_headers(Engine PUBLIC ${ENGINE_DIR}src/Engine/ltpch.h) +target_precompile_headers(Engine PUBLIC ${ENGINE_DIR}src/Engine/ltpch.hpp) if(MSVC) set_property(DIRECTORY ${CMAE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Mirror) diff --git a/Engine/src/Engine/Base/Base.h b/Engine/src/Engine/Base/Base.hpp similarity index 94% rename from Engine/src/Engine/Base/Base.h rename to Engine/src/Engine/Base/Base.hpp index 95516c1..c9ef56a 100644 --- a/Engine/src/Engine/Base/Base.h +++ b/Engine/src/Engine/Base/Base.hpp @@ -90,22 +90,22 @@ constexpr std::unique_ptr MakeScope(T* rawPointer) //========== ESSENTIAL_HEADERS ==========// /* config */ #ifndef LIGHT_CONFIG_H - #include "Base/Config.h" + #include "Base/Config.hpp" #endif /* debug */ #ifndef LIGHT_LOGGER_H - #include "Debug/Logger.h" + #include "Debug/Logger.hpp" #endif -#include "Debug/Exceptions.h" +#include "Debug/Exceptions.hpp" /* portables */ #ifndef LIGHT_DEBUG_TRAP_H - #include "Base/Portables/DebugTrap.h" + #include "Base/Portables/DebugTrap.hpp" #endif /* utility */ #ifndef LIGHT_STRINGIFIER_H - #include "Utility/Stringifier.h" + #include "Utility/Stringifier.hpp" #endif //========== ESSENTIAL_HEADERS ==========// diff --git a/Engine/src/Engine/Base/Config.h b/Engine/src/Engine/Base/Config.hpp similarity index 100% rename from Engine/src/Engine/Base/Config.h rename to Engine/src/Engine/Base/Config.hpp diff --git a/Engine/src/Engine/Base/EntryPoint.h b/Engine/src/Engine/Base/EntryPoint.hpp similarity index 97% rename from Engine/src/Engine/Base/EntryPoint.h rename to Engine/src/Engine/Base/EntryPoint.hpp index e90e9f5..b28f262 100644 --- a/Engine/src/Engine/Base/EntryPoint.h +++ b/Engine/src/Engine/Base/EntryPoint.hpp @@ -2,7 +2,7 @@ #ifdef LIGHT_PLATFORM_WINDOWS - #include + #include // to be defined in client project extern Light::Application* Light::CreateApplication(std::string execName, std::vector args); @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) #elif defined(LIGHT_PLATFORM_LINUX) - #include + #include // to be defined in client project extern Light::Application* Light::CreateApplication(); diff --git a/Engine/src/Engine/Base/Portables/DebugTrap.h b/Engine/src/Engine/Base/Portables/DebugTrap.hpp similarity index 99% rename from Engine/src/Engine/Base/Portables/DebugTrap.h rename to Engine/src/Engine/Base/Portables/DebugTrap.hpp index b5f6a29..1e5454d 100644 --- a/Engine/src/Engine/Base/Portables/DebugTrap.h +++ b/Engine/src/Engine/Base/Portables/DebugTrap.hpp @@ -2,7 +2,7 @@ #ifndef LIGHT_DEBUG_TRAP_H #define LIGHT_DEBUG_TRAP_H - #include "Base/Base.h" + #include "Base/Base.hpp" // https://github.com/nemequ/portable-snippets/tree/master/debug-trap diff --git a/Engine/src/Engine/Camera/Camera.cpp b/Engine/src/Engine/Camera/Camera.cpp index 04d0e62..4037a86 100644 --- a/Engine/src/Engine/Camera/Camera.cpp +++ b/Engine/src/Engine/Camera/Camera.cpp @@ -1,4 +1,4 @@ -#include "Camera.h" +#include "Camera.hpp" namespace Light { diff --git a/Engine/src/Engine/Camera/Camera.h b/Engine/src/Engine/Camera/Camera.h deleted file mode 100644 index 1c11677..0000000 --- a/Engine/src/Engine/Camera/Camera.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class Camera - { - private: - glm::vec4 m_BackgroundColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); - - protected: - glm::mat4 m_Projection; - - public: - Camera() = default; - - inline const glm::mat4& GetProjection() const { return m_Projection; } - - inline const glm::vec4& GetBackgroundColor() const { return m_BackgroundColor; } - - inline void SetBackgroundColor(const glm::vec4& color) { m_BackgroundColor = color; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Camera/Camera.hpp b/Engine/src/Engine/Camera/Camera.hpp new file mode 100644 index 0000000..e0cd5f2 --- /dev/null +++ b/Engine/src/Engine/Camera/Camera.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class Camera +{ +private: + glm::vec4 m_BackgroundColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); + +protected: + glm::mat4 m_Projection; + +public: + Camera() = default; + + inline const glm::mat4& GetProjection() const { return m_Projection; } + + inline const glm::vec4& GetBackgroundColor() const { return m_BackgroundColor; } + + inline void SetBackgroundColor(const glm::vec4& color) { m_BackgroundColor = color; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Camera/OrthographicCamera.cpp b/Engine/src/Engine/Camera/OrthographicCamera.cpp index c06eddf..b829885 100644 --- a/Engine/src/Engine/Camera/OrthographicCamera.cpp +++ b/Engine/src/Engine/Camera/OrthographicCamera.cpp @@ -1,42 +1,38 @@ -#include "OrthographicCamera.h" +#include "OrthographicCamera.hpp" -#include #include +#include namespace Light { - - OrthographicCamera::OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */) - : m_Up(0.0f, 1.0f, 0.0f), - m_Position(position), - m_AspectRatio(aspectRatio), - m_ZoomLevel(zoomLevel), - m_ClearColor(clearColor) - { - } - void OrthographicCamera::CalculateView() - { - m_View = glm::lookAt(glm::vec3(m_Position, 100.0f), glm::vec3(m_Position, 0.0f), m_Up); - } +OrthographicCamera::OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */) + : m_Up(0.0f, 1.0f, 0.0f), m_Position(position), m_AspectRatio(aspectRatio), m_ZoomLevel(zoomLevel), m_ClearColor(clearColor) +{ +} - void OrthographicCamera::CalculateProjection() - { - m_Projection = glm::ortho(-m_ZoomLevel * m_AspectRatio, - +m_ZoomLevel * m_AspectRatio, - -m_ZoomLevel, - +m_ZoomLevel, - FLT_MAX, FLT_MIN); - } +void OrthographicCamera::CalculateView() +{ + m_View = glm::lookAt(glm::vec3(m_Position, 100.0f), glm::vec3(m_Position, 0.0f), m_Up); +} - void OrthographicCamera::OnResize(const glm::vec2& size) - { - m_AspectRatio = size.x / size.y; - CalculateProjection(); - } +void OrthographicCamera::CalculateProjection() +{ + m_Projection = glm::ortho(-m_ZoomLevel * m_AspectRatio, + +m_ZoomLevel * m_AspectRatio, + -m_ZoomLevel, + +m_ZoomLevel, + FLT_MAX, FLT_MIN); +} - void OrthographicCamera::Move(const glm::vec2& position) - { - m_Position += position; - } +void OrthographicCamera::OnResize(const glm::vec2& size) +{ + m_AspectRatio = size.x / size.y; + CalculateProjection(); +} -} \ No newline at end of file +void OrthographicCamera::Move(const glm::vec2& position) +{ + m_Position += position; +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Camera/OrthographicCamera.h b/Engine/src/Engine/Camera/OrthographicCamera.h deleted file mode 100644 index 92055d8..0000000 --- a/Engine/src/Engine/Camera/OrthographicCamera.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class OrthographicCamera - { - private: - glm::vec2 m_Position; - float m_AspectRatio; - float m_ZoomLevel; - - const glm::vec3 m_Up; - - glm::mat4 m_Projection; - glm::mat4 m_View; - - glm::vec4 m_ClearColor; - - public: - OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f)); - - // CAMERA // - void CalculateView(); - void CalculateProjection(); - - void OnResize(const glm::vec2& size); - - inline const glm::mat4& GetView() const { return m_View; } - inline const glm::mat4& GetProjection() const { return m_Projection; } - - inline const glm::vec4& GetClearColor() const { return m_ClearColor; } - - // CAMERA_CONTROLLER // - void Move(const glm::vec2& position); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Camera/OrthographicCamera.hpp b/Engine/src/Engine/Camera/OrthographicCamera.hpp new file mode 100644 index 0000000..5a1b891 --- /dev/null +++ b/Engine/src/Engine/Camera/OrthographicCamera.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class OrthographicCamera +{ +private: + glm::vec2 m_Position; + float m_AspectRatio; + float m_ZoomLevel; + + const glm::vec3 m_Up; + + glm::mat4 m_Projection; + glm::mat4 m_View; + + glm::vec4 m_ClearColor; + +public: + OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f)); + + // CAMERA // + void CalculateView(); + void CalculateProjection(); + + void OnResize(const glm::vec2& size); + + inline const glm::mat4& GetView() const { return m_View; } + inline const glm::mat4& GetProjection() const { return m_Projection; } + + inline const glm::vec4& GetClearColor() const { return m_ClearColor; } + + // CAMERA_CONTROLLER // + void Move(const glm::vec2& position); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Camera/SceneCamera.cpp b/Engine/src/Engine/Camera/SceneCamera.cpp index 6d0001a..ff4bf4b 100644 --- a/Engine/src/Engine/Camera/SceneCamera.cpp +++ b/Engine/src/Engine/Camera/SceneCamera.cpp @@ -1,84 +1,81 @@ -#include "SceneCamera.h" +#include "SceneCamera.hpp" #include namespace Light { - SceneCamera::SceneCamera() - : m_OrthographicSpecification{ 1000.0f, -1.0f, 10000.0f }, - m_PerspectiveSpecification{ glm::radians(45.0f), 0.01f, 10000.0f }, - m_AspectRatio(16.0f / 9.0f), - m_ProjectionType(ProjectionType::Orthographic) - { - CalculateProjection(); - } +SceneCamera::SceneCamera() + : m_OrthographicSpecification { 1000.0f, -1.0f, 10000.0f }, m_PerspectiveSpecification { glm::radians(45.0f), 0.01f, 10000.0f }, m_AspectRatio(16.0f / 9.0f), m_ProjectionType(ProjectionType::Orthographic) +{ + CalculateProjection(); +} - void SceneCamera::SetViewportSize(unsigned int width, unsigned int height) - { - m_AspectRatio = width / (float)height; - CalculateProjection(); - } +void SceneCamera::SetViewportSize(unsigned int width, unsigned int height) +{ + m_AspectRatio = width / (float)height; + CalculateProjection(); +} - void SceneCamera::SetProjectionType(ProjectionType projectionType) - { - m_ProjectionType = projectionType; - CalculateProjection(); - } +void SceneCamera::SetProjectionType(ProjectionType projectionType) +{ + m_ProjectionType = projectionType; + CalculateProjection(); +} - void SceneCamera::SetOrthographicSize(float size) - { - m_OrthographicSpecification.size = size; - CalculateProjection(); - } +void SceneCamera::SetOrthographicSize(float size) +{ + m_OrthographicSpecification.size = size; + CalculateProjection(); +} - void SceneCamera::SetOrthographicFarPlane(float farPlane) - { - m_OrthographicSpecification.farPlane = farPlane; - CalculateProjection(); - } +void SceneCamera::SetOrthographicFarPlane(float farPlane) +{ + m_OrthographicSpecification.farPlane = farPlane; + CalculateProjection(); +} - void SceneCamera::SetOrthographicNearPlane(float nearPlane) - { - m_OrthographicSpecification.nearPlane = nearPlane; - CalculateProjection(); - } +void SceneCamera::SetOrthographicNearPlane(float nearPlane) +{ + m_OrthographicSpecification.nearPlane = nearPlane; + CalculateProjection(); +} - void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV) - { - m_PerspectiveSpecification.verticalFOV = verticalFOV; - CalculateProjection(); - } +void SceneCamera::SetPerspectiveVerticalFOV(float verticalFOV) +{ + m_PerspectiveSpecification.verticalFOV = verticalFOV; + CalculateProjection(); +} - void SceneCamera::SetPerspectiveFarPlane(float farPlane) - { - m_PerspectiveSpecification.farPlane = farPlane; - CalculateProjection(); - } +void SceneCamera::SetPerspectiveFarPlane(float farPlane) +{ + m_PerspectiveSpecification.farPlane = farPlane; + CalculateProjection(); +} - void SceneCamera::SetPerspectiveNearPlane(float nearPlane) - { - m_PerspectiveSpecification.nearPlane = nearPlane; - CalculateProjection(); - } +void SceneCamera::SetPerspectiveNearPlane(float nearPlane) +{ + m_PerspectiveSpecification.nearPlane = nearPlane; + CalculateProjection(); +} - void SceneCamera::CalculateProjection() +void SceneCamera::CalculateProjection() +{ + if (m_ProjectionType == ProjectionType::Orthographic) { - if(m_ProjectionType == ProjectionType::Orthographic) - { - m_Projection = glm::ortho(-m_OrthographicSpecification.size * 0.5f * m_AspectRatio, - m_OrthographicSpecification.size * 0.5f * m_AspectRatio, - -m_OrthographicSpecification.size * 0.5f, - m_OrthographicSpecification.size * 0.5f, - m_OrthographicSpecification.farPlane, - m_OrthographicSpecification.nearPlane); - } - else // perspective - { - m_Projection = glm::perspective(m_PerspectiveSpecification.verticalFOV, - m_AspectRatio, - m_PerspectiveSpecification.nearPlane, - m_PerspectiveSpecification.farPlane); - } + m_Projection = glm::ortho(-m_OrthographicSpecification.size * 0.5f * m_AspectRatio, + m_OrthographicSpecification.size * 0.5f * m_AspectRatio, + -m_OrthographicSpecification.size * 0.5f, + m_OrthographicSpecification.size * 0.5f, + m_OrthographicSpecification.farPlane, + m_OrthographicSpecification.nearPlane); } + else // perspective + { + m_Projection = glm::perspective(m_PerspectiveSpecification.verticalFOV, + m_AspectRatio, + m_PerspectiveSpecification.nearPlane, + m_PerspectiveSpecification.farPlane); + } +} -} \ No newline at end of file +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Camera/SceneCamera.h b/Engine/src/Engine/Camera/SceneCamera.h deleted file mode 100644 index 957fc91..0000000 --- a/Engine/src/Engine/Camera/SceneCamera.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include "Camera.h" - -#include "Base/Base.h" - -namespace Light { - - class SceneCamera : public Camera - { - public: - enum class ProjectionType - { - Orthographic = 0, - Perspetcive = 1 - }; - - struct OrthographicSpecification // :#todo use this - { - float size; - float nearPlane, farPlane; - }; - - struct PerspectiveSpecification - { - float verticalFOV; - float nearPlane, farPlane; - }; - - private: - OrthographicSpecification m_OrthographicSpecification; - PerspectiveSpecification m_PerspectiveSpecification; - float m_AspectRatio; - - ProjectionType m_ProjectionType; - - public: - SceneCamera(); - - void SetViewportSize(unsigned int width, unsigned int height); - - void SetProjectionType(ProjectionType projectionType); - - void SetOrthographicSize(float size); - void SetOrthographicFarPlane(float farPlane); - void SetOrthographicNearPlane(float nearPlane); - - void SetPerspectiveVerticalFOV(float verticalFov); - void SetPerspectiveFarPlane(float farPlane); - void SetPerspectiveNearPlane(float nearPlane); - - inline float GetOrthographicSize() const { return m_OrthographicSpecification.size; } - inline float GetOrthographicFarPlane() const { return m_OrthographicSpecification.farPlane; } - inline float GetOrthographicNearPlane() const { return m_OrthographicSpecification.nearPlane; } - - inline float GetPerspectiveVerticalFOV() const { return m_PerspectiveSpecification.verticalFOV; } - inline float GetPerspectiveFarPlane() const { return m_PerspectiveSpecification.farPlane; } - inline float GetPerspectiveNearPlane() const { return m_PerspectiveSpecification.nearPlane; } - - inline ProjectionType GetProjectionType() const { return m_ProjectionType; } - private: - void CalculateProjection(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Camera/SceneCamera.hpp b/Engine/src/Engine/Camera/SceneCamera.hpp new file mode 100644 index 0000000..8ef9d93 --- /dev/null +++ b/Engine/src/Engine/Camera/SceneCamera.hpp @@ -0,0 +1,65 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Camera.hpp" + +namespace Light { + +class SceneCamera: public Camera +{ +public: + enum class ProjectionType + { + Orthographic = 0, + Perspetcive = 1 + }; + + struct OrthographicSpecification // :#todo use this + { + float size; + float nearPlane, farPlane; + }; + + struct PerspectiveSpecification + { + float verticalFOV; + float nearPlane, farPlane; + }; + +private: + OrthographicSpecification m_OrthographicSpecification; + PerspectiveSpecification m_PerspectiveSpecification; + float m_AspectRatio; + + ProjectionType m_ProjectionType; + +public: + SceneCamera(); + + void SetViewportSize(unsigned int width, unsigned int height); + + void SetProjectionType(ProjectionType projectionType); + + void SetOrthographicSize(float size); + void SetOrthographicFarPlane(float farPlane); + void SetOrthographicNearPlane(float nearPlane); + + void SetPerspectiveVerticalFOV(float verticalFov); + void SetPerspectiveFarPlane(float farPlane); + void SetPerspectiveNearPlane(float nearPlane); + + inline float GetOrthographicSize() const { return m_OrthographicSpecification.size; } + inline float GetOrthographicFarPlane() const { return m_OrthographicSpecification.farPlane; } + inline float GetOrthographicNearPlane() const { return m_OrthographicSpecification.nearPlane; } + + inline float GetPerspectiveVerticalFOV() const { return m_PerspectiveSpecification.verticalFOV; } + inline float GetPerspectiveFarPlane() const { return m_PerspectiveSpecification.farPlane; } + inline float GetPerspectiveNearPlane() const { return m_PerspectiveSpecification.nearPlane; } + + inline ProjectionType GetProjectionType() const { return m_ProjectionType; } + +private: + void CalculateProjection(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Core/Application.cpp b/Engine/src/Engine/Core/Application.cpp index 850f817..0ef549d 100644 --- a/Engine/src/Engine/Core/Application.cpp +++ b/Engine/src/Engine/Core/Application.cpp @@ -1,14 +1,14 @@ -#include "Application.h" +#include "Application.hpp" -#include "Debug/Instrumentor.h" -#include "Events/Event.h" -#include "Graphics/GraphicsContext.h" -#include "Graphics/RenderCommand.h" -#include "Graphics/Renderer.h" -#include "Layer/Layer.h" -#include "Time/Timer.h" -#include "UserInterface/UserInterface.h" -#include "Window.h" +#include "Debug/Instrumentor.hpp" +#include "Events/Event.hpp" +#include "Graphics/GraphicsContext.hpp" +#include "Graphics/RenderCommand.hpp" +#include "Graphics/Renderer.hpp" +#include "Layer/Layer.hpp" +#include "Time/Timer.hpp" +#include "UserInterface/UserInterface.hpp" +#include "Window.hpp" namespace Light { diff --git a/Engine/src/Engine/Core/Application.h b/Engine/src/Engine/Core/Application.h deleted file mode 100644 index 7b8197b..0000000 --- a/Engine/src/Engine/Core/Application.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Debug/Instrumentor.h" - -#include "Input/Input.h" - -#include "Layer/LayerStack.h" - -#include "Utility/ResourceManager.h" - -namespace Light { - - class Window; - class Event; - - class Instrumentor; - - class Application /* singleton */ - { - private: - static Application* s_Context; - - private: - Scope m_Logger; - Scope m_Instrumentor; - Scope m_LayerStack; - Scope m_Input; - Scope m_ResourceManager; - - protected: - Scope m_Window; - - public: - Application(const Application&) = delete; - Application& operator=(const Application&) = delete; - - virtual ~Application(); - - void GameLoop(); - - // To be defined in client project - - static void Quit(); - - protected: - Application(std::string execName, std::vector args); - - private: - void OnEvent(const Event& event); - - void LogDebugData(); - }; - - extern Application* CreateApplication(std::string execName, std::vector args); - -} \ No newline at end of file diff --git a/Engine/src/Engine/Core/Application.hpp b/Engine/src/Engine/Core/Application.hpp new file mode 100644 index 0000000..969b08c --- /dev/null +++ b/Engine/src/Engine/Core/Application.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Debug/Instrumentor.hpp" +#include "Input/Input.hpp" +#include "Layer/LayerStack.hpp" +#include "Utility/ResourceManager.hpp" + +namespace Light { + +class Window; +class Event; + +class Instrumentor; + +class Application /* singleton */ +{ +private: + static Application* s_Context; + +private: + Scope m_Logger; + Scope m_Instrumentor; + Scope m_LayerStack; + Scope m_Input; + Scope m_ResourceManager; + +protected: + Scope m_Window; + +public: + Application(const Application&) = delete; + Application& operator=(const Application&) = delete; + + virtual ~Application(); + + void GameLoop(); + + // To be defined in client project + + static void Quit(); + +protected: + Application(std::string execName, std::vector args); + +private: + void OnEvent(const Event& event); + + void LogDebugData(); +}; + +extern Application* CreateApplication(std::string execName, std::vector args); + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Core/UUID.cpp b/Engine/src/Engine/Core/UUID.cpp index 7984ecd..2998f07 100644 --- a/Engine/src/Engine/Core/UUID.cpp +++ b/Engine/src/Engine/Core/UUID.cpp @@ -1,13 +1,14 @@ -#include "ltpch.h" -#include "UUID.h" +#include "UUID.hpp" + +#include "ltpch.hpp" namespace Light { - std::mt19937_64 UUID::s_Engine = std::mt19937_64(std::random_device()()); - std::uniform_int_distribution UUID::s_UniformDistribution; +std::mt19937_64 UUID::s_Engine = std::mt19937_64(std::random_device()()); +std::uniform_int_distribution UUID::s_UniformDistribution; - UUID::UUID(uint64_t uuid /* = -1 */) - : m_UUID(uuid == -1 ? s_UniformDistribution(s_Engine) : uuid) - { - } -} \ No newline at end of file +UUID::UUID(uint64_t uuid /* = -1 */) + : m_UUID(uuid == -1 ? s_UniformDistribution(s_Engine) : uuid) +{ +} +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Core/UUID.h b/Engine/src/Engine/Core/UUID.hpp similarity index 100% rename from Engine/src/Engine/Core/UUID.h rename to Engine/src/Engine/Core/UUID.hpp diff --git a/Engine/src/Engine/Core/Window.h b/Engine/src/Engine/Core/Window.h deleted file mode 100644 index f64a815..0000000 --- a/Engine/src/Engine/Core/Window.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class Event; - - class GraphicsContext; - - struct WindowProperties - { - std::string title; - glm::uvec2 size; - bool vsync, visible; - }; - - class Window - { - protected: - Scope m_GraphicsContext; - WindowProperties m_Properties; - bool b_Closed; - - public: - static Scope Create(std::function callback); - - Window() - : m_GraphicsContext(nullptr), - m_Properties{}, - b_Closed(false) - { - } - - Window(const Window&) = delete; - Window& operator=(const Window&) = delete; - - virtual ~Window() = default; - - /* events */ - virtual void PollEvents() = 0; - virtual void OnEvent(const Event& event) = 0; - - //======================================== SETTERS ========================================// - virtual void SetProperties(const WindowProperties& properties, bool affectVisibility = false) = 0; - - virtual void SetTitle(const std::string& title) = 0; - - virtual void SetSize(const glm::uvec2& size, bool additive = false) = 0; // pass 0 for width or height for single dimension resizing - - inline void Close() { b_Closed = true; } - virtual void SetVSync(bool vsync, bool toggle = false) = 0; - virtual void SetVisibility(bool visible, bool toggle = false) = 0; - //======================================== SETTERS ========================================// - - //============================== GETTERS ==============================// - inline GraphicsContext* GetGfxContext() const { return m_GraphicsContext.get(); } - - inline const WindowProperties& GetProperties() const { return m_Properties; } - - inline const std::string& GetTitle() const { return m_Properties.title; } - - inline const glm::uvec2& GetSize() const { return m_Properties.size; } - - inline bool IsClosed() const { return b_Closed; } - inline bool IsVSync() const { return m_Properties.vsync; } - inline bool IsVisible() const { return m_Properties.visible; } - //============================== GETTERS ==============================// - - protected: - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Core/Window.hpp b/Engine/src/Engine/Core/Window.hpp new file mode 100644 index 0000000..f9e0f83 --- /dev/null +++ b/Engine/src/Engine/Core/Window.hpp @@ -0,0 +1,73 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class Event; + +class GraphicsContext; + +struct WindowProperties +{ + std::string title; + glm::uvec2 size; + bool vsync, visible; +}; + +class Window +{ +protected: + Scope m_GraphicsContext; + WindowProperties m_Properties; + bool b_Closed; + +public: + static Scope Create(std::function callback); + + Window() + : m_GraphicsContext(nullptr), m_Properties {}, b_Closed(false) + { + } + + Window(const Window&) = delete; + Window& operator=(const Window&) = delete; + + virtual ~Window() = default; + + /* events */ + virtual void PollEvents() = 0; + virtual void OnEvent(const Event& event) = 0; + + //======================================== SETTERS ========================================// + virtual void SetProperties(const WindowProperties& properties, bool affectVisibility = false) = 0; + + virtual void SetTitle(const std::string& title) = 0; + + virtual void SetSize(const glm::uvec2& size, bool additive = false) = 0; // pass 0 for width or height for single dimension resizing + + inline void Close() { b_Closed = true; } + virtual void SetVSync(bool vsync, bool toggle = false) = 0; + virtual void SetVisibility(bool visible, bool toggle = false) = 0; + //======================================== SETTERS ========================================// + + //============================== GETTERS ==============================// + inline GraphicsContext* GetGfxContext() const { return m_GraphicsContext.get(); } + + inline const WindowProperties& GetProperties() const { return m_Properties; } + + inline const std::string& GetTitle() const { return m_Properties.title; } + + inline const glm::uvec2& GetSize() const { return m_Properties.size; } + + inline bool IsClosed() const { return b_Closed; } + inline bool IsVSync() const { return m_Properties.vsync; } + inline bool IsVisible() const { return m_Properties.visible; } + //============================== GETTERS ==============================// + +protected: +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Debug/Exceptions.cpp b/Engine/src/Engine/Debug/Exceptions.cpp index 3cdde25..acbf025 100644 --- a/Engine/src/Engine/Debug/Exceptions.cpp +++ b/Engine/src/Engine/Debug/Exceptions.cpp @@ -1,6 +1,6 @@ -#include "Exceptions.h" +#include "Exceptions.hpp" -#include "Utility/Stringifier.h" +#include "Utility/Stringifier.hpp" #include diff --git a/Engine/src/Engine/Debug/Exceptions.h b/Engine/src/Engine/Debug/Exceptions.hpp similarity index 100% rename from Engine/src/Engine/Debug/Exceptions.h rename to Engine/src/Engine/Debug/Exceptions.hpp diff --git a/Engine/src/Engine/Debug/Instrumentor.cpp b/Engine/src/Engine/Debug/Instrumentor.cpp index d39d1ae..aad9088 100644 --- a/Engine/src/Engine/Debug/Instrumentor.cpp +++ b/Engine/src/Engine/Debug/Instrumentor.cpp @@ -1,4 +1,4 @@ -#include "Instrumentor.h" +#include "Instrumentor.hpp" namespace Light { diff --git a/Engine/src/Engine/Debug/Instrumentor.h b/Engine/src/Engine/Debug/Instrumentor.h deleted file mode 100644 index f11dcd6..0000000 --- a/Engine/src/Engine/Debug/Instrumentor.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include -#include -#include - -namespace Light { - - struct ScopeProfileResult - { - std::string name; - long long start, duration; - uint32_t threadID; - }; - - // #todo: add event categories - // #todo: use ofstream in a separate thread - class Instrumentor /* singleton */ - { - private: - static Instrumentor* s_Context; - - private: - std::ofstream m_OutputFileStream; - - unsigned int m_CurrentSessionCount; - - public: - static Scope Create(); - - static inline void BeginSession(const std::string& outputPath) { s_Context->BeginSessionImpl(outputPath); } - static inline void EndSession() { s_Context->EndSessionImpl(); } - - static inline void SubmitScopeProfile(const ScopeProfileResult& profileResult) { s_Context->SubmitScopeProfileImpl(profileResult); } - - private: - Instrumentor(); - - void BeginSessionImpl(const std::string& outputPath); - void EndSessionImpl(); - - void SubmitScopeProfileImpl(const ScopeProfileResult& profileResult); - }; - - class InstrumentorTimer - { - private: - ScopeProfileResult m_Result; - std::chrono::time_point m_Start; - - public: - InstrumentorTimer(const std::string& scopeName); - ~InstrumentorTimer(); - }; - -} - -/* scope */ -#define LT_PROFILE_SCOPE(name) LT_PROFILE_SCOPE_NO_REDIFINITION(name, __LINE__) -#define LT_PROFILE_SCOPE_NO_REDIFINITION(name, line) LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) -#define LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) InstrumentorTimer timer##line(name) - -/* function */ -#define LT_PROFILE_FUNCTION LT_PROFILE_SCOPE(__FUNCSIG__) - -/* session */ -#define LT_PROFILE_BEGIN_SESSION(outputPath) ::Light::Instrumentor::BeginSession(outputPath) -#define LT_PROFILE_END_SESSION() ::Light::Instrumentor::EndSession() diff --git a/Engine/src/Engine/Debug/Instrumentor.hpp b/Engine/src/Engine/Debug/Instrumentor.hpp new file mode 100644 index 0000000..45905a9 --- /dev/null +++ b/Engine/src/Engine/Debug/Instrumentor.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include "Base/Base.hpp" + +#include +#include +#include + +namespace Light { + +struct ScopeProfileResult +{ + std::string name; + long long start, duration; + uint32_t threadID; +}; + +// #todo: add event categories +// #todo: use ofstream in a separate thread +class Instrumentor /* singleton */ +{ +private: + static Instrumentor* s_Context; + +private: + std::ofstream m_OutputFileStream; + + unsigned int m_CurrentSessionCount; + +public: + static Scope Create(); + + static inline void BeginSession(const std::string& outputPath) { s_Context->BeginSessionImpl(outputPath); } + static inline void EndSession() { s_Context->EndSessionImpl(); } + + static inline void SubmitScopeProfile(const ScopeProfileResult& profileResult) { s_Context->SubmitScopeProfileImpl(profileResult); } + +private: + Instrumentor(); + + void BeginSessionImpl(const std::string& outputPath); + void EndSessionImpl(); + + void SubmitScopeProfileImpl(const ScopeProfileResult& profileResult); +}; + +class InstrumentorTimer +{ +private: + ScopeProfileResult m_Result; + std::chrono::time_point m_Start; + +public: + InstrumentorTimer(const std::string& scopeName); + ~InstrumentorTimer(); +}; + +} // namespace Light + +/* scope */ +#define LT_PROFILE_SCOPE(name) LT_PROFILE_SCOPE_NO_REDIFINITION(name, __LINE__) +#define LT_PROFILE_SCOPE_NO_REDIFINITION(name, line) LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) +#define LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) InstrumentorTimer timer##line(name) + +/* function */ +#define LT_PROFILE_FUNCTION LT_PROFILE_SCOPE(__FUNCSIG__) + +/* session */ +#define LT_PROFILE_BEGIN_SESSION(outputPath) ::Light::Instrumentor::BeginSession(outputPath) +#define LT_PROFILE_END_SESSION() ::Light::Instrumentor::EndSession() diff --git a/Engine/src/Engine/Debug/Logger.cpp b/Engine/src/Engine/Debug/Logger.cpp index b6b6842..979f954 100644 --- a/Engine/src/Engine/Debug/Logger.cpp +++ b/Engine/src/Engine/Debug/Logger.cpp @@ -1,4 +1,4 @@ -#include "Logger.h" +#include "Logger.hpp" #include #include diff --git a/Engine/src/Engine/Debug/Logger.h b/Engine/src/Engine/Debug/Logger.hpp similarity index 97% rename from Engine/src/Engine/Debug/Logger.h rename to Engine/src/Engine/Debug/Logger.hpp index d4a1eed..2513cd5 100644 --- a/Engine/src/Engine/Debug/Logger.h +++ b/Engine/src/Engine/Debug/Logger.hpp @@ -2,7 +2,7 @@ #ifndef LIGHT_LOGGER_H #define LIGHT_LOGGER_H - #include "Base/Base.h" + #include "Base/Base.hpp" #include diff --git a/Engine/src/Engine/Events/CharEvent.h b/Engine/src/Engine/Events/CharEvent.h deleted file mode 100644 index f9d2197..0000000 --- a/Engine/src/Engine/Events/CharEvent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "Event.h" - -#include "Base/Base.h" - -#include - -namespace Light { - - class SetCharEvent : public Event - { - private: - const unsigned int m_Character; - - public: - SetCharEvent(unsigned int character) - : m_Character(character) - { - } - - inline int GetCharacter() const { return m_Character; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "CharSet: " << m_Character; - return ss.str(); - } - EVENT_TYPE(SetChar) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Events/CharEvent.hpp b/Engine/src/Engine/Events/CharEvent.hpp new file mode 100644 index 0000000..1638911 --- /dev/null +++ b/Engine/src/Engine/Events/CharEvent.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Event.hpp" + +#include + +namespace Light { + +class SetCharEvent: public Event +{ +private: + const unsigned int m_Character; + +public: + SetCharEvent(unsigned int character) + : m_Character(character) + { + } + + inline int GetCharacter() const { return m_Character; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "CharSet: " << m_Character; + return ss.str(); + } + EVENT_TYPE(SetChar) + EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Events/Event.h b/Engine/src/Engine/Events/Event.h deleted file mode 100644 index c84a840..0000000 --- a/Engine/src/Engine/Events/Event.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - enum class EventType - { - None = 0, - - // input - MouseMoved, WheelScrolled, ButtonPressed, ButtonReleased, - KeyPressed, KeyRepeated, KeyReleased, - SetChar, - - // window - WindowMoved, WindowResized, WindowClosed, WindowLostFocus, WindowGainFocus, - }; - - enum EventCategory - { - None = 0, - - WindowEventCategory = BIT(0), - InputEventCategory = BIT(1), - KeyboardEventCategory = BIT(2), - MouseEventCategory = BIT(3), - }; - -#define EVENT_TYPE(type) EventType GetEventType() const override { return ::Light::EventType:: type; } -#define EVENT_CATEGORY(eCategory) inline bool HasCategory(EventCategory category) const override { return (eCategory) & category; } - - class Event - { - public: - virtual EventType GetEventType() const = 0; - virtual std::string GetInfoLog() const = 0; - virtual bool HasCategory(EventCategory category) const = 0; - - friend std::ostream & operator<<(std::ostream & os, const Event& e) - { - return os << e.GetInfoLog(); - } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Events/Event.hpp b/Engine/src/Engine/Events/Event.hpp new file mode 100644 index 0000000..7f96490 --- /dev/null +++ b/Engine/src/Engine/Events/Event.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +enum class EventType +{ + None = 0, + + // input + MouseMoved, + WheelScrolled, + ButtonPressed, + ButtonReleased, + KeyPressed, + KeyRepeated, + KeyReleased, + SetChar, + + // window + WindowMoved, + WindowResized, + WindowClosed, + WindowLostFocus, + WindowGainFocus, +}; + +enum EventCategory +{ + None = 0, + + WindowEventCategory = BIT(0), + InputEventCategory = BIT(1), + KeyboardEventCategory = BIT(2), + MouseEventCategory = BIT(3), +}; + +#define EVENT_TYPE(type) \ + EventType GetEventType() const override { return ::Light::EventType::type; } +#define EVENT_CATEGORY(eCategory) \ + inline bool HasCategory(EventCategory category) const override { return (eCategory)&category; } + +class Event +{ +public: + virtual EventType GetEventType() const = 0; + virtual std::string GetInfoLog() const = 0; + virtual bool HasCategory(EventCategory category) const = 0; + + friend std::ostream& operator<<(std::ostream& os, const Event& e) + { + return os << e.GetInfoLog(); + } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Events/KeyboardEvents.h b/Engine/src/Engine/Events/KeyboardEvents.h deleted file mode 100644 index 9da405e..0000000 --- a/Engine/src/Engine/Events/KeyboardEvents.h +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once - -#include "Event.h" - -#include "Base/Base.h" - -#include - -namespace Light { - - class KeyPressedEvent : public Event - { - private: - const int m_Key; - - public: - KeyPressedEvent(int key) - : m_Key(key) - { - } - - inline int GetKey() const { return m_Key; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "KeyPressed: " << m_Key; - return ss.str(); - } - EVENT_TYPE(KeyPressed) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) - }; - - class KeyRepeatEvent : public Event - { - private: - const int m_Key; - - public: - KeyRepeatEvent(int key) - : m_Key(key) - { - } - - inline int GetKey() const { return m_Key; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "KeyRepeated: " << m_Key; - return ss.str(); - } - EVENT_TYPE(KeyRepeated) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) - }; - - class KeyReleasedEvent : public Event - { - private: - const int m_Key; - - public: - KeyReleasedEvent(int key) - : m_Key(key) - { - } - - inline int GetKey() const { return m_Key; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "KeyReleased: " << m_Key; - return ss.str(); - } - EVENT_TYPE(KeyReleased) - EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Events/KeyboardEvents.hpp b/Engine/src/Engine/Events/KeyboardEvents.hpp new file mode 100644 index 0000000..b91c7ec --- /dev/null +++ b/Engine/src/Engine/Events/KeyboardEvents.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Event.hpp" + +#include + +namespace Light { + +class KeyPressedEvent: public Event +{ +private: + const int m_Key; + +public: + KeyPressedEvent(int key) + : m_Key(key) + { + } + + inline int GetKey() const { return m_Key; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "KeyPressed: " << m_Key; + return ss.str(); + } + EVENT_TYPE(KeyPressed) + EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) +}; + +class KeyRepeatEvent: public Event +{ +private: + const int m_Key; + +public: + KeyRepeatEvent(int key) + : m_Key(key) + { + } + + inline int GetKey() const { return m_Key; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "KeyRepeated: " << m_Key; + return ss.str(); + } + EVENT_TYPE(KeyRepeated) + EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) +}; + +class KeyReleasedEvent: public Event +{ +private: + const int m_Key; + +public: + KeyReleasedEvent(int key) + : m_Key(key) + { + } + + inline int GetKey() const { return m_Key; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "KeyReleased: " << m_Key; + return ss.str(); + } + EVENT_TYPE(KeyReleased) + EVENT_CATEGORY(InputEventCategory | KeyboardEventCategory) +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Events/MouseEvents.h b/Engine/src/Engine/Events/MouseEvents.h deleted file mode 100644 index 70e2e1b..0000000 --- a/Engine/src/Engine/Events/MouseEvents.h +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once - -#include "Event.h" - -#include "Base/Base.h" - -#include - -#include - -namespace Light { - - class MouseMovedEvent : public Event - { - private: - const glm::vec2 m_Position; - - public: - MouseMovedEvent(float x, float y) - : m_Position(x, y) - { - } - - inline const glm::vec2& GetPosition() const { return m_Position; } - - inline float GetX() const { return m_Position.x; } - inline float GetY() const { return m_Position.y; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "MouseMoved: " << m_Position.x << ", " << m_Position.y; - return ss.str(); - } - EVENT_TYPE(MouseMoved) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) - }; - - class WheelScrolledEvent : public Event - { - private: - const float m_Offset; - - public: - WheelScrolledEvent(float offset) - : m_Offset(offset) - { - } - - inline float GetOffset() const { return m_Offset; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "WheelScrolled: " << m_Offset; - return ss.str(); - } - EVENT_TYPE(WheelScrolled) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) - }; - - class ButtonPressedEvent : public Event - { - private: - const int m_Button; - - public: - ButtonPressedEvent(int button) - : m_Button(button) - { - } - - inline int GetButton() const { return m_Button; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "ButtonPressed: " << m_Button; - return ss.str(); - } - EVENT_TYPE(ButtonPressed) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) - }; - - class ButtonReleasedEvent : public Event - { - private: - const int m_Button; - - public: - ButtonReleasedEvent(int button) - : m_Button(button) - { - } - - inline int GetButton() const { return m_Button; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "ButtonReleased: " << m_Button; - return ss.str(); - } - EVENT_TYPE(ButtonReleased) - EVENT_CATEGORY(InputEventCategory | MouseEventCategory) - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Events/MouseEvents.hpp b/Engine/src/Engine/Events/MouseEvents.hpp new file mode 100644 index 0000000..f83c3da --- /dev/null +++ b/Engine/src/Engine/Events/MouseEvents.hpp @@ -0,0 +1,106 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Event.hpp" + +#include +#include + +namespace Light { + +class MouseMovedEvent: public Event +{ +private: + const glm::vec2 m_Position; + +public: + MouseMovedEvent(float x, float y) + : m_Position(x, y) + { + } + + inline const glm::vec2& GetPosition() const { return m_Position; } + + inline float GetX() const { return m_Position.x; } + inline float GetY() const { return m_Position.y; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "MouseMoved: " << m_Position.x << ", " << m_Position.y; + return ss.str(); + } + EVENT_TYPE(MouseMoved) + EVENT_CATEGORY(InputEventCategory | MouseEventCategory) +}; + +class WheelScrolledEvent: public Event +{ +private: + const float m_Offset; + +public: + WheelScrolledEvent(float offset) + : m_Offset(offset) + { + } + + inline float GetOffset() const { return m_Offset; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "WheelScrolled: " << m_Offset; + return ss.str(); + } + EVENT_TYPE(WheelScrolled) + EVENT_CATEGORY(InputEventCategory | MouseEventCategory) +}; + +class ButtonPressedEvent: public Event +{ +private: + const int m_Button; + +public: + ButtonPressedEvent(int button) + : m_Button(button) + { + } + + inline int GetButton() const { return m_Button; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "ButtonPressed: " << m_Button; + return ss.str(); + } + EVENT_TYPE(ButtonPressed) + EVENT_CATEGORY(InputEventCategory | MouseEventCategory) +}; + +class ButtonReleasedEvent: public Event +{ +private: + const int m_Button; + +public: + ButtonReleasedEvent(int button) + : m_Button(button) + { + } + + inline int GetButton() const { return m_Button; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "ButtonReleased: " << m_Button; + return ss.str(); + } + EVENT_TYPE(ButtonReleased) + EVENT_CATEGORY(InputEventCategory | MouseEventCategory) +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Events/WindowEvents.h b/Engine/src/Engine/Events/WindowEvents.h deleted file mode 100644 index 4e79771..0000000 --- a/Engine/src/Engine/Events/WindowEvents.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include "Event.h" - -#include "Base/Base.h" - -#include - -#include - -namespace Light { - - class WindowClosedEvent : public Event - { - public: - virtual std::string GetInfoLog() const override - { - return "WindowClosedEvent"; - } - EVENT_TYPE(WindowClosed) - EVENT_CATEGORY(WindowEventCategory) - }; - - class WindowMovedEvent : public Event - { - private: - const glm::ivec2 m_Position; - - public: - WindowMovedEvent(int x, int y) - : m_Position(x, y) - { - } - - const glm::ivec2& GetPosition() const{ return m_Position; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "WindwoMoved: " << m_Position.x << ", " << m_Position.y; - return ss.str(); -; } - EVENT_TYPE(WindowMoved) - EVENT_CATEGORY(WindowEventCategory) - }; - - class WindowResizedEvent : public Event - { - private: - const glm::uvec2 m_Size; - - public: - WindowResizedEvent(unsigned int width, unsigned int height) - : m_Size(width, height) - { - } - - const glm::uvec2& GetSize() const { return m_Size; } - - virtual std::string GetInfoLog() const override - { - std::stringstream ss; - ss << "WindowResized: " << m_Size.x << ", " << m_Size.y; - return ss.str(); - } - EVENT_TYPE(WindowResized) - EVENT_CATEGORY(WindowEventCategory) - }; - - class WindowLostFocusEvent : public Event - { - public: - virtual std::string GetInfoLog() const override - { - return "WindowLostFocus"; - } - EVENT_TYPE(WindowLostFocus) - EVENT_CATEGORY(WindowEventCategory) - }; - - class WindowGainFocusEvent : public Event - { - public: - virtual std::string GetInfoLog() const override - { - return "WindowGainFocus"; - } - EVENT_TYPE(WindowGainFocus) - EVENT_CATEGORY(WindowEventCategory) - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Events/WindowEvents.hpp b/Engine/src/Engine/Events/WindowEvents.hpp new file mode 100644 index 0000000..5a9ed7c --- /dev/null +++ b/Engine/src/Engine/Events/WindowEvents.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Event.hpp" + +#include +#include + +namespace Light { + +class WindowClosedEvent: public Event +{ +public: + virtual std::string GetInfoLog() const override + { + return "WindowClosedEvent"; + } + EVENT_TYPE(WindowClosed) + EVENT_CATEGORY(WindowEventCategory) +}; + +class WindowMovedEvent: public Event +{ +private: + const glm::ivec2 m_Position; + +public: + WindowMovedEvent(int x, int y) + : m_Position(x, y) + { + } + + const glm::ivec2& GetPosition() const { return m_Position; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "WindwoMoved: " << m_Position.x << ", " << m_Position.y; + return ss.str(); + ; + } + EVENT_TYPE(WindowMoved) + EVENT_CATEGORY(WindowEventCategory) +}; + +class WindowResizedEvent: public Event +{ +private: + const glm::uvec2 m_Size; + +public: + WindowResizedEvent(unsigned int width, unsigned int height) + : m_Size(width, height) + { + } + + const glm::uvec2& GetSize() const { return m_Size; } + + virtual std::string GetInfoLog() const override + { + std::stringstream ss; + ss << "WindowResized: " << m_Size.x << ", " << m_Size.y; + return ss.str(); + } + EVENT_TYPE(WindowResized) + EVENT_CATEGORY(WindowEventCategory) +}; + +class WindowLostFocusEvent: public Event +{ +public: + virtual std::string GetInfoLog() const override + { + return "WindowLostFocus"; + } + EVENT_TYPE(WindowLostFocus) + EVENT_CATEGORY(WindowEventCategory) +}; + +class WindowGainFocusEvent: public Event +{ +public: + virtual std::string GetInfoLog() const override + { + return "WindowGainFocus"; + } + EVENT_TYPE(WindowGainFocus) + EVENT_CATEGORY(WindowEventCategory) +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Blender.cpp b/Engine/src/Engine/Graphics/Blender.cpp index 3b486ed..d785b60 100644 --- a/Engine/src/Engine/Graphics/Blender.cpp +++ b/Engine/src/Engine/Graphics/Blender.cpp @@ -1,13 +1,13 @@ -#include "Blender.h" +#include "Blender.hpp" -#include "OpenGL/glBlender.h" +#include "OpenGL/glBlender.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxBlender.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxBlender.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/Blender.h b/Engine/src/Engine/Graphics/Blender.h deleted file mode 100644 index c771b40..0000000 --- a/Engine/src/Engine/Graphics/Blender.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class SharedContext; - - enum class BlendFactor : uint8_t - { - // constants - ZERO, ONE, - - // source - SRC_COLOR, - INVERSE_SRC_COLOR, - - SRC_ALPHA, - INVERSE_SRC_ALPHA, - - // destination - DST_COLOR, - INVERSE_DST_COLOR, - - DST_ALPHA, - INVERSE_DST_ALPHA, - - // source1 - SRC1_COLOR, - INVERSE_SRC1_COLOR, - - SRC1_ALPHA, - INVERSE_SRC1_ALPHA, - }; - - class Blender - { - public: - static Scope Create(Ref sharedContext); - - virtual void Enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; - virtual void Disable() = 0; - - protected: - Blender() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Blender.hpp b/Engine/src/Engine/Graphics/Blender.hpp new file mode 100644 index 0000000..b3da2a1 --- /dev/null +++ b/Engine/src/Engine/Graphics/Blender.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class SharedContext; + +enum class BlendFactor : uint8_t +{ + // constants + ZERO, + ONE, + + // source + SRC_COLOR, + INVERSE_SRC_COLOR, + + SRC_ALPHA, + INVERSE_SRC_ALPHA, + + // destination + DST_COLOR, + INVERSE_DST_COLOR, + + DST_ALPHA, + INVERSE_DST_ALPHA, + + // source1 + SRC1_COLOR, + INVERSE_SRC1_COLOR, + + SRC1_ALPHA, + INVERSE_SRC1_ALPHA, +}; + +class Blender +{ +public: + static Scope Create(Ref sharedContext); + + virtual void Enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; + virtual void Disable() = 0; + +protected: + Blender() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Buffers.cpp b/Engine/src/Engine/Graphics/Buffers.cpp index cc2e045..b8af658 100644 --- a/Engine/src/Engine/Graphics/Buffers.cpp +++ b/Engine/src/Engine/Graphics/Buffers.cpp @@ -1,14 +1,14 @@ -#include "Buffers.h" +#include "Buffers.hpp" -#include "OpenGL/glBuffers.h" -#include "SharedContext.h" +#include "OpenGL/glBuffers.hpp" +#include "SharedContext.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxBuffers.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxBuffers.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/Buffers.h b/Engine/src/Engine/Graphics/Buffers.h deleted file mode 100644 index d237651..0000000 --- a/Engine/src/Engine/Graphics/Buffers.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class SharedContext; - - enum class ConstantBufferIndex - { - ViewProjection = 0u - }; - - //========== CONSTANT_BUFFER ==========// - class ConstantBuffer - { - public: - static Scope Create(ConstantBufferIndex index, unsigned int size, Ref sharedContext); - - virtual void* Map() = 0; - virtual void UnMap() = 0; - - virtual void Bind() = 0; - - protected: - ConstantBuffer() = default; - }; - - //========== VERTEX_BUFFER ==========// - class VertexBuffer - { - public: - static Ref Create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); - - virtual ~VertexBuffer() = default; - - virtual void* Map() = 0; - virtual void UnMap() = 0; - - virtual void Bind() = 0; - virtual void UnBind() = 0; - - protected: - VertexBuffer() = default; - }; - - //========== INDEX_BUFFER ==========// - class IndexBuffer - { - public: - static Ref Create(unsigned int* indices, unsigned int count, Ref sharedContext); - - virtual ~IndexBuffer() = default; - - virtual void Bind() = 0; - virtual void UnBind() = 0; - - protected: - IndexBuffer() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Buffers.hpp b/Engine/src/Engine/Graphics/Buffers.hpp new file mode 100644 index 0000000..6d063e5 --- /dev/null +++ b/Engine/src/Engine/Graphics/Buffers.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class SharedContext; + +enum class ConstantBufferIndex +{ + ViewProjection = 0u +}; + +//========== CONSTANT_BUFFER ==========// +class ConstantBuffer +{ +public: + static Scope Create(ConstantBufferIndex index, unsigned int size, Ref sharedContext); + + virtual void* Map() = 0; + virtual void UnMap() = 0; + + virtual void Bind() = 0; + +protected: + ConstantBuffer() = default; +}; + +//========== VERTEX_BUFFER ==========// +class VertexBuffer +{ +public: + static Ref Create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); + + virtual ~VertexBuffer() = default; + + virtual void* Map() = 0; + virtual void UnMap() = 0; + + virtual void Bind() = 0; + virtual void UnBind() = 0; + +protected: + VertexBuffer() = default; +}; + +//========== INDEX_BUFFER ==========// +class IndexBuffer +{ +public: + static Ref Create(unsigned int* indices, unsigned int count, Ref sharedContext); + + virtual ~IndexBuffer() = default; + + virtual void Bind() = 0; + virtual void UnBind() = 0; + +protected: + IndexBuffer() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Framebuffer.cpp b/Engine/src/Engine/Graphics/Framebuffer.cpp index 418f174..ea1c1ad 100644 --- a/Engine/src/Engine/Graphics/Framebuffer.cpp +++ b/Engine/src/Engine/Graphics/Framebuffer.cpp @@ -1,13 +1,13 @@ -#include "Framebuffer.h" +#include "Framebuffer.hpp" -#include "OpenGL/glFramebuffer.h" +#include "OpenGL/glFramebuffer.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxFramebuffer.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxFramebuffer.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/Framebuffer.h b/Engine/src/Engine/Graphics/Framebuffer.h deleted file mode 100644 index 7946da3..0000000 --- a/Engine/src/Engine/Graphics/Framebuffer.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class SharedContext; - - struct FramebufferSpecification - { - unsigned int width, height; - unsigned int samples = 1; - }; - - class Framebuffer - { - public: - static Ref Create(const FramebufferSpecification& specification, Ref sharedContext); - - virtual void BindAsTarget(const glm::vec4& clearColor) = 0; - virtual void BindAsResource() = 0; - - virtual void Resize(const glm::uvec2& size) = 0; - - virtual void* GetColorAttachment() = 0; - - protected: - Framebuffer() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Framebuffer.hpp b/Engine/src/Engine/Graphics/Framebuffer.hpp new file mode 100644 index 0000000..e7c774b --- /dev/null +++ b/Engine/src/Engine/Graphics/Framebuffer.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class SharedContext; + +struct FramebufferSpecification +{ + unsigned int width, height; + unsigned int samples = 1; +}; + +class Framebuffer +{ +public: + static Ref Create(const FramebufferSpecification& specification, Ref sharedContext); + + virtual void BindAsTarget(const glm::vec4& clearColor) = 0; + virtual void BindAsResource() = 0; + + virtual void Resize(const glm::uvec2& size) = 0; + + virtual void* GetColorAttachment() = 0; + +protected: + Framebuffer() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/GraphicsContext.cpp b/Engine/src/Engine/Graphics/GraphicsContext.cpp index 46361f3..957479e 100644 --- a/Engine/src/Engine/Graphics/GraphicsContext.cpp +++ b/Engine/src/Engine/Graphics/GraphicsContext.cpp @@ -1,18 +1,18 @@ -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" -#include "OpenGL/glGraphicsContext.h" +#include "OpenGL/glGraphicsContext.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxGraphicsContext.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxGraphicsContext.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "Blender.h" // required for forward declaration -#include "Buffers.h" // required for forward declaration -#include "RenderCommand.h" // required for forward declaration -#include "Renderer.h" // required for forward declaration -#include "UserInterface/UserInterface.h" // required for forward declaration -#include "Utility/ResourceManager.h" // required for forward declaration +#include "Blender.hpp" // required for forward declaration +#include "Buffers.hpp" // required for forward declaration +#include "RenderCommand.hpp" // required for forward declaration +#include "Renderer.hpp" // required for forward declaration +#include "UserInterface/UserInterface.hpp" // required for forward declaration +#include "Utility/ResourceManager.hpp" // required for forward declaration namespace Light { diff --git a/Engine/src/Engine/Graphics/GraphicsContext.h b/Engine/src/Engine/Graphics/GraphicsContext.h deleted file mode 100644 index 31d5d98..0000000 --- a/Engine/src/Engine/Graphics/GraphicsContext.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class Renderer; - class ResourceManager; - class SharedContext; - - class UserInterface; - - class WindowResizedEvent; - - enum class GraphicsAPI - { - Default = 0, - OpenGL, - DirectX, - Vulkan, // :#todo - Metal // :#todo - }; - - class GraphicsContext /* singleton */ - { - private: - static GraphicsContext* s_Context; - - private: - - Scope m_UserInterface; - Scope m_Renderer; - - protected: - GraphicsAPI m_GraphicsAPI; - Ref m_SharedContext = nullptr; - - public: - static Scope Create(GraphicsAPI api, GLFWwindow* windowHandle); - - GraphicsContext(const GraphicsContext&) = delete; - GraphicsContext& operator=(const GraphicsContext&) = delete; - - virtual ~GraphicsContext(); - - virtual void LogDebugData() = 0; - - static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; } - static inline Ref GetSharedContext() { return s_Context->m_SharedContext; } - - inline Renderer* GetRenderer() { return m_Renderer.get(); } - inline UserInterface* GetUserInterface() { return m_UserInterface.get(); } - - protected: - GraphicsContext() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/GraphicsContext.hpp b/Engine/src/Engine/Graphics/GraphicsContext.hpp new file mode 100644 index 0000000..adf5632 --- /dev/null +++ b/Engine/src/Engine/Graphics/GraphicsContext.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include "Base/Base.hpp" + +struct GLFWwindow; + +namespace Light { + +class Renderer; +class ResourceManager; +class SharedContext; + +class UserInterface; + +class WindowResizedEvent; + +enum class GraphicsAPI +{ + Default = 0, + OpenGL, + DirectX, + Vulkan, // :#todo + Metal // :#todo +}; + +class GraphicsContext /* singleton */ +{ +private: + static GraphicsContext* s_Context; + +private: + Scope m_UserInterface; + Scope m_Renderer; + +protected: + GraphicsAPI m_GraphicsAPI; + Ref m_SharedContext = nullptr; + +public: + static Scope Create(GraphicsAPI api, GLFWwindow* windowHandle); + + GraphicsContext(const GraphicsContext&) = delete; + GraphicsContext& operator=(const GraphicsContext&) = delete; + + virtual ~GraphicsContext(); + + virtual void LogDebugData() = 0; + + static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; } + static inline Ref GetSharedContext() { return s_Context->m_SharedContext; } + + inline Renderer* GetRenderer() { return m_Renderer.get(); } + inline UserInterface* GetUserInterface() { return m_UserInterface.get(); } + +protected: + GraphicsContext() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RenderCommand.cpp b/Engine/src/Engine/Graphics/RenderCommand.cpp index f2284cb..6d1f7cc 100644 --- a/Engine/src/Engine/Graphics/RenderCommand.cpp +++ b/Engine/src/Engine/Graphics/RenderCommand.cpp @@ -1,13 +1,13 @@ -#include "RenderCommand.h" +#include "RenderCommand.hpp" -#include "OpenGL/glRenderCommand.h" +#include "OpenGL/glRenderCommand.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxRenderCommand.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxRenderCommand.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/RenderCommand.h b/Engine/src/Engine/Graphics/RenderCommand.h deleted file mode 100644 index 449ba0c..0000000 --- a/Engine/src/Engine/Graphics/RenderCommand.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -struct GLFWwindow; - -namespace Light { - - class SharedContext; - - class RenderCommand - { - public: - static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); - - RenderCommand(const RenderCommand&) = delete; - RenderCommand& operator=(const RenderCommand&) = delete; - - virtual ~RenderCommand() = default; - - virtual void SwapBuffers() = 0; - virtual void ClearBackBuffer(const glm::vec4& clearColor) = 0; - - virtual void Draw(unsigned int count) = 0; - virtual void DrawIndexed(unsigned int count) = 0; - - virtual void DefaultTargetFramebuffer() = 0; - - virtual void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) = 0; - - protected: - RenderCommand() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RenderCommand.hpp b/Engine/src/Engine/Graphics/RenderCommand.hpp new file mode 100644 index 0000000..674a239 --- /dev/null +++ b/Engine/src/Engine/Graphics/RenderCommand.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +struct GLFWwindow; + +namespace Light { + +class SharedContext; + +class RenderCommand +{ +public: + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); + + RenderCommand(const RenderCommand&) = delete; + RenderCommand& operator=(const RenderCommand&) = delete; + + virtual ~RenderCommand() = default; + + virtual void SwapBuffers() = 0; + virtual void ClearBackBuffer(const glm::vec4& clearColor) = 0; + + virtual void Draw(unsigned int count) = 0; + virtual void DrawIndexed(unsigned int count) = 0; + + virtual void DefaultTargetFramebuffer() = 0; + + virtual void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) = 0; + +protected: + RenderCommand() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Renderer.cpp b/Engine/src/Engine/Graphics/Renderer.cpp index bf764a0..b9e7ebf 100644 --- a/Engine/src/Engine/Graphics/Renderer.cpp +++ b/Engine/src/Engine/Graphics/Renderer.cpp @@ -1,12 +1,12 @@ -#include "Renderer.h" +#include "Renderer.hpp" -#include "Blender.h" -#include "Buffers.h" -#include "Camera/SceneCamera.h" -#include "Events/WindowEvents.h" -#include "Framebuffer.h" -#include "RenderCommand.h" -#include "Texture.h" +#include "Blender.hpp" +#include "Buffers.hpp" +#include "Camera/SceneCamera.hpp" +#include "Events/WindowEvents.hpp" +#include "Framebuffer.hpp" +#include "RenderCommand.hpp" +#include "Texture.hpp" #include #include diff --git a/Engine/src/Engine/Graphics/Renderer.h b/Engine/src/Engine/Graphics/Renderer.h deleted file mode 100644 index 6fd6c67..0000000 --- a/Engine/src/Engine/Graphics/Renderer.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "RendererPrograms/QuadRendererProgram.h" -#include "RendererPrograms/TextureRendererProgram.h" -#include "RendererPrograms/TintedTextureRendererProgram.h" - -#define LT_MAX_QUAD_RENDERER_VERTICES 1028u * 4u -#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u -#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES 1028u * 4u - -struct GLFWwindow; - -namespace Light { - - class Blender; - class ConstantBuffer; - class Framebuffer; - class RenderCommand; - class Texture; - - class SharedContext; - - class Camera; - - class WindowResizedEvent; - - class Renderer - { - private: - static Renderer* s_Context; - - // renderer programs - QuadRendererProgram m_QuadRenderer; - TextureRendererProgram m_TextureRenderer; - TintedTextureRendererProgram m_TintedTextureRenderer; - - // constant buffers - Scope m_ViewProjectionBuffer; - - Scope m_RenderCommand; - Scope m_Blender; - - Camera* m_DefaultFramebufferCamera; - Ref m_TargetFramebuffer; - - bool m_ShouldClearBackbuffer; - - public: - static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); - - static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref texture) { s_Context->DrawQuadImpl(position, size, tint, texture); } - static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint) { s_Context->DrawQuadImpl(position, size, tint); } - static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, Ref texture) { s_Context->DrawQuadImpl(position, size, texture); } - - static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint, Ref texture) { s_Context->DrawQuadImpl(transform, tint, texture); } - static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint) { s_Context->DrawQuadImpl(transform, tint); } - static void DrawQuad(const glm::mat4& transform, Ref texture) { s_Context->DrawQuadImpl(transform, texture); } - - static inline void BeginScene(Camera* camera, const glm::mat4& cameraTransform, const Ref& targetFrameBuffer = nullptr) { s_Context->BeginSceneImpl(camera, cameraTransform, targetFrameBuffer); } - static inline void EndScene() { s_Context->EndSceneImpl(); } - - void OnWindowResize(const WindowResizedEvent& event); - - void BeginFrame(); - void EndFrame(); - - private: - Renderer(GLFWwindow* windowHandle, Ref sharedContext); - - void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref texture); - void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint); - void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, Ref texture); - - void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint, Ref texture); - void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint); - void DrawQuadImpl(const glm::mat4& transform, Ref texture); - - void BeginSceneImpl(Camera* camera, const glm::mat4& cameraTransform, const Ref& targetFrameBuffer = nullptr); - void FlushScene(); - void EndSceneImpl(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Renderer.hpp b/Engine/src/Engine/Graphics/Renderer.hpp new file mode 100644 index 0000000..c65f806 --- /dev/null +++ b/Engine/src/Engine/Graphics/Renderer.hpp @@ -0,0 +1,84 @@ +#pragma once + +#include "Base/Base.hpp" +#include "RendererPrograms/QuadRendererProgram.hpp" +#include "RendererPrograms/TextureRendererProgram.hpp" +#include "RendererPrograms/TintedTextureRendererProgram.hpp" + +#define LT_MAX_QUAD_RENDERER_VERTICES 1028u * 4u +#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u +#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES 1028u * 4u + +struct GLFWwindow; + +namespace Light { + +class Blender; +class ConstantBuffer; +class Framebuffer; +class RenderCommand; +class Texture; + +class SharedContext; + +class Camera; + +class WindowResizedEvent; + +class Renderer +{ +private: + static Renderer* s_Context; + + // renderer programs + QuadRendererProgram m_QuadRenderer; + TextureRendererProgram m_TextureRenderer; + TintedTextureRendererProgram m_TintedTextureRenderer; + + // constant buffers + Scope m_ViewProjectionBuffer; + + Scope m_RenderCommand; + Scope m_Blender; + + Camera* m_DefaultFramebufferCamera; + Ref m_TargetFramebuffer; + + bool m_ShouldClearBackbuffer; + +public: + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); + + static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref texture) { s_Context->DrawQuadImpl(position, size, tint, texture); } + static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint) { s_Context->DrawQuadImpl(position, size, tint); } + static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, Ref texture) { s_Context->DrawQuadImpl(position, size, texture); } + + static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint, Ref texture) { s_Context->DrawQuadImpl(transform, tint, texture); } + static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint) { s_Context->DrawQuadImpl(transform, tint); } + static void DrawQuad(const glm::mat4& transform, Ref texture) { s_Context->DrawQuadImpl(transform, texture); } + + static inline void BeginScene(Camera* camera, const glm::mat4& cameraTransform, const Ref& targetFrameBuffer = nullptr) { s_Context->BeginSceneImpl(camera, cameraTransform, targetFrameBuffer); } + static inline void EndScene() { s_Context->EndSceneImpl(); } + + void OnWindowResize(const WindowResizedEvent& event); + + void BeginFrame(); + void EndFrame(); + +private: + Renderer(GLFWwindow* windowHandle, Ref sharedContext); + + void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref texture); + void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint); + void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, Ref texture); + + void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint, Ref texture); + void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint); + void DrawQuadImpl(const glm::mat4& transform, Ref texture); + + void BeginSceneImpl(Camera* camera, const glm::mat4& cameraTransform, const Ref& targetFrameBuffer = nullptr); + void FlushScene(); + void EndSceneImpl(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp index 73d4986..11b2a97 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp +++ b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp @@ -1,10 +1,10 @@ -#include "QuadRendererProgram.h" +#include "QuadRendererProgram.hpp" -#include "Camera/Camera.h" -#include "Graphics/Buffers.h" -#include "Graphics/Shader.h" -#include "Graphics/VertexLayout.h" -#include "Utility/ResourceManager.h" +#include "Camera/Camera.hpp" +#include "Graphics/Buffers.hpp" +#include "Graphics/Shader.hpp" +#include "Graphics/VertexLayout.hpp" +#include "Utility/ResourceManager.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h deleted file mode 100644 index 6358bc0..0000000 --- a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include "RendererProgram.h" - -#include "Base/Base.h" - -#include - -namespace Light { - - class Shader; - class VertexBuffer; - class IndexBuffer; - class VertexLayout; - - class OrthographicCamera; - - class SharedContext; - - class QuadRendererProgram : RendererProgram - { - public: - struct QuadVertexData - { - glm::vec4 position; - glm::vec4 tint; - }; - - private: - Ref m_Shader; - Ref m_VertexBuffer; - Ref m_IndexBuffer; - Ref m_VertexLayout; - - QuadVertexData* m_MapCurrent = nullptr; - QuadVertexData* m_MapEnd = nullptr; - - unsigned int m_QuadCount = 0u; - unsigned int m_MaxVertices = 0u; - - public: - QuadRendererProgram(unsigned int maxVertices, Ref sharedContext); - - bool Advance(); - - void Map() override; - void UnMap() override; - - void Bind() override; - - inline QuadVertexData* GetMapCurrent() { return m_MapCurrent; } - inline unsigned int GetQuadCount() const { return m_QuadCount; } - inline constexpr unsigned int GetVertexSize() const { return sizeof(QuadVertexData); } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.hpp b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.hpp new file mode 100644 index 0000000..571e98d --- /dev/null +++ b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include "Base/Base.hpp" +#include "RendererProgram.hpp" + +#include + +namespace Light { + +class Shader; +class VertexBuffer; +class IndexBuffer; +class VertexLayout; + +class OrthographicCamera; + +class SharedContext; + +class QuadRendererProgram: RendererProgram +{ +public: + struct QuadVertexData + { + glm::vec4 position; + glm::vec4 tint; + }; + +private: + Ref m_Shader; + Ref m_VertexBuffer; + Ref m_IndexBuffer; + Ref m_VertexLayout; + + QuadVertexData* m_MapCurrent = nullptr; + QuadVertexData* m_MapEnd = nullptr; + + unsigned int m_QuadCount = 0u; + unsigned int m_MaxVertices = 0u; + +public: + QuadRendererProgram(unsigned int maxVertices, Ref sharedContext); + + bool Advance(); + + void Map() override; + void UnMap() override; + + void Bind() override; + + inline QuadVertexData* GetMapCurrent() { return m_MapCurrent; } + inline unsigned int GetQuadCount() const { return m_QuadCount; } + inline constexpr unsigned int GetVertexSize() const { return sizeof(QuadVertexData); } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.h deleted file mode 100644 index b228c1f..0000000 --- a/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class OrthographicCamera; - - class RendererProgram - { - virtual void Map() = 0; - virtual void UnMap() = 0; - - virtual void Bind() = 0; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.hpp b/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.hpp new file mode 100644 index 0000000..bb27c41 --- /dev/null +++ b/Engine/src/Engine/Graphics/RendererPrograms/RendererProgram.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class OrthographicCamera; + +class RendererProgram +{ + virtual void Map() = 0; + virtual void UnMap() = 0; + + virtual void Bind() = 0; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp index c096e4e..7181349 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp +++ b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp @@ -1,10 +1,10 @@ -#include "TextureRendererProgram.h" +#include "TextureRendererProgram.hpp" -#include "Camera/Camera.h" -#include "Graphics/Buffers.h" -#include "Graphics/Shader.h" -#include "Graphics/VertexLayout.h" -#include "Utility/ResourceManager.h" +#include "Camera/Camera.hpp" +#include "Graphics/Buffers.hpp" +#include "Graphics/Shader.hpp" +#include "Graphics/VertexLayout.hpp" +#include "Utility/ResourceManager.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h deleted file mode 100644 index 64c6e5d..0000000 --- a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "RendererProgram.h" - -#include "Base/Base.h" - -#include - -namespace Light { - - class Shader; - class VertexBuffer; - class IndexBuffer; - class VertexLayout; - - class OrthographicCamera; - - class SharedContext; - - class TextureRendererProgram : RendererProgram - { - public: - struct TextureVertexData - { - glm::vec4 position; - glm::vec2 texcoord; - }; - - private: - Ref m_Shader; - Ref m_VertexBuffer; - Ref m_IndexBuffer; - Ref m_VertexLayout; - - TextureVertexData* m_MapCurrent = nullptr; - TextureVertexData* m_MapEnd = nullptr; - - unsigned int m_QuadCount; - unsigned int m_MaxVertices; - - public: - TextureRendererProgram(unsigned int maxVertices, Ref sharedContext); - - bool Advance(); - - void Map() override; - void UnMap() override; - - void Bind() override; - - inline TextureVertexData* GetMapCurrent() { return m_MapCurrent; } - - inline unsigned int GetQuadCount() const { return m_QuadCount; } - - inline constexpr unsigned int GetVertexSize() const { return sizeof(TextureVertexData); } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.hpp b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.hpp new file mode 100644 index 0000000..285ed04 --- /dev/null +++ b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "Base/Base.hpp" +#include "RendererProgram.hpp" + +#include + +namespace Light { + +class Shader; +class VertexBuffer; +class IndexBuffer; +class VertexLayout; + +class OrthographicCamera; + +class SharedContext; + +class TextureRendererProgram: RendererProgram +{ +public: + struct TextureVertexData + { + glm::vec4 position; + glm::vec2 texcoord; + }; + +private: + Ref m_Shader; + Ref m_VertexBuffer; + Ref m_IndexBuffer; + Ref m_VertexLayout; + + TextureVertexData* m_MapCurrent = nullptr; + TextureVertexData* m_MapEnd = nullptr; + + unsigned int m_QuadCount; + unsigned int m_MaxVertices; + +public: + TextureRendererProgram(unsigned int maxVertices, Ref sharedContext); + + bool Advance(); + + void Map() override; + void UnMap() override; + + void Bind() override; + + inline TextureVertexData* GetMapCurrent() { return m_MapCurrent; } + + inline unsigned int GetQuadCount() const { return m_QuadCount; } + + inline constexpr unsigned int GetVertexSize() const { return sizeof(TextureVertexData); } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.cpp b/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.cpp index 9f0d226..2404f31 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.cpp +++ b/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.cpp @@ -1,10 +1,10 @@ -#include "TintedTextureRendererProgram.h" +#include "TintedTextureRendererProgram.hpp" -#include "Camera/Camera.h" -#include "Graphics/Buffers.h" -#include "Graphics/Shader.h" -#include "Graphics/VertexLayout.h" -#include "Utility/ResourceManager.h" +#include "Camera/Camera.hpp" +#include "Graphics/Buffers.hpp" +#include "Graphics/Shader.hpp" +#include "Graphics/VertexLayout.hpp" +#include "Utility/ResourceManager.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.h deleted file mode 100644 index 107cec0..0000000 --- a/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include "RendererProgram.h" - -#include "Base/Base.h" - -#include - -namespace Light { - - class Shader; - class VertexBuffer; - class IndexBuffer; - class VertexLayout; - - class OrthographicCamera; - - class SharedContext; - - class TintedTextureRendererProgram : RendererProgram - { - public: - struct TintedTextureVertexData - { - glm::vec4 position; - glm::vec4 tint; - glm::vec2 texcoord; - }; - - private: - Ref m_Shader; - Ref m_VertexBuffer; - Ref m_IndexBuffer; - Ref m_VertexLayout; - - TintedTextureVertexData* m_MapCurrent = nullptr; - TintedTextureVertexData* m_MapEnd = nullptr; - - unsigned int m_QuadCount; - unsigned int m_MaxVertices; - - public: - TintedTextureRendererProgram(unsigned int maxVertices, Ref sharedContext); - - bool Advance(); - - void Map() override; - void UnMap() override; - - void Bind() override; - - inline TintedTextureVertexData* GetMapCurrent() { return m_MapCurrent; } - - inline unsigned int GetQuadCount() const { return m_QuadCount; } - - inline constexpr unsigned int GetVertexSize() const { return sizeof(TintedTextureVertexData); } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.hpp b/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.hpp new file mode 100644 index 0000000..1fd308b --- /dev/null +++ b/Engine/src/Engine/Graphics/RendererPrograms/TintedTextureRendererProgram.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include "Base/Base.hpp" +#include "RendererProgram.hpp" + +#include + +namespace Light { + +class Shader; +class VertexBuffer; +class IndexBuffer; +class VertexLayout; + +class OrthographicCamera; + +class SharedContext; + +class TintedTextureRendererProgram: RendererProgram +{ +public: + struct TintedTextureVertexData + { + glm::vec4 position; + glm::vec4 tint; + glm::vec2 texcoord; + }; + +private: + Ref m_Shader; + Ref m_VertexBuffer; + Ref m_IndexBuffer; + Ref m_VertexLayout; + + TintedTextureVertexData* m_MapCurrent = nullptr; + TintedTextureVertexData* m_MapEnd = nullptr; + + unsigned int m_QuadCount; + unsigned int m_MaxVertices; + +public: + TintedTextureRendererProgram(unsigned int maxVertices, Ref sharedContext); + + bool Advance(); + + void Map() override; + void UnMap() override; + + void Bind() override; + + inline TintedTextureVertexData* GetMapCurrent() { return m_MapCurrent; } + + inline unsigned int GetQuadCount() const { return m_QuadCount; } + + inline constexpr unsigned int GetVertexSize() const { return sizeof(TintedTextureVertexData); } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Shader.cpp b/Engine/src/Engine/Graphics/Shader.cpp index c140198..94db2cf 100644 --- a/Engine/src/Engine/Graphics/Shader.cpp +++ b/Engine/src/Engine/Graphics/Shader.cpp @@ -1,13 +1,13 @@ -#include "Shader.h" +#include "Shader.hpp" -#include "OpenGL/glShader.h" +#include "OpenGL/glShader.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxShader.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxShader.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/Shader.h b/Engine/src/Engine/Graphics/Shader.h deleted file mode 100644 index dcb910f..0000000 --- a/Engine/src/Engine/Graphics/Shader.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Utility/FileManager.h" - -#include - -namespace Light { - - class SharedContext; - - class Shader - { - public: - enum Stage - { - NONE = 0, - VERTEX = 1, - PIXEL = 2, - GEOMETRY = 3 - }; - - public: - static Ref Create(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref sharedContext); - - 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/Graphics/Shader.hpp b/Engine/src/Engine/Graphics/Shader.hpp new file mode 100644 index 0000000..82a397b --- /dev/null +++ b/Engine/src/Engine/Graphics/Shader.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Utility/FileManager.hpp" + +#include + +namespace Light { + +class SharedContext; + +class Shader +{ +public: + enum Stage + { + NONE = 0, + VERTEX = 1, + PIXEL = 2, + GEOMETRY = 3 + }; + +public: + static Ref Create(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref sharedContext); + + virtual ~Shader() = default; + + virtual void Bind() = 0; + virtual void UnBind() = 0; + +protected: + Shader() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/SharedContext.h b/Engine/src/Engine/Graphics/SharedContext.h deleted file mode 100644 index a332b86..0000000 --- a/Engine/src/Engine/Graphics/SharedContext.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class SharedContext - { - public: - virtual ~SharedContext() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/SharedContext.hpp b/Engine/src/Engine/Graphics/SharedContext.hpp new file mode 100644 index 0000000..c687d97 --- /dev/null +++ b/Engine/src/Engine/Graphics/SharedContext.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class SharedContext +{ +public: + virtual ~SharedContext() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/Texture.cpp b/Engine/src/Engine/Graphics/Texture.cpp index a43ecc5..ceea48b 100644 --- a/Engine/src/Engine/Graphics/Texture.cpp +++ b/Engine/src/Engine/Graphics/Texture.cpp @@ -1,13 +1,13 @@ -#include "Texture.h" +#include "Texture.hpp" -#include "OpenGL/glTexture.h" +#include "OpenGL/glTexture.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxTexture.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxTexture.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/Texture.h b/Engine/src/Engine/Graphics/Texture.hpp similarity index 96% rename from Engine/src/Engine/Graphics/Texture.h rename to Engine/src/Engine/Graphics/Texture.hpp index 7d84b6d..9c3266f 100644 --- a/Engine/src/Engine/Graphics/Texture.h +++ b/Engine/src/Engine/Graphics/Texture.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Base/Base.h" +#include "Base/Base.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/VertexLayout.cpp b/Engine/src/Engine/Graphics/VertexLayout.cpp index 6b230f7..7445d6c 100644 --- a/Engine/src/Engine/Graphics/VertexLayout.cpp +++ b/Engine/src/Engine/Graphics/VertexLayout.cpp @@ -1,13 +1,13 @@ -#include "VertexLayout.h" +#include "VertexLayout.hpp" -#include "OpenGL/glVertexLayout.h" +#include "OpenGL/glVertexLayout.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxVertexLayout.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxVertexLayout.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "GraphicsContext.h" +#include "GraphicsContext.hpp" namespace Light { diff --git a/Engine/src/Engine/Graphics/VertexLayout.h b/Engine/src/Engine/Graphics/VertexLayout.h deleted file mode 100644 index 0d4f4d9..0000000 --- a/Engine/src/Engine/Graphics/VertexLayout.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class VertexBuffer; - class Shader; - - class SharedContext; - - enum class VertexElementType - { - Byte1 , Byte2 , Byte4 , - UByte1 , UByte2 , UByte4 , - Int1 , Int2 , Int3 , Int4 , - UInt1 , UInt2 , UInt3 , UInt4 , - Float1 , Float2 , Float3 , Float4 , - }; - - class VertexLayout - { - public: - static Ref Create(Ref vertexBuffer, Ref shader, const std::vector>& elements, Ref sharedContext); - - virtual ~VertexLayout() = default;; - - virtual void Bind() = 0; - virtual void UnBind() = 0; - - protected: - VertexLayout() = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/VertexLayout.hpp b/Engine/src/Engine/Graphics/VertexLayout.hpp new file mode 100644 index 0000000..ebe22bf --- /dev/null +++ b/Engine/src/Engine/Graphics/VertexLayout.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class VertexBuffer; +class Shader; + +class SharedContext; + +enum class VertexElementType +{ + Byte1, + Byte2, + Byte4, + UByte1, + UByte2, + UByte4, + Int1, + Int2, + Int3, + Int4, + UInt1, + UInt2, + UInt3, + UInt4, + Float1, + Float2, + Float3, + Float4, +}; + +class VertexLayout +{ +public: + static Ref Create(Ref vertexBuffer, Ref shader, const std::vector>& elements, Ref sharedContext); + + virtual ~VertexLayout() = default; + ; + + virtual void Bind() = 0; + virtual void UnBind() = 0; + +protected: + VertexLayout() = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Input/Input.cpp b/Engine/src/Engine/Input/Input.cpp index 5763bef..5442530 100644 --- a/Engine/src/Engine/Input/Input.cpp +++ b/Engine/src/Engine/Input/Input.cpp @@ -1,11 +1,11 @@ -#include "Input.h" +#include "Input.hpp" -#include "Events/CharEvent.h" -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Input/KeyCodes.h" -#include "ltpch.h" +#include "Events/CharEvent.hpp" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Input/KeyCodes.hpp" +#include "ltpch.hpp" #include diff --git a/Engine/src/Engine/Input/Input.h b/Engine/src/Engine/Input/Input.h deleted file mode 100644 index 760a894..0000000 --- a/Engine/src/Engine/Input/Input.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -#include - -namespace Light { - - class Event; - - class Input /* singleton */ - { - private: - static Input* s_Context; - - private: - - std::array m_KeyboadKeys; - std::array m_MouseButtons; - - glm::vec2 m_MousePosition; - glm::vec2 m_MouseDelta; - float m_MouseWheelDelta; - - bool m_UserInterfaceEvents; - bool m_GameEvents; - - public: - static Scope Create(); - - static inline void ReceiveUserInterfaceEvents(bool receive, bool toggle = false) { s_Context->ReceiveUserInterfaceEventsImpl(receive, toggle); } - static inline void ReceiveGameEvents(bool receive, bool toggle = false) { s_Context->ReceieveGameEventsImpl(receive, toggle); } - - static inline bool GetKeyboardKey(int code) { return s_Context->m_KeyboadKeys[code]; } - static inline bool GetMouseButton(int code) { return s_Context->m_MouseButtons[code]; } - - static inline const glm::vec2& GetMousePosition(int code) { return s_Context->m_MousePosition; } - - void OnEvent(const Event& inputEvent); - - inline bool IsReceivingInputEvents() const { return m_UserInterfaceEvents; } - inline bool IsReceivingGameEvents() const { return m_GameEvents; } - - private: - Input(); - - void ReceiveUserInterfaceEventsImpl(bool receive, bool toggle = false); - void ReceieveGameEventsImpl(bool receive, bool toggle = false); - - void RestartInputState(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Input/Input.hpp b/Engine/src/Engine/Input/Input.hpp new file mode 100644 index 0000000..b9832a8 --- /dev/null +++ b/Engine/src/Engine/Input/Input.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "Base/Base.hpp" + +#include +#include + +namespace Light { + +class Event; + +class Input /* singleton */ +{ +private: + static Input* s_Context; + +private: + std::array m_KeyboadKeys; + std::array m_MouseButtons; + + glm::vec2 m_MousePosition; + glm::vec2 m_MouseDelta; + float m_MouseWheelDelta; + + bool m_UserInterfaceEvents; + bool m_GameEvents; + +public: + static Scope Create(); + + static inline void ReceiveUserInterfaceEvents(bool receive, bool toggle = false) { s_Context->ReceiveUserInterfaceEventsImpl(receive, toggle); } + static inline void ReceiveGameEvents(bool receive, bool toggle = false) { s_Context->ReceieveGameEventsImpl(receive, toggle); } + + static inline bool GetKeyboardKey(int code) { return s_Context->m_KeyboadKeys[code]; } + static inline bool GetMouseButton(int code) { return s_Context->m_MouseButtons[code]; } + + static inline const glm::vec2& GetMousePosition(int code) { return s_Context->m_MousePosition; } + + void OnEvent(const Event& inputEvent); + + inline bool IsReceivingInputEvents() const { return m_UserInterfaceEvents; } + inline bool IsReceivingGameEvents() const { return m_GameEvents; } + +private: + Input(); + + void ReceiveUserInterfaceEventsImpl(bool receive, bool toggle = false); + void ReceieveGameEventsImpl(bool receive, bool toggle = false); + + void RestartInputState(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Input/KeyCodes.h b/Engine/src/Engine/Input/KeyCodes.h deleted file mode 100644 index 5e68d09..0000000 --- a/Engine/src/Engine/Input/KeyCodes.h +++ /dev/null @@ -1,185 +0,0 @@ -#pragma once - -#include "ltpch.h" - -#include - -namespace Light { - - namespace Key - { - enum : uint16_t - { - /* digits */ - D0 = 48, - D1 = 49, - D2 = 50, - D3 = 51, - D4 = 52, - D5 = 53, - D6 = 54, - D7 = 55, - D8 = 56, - D9 = 57, - Semicolon = 59, // ; - Equal = 61, // = - - /* letters */ - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - - /* brackets */ - LeftBracket = 91, // [ - LBracket = LeftBracket, // [ - RightBracket = 93, // ] - RBracket = RightBracket, // ] - - /* arrow */ - Right = 262, - RightArrow = Right, - RArrow = Right, - Left = 263, - LeftArrow = Left, - LArrow = Left, - Down = 264, - DownArrow = Down, - DArrow = Down, - Up = 265, - UpArrow = Up, - UArrow = Up, - - /* page */ - PageUp = 266, - PageDown = 267, - - /* home/end */ - Home = 268, - End = 269, - - /* toggles */ - CapsLock = 280, - ScrollLock = 281, - NumLock = 282, - NumberLock = NumLock, - - /* function */ - F1 = 290, - F2 = 291, - F3 = 292, - F4 = 293, - F5 = 294, - F6 = 295, - F7 = 296, - F8 = 297, - F9 = 298, - F10 = 299, - F11 = 300, - F12 = 301, - F13 = 302, - F14 = 303, - F15 = 304, - F16 = 305, - F17 = 306, - F18 = 307, - F19 = 308, - F20 = 309, - F21 = 310, - F22 = 311, - F23 = 312, - F24 = 313, - F25 = 314, - - /* keypad */ - Kp0 = 320, - Kp1 = 321, - Kp2 = 322, - Kp3 = 323, - Kp4 = 324, - Kp5 = 325, - Kp6 = 326, - Kp7 = 327, - Kp8 = 328, - Kp9 = 329, - KpDecimal = 330, - KpDivide = 331, - KpMultiply = 332, - KpSubstract = 333, - KpAdd = 334, - KpEnter = 335, - KpEqual = 336, - - /* modifiers */ - LeftShift = 340, - LShift = LeftShift, - LeftControl = 341, - LControl = LeftControl, - LeftAlt = 342, - LAlt = LeftAlt, - LeftSuper = 343, - LSuper = LeftSuper, - RightShift = 344, - RShift = 344, - RightControl = 345, - RControl = 345, - RightAlt = 346, - RAlt = 346, - RightSuper = 347, - RSuper = 347, - - /* misc */ - Space = 32, - Apostrophe = 39, // ' - Quote = Apostrophe, - - Comma = 44, // , - Minus = 45, // - - Period = 46, // . - Slash = 47, // / - ForwardSlash = Slash, // / - BackSlash = 92, // \ - - GraveAccent = 96, // ` - Console = GraveAccent, - World1 = 161, // non-US #1 - World2 = 162, // non-US #2 - Escape = 256, - Esc = Escape, - Enter = 257, - Tab = 258, - BackSpace = 259, - Insert = 260, - Delete = 261, - - PrintScreen = 283, - Pause = 284, - - Menu = 348, - - }; - } - -} \ No newline at end of file diff --git a/Engine/src/Engine/Input/KeyCodes.hpp b/Engine/src/Engine/Input/KeyCodes.hpp new file mode 100644 index 0000000..44068b7 --- /dev/null +++ b/Engine/src/Engine/Input/KeyCodes.hpp @@ -0,0 +1,184 @@ +#pragma once + +#include "ltpch.hpp" + +#include + +namespace Light { + +namespace Key { +enum : uint16_t +{ + /* digits */ + D0 = 48, + D1 = 49, + D2 = 50, + D3 = 51, + D4 = 52, + D5 = 53, + D6 = 54, + D7 = 55, + D8 = 56, + D9 = 57, + Semicolon = 59, // ; + Equal = 61, // = + + /* letters */ + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + + /* brackets */ + LeftBracket = 91, // [ + LBracket = LeftBracket, // [ + RightBracket = 93, // ] + RBracket = RightBracket, // ] + + /* arrow */ + Right = 262, + RightArrow = Right, + RArrow = Right, + Left = 263, + LeftArrow = Left, + LArrow = Left, + Down = 264, + DownArrow = Down, + DArrow = Down, + Up = 265, + UpArrow = Up, + UArrow = Up, + + /* page */ + PageUp = 266, + PageDown = 267, + + /* home/end */ + Home = 268, + End = 269, + + /* toggles */ + CapsLock = 280, + ScrollLock = 281, + NumLock = 282, + NumberLock = NumLock, + + /* function */ + F1 = 290, + F2 = 291, + F3 = 292, + F4 = 293, + F5 = 294, + F6 = 295, + F7 = 296, + F8 = 297, + F9 = 298, + F10 = 299, + F11 = 300, + F12 = 301, + F13 = 302, + F14 = 303, + F15 = 304, + F16 = 305, + F17 = 306, + F18 = 307, + F19 = 308, + F20 = 309, + F21 = 310, + F22 = 311, + F23 = 312, + F24 = 313, + F25 = 314, + + /* keypad */ + Kp0 = 320, + Kp1 = 321, + Kp2 = 322, + Kp3 = 323, + Kp4 = 324, + Kp5 = 325, + Kp6 = 326, + Kp7 = 327, + Kp8 = 328, + Kp9 = 329, + KpDecimal = 330, + KpDivide = 331, + KpMultiply = 332, + KpSubstract = 333, + KpAdd = 334, + KpEnter = 335, + KpEqual = 336, + + /* modifiers */ + LeftShift = 340, + LShift = LeftShift, + LeftControl = 341, + LControl = LeftControl, + LeftAlt = 342, + LAlt = LeftAlt, + LeftSuper = 343, + LSuper = LeftSuper, + RightShift = 344, + RShift = 344, + RightControl = 345, + RControl = 345, + RightAlt = 346, + RAlt = 346, + RightSuper = 347, + RSuper = 347, + + /* misc */ + Space = 32, + Apostrophe = 39, // ' + Quote = Apostrophe, + + Comma = 44, // , + Minus = 45, // - + Period = 46, // . + Slash = 47, // / + ForwardSlash = Slash, // / + BackSlash = 92, // \ + + GraveAccent = 96, // ` + Console = GraveAccent, + World1 = 161, // non-US #1 + World2 = 162, // non-US #2 + Escape = 256, + Esc = Escape, + Enter = 257, + Tab = 258, + BackSpace = 259, + Insert = 260, + Delete = 261, + + PrintScreen = 283, + Pause = 284, + + Menu = 348, + +}; +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Input/MouseCodes.h b/Engine/src/Engine/Input/MouseCodes.h deleted file mode 100644 index 9528026..0000000 --- a/Engine/src/Engine/Input/MouseCodes.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "ltpch.h" - -#include - -namespace Light { - - namespace Mouse - { - enum : uint8_t - { - Button1 = 0, - Button2 = 1, - Button3 = 2, - Button4 = 3, - Button5 = 4, - Button6 = 5, - Button7 = 6, - Button8 = 7, - - LButton = Button1, - RButton = Button2, - MButton = Button3, - }; - } - -} \ No newline at end of file diff --git a/Engine/src/Engine/Input/MouseCodes.hpp b/Engine/src/Engine/Input/MouseCodes.hpp new file mode 100644 index 0000000..0bc16d7 --- /dev/null +++ b/Engine/src/Engine/Input/MouseCodes.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "ltpch.hpp" + +#include + +namespace Light { + +namespace Mouse { +enum : uint8_t +{ + Button1 = 0, + Button2 = 1, + Button3 = 2, + Button4 = 3, + Button5 = 4, + Button6 = 5, + Button7 = 6, + Button8 = 7, + + LButton = Button1, + RButton = Button2, + MButton = Button3, +}; +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Layer/Layer.cpp b/Engine/src/Engine/Layer/Layer.cpp index bbbccdd..33bd8a7 100644 --- a/Engine/src/Engine/Layer/Layer.cpp +++ b/Engine/src/Engine/Layer/Layer.cpp @@ -1,62 +1,62 @@ -#include "Layer.h" +#include "Layer.hpp" -#include "Events/Event.h" -#include "Events/CharEvent.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Events/WindowEvents.h" +#include "Events/CharEvent.hpp" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Events/WindowEvents.hpp" namespace Light { - - Layer::Layer(const std::string& name) - : m_LayerName(name) + +Layer::Layer(const std::string& name) + : m_LayerName(name) +{ +} + +bool Layer::OnEvent(const Event& event) +{ + switch (event.GetEventType()) { + /* mouse */ + // cursor + case EventType::MouseMoved: + return OnMouseMoved((MouseMovedEvent&)event); + // button + case EventType::ButtonPressed: + return OnButtonPressed((ButtonPressedEvent&)event); + case EventType::ButtonReleased: + return OnButtonReleased((ButtonReleasedEvent&)event); + // wheel + case EventType::WheelScrolled: + return OnWheelScrolled((WheelScrolledEvent&)event); + + /* keyboard */ + // key + case EventType::KeyPressed: + return OnKeyPressed((KeyPressedEvent&)event); + case EventType::KeyRepeated: + return OnKeyRepeat((KeyRepeatEvent&)event); + case EventType::KeyReleased: + return OnKeyReleased((KeyReleasedEvent&)event); + // char + case EventType::SetChar: + return OnSetChar((SetCharEvent&)event); + + /* window */ + // termination + case EventType::WindowClosed: + return OnWindowClosed((WindowClosedEvent&)event); + // size/position + case EventType::WindowResized: + return OnWindowResized((WindowResizedEvent&)event); + case EventType::WindowMoved: + return OnWindowMoved((WindowMovedEvent&)event); + // focus + case EventType::WindowLostFocus: + return OnWindowLostFocus((WindowLostFocusEvent&)event); + case EventType::WindowGainFocus: + return OnWindowGainFocus((WindowGainFocusEvent&)event); } +} - bool Layer::OnEvent(const Event& event) - { - switch (event.GetEventType()) - { - /* mouse */ - // cursor - case EventType::MouseMoved: - return OnMouseMoved((MouseMovedEvent&)event); - // button - case EventType::ButtonPressed: - return OnButtonPressed((ButtonPressedEvent&)event); - case EventType::ButtonReleased: - return OnButtonReleased((ButtonReleasedEvent&)event); - // wheel - case EventType::WheelScrolled: - return OnWheelScrolled((WheelScrolledEvent&)event); - - /* keyboard */ - // key - case EventType::KeyPressed: - return OnKeyPressed((KeyPressedEvent&)event); - case EventType::KeyRepeated: - return OnKeyRepeat((KeyRepeatEvent&)event); - case EventType::KeyReleased: - return OnKeyReleased((KeyReleasedEvent&)event); - // char - case EventType::SetChar: - return OnSetChar((SetCharEvent&)event); - - /* window */ - // termination - case EventType::WindowClosed: - return OnWindowClosed((WindowClosedEvent&)event); - // size/position - case EventType::WindowResized: - return OnWindowResized((WindowResizedEvent&)event); - case EventType::WindowMoved: - return OnWindowMoved((WindowMovedEvent&)event); - // focus - case EventType::WindowLostFocus: - return OnWindowLostFocus((WindowLostFocusEvent&)event); - case EventType::WindowGainFocus: - return OnWindowGainFocus((WindowGainFocusEvent&)event); - } - } - -} \ No newline at end of file +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Layer/Layer.h b/Engine/src/Engine/Layer/Layer.h deleted file mode 100644 index 95c77bb..0000000 --- a/Engine/src/Engine/Layer/Layer.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class Event; - - // mouse - class MouseMovedEvent; - class ButtonPressedEvent; - class ButtonReleasedEvent; - class WheelScrolledEvent; - - // keyboard - // key - class KeyPressedEvent; - class KeyRepeatEvent; - class KeyReleasedEvent; - // char - class SetCharEvent; - - // window - class WindowClosedEvent; - class WindowResizedEvent; - class WindowMovedEvent; - class WindowLostFocusEvent; - class WindowGainFocusEvent; - - class Layer - { - protected: - std::string m_LayerName; - - public: - Layer(const std::string& name); - virtual ~Layer() = default; - - inline const std::string& GetName() const { return m_LayerName; } - - /* update */ - virtual void OnUpdate(float deltaTime) {} - virtual void OnUserInterfaceUpdate() {} - - virtual void OnRender() {} - - bool OnEvent(const Event& event); - - protected: - /* mouse */ - // cursor - virtual bool OnMouseMoved(const MouseMovedEvent& event) { return false; } - // button - virtual bool OnButtonPressed(const ButtonPressedEvent& event) { return false; } - virtual bool OnButtonReleased(const ButtonReleasedEvent& event) { return false; } - // wheel - virtual bool OnWheelScrolled(const WheelScrolledEvent& event) { return false; } - - /* keyboard */ - // key - virtual bool OnKeyPressed(const KeyPressedEvent& event) { return false; } - virtual bool OnKeyRepeat(const KeyRepeatEvent& event) { return false; } - virtual bool OnKeyReleased(const KeyReleasedEvent& event) { return false; } - // char - virtual bool OnSetChar(const SetCharEvent& event) { return false; } - - /* window */ - // termination - virtual bool OnWindowClosed(const WindowClosedEvent& event) { return false; } - // size/position - virtual bool OnWindowResized(const WindowResizedEvent& event) { return false; } - virtual bool OnWindowMoved(const WindowMovedEvent& event) { return false; } - // focus - virtual bool OnWindowLostFocus(const WindowLostFocusEvent& event) { return false; } - virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Layer/Layer.hpp b/Engine/src/Engine/Layer/Layer.hpp new file mode 100644 index 0000000..21e6fee --- /dev/null +++ b/Engine/src/Engine/Layer/Layer.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class Event; + +// mouse +class MouseMovedEvent; +class ButtonPressedEvent; +class ButtonReleasedEvent; +class WheelScrolledEvent; + +// keyboard +// key +class KeyPressedEvent; +class KeyRepeatEvent; +class KeyReleasedEvent; +// char +class SetCharEvent; + +// window +class WindowClosedEvent; +class WindowResizedEvent; +class WindowMovedEvent; +class WindowLostFocusEvent; +class WindowGainFocusEvent; + +class Layer +{ +protected: + std::string m_LayerName; + +public: + Layer(const std::string& name); + virtual ~Layer() = default; + + inline const std::string& GetName() const { return m_LayerName; } + + /* update */ + virtual void OnUpdate(float deltaTime) {} + virtual void OnUserInterfaceUpdate() {} + + virtual void OnRender() {} + + bool OnEvent(const Event& event); + +protected: + /* mouse */ + // cursor + virtual bool OnMouseMoved(const MouseMovedEvent& event) { return false; } + // button + virtual bool OnButtonPressed(const ButtonPressedEvent& event) { return false; } + virtual bool OnButtonReleased(const ButtonReleasedEvent& event) { return false; } + // wheel + virtual bool OnWheelScrolled(const WheelScrolledEvent& event) { return false; } + + /* keyboard */ + // key + virtual bool OnKeyPressed(const KeyPressedEvent& event) { return false; } + virtual bool OnKeyRepeat(const KeyRepeatEvent& event) { return false; } + virtual bool OnKeyReleased(const KeyReleasedEvent& event) { return false; } + // char + virtual bool OnSetChar(const SetCharEvent& event) { return false; } + + /* window */ + // termination + virtual bool OnWindowClosed(const WindowClosedEvent& event) { return false; } + // size/position + virtual bool OnWindowResized(const WindowResizedEvent& event) { return false; } + virtual bool OnWindowMoved(const WindowMovedEvent& event) { return false; } + // focus + virtual bool OnWindowLostFocus(const WindowLostFocusEvent& event) { return false; } + virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Layer/LayerStack.cpp b/Engine/src/Engine/Layer/LayerStack.cpp index 33655bd..23ae238 100644 --- a/Engine/src/Engine/Layer/LayerStack.cpp +++ b/Engine/src/Engine/Layer/LayerStack.cpp @@ -1,10 +1,10 @@ -#include "LayerStack.h" +#include "LayerStack.hpp" -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Events/WindowEvents.h" -#include "Layer.h" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Events/WindowEvents.hpp" +#include "Layer.hpp" namespace Light { diff --git a/Engine/src/Engine/Layer/LayerStack.h b/Engine/src/Engine/Layer/LayerStack.h deleted file mode 100644 index 5bb1699..0000000 --- a/Engine/src/Engine/Layer/LayerStack.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class Layer; - - class Event; - - class LayerStack /* singleton */ - { - private: - static LayerStack* s_Context; - - private: - - std::vector m_Layers; - - std::vector::iterator m_Begin; - std::vector::iterator m_End; - - public: - static Scope Create(); - - ~LayerStack(); - - // #todo: is this needed? - template - static inline void EmplaceLayer(Args&&... args) { s_Context->AttachLayerImpl(new T((args)...)); } - - static inline void AttachLayer(Layer* layer) { s_Context->AttachLayerImpl(layer); } - static inline void DetachLayer(Layer* layer) { s_Context->DetachLayerImpl(layer); } - - inline bool IsEmpty() { return m_Layers.empty(); } - - std::vector::iterator begin() { return m_Layers.begin(); } - std::vector::iterator end() { return m_Layers.end(); } - std::vector::reverse_iterator rbegin() { return m_Layers.rbegin(); } - std::vector::reverse_iterator rend() { return m_Layers.rend(); } - - private: - LayerStack(); - - void AttachLayerImpl(Layer* layer); - void DetachLayerImpl(Layer* layer); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Layer/LayerStack.hpp b/Engine/src/Engine/Layer/LayerStack.hpp new file mode 100644 index 0000000..535a98f --- /dev/null +++ b/Engine/src/Engine/Layer/LayerStack.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class Layer; + +class Event; + +class LayerStack /* singleton */ +{ +private: + static LayerStack* s_Context; + +private: + std::vector m_Layers; + + std::vector::iterator m_Begin; + std::vector::iterator m_End; + +public: + static Scope Create(); + + ~LayerStack(); + + // #todo: is this needed? + template + static inline void EmplaceLayer(Args&&... args) + { + s_Context->AttachLayerImpl(new T((args)...)); + } + + static inline void AttachLayer(Layer* layer) { s_Context->AttachLayerImpl(layer); } + static inline void DetachLayer(Layer* layer) { s_Context->DetachLayerImpl(layer); } + + inline bool IsEmpty() { return m_Layers.empty(); } + + std::vector::iterator begin() { return m_Layers.begin(); } + std::vector::iterator end() { return m_Layers.end(); } + std::vector::reverse_iterator rbegin() { return m_Layers.rbegin(); } + std::vector::reverse_iterator rend() { return m_Layers.rend(); } + +private: + LayerStack(); + + void AttachLayerImpl(Layer* layer); + void DetachLayerImpl(Layer* layer); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/LightEngine.h b/Engine/src/Engine/LightEngine.h deleted file mode 100644 index 48e1096..0000000 --- a/Engine/src/Engine/LightEngine.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -// core -#include "Core/Application.h" -#include "Core/Window.h" - -// camera -#include "Camera/Camera.h" - -// debug -#include "Debug/Logger.h" - -// events -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Events/WindowEvents.h" - -// graphics -#include "Graphics/Framebuffer.h" -#include "Graphics/GraphicsContext.h" -#include "Graphics/Renderer.h" -#include "Graphics/Texture.h" - -// input -#include "Input/Input.h" -#include "Input/KeyCodes.h" -#include "Input/MouseCodes.h" - -// layer -#include "Layer/Layer.h" -#include "Layer/LayerStack.h" - -// user interface -#include "UserInterface/UserInterface.h" - -// utility -#include "Utility/ResourceManager.h" - -// time -#include "Time/Timer.h" - -// base -#include "Base/Base.h" - -// third party -#include - -// math -#include "Math/Random.h" - -// scene -#include "Scene/Components.h" -#include "Scene/Entity.h" -#include "Scene/Scene.h" - -// entry point -#ifdef LIGHT_ENTRY_POINT - #include "Base/EntryPoint.h" -#endif diff --git a/Engine/src/Engine/LightEngine.hpp b/Engine/src/Engine/LightEngine.hpp new file mode 100644 index 0000000..e076a4d --- /dev/null +++ b/Engine/src/Engine/LightEngine.hpp @@ -0,0 +1,60 @@ +#pragma once + +// core +#include "Core/Application.hpp" +#include "Core/Window.hpp" + +// camera +#include "Camera/Camera.hpp" + +// debug +#include "Debug/Logger.hpp" + +// events +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Events/WindowEvents.hpp" + +// graphics +#include "Graphics/Framebuffer.hpp" +#include "Graphics/GraphicsContext.hpp" +#include "Graphics/Renderer.hpp" +#include "Graphics/Texture.hpp" + +// input +#include "Input/Input.hpp" +#include "Input/KeyCodes.hpp" +#include "Input/MouseCodes.hpp" + +// layer +#include "Layer/Layer.hpp" +#include "Layer/LayerStack.hpp" + +// user interface +#include "UserInterface/UserInterface.hpp" + +// utility +#include "Utility/ResourceManager.hpp" + +// time +#include "Time/Timer.hpp" + +// base +#include "Base/Base.hpp" + +// third party +#include + +// math +#include "Math/Random.hpp" + +// scene +#include "Scene/Components.hpp" +#include "Scene/Entity.hpp" +#include "Scene/Scene.hpp" + +// entry point +#ifdef LIGHT_ENTRY_POINT + #include "Base/EntryPoint.hpp" +#endif diff --git a/Engine/src/Engine/Math/Random.cpp b/Engine/src/Engine/Math/Random.cpp index 8b7ea5b..2159e10 100644 --- a/Engine/src/Engine/Math/Random.cpp +++ b/Engine/src/Engine/Math/Random.cpp @@ -1,40 +1,42 @@ -#include "Random.h" +#include "Random.hpp" #include -namespace Light { namespace Math { +namespace Light { +namespace Math { - float Rand(int min, int max, int decimals /* = 0 */) - { - const int dec = std::pow(10, decimals); - min *= dec; - max *= dec; +float Rand(int min, int max, int decimals /* = 0 */) +{ + const int dec = std::pow(10, decimals); + min *= dec; + max *= dec; - return (min + (rand() % (max)-min)) / (float)dec; - } + return (min + (rand() % (max)-min)) / (float)dec; +} - glm::vec2 RandVec2(int min, int max, int decimals /* = 0 */) - { - const int dec = std::pow(10, decimals); - min *= dec; - max *= dec; +glm::vec2 RandVec2(int min, int max, int decimals /* = 0 */) +{ + const int dec = std::pow(10, decimals); + min *= dec; + max *= dec; - float r1 = (min + (rand() % (max)-min)) / (float)dec; - float r2 = (min + (rand() % (max)-min)) / (float)dec; + float r1 = (min + (rand() % (max)-min)) / (float)dec; + float r2 = (min + (rand() % (max)-min)) / (float)dec; - return glm::vec2(r1, r2); - } + return glm::vec2(r1, r2); +} - glm::vec3 RandVec3(int min, int max, int decimals /* = 0 */) - { - const int dec = std::pow(10, decimals); - min *= dec; - max *= dec; +glm::vec3 RandVec3(int min, int max, int decimals /* = 0 */) +{ + const int dec = std::pow(10, decimals); + min *= dec; + max *= dec; - float r1 = (min + (rand() % (max - min))) / (float)dec; - float r2 = (min + (rand() % (max - min))) / (float)dec; - float r3 = (min + (rand() % (max - min))) / (float)dec; + float r1 = (min + (rand() % (max - min))) / (float)dec; + float r2 = (min + (rand() % (max - min))) / (float)dec; + float r3 = (min + (rand() % (max - min))) / (float)dec; - return glm::vec3(r1, r2, r3); - } -}} \ No newline at end of file + return glm::vec3(r1, r2, r3); +} +} // namespace Math +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Math/Random.h b/Engine/src/Engine/Math/Random.hpp similarity index 100% rename from Engine/src/Engine/Math/Random.h rename to Engine/src/Engine/Math/Random.hpp diff --git a/Engine/src/Engine/Scene/Components.h b/Engine/src/Engine/Scene/Components.h deleted file mode 100644 index 19bded3..0000000 --- a/Engine/src/Engine/Scene/Components.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Components/CameraComponent.h" -#include "Components/NativeScriptComponent.h" -#include "Components/SpriteRendererComponent.h" -#include "Components/TransformComponent.h" -#include "Components/TagComponent.h" \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components.hpp b/Engine/src/Engine/Scene/Components.hpp new file mode 100644 index 0000000..2bc3e05 --- /dev/null +++ b/Engine/src/Engine/Scene/Components.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Components/CameraComponent.hpp" +#include "Components/NativeScriptComponent.hpp" +#include "Components/SpriteRendererComponent.hpp" +#include "Components/TagComponent.hpp" +#include "Components/TransformComponent.hpp" \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/CameraComponent.h b/Engine/src/Engine/Scene/Components/CameraComponent.h deleted file mode 100644 index 5b57390..0000000 --- a/Engine/src/Engine/Scene/Components/CameraComponent.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Camera/SceneCamera.h" - -#include - -namespace Light { - - struct CameraComponent - { - SceneCamera camera; - bool isPrimary; - - CameraComponent() = default; - CameraComponent(const CameraComponent&) = default; - - CameraComponent(SceneCamera _camera, bool _isPrimary = false) - : camera(_camera), - isPrimary(_isPrimary) - { - } - - operator SceneCamera() { return camera; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/CameraComponent.hpp b/Engine/src/Engine/Scene/Components/CameraComponent.hpp new file mode 100644 index 0000000..369ff22 --- /dev/null +++ b/Engine/src/Engine/Scene/Components/CameraComponent.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Camera/SceneCamera.hpp" + +#include + +namespace Light { + +struct CameraComponent +{ + SceneCamera camera; + bool isPrimary; + + CameraComponent() = default; + CameraComponent(const CameraComponent&) = default; + + CameraComponent(SceneCamera _camera, bool _isPrimary = false) + : camera(_camera), isPrimary(_isPrimary) + { + } + + operator SceneCamera() { return camera; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/NativeScriptComponent.h b/Engine/src/Engine/Scene/Components/NativeScriptComponent.h deleted file mode 100644 index 982aa8f..0000000 --- a/Engine/src/Engine/Scene/Components/NativeScriptComponent.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "ScriptableEntity.h" - -namespace Light { - - struct NativeScriptComponent - { - NativeScript* instance; - - NativeScript* (*CreateInstance)(); - void (*DestroyInstance)(NativeScriptComponent*); - - template - void Bind() - { - CreateInstance = []() { return static_cast(new T()); }; - DestroyInstance = [](NativeScriptComponent* nsc) { delete (T*)(nsc->instance); nsc->instance = nullptr; }; - } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/NativeScriptComponent.hpp b/Engine/src/Engine/Scene/Components/NativeScriptComponent.hpp new file mode 100644 index 0000000..5bd2d0d --- /dev/null +++ b/Engine/src/Engine/Scene/Components/NativeScriptComponent.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "Base/Base.hpp" +#include "ScriptableEntity.hpp" + +namespace Light { + +struct NativeScriptComponent +{ + NativeScript* instance; + + NativeScript* (*CreateInstance)(); + void (*DestroyInstance)(NativeScriptComponent*); + + template + void Bind() + { + CreateInstance = []() { + return static_cast(new T()); + }; + DestroyInstance = [](NativeScriptComponent* nsc) { + delete (T*)(nsc->instance); + nsc->instance = nullptr; + }; + } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/ScriptableEntity.h b/Engine/src/Engine/Scene/Components/ScriptableEntity.h deleted file mode 100644 index 2ebf6a3..0000000 --- a/Engine/src/Engine/Scene/Components/ScriptableEntity.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "Scene/Entity.h" - -#include "Base/Base.h" - -namespace Light { - -class NativeScript { - friend class Scene; - -private: - Entity m_Entity; - unsigned int m_UniqueIdentifier = 0; // :#todo - -public: - NativeScript() = default; - virtual ~NativeScript() = default; - - inline unsigned int GetUID() const { return m_UniqueIdentifier; } - - template T &GetComponent() { return m_Entity.GetComponent(); } - -protected: - virtual void OnCreate() {} - virtual void OnDestroy() {} - virtual void OnUpdate(float ts) {} -}; - -} // namespace Light diff --git a/Engine/src/Engine/Scene/Components/ScriptableEntity.hpp b/Engine/src/Engine/Scene/Components/ScriptableEntity.hpp new file mode 100644 index 0000000..9c13e6d --- /dev/null +++ b/Engine/src/Engine/Scene/Components/ScriptableEntity.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Scene/Entity.hpp" + +namespace Light { + +class NativeScript +{ + friend class Scene; + +private: + Entity m_Entity; + unsigned int m_UniqueIdentifier = 0; // :#todo + +public: + NativeScript() = default; + virtual ~NativeScript() = default; + + inline unsigned int GetUID() const { return m_UniqueIdentifier; } + + template + T& GetComponent() + { + return m_Entity.GetComponent(); + } + +protected: + virtual void OnCreate() {} + virtual void OnDestroy() {} + virtual void OnUpdate(float ts) {} +}; + +} // namespace Light diff --git a/Engine/src/Engine/Scene/Components/SpriteRendererComponent.h b/Engine/src/Engine/Scene/Components/SpriteRendererComponent.h deleted file mode 100644 index a61a817..0000000 --- a/Engine/src/Engine/Scene/Components/SpriteRendererComponent.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class Texture; - - struct SpriteRendererComponent - { - Ref texture; - glm::vec4 tint; - - SpriteRendererComponent() = default; - SpriteRendererComponent(const SpriteRendererComponent&) = default; - - SpriteRendererComponent(Ref _texture, const glm::vec4& _tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) - : texture(_texture), - tint(_tint) - { - } - - operator Ref() { return texture; } - }; - -} diff --git a/Engine/src/Engine/Scene/Components/SpriteRendererComponent.hpp b/Engine/src/Engine/Scene/Components/SpriteRendererComponent.hpp new file mode 100644 index 0000000..fb084b3 --- /dev/null +++ b/Engine/src/Engine/Scene/Components/SpriteRendererComponent.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class Texture; + +struct SpriteRendererComponent +{ + Ref texture; + glm::vec4 tint; + + SpriteRendererComponent() = default; + SpriteRendererComponent(const SpriteRendererComponent&) = default; + + SpriteRendererComponent(Ref _texture, const glm::vec4& _tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) + : texture(_texture), tint(_tint) + { + } + + operator Ref() { return texture; } +}; + +} // namespace Light diff --git a/Engine/src/Engine/Scene/Components/TagComponent.h b/Engine/src/Engine/Scene/Components/TagComponent.h deleted file mode 100644 index 66c8319..0000000 --- a/Engine/src/Engine/Scene/Components/TagComponent.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - struct TagComponent - { - std::string tag = "Unnamed"; - - TagComponent() = default; - TagComponent(const TagComponent&) = default; - - TagComponent(const std::string& _tag) - : tag(_tag) - { - } - - operator std::string() { return tag; } - operator const std::string&() const { return tag; } - }; - -} - diff --git a/Engine/src/Engine/Scene/Components/TagComponent.hpp b/Engine/src/Engine/Scene/Components/TagComponent.hpp new file mode 100644 index 0000000..c9f502f --- /dev/null +++ b/Engine/src/Engine/Scene/Components/TagComponent.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +struct TagComponent +{ + std::string tag = "Unnamed"; + + TagComponent() = default; + TagComponent(const TagComponent&) = default; + + TagComponent(const std::string& _tag) + : tag(_tag) + { + } + + operator std::string() { return tag; } + operator const std::string&() const { return tag; } +}; + +} // namespace Light diff --git a/Engine/src/Engine/Scene/Components/TransformComponent.h b/Engine/src/Engine/Scene/Components/TransformComponent.h deleted file mode 100644 index b9aeb94..0000000 --- a/Engine/src/Engine/Scene/Components/TransformComponent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include -#include -#include - -namespace Light { - - struct TransformComponent - { - glm::vec3 translation; - glm::vec3 scale; - glm::vec3 rotation; - - TransformComponent(const TransformComponent&) = default; - - TransformComponent(const glm::vec3& _translation = glm::vec3(0.0f, 0.0f, 0.0f), - const glm::vec3& _scale = glm::vec3(1.0f, 1.0f, 1.0f), - const glm::vec3& _rotation = glm::vec3(0.0f, 0.0f, 0.0f)) - - : translation(_translation), - scale(_scale), - rotation(_rotation) - { - } - - inline glm::mat4 GetTransform() const { return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(scale); } - - operator const glm::mat4() const { return GetTransform(); } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/TransformComponent.hpp b/Engine/src/Engine/Scene/Components/TransformComponent.hpp new file mode 100644 index 0000000..3df213a --- /dev/null +++ b/Engine/src/Engine/Scene/Components/TransformComponent.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "Base/Base.hpp" + +#include +#include +#include + +namespace Light { + +struct TransformComponent +{ + glm::vec3 translation; + glm::vec3 scale; + glm::vec3 rotation; + + TransformComponent(const TransformComponent&) = default; + + TransformComponent(const glm::vec3& _translation = glm::vec3(0.0f, 0.0f, 0.0f), + const glm::vec3& _scale = glm::vec3(1.0f, 1.0f, 1.0f), + const glm::vec3& _rotation = glm::vec3(0.0f, 0.0f, 0.0f)) + + : translation(_translation), scale(_scale), rotation(_rotation) + { + } + + inline glm::mat4 GetTransform() const { return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(scale); } + + operator const glm::mat4() const { return GetTransform(); } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/UUIDComponent.h b/Engine/src/Engine/Scene/Components/UUIDComponent.h deleted file mode 100644 index b147671..0000000 --- a/Engine/src/Engine/Scene/Components/UUIDComponent.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Core/UUID.h" - -namespace Light { - - struct UUIDComponent - { - UUID uuid; - - UUIDComponent(UUID _uuid): uuid(_uuid) {} - UUIDComponent(const UUIDComponent&) = default; - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Components/UUIDComponent.hpp b/Engine/src/Engine/Scene/Components/UUIDComponent.hpp new file mode 100644 index 0000000..203c8da --- /dev/null +++ b/Engine/src/Engine/Scene/Components/UUIDComponent.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Core/UUID.hpp" + +namespace Light { + +struct UUIDComponent +{ + UUID uuid; + + UUIDComponent(UUID _uuid) + : uuid(_uuid) {} + UUIDComponent(const UUIDComponent&) = default; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Entity.cpp b/Engine/src/Engine/Scene/Entity.cpp index d77e9ca..22ad370 100644 --- a/Engine/src/Engine/Scene/Entity.cpp +++ b/Engine/src/Engine/Scene/Entity.cpp @@ -1,16 +1,16 @@ -#include "Entity.h" +#include "Entity.hpp" -#include "Scene.h" +#include "Scene.hpp" namespace Light { - Entity::Entity(entt::entity handle, Scene* scene) - : m_Handle(handle), m_Scene(scene) - { - } +Entity::Entity(entt::entity handle, Scene* scene) + : m_Handle(handle), m_Scene(scene) +{ +} - Entity::~Entity() - { - } +Entity::~Entity() +{ +} -} \ No newline at end of file +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Entity.h b/Engine/src/Engine/Scene/Entity.h deleted file mode 100644 index b6b3661..0000000 --- a/Engine/src/Engine/Scene/Entity.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Scene.h" - -#include "Components/UUIDComponent.h" - -#include - -namespace Light { - - class Entity - { - private: - entt::entity m_Handle; - Scene* m_Scene; - - public: - Entity(entt::entity handle = entt::null, Scene* registry = nullptr); - ~Entity(); - - template - inline T& AddComponent(Args&&... args) - { - return m_Scene->m_Registry.emplace(m_Handle, std::forward(args)...); - } - - template - inline T& GetComponent() - { - return m_Scene->m_Registry.get(m_Handle); - } - - template - inline bool HasComponent() - { - return m_Scene->m_Registry.any_of(m_Handle); - } - - template - inline void RemoveComponent() - { - m_Scene->m_Registry.remove(m_Handle); - } - - inline uint64_t GetUUID() { return GetComponent().uuid; } - - inline bool IsValid() const { return m_Handle != entt::null && m_Scene != nullptr; } - - operator uint32_t() { return (uint32_t)m_Handle; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Entity.hpp b/Engine/src/Engine/Scene/Entity.hpp new file mode 100644 index 0000000..e4892ca --- /dev/null +++ b/Engine/src/Engine/Scene/Entity.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Components/UUIDComponent.hpp" +#include "Scene.hpp" + +#include + +namespace Light { + +class Entity +{ +private: + entt::entity m_Handle; + Scene* m_Scene; + +public: + Entity(entt::entity handle = entt::null, Scene* registry = nullptr); + ~Entity(); + + template + inline T& AddComponent(Args&&... args) + { + return m_Scene->m_Registry.emplace(m_Handle, std::forward(args)...); + } + + template + inline T& GetComponent() + { + return m_Scene->m_Registry.get(m_Handle); + } + + template + inline bool HasComponent() + { + return m_Scene->m_Registry.any_of(m_Handle); + } + + template + inline void RemoveComponent() + { + m_Scene->m_Registry.remove(m_Handle); + } + + inline uint64_t GetUUID() { return GetComponent().uuid; } + + inline bool IsValid() const { return m_Handle != entt::null && m_Scene != nullptr; } + + operator uint32_t() { return (uint32_t)m_Handle; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Scene.cpp b/Engine/src/Engine/Scene/Scene.cpp index 1f03133..5d0ca2f 100644 --- a/Engine/src/Engine/Scene/Scene.cpp +++ b/Engine/src/Engine/Scene/Scene.cpp @@ -1,8 +1,8 @@ -#include "Scene.h" +#include "Scene.hpp" -#include "Components.h" -#include "Entity.h" -#include "Graphics/Renderer.h" +#include "Components.hpp" +#include "Entity.hpp" +#include "Graphics/Renderer.hpp" #include diff --git a/Engine/src/Engine/Scene/Scene.h b/Engine/src/Engine/Scene/Scene.h deleted file mode 100644 index c738ccc..0000000 --- a/Engine/src/Engine/Scene/Scene.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Core/UUID.h" - -#include "Components/TransformComponent.h" - -#include - -#include - -namespace Light { - - class Entity; - - class Framebuffer; - - class Scene - { - private: - friend class Entity; - friend class SceneSerializer; - friend class SceneHierarchyPanel; - - private: - entt::registry m_Registry; - - public: - Scene(); - ~Scene(); - - void OnCreate(); - - void OnUpdate(float deltaTime); - void OnRender(const Ref& targetFrameBuffer = nullptr); - - Entity CreateEntity(const std::string& name, const TransformComponent& transform = TransformComponent()); - - Entity GetEntityByTag(const std::string& tag); - - private: - Entity CreateEntityWithUUID(const std::string& name, UUID uuid, const TransformComponent& transform = TransformComponent()); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Scene/Scene.hpp b/Engine/src/Engine/Scene/Scene.hpp new file mode 100644 index 0000000..84dfd1c --- /dev/null +++ b/Engine/src/Engine/Scene/Scene.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Components/TransformComponent.hpp" +#include "Core/UUID.hpp" + +#include +#include + +namespace Light { + +class Entity; + +class Framebuffer; + +class Scene +{ +private: + friend class Entity; + friend class SceneSerializer; + friend class SceneHierarchyPanel; + +private: + entt::registry m_Registry; + +public: + Scene(); + ~Scene(); + + void OnCreate(); + + void OnUpdate(float deltaTime); + void OnRender(const Ref& targetFrameBuffer = nullptr); + + Entity CreateEntity(const std::string& name, const TransformComponent& transform = TransformComponent()); + + Entity GetEntityByTag(const std::string& tag); + +private: + Entity CreateEntityWithUUID(const std::string& name, UUID uuid, const TransformComponent& transform = TransformComponent()); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Time/Timer.cpp b/Engine/src/Engine/Time/Timer.cpp index 7cc4742..e4f1fa8 100644 --- a/Engine/src/Engine/Time/Timer.cpp +++ b/Engine/src/Engine/Time/Timer.cpp @@ -1,23 +1,22 @@ -#include "Timer.h" +#include "Timer.hpp" namespace Light { - Timer::Timer() - : m_Start(std::chrono::steady_clock::now()) - { - } +Timer::Timer() + : m_Start(std::chrono::steady_clock::now()) +{ +} - DeltaTimer::DeltaTimer() - : m_PreviousFrame(NULL), - m_DeltaTime(60.0f / 1000.0f) - { - } +DeltaTimer::DeltaTimer() + : m_PreviousFrame(NULL), m_DeltaTime(60.0f / 1000.0f) +{ +} - void DeltaTimer::Update() - { - float currentFrame = timer.GetElapsedTime(); - m_DeltaTime = currentFrame - m_PreviousFrame; - m_PreviousFrame = currentFrame; - } +void DeltaTimer::Update() +{ + float currentFrame = timer.GetElapsedTime(); + m_DeltaTime = currentFrame - m_PreviousFrame; + m_PreviousFrame = currentFrame; +} -} \ No newline at end of file +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Time/Timer.h b/Engine/src/Engine/Time/Timer.h deleted file mode 100644 index 3e034b0..0000000 --- a/Engine/src/Engine/Time/Timer.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class Timer - { - private: - std::chrono::time_point m_Start; - - public: - Timer(); - - inline float GetElapsedTime() const { return (std::chrono::duration_cast(std::chrono::steady_clock::now() - m_Start).count()) / 1000.; } - - inline void Reset() { m_Start = std::chrono::steady_clock::now(); } - }; - - class DeltaTimer - { - private: - Timer timer; - - float m_PreviousFrame; - float m_DeltaTime; - - public: - DeltaTimer(); - - void Update(); - - inline float GetDeltaTime() const { return m_DeltaTime; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Time/Timer.hpp b/Engine/src/Engine/Time/Timer.hpp new file mode 100644 index 0000000..d056586 --- /dev/null +++ b/Engine/src/Engine/Time/Timer.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class Timer +{ +private: + std::chrono::time_point m_Start; + +public: + Timer(); + + inline float GetElapsedTime() const { return (std::chrono::duration_cast(std::chrono::steady_clock::now() - m_Start).count()) / 1000.; } + + inline void Reset() { m_Start = std::chrono::steady_clock::now(); } +}; + +class DeltaTimer +{ +private: + Timer timer; + + float m_PreviousFrame; + float m_DeltaTime; + +public: + DeltaTimer(); + + void Update(); + + inline float GetDeltaTime() const { return m_DeltaTime; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/UserInterface/UserInterface.cpp b/Engine/src/Engine/UserInterface/UserInterface.cpp index 36d7968..e5f5121 100644 --- a/Engine/src/Engine/UserInterface/UserInterface.cpp +++ b/Engine/src/Engine/UserInterface/UserInterface.cpp @@ -1,18 +1,18 @@ -#include "UserInterface.h" +#include "UserInterface.hpp" -#include "OpenGL/glUserInterface.h" +#include "OpenGL/glUserInterface.hpp" #ifdef LIGHT_PLATFORM_WINDOWS - #include "DirectX/dxUserInterface.h" - #include "DirectX/dxSharedContext.h" + #include "DirectX/dxUserInterface.hpp" + #include "DirectX/dxSharedContext.hpp" #endif -#include "Events/CharEvent.h" -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Graphics/GraphicsContext.h" -#include "Input/KeyCodes.h" +#include "Events/CharEvent.hpp" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Graphics/GraphicsContext.hpp" +#include "Input/KeyCodes.hpp" #include diff --git a/Engine/src/Engine/UserInterface/UserInterface.h b/Engine/src/Engine/UserInterface/UserInterface.h deleted file mode 100644 index 5958aa3..0000000 --- a/Engine/src/Engine/UserInterface/UserInterface.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -struct GLFWwindow; - -namespace Light { - - class Event; - - class SharedContext; - - // #todo: fix the UserIntreface mess!! - class UserInterface /* singleton */ - { - private: - static UserInterface* s_Context; - - private: - - ImGuiWindowFlags m_DockspaceFlags; - - public: - static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); - - UserInterface(const UserInterface&) = delete; - UserInterface& operator=(const UserInterface&) = delete; - - virtual ~UserInterface() = default; - - void Init(GLFWwindow* windowHandle, Ref sharedContext); - - static void DockspaceBegin(); - static void DockspaceEnd(); - - virtual void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) = 0; - - virtual void Begin() = 0; - virtual void End() = 0; - - virtual void LogDebugData() = 0; - - protected: - UserInterface(); - - private: - void SetDarkThemeColors(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/UserInterface/UserInterface.hpp b/Engine/src/Engine/UserInterface/UserInterface.hpp new file mode 100644 index 0000000..2d50474 --- /dev/null +++ b/Engine/src/Engine/UserInterface/UserInterface.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +struct GLFWwindow; + +namespace Light { + +class Event; + +class SharedContext; + +// #todo: fix the UserIntreface mess!! +class UserInterface /* singleton */ +{ +private: + static UserInterface* s_Context; + +private: + ImGuiWindowFlags m_DockspaceFlags; + +public: + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); + + UserInterface(const UserInterface&) = delete; + UserInterface& operator=(const UserInterface&) = delete; + + virtual ~UserInterface() = default; + + void Init(GLFWwindow* windowHandle, Ref sharedContext); + + static void DockspaceBegin(); + static void DockspaceEnd(); + + virtual void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) = 0; + + virtual void Begin() = 0; + virtual void End() = 0; + + virtual void LogDebugData() = 0; + +protected: + UserInterface(); + +private: + void SetDarkThemeColors(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Utility/FileManager.cpp b/Engine/src/Engine/Utility/FileManager.cpp index 7bd6f8d..ae573e1 100644 --- a/Engine/src/Engine/Utility/FileManager.cpp +++ b/Engine/src/Engine/Utility/FileManager.cpp @@ -1,4 +1,4 @@ -#include "FileManager.h" +#include "FileManager.hpp" #include diff --git a/Engine/src/Engine/Utility/FileManager.h b/Engine/src/Engine/Utility/FileManager.h deleted file mode 100644 index 4567c82..0000000 --- a/Engine/src/Engine/Utility/FileManager.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include - -namespace Light { - - class BasicFileHandle - { - public: - BasicFileHandle(uint8_t* data = nullptr, uint32_t size = 0ull, const std::string& path = "", const std::string& name = "", const std::string& extension = "") : - m_Data(data), - m_Size(size), - m_Path(path), - m_Name(name), - m_Extension(extension) - { - } - - virtual void Release() - { - delete m_Data; - m_Data = nullptr; - m_Size = 0ull; - } - - // getters - inline uint8_t* GetData() { return m_Data; } - inline uint32_t GetSize() { return m_Size; } - - inline const std::string& GetPath() { return m_Path; } - inline const std::string& GetName() { return m_Name; } - inline const std::string& GetExtension() { return m_Extension; } - - inline const std::string& GetNameWithExtension() { return m_Name + '.' + m_Extension; } - - inline bool IsValid() const { return !!m_Data; } - - // operators - inline operator bool() const { return IsValid(); } - - protected: - // made protected for custom Free(): - uint8_t* m_Data; - uint32_t m_Size; - - private: - const std::string m_Path, m_Name, m_Extension; - }; - - class ImageFileHandle : public BasicFileHandle - { - public: - ImageFileHandle(uint8_t* data, uint32_t size, const std::string& path, const std::string& name, const std::string& extension, - uint32_t width, uint32_t height, uint32_t components, uint32_t desiredComponents): - BasicFileHandle(data, size, path, name, extension), - m_Width(width), m_Height(height), m_Components(components), m_DesiredComponents(desiredComponents) - { - } - - void Release() override - { - stbi_image_free(reinterpret_cast(m_Data)); - m_Data = nullptr; - m_Size = 0ull; - } - - // getters - inline uint32_t GetWidth() const { return m_Width; } - inline uint32_t GetHeight() const { return m_Height; } - inline uint32_t GetComponents() const { return m_Components; } - inline uint32_t GetDesiredComponents() const { return m_DesiredComponents; } - - private: - uint32_t m_Width, m_Height, m_Components, m_DesiredComponents; - }; - - class FileManager - { - public: - static BasicFileHandle ReadTextFile(const std::string& path); - static ImageFileHandle ReadImageFile(const std::string& path, int32_t desiredComponents); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Utility/FileManager.hpp b/Engine/src/Engine/Utility/FileManager.hpp new file mode 100644 index 0000000..61b8cca --- /dev/null +++ b/Engine/src/Engine/Utility/FileManager.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include "Base/Base.hpp" + +#include + +namespace Light { + +class BasicFileHandle +{ +public: + BasicFileHandle(uint8_t* data = nullptr, uint32_t size = 0ull, const std::string& path = "", const std::string& name = "", const std::string& extension = "") + : m_Data(data), m_Size(size), m_Path(path), m_Name(name), m_Extension(extension) + { + } + + virtual void Release() + { + delete m_Data; + m_Data = nullptr; + m_Size = 0ull; + } + + // getters + inline uint8_t* GetData() { return m_Data; } + inline uint32_t GetSize() { return m_Size; } + + inline const std::string& GetPath() { return m_Path; } + inline const std::string& GetName() { return m_Name; } + inline const std::string& GetExtension() { return m_Extension; } + + inline const std::string& GetNameWithExtension() { return m_Name + '.' + m_Extension; } + + inline bool IsValid() const { return !!m_Data; } + + // operators + inline operator bool() const { return IsValid(); } + +protected: + // made protected for custom Free(): + uint8_t* m_Data; + uint32_t m_Size; + +private: + const std::string m_Path, m_Name, m_Extension; +}; + +class ImageFileHandle: public BasicFileHandle +{ +public: + ImageFileHandle(uint8_t* data, uint32_t size, const std::string& path, const std::string& name, const std::string& extension, + uint32_t width, uint32_t height, uint32_t components, uint32_t desiredComponents) + : BasicFileHandle(data, size, path, name, extension), m_Width(width), m_Height(height), m_Components(components), m_DesiredComponents(desiredComponents) + { + } + + void Release() override + { + stbi_image_free(reinterpret_cast(m_Data)); + m_Data = nullptr; + m_Size = 0ull; + } + + // getters + inline uint32_t GetWidth() const { return m_Width; } + inline uint32_t GetHeight() const { return m_Height; } + inline uint32_t GetComponents() const { return m_Components; } + inline uint32_t GetDesiredComponents() const { return m_DesiredComponents; } + +private: + uint32_t m_Width, m_Height, m_Components, m_DesiredComponents; +}; + +class FileManager +{ +public: + static BasicFileHandle ReadTextFile(const std::string& path); + static ImageFileHandle ReadImageFile(const std::string& path, int32_t desiredComponents); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Utility/ResourceManager.cpp b/Engine/src/Engine/Utility/ResourceManager.cpp index 5e8bbe8..64ae833 100644 --- a/Engine/src/Engine/Utility/ResourceManager.cpp +++ b/Engine/src/Engine/Utility/ResourceManager.cpp @@ -1,9 +1,9 @@ -#include "ResourceManager.h" +#include "ResourceManager.hpp" -#include "FileManager.h" -#include "Graphics/GraphicsContext.h" -#include "Graphics/Shader.h" -#include "Graphics/Texture.h" +#include "FileManager.hpp" +#include "Graphics/GraphicsContext.hpp" +#include "Graphics/Shader.hpp" +#include "Graphics/Texture.hpp" namespace Light { diff --git a/Engine/src/Engine/Utility/ResourceManager.h b/Engine/src/Engine/Utility/ResourceManager.h deleted file mode 100644 index 0f124b8..0000000 --- a/Engine/src/Engine/Utility/ResourceManager.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -namespace Light { - - class Shader; - class Texture; - - class SharedContext; - - class ResourceManager /* singleton */ - { - private: - static ResourceManager* s_Context; - - private: - std::unordered_map> m_Shaders; - std::unordered_map> m_Textures; - - public: - static Scope Create(); - - // #todo: add geometry shader support - static inline void LoadShader(const std::string& name, const std::string& vertexPath, const std::string& pixelPath) { s_Context->LoadShaderImpl(name, vertexPath, pixelPath); } - - static inline void LoadTexture(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u) { s_Context->LoadTextureImpl(name, path, desiredComponents); } - - static inline void ReleaseTexture(const std::string& name) { s_Context->ReleaseTextureImpl(name); } - - static inline Ref GetShader(const std::string& name) { return s_Context->m_Shaders[name]; } - static inline Ref GetTexture(const std::string& name) { return s_Context->m_Textures[name]; } - - private: - ResourceManager(); - - void LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath); - - void LoadTextureImpl(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u); - - void ReleaseTextureImpl(const std::string& name); - }; - -} \ No newline at end of file diff --git a/Engine/src/Engine/Utility/ResourceManager.hpp b/Engine/src/Engine/Utility/ResourceManager.hpp new file mode 100644 index 0000000..ed2bf34 --- /dev/null +++ b/Engine/src/Engine/Utility/ResourceManager.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include "Base/Base.hpp" + +namespace Light { + +class Shader; +class Texture; + +class SharedContext; + +class ResourceManager /* singleton */ +{ +private: + static ResourceManager* s_Context; + +private: + std::unordered_map> m_Shaders; + std::unordered_map> m_Textures; + +public: + static Scope Create(); + + // #todo: add geometry shader support + static inline void LoadShader(const std::string& name, const std::string& vertexPath, const std::string& pixelPath) { s_Context->LoadShaderImpl(name, vertexPath, pixelPath); } + + static inline void LoadTexture(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u) { s_Context->LoadTextureImpl(name, path, desiredComponents); } + + static inline void ReleaseTexture(const std::string& name) { s_Context->ReleaseTextureImpl(name); } + + static inline Ref GetShader(const std::string& name) { return s_Context->m_Shaders[name]; } + static inline Ref GetTexture(const std::string& name) { return s_Context->m_Textures[name]; } + +private: + ResourceManager(); + + void LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath); + + void LoadTextureImpl(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u); + + void ReleaseTextureImpl(const std::string& name); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Serializer.cpp b/Engine/src/Engine/Utility/Serializer.cpp index bbf3f79..1610bc4 100644 --- a/Engine/src/Engine/Utility/Serializer.cpp +++ b/Engine/src/Engine/Utility/Serializer.cpp @@ -1,8 +1,8 @@ -#include "Serializer.h" +#include "Serializer.hpp" -#include "Graphics/Texture.h" -#include "Scene/Components.h" -#include "Utility/ResourceManager.h" +#include "Graphics/Texture.hpp" +#include "Scene/Components.hpp" +#include "Utility/ResourceManager.hpp" namespace YAML { diff --git a/Engine/src/Engine/Utility/Serializer.h b/Engine/src/Engine/Utility/Serializer.h deleted file mode 100644 index f990a8e..0000000 --- a/Engine/src/Engine/Utility/Serializer.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "Base/Base.h" - -#include "Scene/Scene.h" -#include "Scene/Entity.h" - -#include - -namespace Light { - - class SceneSerializer - { - public: - SceneSerializer(const Ref& scene); - - void Serialize(const std::string& filePath); - bool Deserialize(const std::string& filePath); - - void SerializeBinary(const std::string& filePath); - bool DeserializeBinary(const std::string& filePath); - private: - void SerializeEntity(YAML::Emitter& out, Entity entity); - - private: - Ref m_Scene; - }; - - -} \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Serializer.hpp b/Engine/src/Engine/Utility/Serializer.hpp new file mode 100644 index 0000000..906aa30 --- /dev/null +++ b/Engine/src/Engine/Utility/Serializer.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Scene/Entity.hpp" +#include "Scene/Scene.hpp" + +#include + +namespace Light { + +class SceneSerializer +{ +public: + SceneSerializer(const Ref& scene); + + void Serialize(const std::string& filePath); + bool Deserialize(const std::string& filePath); + + void SerializeBinary(const std::string& filePath); + bool DeserializeBinary(const std::string& filePath); + +private: + void SerializeEntity(YAML::Emitter& out, Entity entity); + +private: + Ref m_Scene; +}; + + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Stringifier.cpp b/Engine/src/Engine/Utility/Stringifier.cpp index fdebece..5610f10 100644 --- a/Engine/src/Engine/Utility/Stringifier.cpp +++ b/Engine/src/Engine/Utility/Stringifier.cpp @@ -1,88 +1,87 @@ -#include "Stringifier.h" +#include "Stringifier.hpp" -#include "Graphics/GraphicsContext.h" +#include "Graphics/GraphicsContext.hpp" #include - #include namespace Light { - //============================== OPENGL ==============================// - std::string Stringifier::glDebugMsgSeverity(unsigned int severity) +//============================== OPENGL ==============================// +std::string Stringifier::glDebugMsgSeverity(unsigned int severity) +{ + switch (severity) { - switch (severity) - { - case GL_DEBUG_SEVERITY_NOTIFICATION: return "GL_DEBUG_SEVERITY_NOTIFICATION"; - case GL_DEBUG_SEVERITY_LOW: return "GL_DEBUG_SEVERITY_LOW"; - case GL_DEBUG_SEVERITY_MEDIUM: return "GL_DEBUG_SEVERITY_MEDIUM"; - case GL_DEBUG_SEVERITY_HIGH: return "GL_DEBUG_SEVERITY_HIGH"; - default: return "UNKNOWN"; - } + case GL_DEBUG_SEVERITY_NOTIFICATION: return "GL_DEBUG_SEVERITY_NOTIFICATION"; + case GL_DEBUG_SEVERITY_LOW: return "GL_DEBUG_SEVERITY_LOW"; + case GL_DEBUG_SEVERITY_MEDIUM: return "GL_DEBUG_SEVERITY_MEDIUM"; + case GL_DEBUG_SEVERITY_HIGH: return "GL_DEBUG_SEVERITY_HIGH"; + default: return "UNKNOWN"; } +} - std::string Stringifier::glDebugMsgSource(unsigned int source) +std::string Stringifier::glDebugMsgSource(unsigned int source) +{ + switch (source) { - switch (source) - { - case GL_DEBUG_SOURCE_API: return "GL_DEBUG_SOURCE_API"; - case GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "GL_DEBUG_SOURCE_WINDOW_SYSTEM"; - case GL_DEBUG_SOURCE_SHADER_COMPILER: return "GL_DEBUG_SOURCE_SHADER_COMPILER"; - case GL_DEBUG_SOURCE_THIRD_PARTY: return "GL_DEBUG_SOURCE_THIRD_PARTY"; - case GL_DEBUG_SOURCE_APPLICATION: return "GL_DEBUG_SOURCE_APPLICATION"; - case GL_DEBUG_SOURCE_OTHER: return "GL_DEBUG_SOURCE_OTHER"; - default: return "UNKNOWN"; - } + case GL_DEBUG_SOURCE_API: return "GL_DEBUG_SOURCE_API"; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "GL_DEBUG_SOURCE_WINDOW_SYSTEM"; + case GL_DEBUG_SOURCE_SHADER_COMPILER: return "GL_DEBUG_SOURCE_SHADER_COMPILER"; + case GL_DEBUG_SOURCE_THIRD_PARTY: return "GL_DEBUG_SOURCE_THIRD_PARTY"; + case GL_DEBUG_SOURCE_APPLICATION: return "GL_DEBUG_SOURCE_APPLICATION"; + case GL_DEBUG_SOURCE_OTHER: return "GL_DEBUG_SOURCE_OTHER"; + default: return "UNKNOWN"; } +} - std::string Stringifier::glDebugMsgType(unsigned int type) +std::string Stringifier::glDebugMsgType(unsigned int type) +{ + switch (type) { - switch (type) - { - case GL_DEBUG_TYPE_ERROR: return "GL_DEBUG_TYPE_ERROR"; - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"; - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"; - case GL_DEBUG_TYPE_PORTABILITY: return "GL_DEBUG_TYPE_PORTABILITY"; - case GL_DEBUG_TYPE_PERFORMANCE: return "GL_DEBUG_TYPE_PERFORMANCE"; - case GL_DEBUG_TYPE_MARKER: return "GL_DEBUG_TYPE_MARKER"; - case GL_DEBUG_TYPE_PUSH_GROUP: return "GL_DEBUG_TYPE_PUSH_GROUP"; - case GL_DEBUG_TYPE_POP_GROUP: return "GL_DEBUG_TYPE_POP_GROUP"; - case GL_DEBUG_TYPE_OTHER: return "GL_DEBUG_TYPE_OTHER"; - default: return "UNKNOWN"; - } + case GL_DEBUG_TYPE_ERROR: return "GL_DEBUG_TYPE_ERROR"; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"; + case GL_DEBUG_TYPE_PORTABILITY: return "GL_DEBUG_TYPE_PORTABILITY"; + case GL_DEBUG_TYPE_PERFORMANCE: return "GL_DEBUG_TYPE_PERFORMANCE"; + case GL_DEBUG_TYPE_MARKER: return "GL_DEBUG_TYPE_MARKER"; + case GL_DEBUG_TYPE_PUSH_GROUP: return "GL_DEBUG_TYPE_PUSH_GROUP"; + case GL_DEBUG_TYPE_POP_GROUP: return "GL_DEBUG_TYPE_POP_GROUP"; + case GL_DEBUG_TYPE_OTHER: return "GL_DEBUG_TYPE_OTHER"; + default: return "UNKNOWN"; } - //============================== OPENGL ==============================// +} +//============================== OPENGL ==============================// - //==================== SPDLOG ====================// - std::string Stringifier::spdlogLevel(unsigned int level) +//==================== SPDLOG ====================// +std::string Stringifier::spdlogLevel(unsigned int level) +{ + switch (level) { - switch (level) - { - case SPDLOG_LEVEL_TRACE: return "SPDLOG_LEVEL_TRACE"; - case SPDLOG_LEVEL_DEBUG: return "SPDLOG_LEVEL_DEBUG"; - case SPDLOG_LEVEL_INFO: return "SPDLOG_LEVEL_INFO"; - case SPDLOG_LEVEL_WARN: return "SPDLOG_LEVEL_WARN"; - case SPDLOG_LEVEL_ERROR: return "SPDLOG_LEVEL_ERROR"; - case SPDLOG_LEVEL_CRITICAL: return "SPDLOG_LEVEL_CRITICAL"; - case SPDLOG_LEVEL_OFF: return "SPDLOG_LEVEL_OFF"; - default: return "UNKNOWN"; - } + case SPDLOG_LEVEL_TRACE: return "SPDLOG_LEVEL_TRACE"; + case SPDLOG_LEVEL_DEBUG: return "SPDLOG_LEVEL_DEBUG"; + case SPDLOG_LEVEL_INFO: return "SPDLOG_LEVEL_INFO"; + case SPDLOG_LEVEL_WARN: return "SPDLOG_LEVEL_WARN"; + case SPDLOG_LEVEL_ERROR: return "SPDLOG_LEVEL_ERROR"; + case SPDLOG_LEVEL_CRITICAL: return "SPDLOG_LEVEL_CRITICAL"; + case SPDLOG_LEVEL_OFF: return "SPDLOG_LEVEL_OFF"; + default: return "UNKNOWN"; } - //==================== SPDLOG ====================// +} +//==================== SPDLOG ====================// - //==================== GRAPHICS_API ====================// - std::string Stringifier::GraphicsAPIToString(GraphicsAPI api) +//==================== GRAPHICS_API ====================// +std::string Stringifier::GraphicsAPIToString(GraphicsAPI api) +{ + switch (api) { - switch (api) - { - case Light::GraphicsAPI::Default: return "Default"; - case Light::GraphicsAPI::OpenGL: return "OpenGL"; - case Light::GraphicsAPI::DirectX: return "DirectX"; - case Light::GraphicsAPI::Vulkan: return "Vulkan"; - case Light::GraphicsAPI::Metal: return "Metal"; - default: return "UNKNOWN"; - } + case Light::GraphicsAPI::Default: return "Default"; + case Light::GraphicsAPI::OpenGL: return "OpenGL"; + case Light::GraphicsAPI::DirectX: return "DirectX"; + case Light::GraphicsAPI::Vulkan: return "Vulkan"; + case Light::GraphicsAPI::Metal: return "Metal"; + default: return "UNKNOWN"; } - //==================== GRAPHICS_API ====================// +} +//==================== GRAPHICS_API ====================// -} \ No newline at end of file +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Stringifier.h b/Engine/src/Engine/Utility/Stringifier.h deleted file mode 100644 index fa74c18..0000000 --- a/Engine/src/Engine/Utility/Stringifier.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#ifndef LIGHT_STRINGIFIER_H -#define LIGHT_STRINGIFIER_H - -#include "Base/Base.h" - -namespace Light { - - enum class GraphicsAPI; - - class Stringifier - { - public: - static std::string glDebugMsgSeverity(unsigned int severity); - static std::string glDebugMsgSource(unsigned int source); - static std::string glDebugMsgType(unsigned int type); - - static std::string spdlogLevel(unsigned int level); - - static std::string GraphicsAPIToString(GraphicsAPI api); - }; - -} - -#endif \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Stringifier.hpp b/Engine/src/Engine/Utility/Stringifier.hpp new file mode 100644 index 0000000..cef6585 --- /dev/null +++ b/Engine/src/Engine/Utility/Stringifier.hpp @@ -0,0 +1,25 @@ +#pragma once +#ifndef LIGHT_STRINGIFIER_H + #define LIGHT_STRINGIFIER_H + + #include "Base/Base.hpp" + +namespace Light { + +enum class GraphicsAPI; + +class Stringifier +{ +public: + static std::string glDebugMsgSeverity(unsigned int severity); + static std::string glDebugMsgSource(unsigned int source); + static std::string glDebugMsgType(unsigned int type); + + static std::string spdlogLevel(unsigned int level); + + static std::string GraphicsAPIToString(GraphicsAPI api); +}; + +} // namespace Light + +#endif \ No newline at end of file diff --git a/Engine/src/Engine/ltpch.cpp b/Engine/src/Engine/ltpch.cpp index f3b8457..0a753c2 100644 --- a/Engine/src/Engine/ltpch.cpp +++ b/Engine/src/Engine/ltpch.cpp @@ -1 +1 @@ -#include "ltpch.h" \ No newline at end of file +#include "ltpch.hpp" \ No newline at end of file diff --git a/Engine/src/Engine/ltpch.h b/Engine/src/Engine/ltpch.hpp similarity index 91% rename from Engine/src/Engine/ltpch.h rename to Engine/src/Engine/ltpch.hpp index 20bdbb6..d198d9b 100644 --- a/Engine/src/Engine/ltpch.h +++ b/Engine/src/Engine/ltpch.hpp @@ -1,7 +1,7 @@ #pragma once /* engine */ -#include "Base/Base.h" +#include "Base/Base.hpp" /* windows */ #ifdef _WIN32 @@ -12,13 +12,13 @@ /* containers */ #include -#include -#include -#include #include +#include #include +#include #include #include +#include /* misc */ #include @@ -28,13 +28,13 @@ #include /* input/output */ -#include #include +#include #include /* multi threading */ -#include #include +#include /* string */ #include @@ -44,5 +44,5 @@ #include /* c libraries */ -#include -#include \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp index 5533e17..08e7829 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp @@ -1,81 +1,82 @@ -#include "dxBlender.h" -#include "dxSharedContext.h" +#include "dxBlender.hpp" + +#include "dxSharedContext.hpp" namespace Light { - dxBlender::dxBlender(Ref sharedContext) - : m_Context(sharedContext), - m_FactorMap{ // constants - { BlendFactor::ZERO, D3D11_BLEND_ZERO }, - { BlendFactor::ONE, D3D11_BLEND_ONE }, - - // source - { BlendFactor::SRC_COLOR, D3D11_BLEND_SRC_COLOR }, - { BlendFactor::INVERSE_SRC_COLOR, D3D11_BLEND_INV_SRC_COLOR }, - - { BlendFactor::SRC_ALPHA, D3D11_BLEND_SRC_ALPHA }, - { BlendFactor::INVERSE_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA }, - - // destination - { BlendFactor::DST_COLOR, D3D11_BLEND_DEST_COLOR }, - { BlendFactor::INVERSE_DST_COLOR, D3D11_BLEND_INV_DEST_COLOR }, - - { BlendFactor::DST_ALPHA, D3D11_BLEND_DEST_ALPHA }, - { BlendFactor::INVERSE_DST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA }, - - // source1 - { BlendFactor::SRC1_COLOR, D3D11_BLEND_SRC1_COLOR }, - { BlendFactor::INVERSE_SRC1_COLOR, D3D11_BLEND_INV_SRC1_COLOR }, - - { BlendFactor::SRC1_ALPHA, D3D11_BLEND_SRC1_ALPHA }, - { BlendFactor::INVERSE_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA } }, - m_BlendState(nullptr), - m_Desc{} - { - // factor map - // blender desc - m_Desc = { }; +dxBlender::dxBlender(Ref sharedContext) + : m_Context(sharedContext), m_FactorMap { // constants + { BlendFactor::ZERO, D3D11_BLEND_ZERO }, + { BlendFactor::ONE, D3D11_BLEND_ONE }, - m_Desc.RenderTarget[0].BlendEnable = true; - m_Desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO; - m_Desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; - m_Desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - m_Desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; - m_Desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; - m_Desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - m_Desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + // source + { BlendFactor::SRC_COLOR, D3D11_BLEND_SRC_COLOR }, + { BlendFactor::INVERSE_SRC_COLOR, D3D11_BLEND_INV_SRC_COLOR }, - // create blend state - HRESULT hr; - DXC(m_Context->GetDevice()->CreateBlendState( &m_Desc, &m_BlendState ) ); - } + { BlendFactor::SRC_ALPHA, D3D11_BLEND_SRC_ALPHA }, + { BlendFactor::INVERSE_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA }, - void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) - { - // update desc - m_Desc.RenderTarget[0].BlendEnable = true; - m_Desc.RenderTarget[0].SrcBlend = m_FactorMap.at(srcFactor); - m_Desc.RenderTarget[0].DestBlend = m_FactorMap.at(dstFactor); + // destination + { BlendFactor::DST_COLOR, D3D11_BLEND_DEST_COLOR }, + { BlendFactor::INVERSE_DST_COLOR, D3D11_BLEND_INV_DEST_COLOR }, - // re-create blind state - HRESULT hr; - DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); + { BlendFactor::DST_ALPHA, D3D11_BLEND_DEST_ALPHA }, + { BlendFactor::INVERSE_DST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA }, - // bind blend state - m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0x0000000f); - } + // source1 + { BlendFactor::SRC1_COLOR, D3D11_BLEND_SRC1_COLOR }, + { BlendFactor::INVERSE_SRC1_COLOR, D3D11_BLEND_INV_SRC1_COLOR }, - void dxBlender::Disable() - { - // update desc - m_Desc.RenderTarget[0].BlendEnable = false; + { BlendFactor::SRC1_ALPHA, D3D11_BLEND_SRC1_ALPHA }, + { BlendFactor::INVERSE_SRC1_ALPHA, D3D11_BLEND_INV_SRC1_ALPHA } + } + , m_BlendState(nullptr) + , m_Desc {} +{ + // factor map + // blender desc + m_Desc = {}; - // re-create blind state - HRESULT hr; - DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); + m_Desc.RenderTarget[0].BlendEnable = true; + m_Desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ZERO; + m_Desc.RenderTarget[0].DestBlend = D3D11_BLEND_ZERO; + m_Desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + m_Desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; + m_Desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + m_Desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + m_Desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - // bind blend state - m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0xffffffff); - } + // create blend state + HRESULT hr; + DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); +} -} \ No newline at end of file +void dxBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) +{ + // update desc + m_Desc.RenderTarget[0].BlendEnable = true; + m_Desc.RenderTarget[0].SrcBlend = m_FactorMap.at(srcFactor); + m_Desc.RenderTarget[0].DestBlend = m_FactorMap.at(dstFactor); + + // re-create blind state + HRESULT hr; + DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); + + // bind blend state + m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0x0000000f); +} + +void dxBlender::Disable() +{ + // update desc + m_Desc.RenderTarget[0].BlendEnable = false; + + // re-create blind state + HRESULT hr; + DXC(m_Context->GetDevice()->CreateBlendState(&m_Desc, &m_BlendState)); + + // bind blend state + m_Context->GetDeviceContext()->OMSetBlendState(m_BlendState.Get(), nullptr, 0xffffffff); +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h deleted file mode 100644 index 0070702..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "Graphics/Blender.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - class dxBlender : public Blender - { - private: - Ref m_Context; - - const std::unordered_map m_FactorMap; - - Microsoft::WRL::ComPtr m_BlendState; - - D3D11_BLEND_DESC m_Desc; - - public: - dxBlender(Ref sharedContext); - - void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; - void Disable() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.hpp new file mode 100644 index 0000000..698fead --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Blender.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +class dxBlender: public Blender +{ +private: + Ref m_Context; + + const std::unordered_map m_FactorMap; + + Microsoft::WRL::ComPtr m_BlendState; + + D3D11_BLEND_DESC m_Desc; + +public: + dxBlender(Ref sharedContext); + + void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; + void Disable() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp index afae98b..5f4a873 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp @@ -1,6 +1,6 @@ -#include "dxBuffers.h" +#include "dxBuffers.hpp" -#include "dxSharedContext.h" +#include "dxSharedContext.hpp" namespace Light { diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h deleted file mode 100644 index 6e7c7ec..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "Graphics/Buffers.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - //========== CONSTANT_BUFFER ==========// - class dxConstantBuffer : public ConstantBuffer - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_Buffer; - D3D11_MAPPED_SUBRESOURCE m_Map; - - unsigned int m_Index; - - public: - dxConstantBuffer(ConstantBufferIndex index, unsigned int size, Ref sharedContext); - - void Bind() override; - - void* Map() override; - void UnMap() override; - }; - - //========== VERTEX_BUFFER ==========// - class dxVertexBuffer : public VertexBuffer - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_Buffer; - D3D11_MAPPED_SUBRESOURCE m_Map; - - unsigned int m_Stride; - - public: - dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); - ~dxVertexBuffer(); - - void Bind() override; - void UnBind() override; - - void* Map() override; - void UnMap() override; - }; - - //========== INDEX_BUFFER ==========// - class dxIndexBuffer : public IndexBuffer - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_Buffer; - - public: - dxIndexBuffer(unsigned int* indices, unsigned int count, Ref sharedContext); - ~dxIndexBuffer(); - - void Bind() override; - void UnBind() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.hpp new file mode 100644 index 0000000..805c6f8 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.hpp @@ -0,0 +1,71 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Buffers.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +//========== CONSTANT_BUFFER ==========// +class dxConstantBuffer: public ConstantBuffer +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_Buffer; + D3D11_MAPPED_SUBRESOURCE m_Map; + + unsigned int m_Index; + +public: + dxConstantBuffer(ConstantBufferIndex index, unsigned int size, Ref sharedContext); + + void Bind() override; + + void* Map() override; + void UnMap() override; +}; + +//========== VERTEX_BUFFER ==========// +class dxVertexBuffer: public VertexBuffer +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_Buffer; + D3D11_MAPPED_SUBRESOURCE m_Map; + + unsigned int m_Stride; + +public: + dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); + ~dxVertexBuffer(); + + void Bind() override; + void UnBind() override; + + void* Map() override; + void UnMap() override; +}; + +//========== INDEX_BUFFER ==========// +class dxIndexBuffer: public IndexBuffer +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_Buffer; + +public: + dxIndexBuffer(unsigned int* indices, unsigned int count, Ref sharedContext); + ~dxIndexBuffer(); + + void Bind() override; + void UnBind() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp index 79a06a3..0da490f 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp @@ -1,6 +1,6 @@ -#include "dxFramebuffer.h" +#include "dxFramebuffer.hpp" -#include "dxSharedContext.h" +#include "dxSharedContext.hpp" namespace Light { diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h deleted file mode 100644 index d07a2c3..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "Graphics/Framebuffer.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - class dxFramebuffer : public Framebuffer - { - private: - Ref m_Context; - - FramebufferSpecification m_Specification; - - Microsoft::WRL::ComPtr m_RenderTargetView; - Microsoft::WRL::ComPtr m_ColorAttachment; - Microsoft::WRL::ComPtr m_DepthStencilAttachment; - Microsoft::WRL::ComPtr m_ShaderResourceView; - Microsoft::WRL::ComPtr m_DepthStencilView; - - public: - dxFramebuffer(const FramebufferSpecification& specification, Ref sharedContext); - - inline void* GetColorAttachment() override { return (void*)m_ShaderResourceView.Get(); } - - void BindAsTarget(const glm::vec4& clearColor) override; - void BindAsResource() override; - - void Resize(const glm::uvec2& size) override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.hpp new file mode 100644 index 0000000..c5ec426 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Framebuffer.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +class dxFramebuffer: public Framebuffer +{ +private: + Ref m_Context; + + FramebufferSpecification m_Specification; + + Microsoft::WRL::ComPtr m_RenderTargetView; + Microsoft::WRL::ComPtr m_ColorAttachment; + Microsoft::WRL::ComPtr m_DepthStencilAttachment; + Microsoft::WRL::ComPtr m_ShaderResourceView; + Microsoft::WRL::ComPtr m_DepthStencilView; + +public: + dxFramebuffer(const FramebufferSpecification& specification, Ref sharedContext); + + inline void* GetColorAttachment() override { return (void*)m_ShaderResourceView.Get(); } + + void BindAsTarget(const glm::vec4& clearColor) override; + void BindAsResource() override; + + void Resize(const glm::uvec2& size) override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp index f6dd5b9..1cc73e2 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp @@ -1,13 +1,13 @@ -#include "dxGraphicsContext.h" +#include "dxGraphicsContext.hpp" -#include "Events/WindowEvents.h" -#include "Graphics/Blender.h" // required for forward declaration -#include "Graphics/Buffers.h" // required for forward declaration -#include "Graphics/RenderCommand.h" // required for forward declaration -#include "Graphics/Renderer.h" // required for forward declaration -#include "UserInterface/UserInterface.h" // required for forward declaration -#include "Utility/ResourceManager.h" // required for forward declaration -#include "dxSharedContext.h" +#include "Events/WindowEvents.hpp" +#include "Graphics/Blender.hpp" // required for forward declaration +#include "Graphics/Buffers.hpp" // required for forward declaration +#include "Graphics/RenderCommand.hpp" // required for forward declaration +#include "Graphics/Renderer.hpp" // required for forward declaration +#include "UserInterface/UserInterface.hpp" // required for forward declaration +#include "Utility/ResourceManager.hpp" // required for forward declaration +#include "dxSharedContext.hpp" #define GLFW_EXPOSE_NATIVE_WIN32 #include diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.h deleted file mode 100644 index b464101..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "Graphics/GraphicsContext.h" - -#include "Base/Base.h" - -#include -#include - -struct GLFWwindow; - -namespace Light { - - class dxGraphicsContext : public GraphicsContext - { - private: - GLFWwindow* m_WindowHandle; - - Microsoft::WRL::ComPtr m_DebugInterface; - - public: - dxGraphicsContext(GLFWwindow* windowHandle); - - virtual void LogDebugData() override; - - private: - void SetupDeviceAndSwapChain(GLFWwindow* windowHandle); - void SetupRenderTargets(); - void SetupDebugInterface(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.hpp new file mode 100644 index 0000000..867e505 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/GraphicsContext.hpp" + +#include +#include + +struct GLFWwindow; + +namespace Light { + +class dxGraphicsContext: public GraphicsContext +{ +private: + GLFWwindow* m_WindowHandle; + + Microsoft::WRL::ComPtr m_DebugInterface; + +public: + dxGraphicsContext(GLFWwindow* windowHandle); + + virtual void LogDebugData() override; + +private: + void SetupDeviceAndSwapChain(GLFWwindow* windowHandle); + void SetupRenderTargets(); + void SetupDebugInterface(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp index 857cb8d..a0f43e9 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp @@ -1,6 +1,6 @@ -#include "dxRenderCommand.h" +#include "dxRenderCommand.hpp" -#include "dxSharedContext.h" +#include "dxSharedContext.hpp" namespace Light { diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h deleted file mode 100644 index aaaf9e2..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "Graphics/RenderCommand.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - class dxRenderCommand : public RenderCommand - { - private: - Ref m_Context; - - public: - dxRenderCommand(Ref sharedContext); - - virtual void SwapBuffers() override; - virtual void ClearBackBuffer(const glm::vec4& clearColor) override; - - virtual void Draw(unsigned int count) override; - virtual void DrawIndexed(unsigned int count) override; - - virtual void DefaultTargetFramebuffer() override; - - virtual void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) override; - - private: - void SetResolution(unsigned int width, unsigned int height); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.hpp new file mode 100644 index 0000000..1d26f53 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/RenderCommand.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +class dxRenderCommand: public RenderCommand +{ +private: + Ref m_Context; + +public: + dxRenderCommand(Ref sharedContext); + + virtual void SwapBuffers() override; + virtual void ClearBackBuffer(const glm::vec4& clearColor) override; + + virtual void Draw(unsigned int count) override; + virtual void DrawIndexed(unsigned int count) override; + + virtual void DefaultTargetFramebuffer() override; + + virtual void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) override; + +private: + void SetResolution(unsigned int width, unsigned int height); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp index 4210d60..b1409b9 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp @@ -1,6 +1,6 @@ -#include "dxShader.h" +#include "dxShader.hpp" -#include "dxSharedContext.h" +#include "dxSharedContext.hpp" #include diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h deleted file mode 100644 index 8393b5c..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "Graphics/Shader.h" - -#include "Base/Base.h" - -#include "Utility/FileManager.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - class dxShader : public Shader - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_VertexShader; - Microsoft::WRL::ComPtr m_PixelShader; - - Microsoft::WRL::ComPtr m_VertexBlob; - - public: - dxShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref sharedContext); - ~dxShader(); - - void Bind() override; - void UnBind() override; - - inline Microsoft::WRL::ComPtr GetVertexBlob() { return m_VertexBlob; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.hpp new file mode 100644 index 0000000..3b500b4 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Shader.hpp" +#include "Utility/FileManager.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +class dxShader: public Shader +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_VertexShader; + Microsoft::WRL::ComPtr m_PixelShader; + + Microsoft::WRL::ComPtr m_VertexBlob; + +public: + dxShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref sharedContext); + ~dxShader(); + + void Bind() override; + void UnBind() override; + + inline Microsoft::WRL::ComPtr GetVertexBlob() { return m_VertexBlob; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.h deleted file mode 100644 index f61cb15..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "Base/Base.h" -#include "Graphics/SharedContext.h" - -#include -#include - -namespace Light { - - class dxSharedContext : public SharedContext - { - private: - Microsoft::WRL::ComPtr m_Device = nullptr; - Microsoft::WRL::ComPtr m_DeviceContext = nullptr; - Microsoft::WRL::ComPtr m_SwapChain = nullptr; - Microsoft::WRL::ComPtr m_RenderTargetView = nullptr; - - public: - inline Microsoft::WRL::ComPtr GetDevice () { return m_Device; } - inline Microsoft::WRL::ComPtr GetDeviceContext () { return m_DeviceContext; } - inline Microsoft::WRL::ComPtr GetSwapChain () { return m_SwapChain; } - inline Microsoft::WRL::ComPtr GetRenderTargetView() { return m_RenderTargetView; } - - inline Microsoft::WRL::ComPtr& GetDeviceRef () { return m_Device; } - inline Microsoft::WRL::ComPtr& GetDeviceContextRef () { return m_DeviceContext; } - inline Microsoft::WRL::ComPtr& GetSwapChainRef () { return m_SwapChain; } - inline Microsoft::WRL::ComPtr& GetRenderTargetViewRef() { return m_RenderTargetView; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.hpp new file mode 100644 index 0000000..9f08f06 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxSharedContext.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/SharedContext.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext: public SharedContext +{ +private: + Microsoft::WRL::ComPtr m_Device = nullptr; + Microsoft::WRL::ComPtr m_DeviceContext = nullptr; + Microsoft::WRL::ComPtr m_SwapChain = nullptr; + Microsoft::WRL::ComPtr m_RenderTargetView = nullptr; + +public: + inline Microsoft::WRL::ComPtr GetDevice() { return m_Device; } + inline Microsoft::WRL::ComPtr GetDeviceContext() { return m_DeviceContext; } + inline Microsoft::WRL::ComPtr GetSwapChain() { return m_SwapChain; } + inline Microsoft::WRL::ComPtr GetRenderTargetView() { return m_RenderTargetView; } + + inline Microsoft::WRL::ComPtr& GetDeviceRef() { return m_Device; } + inline Microsoft::WRL::ComPtr& GetDeviceContextRef() { return m_DeviceContext; } + inline Microsoft::WRL::ComPtr& GetSwapChainRef() { return m_SwapChain; } + inline Microsoft::WRL::ComPtr& GetRenderTargetViewRef() { return m_RenderTargetView; } +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp index 1ec4b8e..8194aef 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp @@ -1,68 +1,67 @@ -#include "dxTexture.h" -#include "dxSharedContext.h" +#include "dxTexture.hpp" + +#include "dxSharedContext.hpp" namespace Light { - dxTexture::dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath): - Texture(filePath), - m_Context(sharedContext), - m_Texture2D(nullptr), - m_ShaderResourceView(nullptr), - m_SamplerState(nullptr) - { - // texture2d desc - D3D11_TEXTURE2D_DESC t2dDesc = {}; - t2dDesc.Width = width; - t2dDesc.Height = height; - t2dDesc.MipLevels = 0u; - t2dDesc.ArraySize = 1u; - t2dDesc.Format = components == 4u ? DXGI_FORMAT_R8G8B8A8_UNORM : - components == 3u ? DXGI_FORMAT_R8G8B8A8_UNORM : // #todo: figure out what to do with this bitch ._. - components == 2u ? DXGI_FORMAT_R8G8_UNORM : - components == 1u ? DXGI_FORMAT_R8_UNORM : DXGI_FORMAT_UNKNOWN; - t2dDesc.SampleDesc.Count = 1u; - t2dDesc.SampleDesc.Quality = 0u; - t2dDesc.Usage = D3D11_USAGE_DEFAULT; - t2dDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; - t2dDesc.CPUAccessFlags = NULL; - t2dDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; +dxTexture::dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath) + : Texture(filePath), m_Context(sharedContext), m_Texture2D(nullptr), m_ShaderResourceView(nullptr), m_SamplerState(nullptr) +{ + // texture2d desc + D3D11_TEXTURE2D_DESC t2dDesc = {}; + t2dDesc.Width = width; + t2dDesc.Height = height; + t2dDesc.MipLevels = 0u; + t2dDesc.ArraySize = 1u; + t2dDesc.Format = components == 4u ? DXGI_FORMAT_R8G8B8A8_UNORM : + components == 3u ? DXGI_FORMAT_R8G8B8A8_UNORM : + // #todo: figure out what to do with this bitch ._. + components == 2u ? DXGI_FORMAT_R8G8_UNORM : + components == 1u ? DXGI_FORMAT_R8_UNORM : + DXGI_FORMAT_UNKNOWN; + t2dDesc.SampleDesc.Count = 1u; + t2dDesc.SampleDesc.Quality = 0u; + t2dDesc.Usage = D3D11_USAGE_DEFAULT; + t2dDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + t2dDesc.CPUAccessFlags = NULL; + t2dDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; - // create texture - HRESULT hr; - DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_Texture2D)); - m_Context->GetDeviceContext()->UpdateSubresource(m_Texture2D.Get(), 0u, nullptr, pixels, width * 4u, 0u); - - m_Texture2D->GetDesc(&t2dDesc); + // create texture + HRESULT hr; + DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_Texture2D)); + m_Context->GetDeviceContext()->UpdateSubresource(m_Texture2D.Get(), 0u, nullptr, pixels, width * 4u, 0u); - // shader resource view desc - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.Format = t2dDesc.Format; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MostDetailedMip = 0u; - srvDesc.Texture2D.MipLevels = -1; + m_Texture2D->GetDesc(&t2dDesc); - // create shader resource view - m_Context->GetDevice()->CreateShaderResourceView(m_Texture2D.Get(), &srvDesc, &m_ShaderResourceView); - m_Context->GetDeviceContext()->GenerateMips(m_ShaderResourceView.Get()); + // shader resource view desc + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.Format = t2dDesc.Format; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MostDetailedMip = 0u; + srvDesc.Texture2D.MipLevels = -1; - // sampler desc - D3D11_SAMPLER_DESC sDesc = {}; - sDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - sDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; - sDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; - sDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; - sDesc.MinLOD = 0.0f; - sDesc.MipLODBias = 0.0f; - sDesc.MaxLOD = D3D11_FLOAT32_MAX; + // create shader resource view + m_Context->GetDevice()->CreateShaderResourceView(m_Texture2D.Get(), &srvDesc, &m_ShaderResourceView); + m_Context->GetDeviceContext()->GenerateMips(m_ShaderResourceView.Get()); - // create sampler - m_Context->GetDevice()->CreateSamplerState(&sDesc, &m_SamplerState); - } + // sampler desc + D3D11_SAMPLER_DESC sDesc = {}; + sDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + sDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + sDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; + sDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; + sDesc.MinLOD = 0.0f; + sDesc.MipLODBias = 0.0f; + sDesc.MaxLOD = D3D11_FLOAT32_MAX; - void dxTexture::Bind(unsigned int slot /* = 0u */) - { - m_Context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_SamplerState.GetAddressOf()); - m_Context->GetDeviceContext()->PSSetShaderResources(slot, 1u, m_ShaderResourceView.GetAddressOf()); - } + // create sampler + m_Context->GetDevice()->CreateSamplerState(&sDesc, &m_SamplerState); +} -} \ No newline at end of file +void dxTexture::Bind(unsigned int slot /* = 0u */) +{ + m_Context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_SamplerState.GetAddressOf()); + m_Context->GetDeviceContext()->PSSetShaderResources(slot, 1u, m_ShaderResourceView.GetAddressOf()); +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h deleted file mode 100644 index 3157d30..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "Graphics/Texture.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class dxSharedContext; - - class dxTexture : public Texture - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_Texture2D; - Microsoft::WRL::ComPtr m_ShaderResourceView; - Microsoft::WRL::ComPtr m_SamplerState; - - public: - dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath); - - void Bind(unsigned int slot = 0u) override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.hpp new file mode 100644 index 0000000..62ff41a --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Texture.hpp" + +#include +#include + +namespace Light { + +class dxSharedContext; + +class dxTexture: public Texture +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_Texture2D; + Microsoft::WRL::ComPtr m_ShaderResourceView; + Microsoft::WRL::ComPtr m_SamplerState; + +public: + dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext, const std::string& filePath); + + void Bind(unsigned int slot = 0u) override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp index dbca69a..74637e8 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp @@ -1,7 +1,7 @@ -#include "dxUserInterface.h" +#include "dxUserInterface.hpp" -#include "Input/KeyCodes.h" -#include "dxSharedContext.h" +#include "Input/KeyCodes.hpp" +#include "dxSharedContext.hpp" #define GLFW_EXPOSE_NATIVE_WIN32 #include diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h deleted file mode 100644 index fed72a4..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "UserInterface/UserInterface.h" - -#include "Base/Base.h" - -#include -#include - -struct GLFWwindow; - -namespace Light { - - class dxSharedContext; - - class dxUserInterface : public UserInterface - { - public: - dxUserInterface() = default; - ~dxUserInterface(); - - void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) override; - - void Begin() override; - void End() override; - - void LogDebugData() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.hpp new file mode 100644 index 0000000..e15e430 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "Base/Base.hpp" +#include "UserInterface/UserInterface.hpp" + +#include +#include + +struct GLFWwindow; + +namespace Light { + +class dxSharedContext; + +class dxUserInterface: public UserInterface +{ +public: + dxUserInterface() = default; + ~dxUserInterface(); + + void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) override; + + void Begin() override; + void End() override; + + void LogDebugData() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp index 6f5032d..9f6a63b 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp @@ -1,7 +1,7 @@ -#include "dxVertexLayout.h" +#include "dxVertexLayout.hpp" -#include "dxShader.h" -#include "dxSharedContext.h" +#include "dxShader.hpp" +#include "dxSharedContext.hpp" namespace Light { diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h deleted file mode 100644 index 4b87071..0000000 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "Graphics/VertexLayout.h" - -#include "Base/Base.h" - -#include -#include - -namespace Light { - - class Shader; - - class dxSharedContext; - - class dxVertexLayout : public VertexLayout - { - private: - Ref m_Context; - - Microsoft::WRL::ComPtr m_InputLayout; - - public: - dxVertexLayout(Ref shader, const std::vector>& elements, Ref sharedContext); - ~dxVertexLayout(); - - void Bind() override; - void UnBind() override; - - private: - DXGI_FORMAT GetDxgiFormat(VertexElementType type); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.hpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.hpp new file mode 100644 index 0000000..d1f863d --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/VertexLayout.hpp" + +#include +#include + +namespace Light { + +class Shader; + +class dxSharedContext; + +class dxVertexLayout: public VertexLayout +{ +private: + Ref m_Context; + + Microsoft::WRL::ComPtr m_InputLayout; + +public: + dxVertexLayout(Ref shader, const std::vector>& elements, Ref sharedContext); + ~dxVertexLayout(); + + void Bind() override; + void UnBind() override; + +private: + DXGI_FORMAT GetDxgiFormat(VertexElementType type); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.cpp index a3bd657..cffb55a 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.cpp @@ -1,46 +1,47 @@ -#include "glBlender.h" +#include "glBlender.hpp" #include namespace Light { - glBlender::glBlender() - : m_FactorMap{ // constants - { BlendFactor::ZERO , GL_ZERO }, - { BlendFactor::ONE , GL_ONE }, - - // source , - { BlendFactor::SRC_COLOR , GL_SRC_COLOR }, - { BlendFactor::INVERSE_SRC_COLOR , GL_ONE_MINUS_SRC_COLOR }, - - { BlendFactor::SRC_ALPHA , GL_SRC_ALPHA }, - { BlendFactor::INVERSE_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA }, - - // destination , - { BlendFactor::DST_COLOR , GL_DST_COLOR }, - { BlendFactor::INVERSE_DST_COLOR , GL_ONE_MINUS_DST_COLOR }, - - { BlendFactor::DST_ALPHA , GL_DST_ALPHA }, - { BlendFactor::INVERSE_DST_ALPHA , GL_ONE_MINUS_DST_ALPHA }, - - // source1 , - { BlendFactor::SRC1_COLOR , GL_SRC1_COLOR }, - { BlendFactor::INVERSE_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR }, - - { BlendFactor::SRC1_ALPHA , GL_SRC1_ALPHA }, - { BlendFactor::INVERSE_SRC1_ALPHA, GL_ONE_MINUS_SRC_ALPHA } } - { - } +glBlender::glBlender() + : m_FactorMap { // constants + { BlendFactor::ZERO, GL_ZERO }, + { BlendFactor::ONE, GL_ONE }, - void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) - { - glEnable(GL_BLEND); - glBlendFunc(m_FactorMap.at(srcFactor), m_FactorMap.at(dstFactor)); - } + // source , + { BlendFactor::SRC_COLOR, GL_SRC_COLOR }, + { BlendFactor::INVERSE_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR }, - void glBlender::Disable() - { - glDisable(GL_BLEND); - } + { BlendFactor::SRC_ALPHA, GL_SRC_ALPHA }, + { BlendFactor::INVERSE_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }, -} \ No newline at end of file + // destination , + { BlendFactor::DST_COLOR, GL_DST_COLOR }, + { BlendFactor::INVERSE_DST_COLOR, GL_ONE_MINUS_DST_COLOR }, + + { BlendFactor::DST_ALPHA, GL_DST_ALPHA }, + { BlendFactor::INVERSE_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA }, + + // source1 , + { BlendFactor::SRC1_COLOR, GL_SRC1_COLOR }, + { BlendFactor::INVERSE_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR }, + + { BlendFactor::SRC1_ALPHA, GL_SRC1_ALPHA }, + { BlendFactor::INVERSE_SRC1_ALPHA, GL_ONE_MINUS_SRC_ALPHA } + } +{ +} + +void glBlender::Enable(BlendFactor srcFactor, BlendFactor dstFactor) +{ + glEnable(GL_BLEND); + glBlendFunc(m_FactorMap.at(srcFactor), m_FactorMap.at(dstFactor)); +} + +void glBlender::Disable() +{ + glDisable(GL_BLEND); +} + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.h deleted file mode 100644 index fc9dc69..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "Graphics/Blender.h" - -#include "Base/Base.h" - -namespace Light { - - class glBlender : public Blender - { - private: - std::unordered_map m_FactorMap; - - public: - glBlender(); - - void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; - void Disable() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.hpp new file mode 100644 index 0000000..a372fed --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glBlender.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Blender.hpp" + +namespace Light { + +class glBlender: public Blender +{ +private: + std::unordered_map m_FactorMap; + +public: + glBlender(); + + void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; + void Disable() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.cpp index 1c645bd..1229f4e 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.cpp @@ -1,4 +1,4 @@ -#include "glBuffers.h" +#include "glBuffers.hpp" #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.h deleted file mode 100644 index 6fd4eaa..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "Graphics/Buffers.h" - -#include "Base/Base.h" - -namespace Light { - - //========== CONSTANT_BUFFER ==========// - class glConstantBuffer : public ConstantBuffer - { - private: - unsigned int m_BufferID; - unsigned int m_Index; - - public: - glConstantBuffer(ConstantBufferIndex index, unsigned int size); - ~glConstantBuffer(); - - void Bind() override; - - void* Map() override; - void UnMap() override; - }; - - //========== VERTEX_BUFFER ==========// - class glVertexBuffer : public VertexBuffer - { - private: - unsigned int m_BufferID; - - public: - glVertexBuffer(float* vertices, unsigned int stride, unsigned int count); - ~glVertexBuffer(); - - void Bind() override; - void UnBind() override; - - void* Map() override; - void UnMap() override; - }; - - //========== INDEX_BUFFER ==========// - class glIndexBuffer : public IndexBuffer - { - private: - unsigned int m_BufferID; - - public: - glIndexBuffer(unsigned int* indices, unsigned int count); - ~glIndexBuffer(); - - void Bind() override; - void UnBind() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.hpp new file mode 100644 index 0000000..a5f85a8 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glBuffers.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Buffers.hpp" + +namespace Light { + +//========== CONSTANT_BUFFER ==========// +class glConstantBuffer: public ConstantBuffer +{ +private: + unsigned int m_BufferID; + unsigned int m_Index; + +public: + glConstantBuffer(ConstantBufferIndex index, unsigned int size); + ~glConstantBuffer(); + + void Bind() override; + + void* Map() override; + void UnMap() override; +}; + +//========== VERTEX_BUFFER ==========// +class glVertexBuffer: public VertexBuffer +{ +private: + unsigned int m_BufferID; + +public: + glVertexBuffer(float* vertices, unsigned int stride, unsigned int count); + ~glVertexBuffer(); + + void Bind() override; + void UnBind() override; + + void* Map() override; + void UnMap() override; +}; + +//========== INDEX_BUFFER ==========// +class glIndexBuffer: public IndexBuffer +{ +private: + unsigned int m_BufferID; + +public: + glIndexBuffer(unsigned int* indices, unsigned int count); + ~glIndexBuffer(); + + void Bind() override; + void UnBind() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.cpp index 2533c57..2dd8aca 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.cpp @@ -1,4 +1,4 @@ -#include "glFramebuffer.h" +#include "glFramebuffer.hpp" #include #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.h deleted file mode 100644 index 5ae4bd0..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "Graphics/Framebuffer.h" - -#include "Base/Base.h" - -namespace Light { - - class glFramebuffer : public Framebuffer - { - private: - FramebufferSpecification m_Specification; - - unsigned int m_BufferID; - unsigned int m_ColorAttachmentID, m_DepthStencilAttachmentID; - - public: - glFramebuffer(const FramebufferSpecification& specification); - ~glFramebuffer(); - - void BindAsTarget(const glm::vec4& clearColor) override; - void BindAsResource() override; - - void Resize(const glm::uvec2& size) override; - - inline void* GetColorAttachment() override { return (void*)m_ColorAttachmentID; } - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.hpp new file mode 100644 index 0000000..19ec718 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glFramebuffer.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/Framebuffer.hpp" + +namespace Light { + +class glFramebuffer: public Framebuffer +{ +private: + FramebufferSpecification m_Specification; + + unsigned int m_BufferID; + unsigned int m_ColorAttachmentID, m_DepthStencilAttachmentID; + +public: + glFramebuffer(const FramebufferSpecification& specification); + ~glFramebuffer(); + + void BindAsTarget(const glm::vec4& clearColor) override; + void BindAsResource() override; + + void Resize(const glm::uvec2& size) override; + + inline void* GetColorAttachment() override { return (void*)m_ColorAttachmentID; } +}; + +} // namespace Light \ 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 47fc98a..072c89f 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.cpp @@ -1,12 +1,12 @@ -#include "glGraphicsContext.h" +#include "glGraphicsContext.hpp" -#include "Events/WindowEvents.h" -#include "Graphics/Blender.h" // required for forward declaration -#include "Graphics/Buffers.h" // required for forward declaration -#include "Graphics/RenderCommand.h" // required for forward declaration -#include "Graphics/Renderer.h" // required for forward declaration -#include "UserInterface/UserInterface.h" // required for forward declaration -#include "Utility/ResourceManager.h" // required for forward declaration +#include "Events/WindowEvents.hpp" +#include "Graphics/Blender.hpp" // required for forward declaration +#include "Graphics/Buffers.hpp" // required for forward declaration +#include "Graphics/RenderCommand.hpp" // required for forward declaration +#include "Graphics/Renderer.hpp" // required for forward declaration +#include "UserInterface/UserInterface.hpp" // required for forward declaration +#include "Utility/ResourceManager.hpp" // required for forward declaration #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.h deleted file mode 100644 index 0f1789e..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "Graphics/GraphicsContext.h" - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class glGraphicsContext : public GraphicsContext - { - private: - GLFWwindow* m_WindowHandle; - - public: - glGraphicsContext(GLFWwindow* windowHandle); - - void LogDebugData() override; - - private: - void SetDebugMessageCallback(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.hpp new file mode 100644 index 0000000..2e6120d --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glGraphicsContext.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/GraphicsContext.hpp" + +struct GLFWwindow; + +namespace Light { + +class glGraphicsContext: public GraphicsContext +{ +private: + GLFWwindow* m_WindowHandle; + +public: + glGraphicsContext(GLFWwindow* windowHandle); + + void LogDebugData() override; + +private: + void SetDebugMessageCallback(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.cpp index 70f6733..a67f7c8 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.cpp @@ -1,44 +1,46 @@ -#include "glRenderCommand.h" +#include "glRenderCommand.hpp" #include -#include +#ifndef DONT_FUCKING_ORDER_THESSE_PLEASE_FOR_THE_LOVE_OF_GOD_CLANG_FORMAT + #include +#endif namespace Light { - glRenderCommand::glRenderCommand(GLFWwindow* windowHandle) - : m_WindowHandle(windowHandle) - { - } +glRenderCommand::glRenderCommand(GLFWwindow* windowHandle) + : m_WindowHandle(windowHandle) +{ +} - void glRenderCommand::SwapBuffers() - { - glfwSwapBuffers(m_WindowHandle); - } +void glRenderCommand::SwapBuffers() +{ + glfwSwapBuffers(m_WindowHandle); +} - void glRenderCommand::ClearBackBuffer(const glm::vec4& clearColor) - { - glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); - glClear(GL_COLOR_BUFFER_BIT); - } +void glRenderCommand::ClearBackBuffer(const glm::vec4& clearColor) +{ + glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); + glClear(GL_COLOR_BUFFER_BIT); +} - void glRenderCommand::Draw(unsigned int count) - { - glDrawArrays(GL_TRIANGLES, 0, count); - } +void glRenderCommand::Draw(unsigned int count) +{ + glDrawArrays(GL_TRIANGLES, 0, count); +} - void glRenderCommand::DrawIndexed(unsigned int count) - { - glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); - } +void glRenderCommand::DrawIndexed(unsigned int count) +{ + glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); +} - void glRenderCommand::DefaultTargetFramebuffer() - { - glBindFramebuffer(GL_FRAMEBUFFER, NULL); - } +void glRenderCommand::DefaultTargetFramebuffer() +{ + glBindFramebuffer(GL_FRAMEBUFFER, NULL); +} - void glRenderCommand::SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) - { - glViewport(x, y, width, height); - } +void glRenderCommand::SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + glViewport(x, y, width, height); +} -} \ No newline at end of file +} // namespace Light diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h deleted file mode 100644 index e20f9f8..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "Graphics/RenderCommand.h" - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class glRenderCommand : public RenderCommand - { - private: - GLFWwindow* m_WindowHandle; - - public: - glRenderCommand(GLFWwindow* windowHandle); - - void SwapBuffers() override; - void ClearBackBuffer(const glm::vec4& clearColor) override; - - void Draw(unsigned int count) override; - void DrawIndexed(unsigned int count) override; - - void DefaultTargetFramebuffer() override; - - void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.hpp new file mode 100644 index 0000000..e3ba70f --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glRenderCommand.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/RenderCommand.hpp" + +struct GLFWwindow; + +namespace Light { + +class glRenderCommand: public RenderCommand +{ +private: + GLFWwindow* m_WindowHandle; + +public: + glRenderCommand(GLFWwindow* windowHandle); + + void SwapBuffers() override; + void ClearBackBuffer(const glm::vec4& clearColor) override; + + void Draw(unsigned int count) override; + void DrawIndexed(unsigned int count) override; + + void DefaultTargetFramebuffer() override; + + void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp index 4f579eb..b20f685 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp @@ -1,4 +1,4 @@ -#include "glShader.h" +#include "glShader.hpp" #include #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.hpp similarity index 83% rename from Engine/src/Platform/GraphicsAPI/OpenGL/glShader.h rename to Engine/src/Platform/GraphicsAPI/OpenGL/glShader.hpp index 068e3a2..88dc893 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.h +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.hpp @@ -1,10 +1,8 @@ #pragma once -#include "Graphics/Shader.h" - -#include "Base/Base.h" - -#include "Utility/FileManager.h" +#include "Base/Base.hpp" +#include "Graphics/Shader.hpp" +#include "Utility/FileManager.hpp" #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.h deleted file mode 100644 index e5cbcac..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Graphics/SharedContext.h" - -#include "Base/Base.h" - -namespace Light { - - class glSharedContext : public SharedContext - { - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.hpp new file mode 100644 index 0000000..70d3f7b --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glSharedContext.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/SharedContext.hpp" + +namespace Light { + +class glSharedContext: public SharedContext +{ +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.cpp index f4cd685..8eb8b1b 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.cpp @@ -1,4 +1,4 @@ -#include "glTexture.h" +#include "glTexture.hpp" #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.hpp similarity index 86% rename from Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.h rename to Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.hpp index 84f59e6..3fbcdbe 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.h +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glTexture.hpp @@ -1,7 +1,7 @@ #pragma once -#include "Base/Base.h" -#include "Graphics/Texture.h" +#include "Base/Base.hpp" +#include "Graphics/Texture.hpp" namespace Light { diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp index 469cb01..56e54eb 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp @@ -1,6 +1,6 @@ -#include "glUserInterface.h" +#include "glUserInterface.hpp" -#include "Input/KeyCodes.h" +#include "Input/KeyCodes.hpp" #include #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h deleted file mode 100644 index b9e9046..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "UserInterface/UserInterface.h" - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class glUserInterface : public UserInterface - { - private: - GLFWwindow* m_WindowHandle; - - public: - glUserInterface() = default; - ~glUserInterface(); - - void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) override; - - void Begin() override; - void End() override; - - void LogDebugData() override; - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.hpp new file mode 100644 index 0000000..4235046 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "Base/Base.hpp" +#include "UserInterface/UserInterface.hpp" + +struct GLFWwindow; + +namespace Light { + +class glUserInterface: public UserInterface +{ +private: + GLFWwindow* m_WindowHandle; + +public: + glUserInterface() = default; + ~glUserInterface(); + + void PlatformImplementation(GLFWwindow* windowHandle, Ref sharedContext) override; + + void Begin() override; + void End() override; + + void LogDebugData() override; +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp index 7f6b4a2..10594c5 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp @@ -1,6 +1,6 @@ -#include "glVertexLayout.h" +#include "glVertexLayout.hpp" -#include "glBuffers.h" +#include "glBuffers.hpp" #include diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h deleted file mode 100644 index 72b2d6a..0000000 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "Graphics/VertexLayout.h" - -#include "Base/Base.h" - -namespace Light { - - class VertexBuffer; - - struct glVertexElementDesc - { - unsigned int type; - unsigned int count; - unsigned int typeSize; - unsigned int offset; - }; - - class glVertexLayout : public VertexLayout - { - private: - unsigned int m_ArrayID; - - public: - glVertexLayout(Ref buffer, const std::vector>& elements); - ~glVertexLayout(); - - void Bind() override; - void UnBind() override; - - private: - glVertexElementDesc GetElementDesc(VertexElementType type, unsigned int offset); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.hpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.hpp new file mode 100644 index 0000000..b1842b4 --- /dev/null +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Graphics/VertexLayout.hpp" + +namespace Light { + +class VertexBuffer; + +struct glVertexElementDesc +{ + unsigned int type; + unsigned int count; + unsigned int typeSize; + unsigned int offset; +}; + +class glVertexLayout: public VertexLayout +{ +private: + unsigned int m_ArrayID; + +public: + glVertexLayout(Ref buffer, const std::vector>& elements); + ~glVertexLayout(); + + void Bind() override; + void UnBind() override; + +private: + glVertexElementDesc GetElementDesc(VertexElementType type, unsigned int offset); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/OS/Linux/lWindow.cpp b/Engine/src/Platform/OS/Linux/lWindow.cpp index d1def04..12d39cd 100644 --- a/Engine/src/Platform/OS/Linux/lWindow.cpp +++ b/Engine/src/Platform/OS/Linux/lWindow.cpp @@ -1,11 +1,11 @@ -#include "lWindow.h" +#include "lWindow.hpp" -#include "Events/CharEvent.h" -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Events/WindowEvents.h" -#include "Graphics/GraphicsContext.h" +#include "Events/CharEvent.hpp" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Events/WindowEvents.hpp" +#include "Graphics/GraphicsContext.hpp" #include diff --git a/Engine/src/Platform/OS/Linux/lWindow.h b/Engine/src/Platform/OS/Linux/lWindow.h deleted file mode 100644 index c31f972..0000000 --- a/Engine/src/Platform/OS/Linux/lWindow.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "Core/Window.h" - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class Event; - class WindowResizedEvent; - - class lWindow : public Window - { - private: - GLFWwindow* m_Handle; - - std::function m_EventCallback; - - public: - lWindow(std::function callback); - ~lWindow(); - - /* events */ - void PollEvents() override; - void OnEvent(const Event& event) override; - - //======================================== SETTERS ========================================// - void SetProperties(const WindowProperties& properties, bool overrideVisibility = false) override; - - void SetTitle(const std::string& title) override; - - void SetSize(const glm::uvec2& size, bool additive = false) override; - - void SetVSync(bool vsync, bool toggle = false) override; - void SetVisibility(bool visible, bool toggle = false) override; - //======================================== SETTERS ========================================// - - private: - void OnWindowResize(const WindowResizedEvent& event); - - void BindGlfwEvents(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/OS/Linux/lWindow.hpp b/Engine/src/Platform/OS/Linux/lWindow.hpp new file mode 100644 index 0000000..008e735 --- /dev/null +++ b/Engine/src/Platform/OS/Linux/lWindow.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Core/Window.hpp" + +struct GLFWwindow; + +namespace Light { + +class Event; +class WindowResizedEvent; + +class lWindow: public Window +{ +private: + GLFWwindow* m_Handle; + + std::function m_EventCallback; + +public: + lWindow(std::function callback); + ~lWindow(); + + /* events */ + void PollEvents() override; + void OnEvent(const Event& event) override; + + //======================================== SETTERS ========================================// + void SetProperties(const WindowProperties& properties, bool overrideVisibility = false) override; + + void SetTitle(const std::string& title) override; + + void SetSize(const glm::uvec2& size, bool additive = false) override; + + void SetVSync(bool vsync, bool toggle = false) override; + void SetVisibility(bool visible, bool toggle = false) override; + //======================================== SETTERS ========================================// + +private: + void OnWindowResize(const WindowResizedEvent& event); + + void BindGlfwEvents(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/Platform/OS/Windows/wWindow.cpp b/Engine/src/Platform/OS/Windows/wWindow.cpp index 6a4cc53..5366103 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.cpp +++ b/Engine/src/Platform/OS/Windows/wWindow.cpp @@ -1,11 +1,11 @@ -#include "wWindow.h" +#include "wWindow.hpp" -#include "Events/CharEvent.h" -#include "Events/Event.h" -#include "Events/KeyboardEvents.h" -#include "Events/MouseEvents.h" -#include "Events/WindowEvents.h" -#include "Graphics/GraphicsContext.h" +#include "Events/CharEvent.hpp" +#include "Events/Event.hpp" +#include "Events/KeyboardEvents.hpp" +#include "Events/MouseEvents.hpp" +#include "Events/WindowEvents.hpp" +#include "Graphics/GraphicsContext.hpp" #include diff --git a/Engine/src/Platform/OS/Windows/wWindow.h b/Engine/src/Platform/OS/Windows/wWindow.h deleted file mode 100644 index be9adf6..0000000 --- a/Engine/src/Platform/OS/Windows/wWindow.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "Core/Window.h" - -#include "Base/Base.h" - -struct GLFWwindow; - -namespace Light { - - class Event; - class WindowResizedEvent; - - class wWindow : public Window - { - private: - GLFWwindow* m_Handle; - - std::function m_EventCallback; - - public: - wWindow(std::function callback); - ~wWindow(); - - /* events */ - void PollEvents() override; - void OnEvent(const Event& event) override; - - //======================================== SETTERS ========================================// - void SetProperties(const WindowProperties& properties, bool overrideVisibility = false) override; - - void SetTitle(const std::string& title) override; - - void SetSize(const glm::uvec2& size, bool additive = false) override; - - void SetVSync(bool vsync, bool toggle = false) override; - void SetVisibility(bool visible, bool toggle = false) override; - //======================================== SETTERS ========================================// - - private: - void OnWindowResize(const WindowResizedEvent& event); - - void BindGlfwEvents(); - }; - -} \ No newline at end of file diff --git a/Engine/src/Platform/OS/Windows/wWindow.hpp b/Engine/src/Platform/OS/Windows/wWindow.hpp new file mode 100644 index 0000000..f25941b --- /dev/null +++ b/Engine/src/Platform/OS/Windows/wWindow.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Core/Window.hpp" + +struct GLFWwindow; + +namespace Light { + +class Event; +class WindowResizedEvent; + +class wWindow: public Window +{ +private: + GLFWwindow* m_Handle; + + std::function m_EventCallback; + +public: + wWindow(std::function callback); + ~wWindow(); + + /* events */ + void PollEvents() override; + void OnEvent(const Event& event) override; + + //======================================== SETTERS ========================================// + void SetProperties(const WindowProperties& properties, bool overrideVisibility = false) override; + + void SetTitle(const std::string& title) override; + + void SetSize(const glm::uvec2& size, bool additive = false) override; + + void SetVSync(bool vsync, bool toggle = false) override; + void SetVisibility(bool visible, bool toggle = false) override; + //======================================== SETTERS ========================================// + +private: + void OnWindowResize(const WindowResizedEvent& event); + + void BindGlfwEvents(); +}; + +} // namespace Light \ No newline at end of file diff --git a/Engine/src/renameall.sh b/Engine/src/renameall.sh new file mode 100755 index 0000000..ccead89 --- /dev/null +++ b/Engine/src/renameall.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +for f in $(find `pwd` -name "*.cppE"); do + rm "${f}" +done diff --git a/Mirror/src/EditorLayer.cpp b/Mirror/src/EditorLayer.cpp index 455cd19..26db384 100644 --- a/Mirror/src/EditorLayer.cpp +++ b/Mirror/src/EditorLayer.cpp @@ -1,6 +1,6 @@ -#include "EditorLayer.h" +#include "EditorLayer.hpp" -#include "Utility/Serializer.h" +#include "Utility/Serializer.hpp" namespace Light { diff --git a/Mirror/src/EditorLayer.cpp~ b/Mirror/src/EditorLayer.cpp~ deleted file mode 100644 index 4d9163e..0000000 --- a/Mirror/src/EditorLayer.cpp~ +++ /dev/null @@ -1,102 +0,0 @@ -#include "EditorLayer.h" -#include "Utility/Serializer.h" - -namespace Light { - -EditorLayer::EditorLayer(const std::string& name, const std::vector& args) - : Layer(name), m_SceneDir(args.empty() ? "" : args[0]) -{ - m_Scene = CreateRef(); - - m_PropertiesPanel = CreateRef(); - m_SceneHierarchyPanel = CreateRef(m_Scene, m_PropertiesPanel); - m_ContentBrowserPanel = CreateRef(); - - m_Framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext()); - - if (m_SceneDir.empty()) - { - m_CameraEntity = m_Scene->CreateEntity("Camera"); - m_CameraEntity.AddComponent(SceneCamera(), true); - - ResourceManager::LoadTexture("Awesomeface", "Assets/Textures/awesomeface.png"); - Entity entity = m_Scene->CreateEntity("Awesomeface", {}); - entity.AddComponent(ResourceManager::GetTexture("Awesomeface"), glm::vec4 { 0.0f, 1.0f, 1.0f, 1.0f }); - } - else - { - SceneSerializer serializer(m_Scene); - ASSERT(serializer.Deserialize(m_SceneDir), "EditorLayer::EditorLayer: failed to de-serialize: ", m_SceneDir); - - m_CameraEntity = m_Scene->GetEntityByTag("Game Camera"); - } -} - -EditorLayer::~EditorLayer() -{ - if (!m_SceneDir.empty()) - { - SceneSerializer serializer(m_Scene); - serializer.Serialize(m_SceneDir); - } -} - -void EditorLayer::OnUpdate(float deltaTime) -{ - m_Scene->OnUpdate(deltaTime); - - m_Direction.x = Input::GetKeyboardKey(Key::A) ? -1.0f : - Input::GetKeyboardKey(Key::D) ? 1.0f : - 0.0f; - - m_Direction.y = Input::GetKeyboardKey(Key::S) ? -1.0f : - Input::GetKeyboardKey(Key::W) ? 1.0f : - 0.0f; - - auto& cameraTranslation = m_CameraEntity.GetComponent().translation; - cameraTranslation += glm::vec3(m_Direction * m_Speed * deltaTime, 0.0f); - - if (Input::GetKeyboardKey(Key::Escape)) - Application::Quit(); -} - -void EditorLayer::OnRender() -{ - m_Scene->OnRender(m_Framebuffer); -} - -void EditorLayer::OnUserInterfaceUpdate() -{ - UserInterface::DockspaceBegin(); - ImGui::ShowDemoWindow(); - - if (ImGui::Begin("Game")) - { - Input::ReceiveGameEvents(ImGui::IsWindowFocused()); - ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - - if (m_AvailableContentRegionPrev != regionAvail) - { - m_Framebuffer->Resize({ regionAvail.x, regionAvail.y }); - auto& camera = m_CameraEntity.GetComponent().camera; - camera.SetViewportSize(regionAvail.x, regionAvail.y); - - m_AvailableContentRegionPrev = regionAvail; - } - - if (GraphicsContext::GetGraphicsAPI() == GraphicsAPI::DirectX) - ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail); - else - ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - } - ImGui::End(); - - // Panels - m_SceneHierarchyPanel->OnUserInterfaceUpdate(); - m_PropertiesPanel->OnUserInterfaceUpdate(); - m_ContentBrowserPanel->OnUserInterfaceUpdate(); - - UserInterface::DockspaceEnd(); -} - -} // namespace Light diff --git a/Mirror/src/EditorLayer.h b/Mirror/src/EditorLayer.hpp similarity index 83% rename from Mirror/src/EditorLayer.h rename to Mirror/src/EditorLayer.hpp index e00672b..e707c81 100644 --- a/Mirror/src/EditorLayer.h +++ b/Mirror/src/EditorLayer.hpp @@ -1,10 +1,10 @@ #pragma once -#include "Panels/ContentBrowser.h" -#include "Panels/PropertiesPanel.h" -#include "Panels/SceneHierarchyPanel.h" +#include "Panels/ContentBrowser.hpp" +#include "Panels/PropertiesPanel.hpp" +#include "Panels/SceneHierarchyPanel.hpp" -#include +#include #include namespace Light { diff --git a/Mirror/src/MirrorApp.cpp b/Mirror/src/MirrorApp.cpp index dbd10e2..4b05ef4 100644 --- a/Mirror/src/MirrorApp.cpp +++ b/Mirror/src/MirrorApp.cpp @@ -1,32 +1,32 @@ #define LIGHT_ENTRY_POINT -#include +#include "EditorLayer.hpp" -#include "EditorLayer.h" +#include namespace Light { - class Mirror : public Light::Application +class Mirror: public Light::Application +{ +public: + Mirror(std::string execName, std::vector args) + : Application(execName, args) { - public: - Mirror(std::string execName, std::vector args) - : Application(execName, args) - { - // Set window properties - Light::WindowProperties properties; - properties.title = "Mirror"; - properties.size = glm::uvec2(1280u, 720u); - properties.vsync = true; + // Set window properties + Light::WindowProperties properties; + properties.title = "Mirror"; + properties.size = glm::uvec2(1280u, 720u); + properties.vsync = true; - m_Window->SetProperties(properties); + m_Window->SetProperties(properties); - // Attach the sandbox layer - LayerStack::EmplaceLayer(("MirrorLayer"), args); - } - }; - - Application* CreateApplication(std::string execName, std::vector args) - { - return new Mirror(execName, args); + // Attach the sandbox layer + LayerStack::EmplaceLayer(("MirrorLayer"), args); } +}; +Application* CreateApplication(std::string execName, std::vector args) +{ + return new Mirror(execName, args); } + +} // namespace Light diff --git a/Mirror/src/Panels/ContentBrowser.cpp b/Mirror/src/Panels/ContentBrowser.cpp index 364621d..f2acae2 100644 --- a/Mirror/src/Panels/ContentBrowser.cpp +++ b/Mirror/src/Panels/ContentBrowser.cpp @@ -1,6 +1,6 @@ -#include "ContentBrowser.h" +#include "ContentBrowser.hpp" -#include +#include #include namespace Light { diff --git a/Mirror/src/Panels/ContentBrowser.h b/Mirror/src/Panels/ContentBrowser.hpp similarity index 91% rename from Mirror/src/Panels/ContentBrowser.h rename to Mirror/src/Panels/ContentBrowser.hpp index dd469a4..40c6913 100644 --- a/Mirror/src/Panels/ContentBrowser.h +++ b/Mirror/src/Panels/ContentBrowser.hpp @@ -1,8 +1,8 @@ #pragma once -#include "Panel.h" +#include "Panel.hpp" -#include +#include #include namespace Light { diff --git a/Mirror/src/Panels/Panel.h b/Mirror/src/Panels/Panel.hpp similarity index 100% rename from Mirror/src/Panels/Panel.h rename to Mirror/src/Panels/Panel.hpp diff --git a/Mirror/src/Panels/PropertiesPanel.cpp b/Mirror/src/Panels/PropertiesPanel.cpp index 939e899..ca19346 100644 --- a/Mirror/src/Panels/PropertiesPanel.cpp +++ b/Mirror/src/Panels/PropertiesPanel.cpp @@ -1,7 +1,7 @@ -#include "PropertiesPanel.h" +#include "PropertiesPanel.hpp" -#include "Scene/Components.h" -#include "Utility/ResourceManager.h" +#include "Scene/Components.hpp" +#include "Utility/ResourceManager.hpp" #include #include diff --git a/Mirror/src/Panels/PropertiesPanel.h b/Mirror/src/Panels/PropertiesPanel.hpp similarity index 91% rename from Mirror/src/Panels/PropertiesPanel.h rename to Mirror/src/Panels/PropertiesPanel.hpp index cc45cd8..7e3017b 100644 --- a/Mirror/src/Panels/PropertiesPanel.h +++ b/Mirror/src/Panels/PropertiesPanel.hpp @@ -1,7 +1,7 @@ #pragma once -#include "Panel.h" -#include "Scene/Entity.h" +#include "Panel.hpp" +#include "Scene/Entity.hpp" namespace Light { diff --git a/Mirror/src/Panels/SceneHierarchyPanel.cpp b/Mirror/src/Panels/SceneHierarchyPanel.cpp index ad99999..3661fc5 100644 --- a/Mirror/src/Panels/SceneHierarchyPanel.cpp +++ b/Mirror/src/Panels/SceneHierarchyPanel.cpp @@ -1,74 +1,67 @@ -#include "SceneHierarchyPanel.h" +#include "SceneHierarchyPanel.hpp" -#include "PropertiesPanel.h" - -#include "Scene/Components.h" +#include "PropertiesPanel.hpp" +#include "Scene/Components.hpp" #include - #include namespace Light { - SceneHierarchyPanel::SceneHierarchyPanel() - : m_Context(nullptr), - m_PropertiesPanelContext(nullptr), - m_SelectionContext() +SceneHierarchyPanel::SceneHierarchyPanel() + : m_Context(nullptr), m_PropertiesPanelContext(nullptr), m_SelectionContext() +{ +} + +SceneHierarchyPanel::SceneHierarchyPanel(Ref context, Ref propertiesPanel /* = nullptr */) + : m_Context(context), m_PropertiesPanelContext(propertiesPanel) +{ +} + +void SceneHierarchyPanel::OnUserInterfaceUpdate() +{ + if (m_Context) { + ImGui::Begin("Hierarchy"); + + m_Context->m_Registry.each([&](auto entityID) { + Entity entity(entityID, m_Context.get()); + const std::string& tag = entity.GetComponent(); + + DrawNode(entity, tag); + }); + + ImGui::End(); + } +} + +void SceneHierarchyPanel::SetContext(Ref context, Ref propertiesPanel /* = nullptr */) +{ + if (propertiesPanel) + m_PropertiesPanelContext = propertiesPanel; + + m_Context = context; +} + +void SceneHierarchyPanel::DrawNode(Entity entity, const std::string& label) +{ + ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL) | + ImGuiTreeNodeFlags_OpenOnArrow | + ImGuiTreeNodeFlags_SpanFullWidth; + + bool expanded = ImGui::TreeNodeEx((void*)(uint64_t)(uint32_t)(entity), flags, label.c_str()); + + if (ImGui::IsItemClicked()) + { + m_SelectionContext = entity; + m_PropertiesPanelContext->SetEntityContext(entity); } - SceneHierarchyPanel::SceneHierarchyPanel(Ref context, Ref propertiesPanel /* = nullptr */) - : m_Context(context), - m_PropertiesPanelContext(propertiesPanel) + if (expanded) { + ImGui::Text("TEST_OPENED_TREE!"); + ImGui::TreePop(); } +} - void SceneHierarchyPanel::OnUserInterfaceUpdate() - { - if(m_Context) - { - ImGui::Begin("Hierarchy"); - - m_Context->m_Registry. - each([&](auto entityID) - { - Entity entity(entityID, m_Context.get()); - const std::string& tag = entity.GetComponent(); - - DrawNode(entity, tag); - }); - - ImGui::End(); - } - } - - void SceneHierarchyPanel::SetContext(Ref context, Ref propertiesPanel /* = nullptr */) - { - if (propertiesPanel) - m_PropertiesPanelContext = propertiesPanel; - - m_Context = context; - } - - void SceneHierarchyPanel::DrawNode(Entity entity, const std::string& label) - { - ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL) | - ImGuiTreeNodeFlags_OpenOnArrow | - ImGuiTreeNodeFlags_SpanFullWidth ; - - bool expanded = ImGui::TreeNodeEx((void*)(uint64_t)(uint32_t)(entity), flags, label.c_str()); - - if (ImGui::IsItemClicked()) - { - m_SelectionContext = entity; - m_PropertiesPanelContext->SetEntityContext(entity); - } - - if(expanded) - { - ImGui::Text("TEST_OPENED_TREE!"); - ImGui::TreePop(); - } - } - -} \ No newline at end of file +} // namespace Light diff --git a/Mirror/src/Panels/SceneHierarchyPanel.h b/Mirror/src/Panels/SceneHierarchyPanel.h deleted file mode 100644 index 0674d52..0000000 --- a/Mirror/src/Panels/SceneHierarchyPanel.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "Panel.h" - -#include "Base/Base.h" - -#include "Scene/Entity.h" -#include "Scene/Scene.h" - -namespace Light { - - class PropertiesPanel; - - class SceneHierarchyPanel : public Panel - { - private: - Ref m_Context; - Ref m_PropertiesPanelContext; - Entity m_SelectionContext; - - public: - SceneHierarchyPanel(); - SceneHierarchyPanel(Ref context, Ref propertiesPanel = nullptr); - - void OnUserInterfaceUpdate(); - - void SetContext(Ref context, Ref propertiesPanel = nullptr); - - private: - void DrawNode(Entity entity, const std::string& label); - }; - -} \ No newline at end of file diff --git a/Mirror/src/Panels/SceneHierarchyPanel.hpp b/Mirror/src/Panels/SceneHierarchyPanel.hpp new file mode 100644 index 0000000..4e2a19a --- /dev/null +++ b/Mirror/src/Panels/SceneHierarchyPanel.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Base/Base.hpp" +#include "Panel.hpp" +#include "Scene/Entity.hpp" +#include "Scene/Scene.hpp" + +namespace Light { + +class PropertiesPanel; + +class SceneHierarchyPanel: public Panel +{ +private: + Ref m_Context; + Ref m_PropertiesPanelContext; + Entity m_SelectionContext; + +public: + SceneHierarchyPanel(); + SceneHierarchyPanel(Ref context, Ref propertiesPanel = nullptr); + + void OnUserInterfaceUpdate(); + + void SetContext(Ref context, Ref propertiesPanel = nullptr); + +private: + void DrawNode(Entity entity, const std::string& label); +}; + +} // namespace Light