diff --git a/Engine/src/Engine/Base.h b/Engine/src/Engine/Base.h index cc22097..b5b0037 100644 --- a/Engine/src/Engine/Base.h +++ b/Engine/src/Engine/Base.h @@ -1,14 +1,43 @@ #pragma once -#ifndef LOGGER_H - #include "Debug/Logger.h" -#endif - -#include "Debug/Exceptions.h" -#include "Utility/Stringifier.h" - #include +namespace Light { + + // Ref (Ref) + template + using Ref = std::shared_ptr; + + template + constexpr Ref CreateRef(Args&&... args) + { + return std::make_shared(std::forward(args)...); + } + + template + constexpr Ref MakeRef(T* rawPointer) + { + return std::shared_ptr(T); + } + + // Scope (std::unique_ptr) + template + using Scope = std::unique_ptr; + + template + constexpr std::unique_ptr CreateScope(Args&&... args) + { + return std::make_unique(std::forward(args)...); + } + + template + constexpr std::unique_ptr MakeScope(T* rawPointer) + { + return std::unique_ptr(rawPointer); + } + +} + // platform #define LT_WIN(x) // windows #define LT_LIN(x) // linux @@ -44,42 +73,6 @@ #define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedClientAssertion(__FILE__, __LINE__); } } #endif -namespace Light { - - // Ref (std::shared_ptr) - template - using Ref = std::shared_ptr; - - template - constexpr std::shared_ptr CreateRef(Args... args) - { - return std::make_shared(std::forward(args)...); - } - - template - constexpr std::shared_ptr MakeRef(T* rawPointer) - { - return std::shared_ptr(T); - } - - // Scope (std::unique_ptr) - template - using Scope = std::unique_ptr; - - template - constexpr std::unique_ptr CreateScope(Args... args) - { - return std::make_unique(std::forward(args)...); - } - - template - constexpr std::unique_ptr MakeScope(T* rawPointer) - { - return std::unique_ptr(rawPointer); - } - -} - ///*** [ PORTABLES ] ***/// //** PORTABLE_DEBUG_BREAK **// // copied from: https://github.com/nemequ/portable-snippets/tree/master/debug-trap @@ -157,3 +150,11 @@ namespace Light { //** PORTABLE_DEBUG_BREAK **// ///*** [ PORTABLES ] ***/// + +#ifndef LT_LOGGER_H +#include "Debug/Logger.h" +#define LT_LOGGER_H +#endif + +#include "Debug/Exceptions.h" +#include "Utility/Stringifier.h" \ No newline at end of file diff --git a/Engine/src/Engine/Core/Application.cpp b/Engine/src/Engine/Core/Application.cpp index 786e873..19e5fa2 100644 --- a/Engine/src/Engine/Core/Application.cpp +++ b/Engine/src/Engine/Core/Application.cpp @@ -22,10 +22,12 @@ namespace Light { Application::Application() { Logger::Initialize(); - m_Instrumentor = std::unique_ptr(Instrumentor::Create()); + m_Instrumentor = Instrumentor::Create(); + m_LayerStack = LayerStack::Create(); + m_Input = Input::Create(); m_Instrumentor->BeginSession("Logs/ProfileResults_Startup.json"); - m_Window = std::unique_ptr(Light::Window::Create(std::bind(&Light::Application::OnEvent, this, std::placeholders::_1))); + m_Window = Window::Create(std::bind(&Application::OnEvent, this, std::placeholders::_1)); } Application::~Application() @@ -59,7 +61,7 @@ namespace Light { // update layers LT_PROFILE_SCOPE("GameLoop::Update"); - for (auto it = m_LayerStack.begin(); it != m_LayerStack.end(); it++) + for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) (*it)->OnUpdate(deltaTimer.GetDeltaTime()); } @@ -68,7 +70,7 @@ namespace Light { LT_PROFILE_SCOPE("GameLoop::Render"); m_Window->GetGfxContext()->GetRenderer()->BeginFrame(); - for (auto it = m_LayerStack.begin(); it != m_LayerStack.end(); it++) + for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) (*it)->OnRender(); m_Window->GetGfxContext()->GetRenderer()->EndFrame(); @@ -79,7 +81,7 @@ namespace Light { LT_PROFILE_SCOPE("GameLoop::UserInterface"); m_Window->GetGfxContext()->GetUserInterface()->Begin(); - for (auto it = m_LayerStack.begin(); it != m_LayerStack.end(); it++) + for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) (*it)->OnUserInterfaceUpdate(); m_Window->GetGfxContext()->GetUserInterface()->End(); @@ -112,14 +114,14 @@ namespace Light { // input if (event.HasCategory(InputEventCategory)) - m_Input.OnEvent(event); + m_Input->OnEvent(event); // layers // return if the event is an input event and 'Input' has disabled the game events - if (event.HasCategory(InputEventCategory) && !m_Input.IsReceivingGameEvents()) + if (event.HasCategory(InputEventCategory) && !m_Input->IsReceivingGameEvents()) return; - for (auto it = m_LayerStack.rbegin(); it != m_LayerStack.rend(); it++) + for (auto it = m_LayerStack->rbegin(); it != m_LayerStack->rend(); it++) if ((*it)->OnEvent(event)) return; } diff --git a/Engine/src/Engine/Core/Application.h b/Engine/src/Engine/Core/Application.h index 995585a..22dc91d 100644 --- a/Engine/src/Engine/Core/Application.h +++ b/Engine/src/Engine/Core/Application.h @@ -18,12 +18,12 @@ namespace Light { class Application { private: - std::unique_ptr m_Instrumentor = nullptr; - LayerStack m_LayerStack; - Input m_Input; + Scope m_Instrumentor = nullptr; + Scope m_LayerStack; + Scope m_Input; protected: - std::unique_ptr m_Window = nullptr; + Scope m_Window = nullptr; public: Application(const Application&) = delete; diff --git a/Engine/src/Engine/Core/Window.h b/Engine/src/Engine/Core/Window.h index 8816aca..8cfd3eb 100644 --- a/Engine/src/Engine/Core/Window.h +++ b/Engine/src/Engine/Core/Window.h @@ -19,12 +19,12 @@ namespace Light { class Window { protected: - std::unique_ptr m_GraphicsContext; + Scope m_GraphicsContext; WindowProperties m_Properties = {}; bool b_Closed = false; public: - static Window* Create(std::function callback); + static Scope Create(std::function callback); Window(const Window&) = delete; Window& operator=(const Window&) = delete; diff --git a/Engine/src/Engine/Debug/Instrumentor.cpp b/Engine/src/Engine/Debug/Instrumentor.cpp index 0006721..a3ba5eb 100644 --- a/Engine/src/Engine/Debug/Instrumentor.cpp +++ b/Engine/src/Engine/Debug/Instrumentor.cpp @@ -5,9 +5,9 @@ namespace Light { Instrumentor* Instrumentor::s_Context = nullptr; - Instrumentor* Instrumentor::Create() + Scope Instrumentor::Create() { - return new Instrumentor; + return MakeScope(new Instrumentor); } Instrumentor::Instrumentor() diff --git a/Engine/src/Engine/Debug/Instrumentor.h b/Engine/src/Engine/Debug/Instrumentor.h index 265674b..2943dd8 100644 --- a/Engine/src/Engine/Debug/Instrumentor.h +++ b/Engine/src/Engine/Debug/Instrumentor.h @@ -28,7 +28,7 @@ namespace Light { unsigned int m_CurrentSessionCount; public: - static Instrumentor* Create(); + static Scope Create(); static inline void BeginSession(const std::string& outputPath) { s_Context->BeginSessionImpl(outputPath); } static inline void EndSession() { s_Context->EndSessionImpl(); } diff --git a/Engine/src/Engine/Debug/Logger.cpp b/Engine/src/Engine/Debug/Logger.cpp index 57ccfbe..04095db 100644 --- a/Engine/src/Engine/Debug/Logger.cpp +++ b/Engine/src/Engine/Debug/Logger.cpp @@ -6,9 +6,9 @@ namespace Light { - std::shared_ptr Logger::s_EngineLogger = nullptr; - std::shared_ptr Logger::s_ClientLogger = nullptr; - std::shared_ptr Logger::s_FileLogger = nullptr; + Ref Logger::s_EngineLogger = nullptr; + Ref Logger::s_ClientLogger = nullptr; + Ref Logger::s_FileLogger = nullptr; std::string Logger::s_LogFilePath = LT_LOG_FILE_LOCATION; diff --git a/Engine/src/Engine/Debug/Logger.h b/Engine/src/Engine/Debug/Logger.h index f06d132..3517510 100644 --- a/Engine/src/Engine/Debug/Logger.h +++ b/Engine/src/Engine/Debug/Logger.h @@ -1,5 +1,6 @@ #pragma once +#define LT_LOGGER_H #include "Base.h" #include @@ -47,7 +48,7 @@ namespace Light { class Logger { private: - static std::shared_ptr s_EngineLogger, s_ClientLogger, s_FileLogger; + static Ref s_EngineLogger, s_ClientLogger, s_FileLogger; static std::string s_LogFilePath; public: @@ -55,11 +56,12 @@ namespace Light { static void Initialize(); - static inline std::shared_ptr GetEngineLogger() { return s_EngineLogger; } - static inline std::shared_ptr GetClientLogger() { return s_ClientLogger; } - static inline std::shared_ptr GetFileLogger() { return s_FileLogger; } + static inline Ref GetEngineLogger() { return s_EngineLogger; } + static inline Ref GetClientLogger() { return s_ClientLogger; } + static inline Ref GetFileLogger() { return s_FileLogger; } static void LogDebugData(); }; -} \ No newline at end of file +} + diff --git a/Engine/src/Engine/Graphics/Blender.cpp b/Engine/src/Engine/Graphics/Blender.cpp index b57c87b..16c242f 100644 --- a/Engine/src/Engine/Graphics/Blender.cpp +++ b/Engine/src/Engine/Graphics/Blender.cpp @@ -12,15 +12,15 @@ namespace Light { - Blender* Blender::Create(std::shared_ptr sharedContext) + Scope Blender::Create(Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glBlender(); + return CreateScope(); case GraphicsAPI::DirectX: LT_WIN( - return new dxBlender(std::static_pointer_cast(sharedContext));) + return CreateScope(std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "Blender::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/Blender.h b/Engine/src/Engine/Graphics/Blender.h index 6e548ee..d310485 100644 --- a/Engine/src/Engine/Graphics/Blender.h +++ b/Engine/src/Engine/Graphics/Blender.h @@ -38,7 +38,7 @@ namespace Light { private: public: - static Blender* Create(std::shared_ptr sharedContext); + static Scope Create(Ref sharedContext); virtual void Enable(BlendFactor srcFactor, BlendFactor dstFactor) = 0; virtual void Disable() = 0; diff --git a/Engine/src/Engine/Graphics/Buffers.cpp b/Engine/src/Engine/Graphics/Buffers.cpp index b6017bd..cd59060 100644 --- a/Engine/src/Engine/Graphics/Buffers.cpp +++ b/Engine/src/Engine/Graphics/Buffers.cpp @@ -14,32 +14,32 @@ namespace Light { //* CONSTANT_BUFFER *// - ConstantBuffer* ConstantBuffer::Create(ConstantBufferIndex index, unsigned int size, std::shared_ptr sharedContext) + Scope ConstantBuffer::Create(ConstantBufferIndex index, unsigned int size, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glConstantBuffer(index, size); + return CreateScope(index, size); case GraphicsAPI::DirectX: LT_WIN( - return new dxConstantBuffer(index, size, std::static_pointer_cast(sharedContext));) + return CreateScope(index, size, std::static_pointer_cast(sharedContext));) default: - LT_ENGINE_ASSERT(false, "VertexBuffer::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); + LT_ENGINE_ASSERT(false, "ConstantBuffer::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); return nullptr; } } //* VERTEX_BUFFER *// - VertexBuffer* VertexBuffer::Create(float* vertices, unsigned int stride, unsigned int count, std::shared_ptr sharedContext) + Ref VertexBuffer::Create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glVertexBuffer(vertices, count); + return CreateRef(vertices, count); case GraphicsAPI::DirectX: LT_WIN( - return new dxVertexBuffer(vertices, stride, count, std::static_pointer_cast(sharedContext));) + return CreateRef(vertices, stride, count, std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "VertexBuffer::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); @@ -48,15 +48,15 @@ namespace Light { } //* INDEX_BUFFER *// - IndexBuffer* IndexBuffer::Create(unsigned int* indices, unsigned int count, std::shared_ptr sharedContext) + Ref IndexBuffer::Create(unsigned int* indices, unsigned int count, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glIndexBuffer(indices, count); + return CreateRef(indices, count); case GraphicsAPI::DirectX: LT_WIN( - return new dxIndexBuffer(indices, count, std::dynamic_pointer_cast(sharedContext));) + return CreateRef(indices, count, std::dynamic_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "IndexBuffer::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/Buffers.h b/Engine/src/Engine/Graphics/Buffers.h index 8f56f1f..86e4c5c 100644 --- a/Engine/src/Engine/Graphics/Buffers.h +++ b/Engine/src/Engine/Graphics/Buffers.h @@ -15,19 +15,22 @@ namespace Light { class ConstantBuffer { public: - static ConstantBuffer* Create(ConstantBufferIndex index, unsigned int size, std::shared_ptr sharedContext); + static Scope Create(ConstantBufferIndex index, unsigned int size, Ref sharedContext); virtual void Bind() = 0; virtual void* Map() = 0; virtual void UnMap() = 0; + + protected: + ConstantBuffer() = default; }; //* VERTEX_BUFFER *// class VertexBuffer { public: - static VertexBuffer* Create(float* vertices, unsigned int stride, unsigned int count, std::shared_ptr sharedContext); + static Ref Create(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); virtual ~VertexBuffer() = default; @@ -45,7 +48,7 @@ namespace Light { class IndexBuffer { public: - static IndexBuffer* Create(unsigned int* indices, unsigned int count, std::shared_ptr sharedContext); + static Ref Create(unsigned int* indices, unsigned int count, Ref sharedContext); virtual ~IndexBuffer() = default; diff --git a/Engine/src/Engine/Graphics/Framebuffer.cpp b/Engine/src/Engine/Graphics/Framebuffer.cpp index f575235..b0848c7 100644 --- a/Engine/src/Engine/Graphics/Framebuffer.cpp +++ b/Engine/src/Engine/Graphics/Framebuffer.cpp @@ -11,15 +11,15 @@ namespace Light { - Framebuffer* Framebuffer::Create(const FramebufferSpecification& specification, std::shared_ptr sharedContext) + Ref Framebuffer::Create(const FramebufferSpecification& specification, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glFramebuffer(specification); + return CreateRef(specification); case GraphicsAPI::DirectX: LT_WIN( - return new dxFramebuffer(specification, std::static_pointer_cast(sharedContext));) + return CreateRef(specification, std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "Shader::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/Framebuffer.h b/Engine/src/Engine/Graphics/Framebuffer.h index 6868575..2ed9a1d 100644 --- a/Engine/src/Engine/Graphics/Framebuffer.h +++ b/Engine/src/Engine/Graphics/Framebuffer.h @@ -21,7 +21,7 @@ namespace Light { class Framebuffer { public: - static Framebuffer* Create(const FramebufferSpecification& specification, std::shared_ptr sharedContext); + static Ref Create(const FramebufferSpecification& specification, Ref sharedContext); virtual void* GetColorAttachment() = 0; diff --git a/Engine/src/Engine/Graphics/GraphicsContext.cpp b/Engine/src/Engine/Graphics/GraphicsContext.cpp index e867b2b..ad671dc 100644 --- a/Engine/src/Engine/Graphics/GraphicsContext.cpp +++ b/Engine/src/Engine/Graphics/GraphicsContext.cpp @@ -17,9 +17,9 @@ namespace Light { GraphicsContext* GraphicsContext::s_Context = nullptr; - GraphicsContext::~GraphicsContext() { } + GraphicsContext::~GraphicsContext() {} - GraphicsContext* GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle) + Scope GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle) { // terminate 'GraphicsContext' dependent classes if (s_Context) @@ -43,14 +43,17 @@ namespace Light { } // create gfx context + Scope scopeGfx; switch (api) { case GraphicsAPI::OpenGL: - s_Context = new glGraphicsContext(windowHandle); + scopeGfx = CreateScope(windowHandle); + s_Context = scopeGfx.get(); break; case GraphicsAPI::DirectX: LT_WIN( - s_Context = new dxGraphicsContext(windowHandle); + scopeGfx = CreateScope(windowHandle); + s_Context = scopeGfx.get(); break;) default: @@ -59,16 +62,16 @@ namespace Light { } // create 'GraphicsContext' dependent classes - s_Context->m_ResourceManager = std::unique_ptr(ResourceManager::Create(s_Context->m_SharedContext)); - s_Context->m_UserInterface = std::unique_ptr(UserInterface::Create(windowHandle, s_Context->m_SharedContext)); - s_Context->m_Renderer = std::unique_ptr(Renderer::Create(windowHandle, s_Context->m_SharedContext)); + s_Context->m_ResourceManager = ResourceManager::Create(s_Context->m_SharedContext); + s_Context->m_UserInterface = UserInterface::Create(windowHandle, s_Context->m_SharedContext); + s_Context->m_Renderer = Renderer::Create(windowHandle, s_Context->m_SharedContext); // check LT_ENGINE_ASSERT(s_Context->m_ResourceManager, "GraphicsContext::Create: failed to create ResourceManager"); LT_ENGINE_ASSERT(s_Context->m_UserInterface, "GraphicsContext::Create: failed to create UserInterface"); LT_ENGINE_ASSERT(s_Context->m_Renderer, "GraphicsContext::Create: failed to create Renderer"); - return s_Context; + return std::move(scopeGfx); } } \ No newline at end of file diff --git a/Engine/src/Engine/Graphics/GraphicsContext.h b/Engine/src/Engine/Graphics/GraphicsContext.h index 1385533..6a5d1ef 100644 --- a/Engine/src/Engine/Graphics/GraphicsContext.h +++ b/Engine/src/Engine/Graphics/GraphicsContext.h @@ -28,16 +28,16 @@ namespace Light { private: static GraphicsContext* s_Context; - std::unique_ptr m_ResourceManager; - std::unique_ptr m_UserInterface; - std::unique_ptr m_Renderer; + Scope m_ResourceManager; + Scope m_UserInterface; + Scope m_Renderer; protected: GraphicsAPI m_GraphicsAPI; - std::shared_ptr m_SharedContext = nullptr; + Ref m_SharedContext = nullptr; public: - static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle); + static Scope Create(GraphicsAPI api, GLFWwindow* windowHandle); GraphicsContext(const GraphicsContext&) = delete; GraphicsContext& operator=(const GraphicsContext&) = delete; @@ -47,15 +47,13 @@ namespace Light { virtual void LogDebugData() = 0; static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; } - static inline std::shared_ptr GetSharedContext() { return s_Context->m_SharedContext; } + 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/RenderCommand.cpp b/Engine/src/Engine/Graphics/RenderCommand.cpp index 30718d6..e22fc81 100644 --- a/Engine/src/Engine/Graphics/RenderCommand.cpp +++ b/Engine/src/Engine/Graphics/RenderCommand.cpp @@ -11,15 +11,15 @@ namespace Light { - RenderCommand* RenderCommand::Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext) + Scope RenderCommand::Create(GLFWwindow* windowHandle, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glRenderCommand(windowHandle); + return CreateScope(windowHandle); case GraphicsAPI::DirectX: LT_WIN( - return new dxRenderCommand((std::static_pointer_cast)(sharedContext));) + return CreateScope((std::static_pointer_cast)(sharedContext));) default: LT_ENGINE_ASSERT(false, "RenderCommand::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/RenderCommand.h b/Engine/src/Engine/Graphics/RenderCommand.h index 473e408..34275bb 100644 --- a/Engine/src/Engine/Graphics/RenderCommand.h +++ b/Engine/src/Engine/Graphics/RenderCommand.h @@ -13,7 +13,7 @@ namespace Light { class RenderCommand { public: - static RenderCommand* Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext); + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); RenderCommand(const RenderCommand&) = delete; RenderCommand& operator=(const RenderCommand&) = delete; diff --git a/Engine/src/Engine/Graphics/Renderer.cpp b/Engine/src/Engine/Graphics/Renderer.cpp index 529dbd0..2208394 100644 --- a/Engine/src/Engine/Graphics/Renderer.cpp +++ b/Engine/src/Engine/Graphics/Renderer.cpp @@ -19,24 +19,24 @@ namespace Light { Renderer* Renderer::s_Context = nullptr; - Renderer::Renderer(GLFWwindow* windowHandle, std::shared_ptr sharedContext) + Renderer::Renderer(GLFWwindow* windowHandle, Ref sharedContext) : m_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext), m_TextureRenderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext) { LT_ENGINE_ASSERT(!s_Context, "Renderer::Renderer: an instance of 'Renderer' already exists, do not construct this class!"); s_Context = this; - m_RenderCommand = std::unique_ptr(RenderCommand::Create(windowHandle, sharedContext)); + m_RenderCommand = RenderCommand::Create(windowHandle, sharedContext); - m_ViewProjectionBuffer = std::unique_ptr(ConstantBuffer::Create(ConstantBufferIndex::ViewProjection, sizeof(glm::mat4), sharedContext)); + m_ViewProjectionBuffer = ConstantBuffer::Create(ConstantBufferIndex::ViewProjection, sizeof(glm::mat4), sharedContext); - m_Blender = std::unique_ptr(Blender::Create(sharedContext)); + m_Blender = Blender::Create(sharedContext); m_Blender->Enable(BlendFactor::SRC_ALPHA, BlendFactor::INVERSE_SRC_ALPHA); } - Renderer* Renderer::Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext) + Scope Renderer::Create(GLFWwindow* windowHandle, Ref sharedContext) { - return new Renderer(windowHandle, sharedContext); + return MakeScope(new Renderer(windowHandle, sharedContext)); } void Renderer::OnWindowResize(const WindowResizedEvent& event) @@ -78,7 +78,7 @@ namespace Light { } } - void Renderer::DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, std::shared_ptr texture) + void Renderer::DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, Ref texture) { // #todo: implement a proper binding texture->Bind(); @@ -125,7 +125,7 @@ namespace Light { m_RenderCommand->ClearBackBuffer(m_Camera->GetClearColor()); } - void Renderer::BeginSceneImpl(const std::shared_ptr& camera, const std::shared_ptr& targetFrameBuffer /* = nullptr */) + void Renderer::BeginSceneImpl(const Ref& camera, const Ref& targetFrameBuffer /* = nullptr */) { m_TargetFramebuffer = targetFrameBuffer; diff --git a/Engine/src/Engine/Graphics/Renderer.h b/Engine/src/Engine/Graphics/Renderer.h index ad102d5..3bfd16f 100644 --- a/Engine/src/Engine/Graphics/Renderer.h +++ b/Engine/src/Engine/Graphics/Renderer.h @@ -39,24 +39,24 @@ namespace Light { TextureRendererProgram m_TextureRenderer; // constant buffers - std::unique_ptr m_ViewProjectionBuffer; + Scope m_ViewProjectionBuffer; - std::unique_ptr m_RenderCommand; - std::unique_ptr m_Blender; + Scope m_RenderCommand; + Scope m_Blender; - std::shared_ptr m_TargetFramebuffer; + Ref m_TargetFramebuffer; - std::shared_ptr m_Camera; + Ref m_Camera; public: - static Renderer* Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext); + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); - static inline void SetTargetFramebuffer(std::shared_ptr framebuffer) { s_Context->SetTargetFramebufferImpl(framebuffer); } + static inline void SetTargetFramebuffer(Ref framebuffer) { s_Context->SetTargetFramebufferImpl(framebuffer); } 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, std::shared_ptr texture) { s_Context->DrawQuadImpl(position, size, texture); } + static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, Ref texture) { s_Context->DrawQuadImpl(position, size, texture); } - static inline void BeginScene(const std::shared_ptr& camera, const std::shared_ptr& targetFrameBuffer = nullptr) { s_Context->BeginSceneImpl(camera, targetFrameBuffer); } + static inline void BeginScene(const Ref& camera, const Ref& targetFrameBuffer = nullptr) { s_Context->BeginSceneImpl(camera, targetFrameBuffer); } static inline void EndScene() { s_Context->EndSceneImpl(); } void OnWindowResize(const WindowResizedEvent& event); @@ -65,14 +65,14 @@ namespace Light { void EndFrame(); private: - Renderer(GLFWwindow* windowHandle, std::shared_ptr sharedContext); + Renderer(GLFWwindow* windowHandle, Ref sharedContext); - void SetTargetFramebufferImpl(std::shared_ptr framebuffer); + void SetTargetFramebufferImpl(Ref framebuffer); void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint); - void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, std::shared_ptr texture); + void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, Ref texture); - void BeginSceneImpl(const std::shared_ptr& camera, const std::shared_ptr& targetFrameBuffer = nullptr); + void BeginSceneImpl(const Ref& camera, const Ref& targetFrameBuffer = nullptr); void FlushScene(); void EndSceneImpl(); }; diff --git a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp index 302e383..7a59afa 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp +++ b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.cpp @@ -11,15 +11,15 @@ namespace Light { - QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, std::shared_ptr sharedContext) + QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref sharedContext) : m_MaxVertices(maxVertices) { ResourceManager::LoadShader("LT_ENGINE_RESOURCES_QUAD_SHADER", "../Engine/res/Shaders/Quad/Quad_VS", "../Engine//res/Shaders/Quad/Quad_PS"); m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER"); - m_VertexBuffer = std::shared_ptr(VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)); - m_IndexBuffer = std::shared_ptr(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); - m_VertexLayout = std::shared_ptr(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float3 }, + m_VertexBuffer = Ref(VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)); + m_IndexBuffer = Ref(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); + m_VertexLayout = Ref(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float3 }, { "COLOR" , VertexElementType::Float4 }}, sharedContext)); } diff --git a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h index 01cf56e..e1534e7 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h +++ b/Engine/src/Engine/Graphics/RendererPrograms/QuadRendererProgram.h @@ -26,10 +26,10 @@ namespace Light { }; private: - std::shared_ptr m_Shader; - std::shared_ptr m_VertexBuffer; - std::shared_ptr m_IndexBuffer; - std::shared_ptr m_VertexLayout; + Ref m_Shader; + Ref m_VertexBuffer; + Ref m_IndexBuffer; + Ref m_VertexLayout; QuadVertexData* m_MapCurrent = nullptr; QuadVertexData* m_MapEnd = nullptr; @@ -38,7 +38,7 @@ namespace Light { unsigned int m_MaxVertices = 0u; public: - QuadRendererProgram(unsigned int maxVertices, std::shared_ptr sharedContext); + QuadRendererProgram(unsigned int maxVertices, Ref sharedContext); bool Advance(); diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp index 6de25ca..3c420d9 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp +++ b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.cpp @@ -11,15 +11,15 @@ namespace Light { - TextureRendererProgram::TextureRendererProgram(unsigned int maxVertices, std::shared_ptr sharedContext) + TextureRendererProgram::TextureRendererProgram(unsigned int maxVertices, Ref sharedContext) : m_MaxVertices(maxVertices) { ResourceManager::LoadShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER", "../Engine/res/Shaders/Texture/Texture_VS", "../Engine/res/Shaders/Texture/Texture_PS"); m_Shader = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER"); - m_VertexBuffer = std::shared_ptr(VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)); - m_IndexBuffer = std::shared_ptr(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); - m_VertexLayout = std::shared_ptr(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float3 }, + m_VertexBuffer = Ref(VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)); + m_IndexBuffer = Ref(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); + m_VertexLayout = Ref(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float3 }, { "TEXCOORD", VertexElementType::Float2 }}, sharedContext)); } diff --git a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h index 358a89a..490997d 100644 --- a/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h +++ b/Engine/src/Engine/Graphics/RendererPrograms/TextureRendererProgram.h @@ -26,10 +26,10 @@ namespace Light { }; private: - std::shared_ptr m_Shader; - std::shared_ptr m_VertexBuffer; - std::shared_ptr m_IndexBuffer; - std::shared_ptr m_VertexLayout; + Ref m_Shader; + Ref m_VertexBuffer; + Ref m_IndexBuffer; + Ref m_VertexLayout; TextureVertexData* m_MapCurrent = nullptr; TextureVertexData* m_MapEnd = nullptr; @@ -38,7 +38,7 @@ namespace Light { unsigned int m_MaxVertices = 0u; public: - TextureRendererProgram(unsigned int maxVertices, std::shared_ptr sharedContext); + TextureRendererProgram(unsigned int maxVertices, Ref sharedContext); bool Advance(); diff --git a/Engine/src/Engine/Graphics/Shader.cpp b/Engine/src/Engine/Graphics/Shader.cpp index 1825b30..cd25b64 100644 --- a/Engine/src/Engine/Graphics/Shader.cpp +++ b/Engine/src/Engine/Graphics/Shader.cpp @@ -11,16 +11,16 @@ namespace Light { - Shader* Shader::Create(const std::string& vertexSource, const std::string& pixelSource, std::shared_ptr sharedContext) + Ref Shader::Create(const std::string& vertexSource, const std::string& pixelSource, Ref sharedContext) { // load shader source switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glShader(vertexSource, pixelSource); + return CreateRef(vertexSource, pixelSource); case GraphicsAPI::DirectX: LT_WIN( - return new dxShader(vertexSource, pixelSource, std::static_pointer_cast(sharedContext));) + return CreateRef(vertexSource, pixelSource, std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "Shader::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/Shader.h b/Engine/src/Engine/Graphics/Shader.h index 38c4d36..e2a07db 100644 --- a/Engine/src/Engine/Graphics/Shader.h +++ b/Engine/src/Engine/Graphics/Shader.h @@ -11,14 +11,13 @@ namespace Light { class Shader { public: - static Shader* Create(const std::string& vertexPath, const std::string& pixelPath, std::shared_ptr sharedContext); + static Ref Create(const std::string& vertexPath, const std::string& pixelPath, Ref sharedContext); virtual ~Shader() = default; virtual void Bind() = 0; virtual void UnBind() = 0; - //** #TEMP_SHADER_UNIFORMS_TEMP# **// virtual void SetUniformMat4(const std::string& name, const glm::mat4& value) = 0; diff --git a/Engine/src/Engine/Graphics/Texture.cpp b/Engine/src/Engine/Graphics/Texture.cpp index 6c2c217..015f830 100644 --- a/Engine/src/Engine/Graphics/Texture.cpp +++ b/Engine/src/Engine/Graphics/Texture.cpp @@ -11,15 +11,15 @@ namespace Light { - Texture* Texture::Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, std::shared_ptr sharedContext) + RefTexture::Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glTexture(width, height, components, pixels); + return CreateRef(width, height, components, pixels); case GraphicsAPI::DirectX: LT_WIN( - return new dxTexture(width, height, components, pixels, std::static_pointer_cast(sharedContext));) + return CreateRef(width, height, components, pixels, std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "Texture::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/Texture.h b/Engine/src/Engine/Graphics/Texture.h index 34b0826..65664cd 100644 --- a/Engine/src/Engine/Graphics/Texture.h +++ b/Engine/src/Engine/Graphics/Texture.h @@ -10,7 +10,7 @@ namespace Light { class Texture { public: - static Texture* Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, std::shared_ptr sharedContext); + static Ref Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext); Texture(const Texture&) = delete; Texture& operator=(const Texture&) = delete; diff --git a/Engine/src/Engine/Graphics/VertexLayout.cpp b/Engine/src/Engine/Graphics/VertexLayout.cpp index 6c06152..8d82dff 100644 --- a/Engine/src/Engine/Graphics/VertexLayout.cpp +++ b/Engine/src/Engine/Graphics/VertexLayout.cpp @@ -11,15 +11,15 @@ namespace Light { - VertexLayout* VertexLayout::Create(std::shared_ptr vertexBuffer, std::shared_ptr shader, const std::vector>& elements, std::shared_ptr sharedContext) + Ref VertexLayout::Create(Ref vertexBuffer, Ref shader, const std::vector>& elements, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glVertexLayout(vertexBuffer, elements); + return CreateRef(vertexBuffer, elements); case GraphicsAPI::DirectX: LT_WIN( - return new dxVertexLayout(shader, elements, std::static_pointer_cast(sharedContext));) + return CreateRef(shader, elements, std::static_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "VertexLayout::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/Graphics/VertexLayout.h b/Engine/src/Engine/Graphics/VertexLayout.h index 90ca231..5b13f24 100644 --- a/Engine/src/Engine/Graphics/VertexLayout.h +++ b/Engine/src/Engine/Graphics/VertexLayout.h @@ -20,7 +20,7 @@ namespace Light { class VertexLayout { public: - static VertexLayout* Create(std::shared_ptr vertexBuffer, std::shared_ptr shader, const std::vector>& elements, std::shared_ptr sharedContext); + static Ref Create(Ref vertexBuffer, Ref shader, const std::vector>& elements, Ref sharedContext); virtual ~VertexLayout() = default;; diff --git a/Engine/src/Engine/Input/Input.cpp b/Engine/src/Engine/Input/Input.cpp index 376312f..66f518a 100644 --- a/Engine/src/Engine/Input/Input.cpp +++ b/Engine/src/Engine/Input/Input.cpp @@ -11,6 +11,11 @@ namespace Light { Input* Input::s_Context = nullptr; + Scope Input::Create() + { + return MakeScope(new Input); + } + Input::Input() { LT_ENGINE_ASSERT(!s_Context, "Input::Input: an instance of 'Input' already exists, do not construct this class!"); diff --git a/Engine/src/Engine/Input/Input.h b/Engine/src/Engine/Input/Input.h index 43ef080..f9454a4 100644 --- a/Engine/src/Engine/Input/Input.h +++ b/Engine/src/Engine/Input/Input.h @@ -23,7 +23,7 @@ namespace Light { bool m_UserInterfaceEvents = true; bool m_GameEvents = true; public: - Input(); + 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); } @@ -39,6 +39,8 @@ namespace Light { inline bool IsReceivingGameEvents() const { return m_GameEvents; } private: + Input(); + void ReceiveUserInterfaceEventsImpl(bool receive, bool toggle = false); void ReceieveGameEventsImpl(bool receive, bool toggle = false); diff --git a/Engine/src/Engine/Layer/Layer.h b/Engine/src/Engine/Layer/Layer.h index a19d05c..2568da6 100644 --- a/Engine/src/Engine/Layer/Layer.h +++ b/Engine/src/Engine/Layer/Layer.h @@ -22,14 +22,14 @@ namespace Light { class Layer { - private: - std::string m_Name; + protected: + std::string m_LayerName; public: - Layer(const std::string& name): m_Name(name) {} + Layer(const std::string& name): m_LayerName(name) {} virtual ~Layer() = default; - inline const std::string& GetName() const { return m_Name; } + inline const std::string& GetName() const { return m_LayerName; } //** UPDATES // virtual void OnUpdate(float deltaTime) {} diff --git a/Engine/src/Engine/Layer/LayerStack.cpp b/Engine/src/Engine/Layer/LayerStack.cpp index 628d161..5d1c384 100644 --- a/Engine/src/Engine/Layer/LayerStack.cpp +++ b/Engine/src/Engine/Layer/LayerStack.cpp @@ -12,6 +12,11 @@ namespace Light { LayerStack* LayerStack::s_Context = nullptr; + Scope LayerStack::Create() + { + return MakeScope(new LayerStack()); + } + LayerStack::LayerStack() { LT_ENGINE_ASSERT(!s_Context, "LayerStack::LayerStack: an instance of 'LayerStack' already exists, do not construct this class!") diff --git a/Engine/src/Engine/Layer/LayerStack.h b/Engine/src/Engine/Layer/LayerStack.h index 4c56df7..8a0d873 100644 --- a/Engine/src/Engine/Layer/LayerStack.h +++ b/Engine/src/Engine/Layer/LayerStack.h @@ -18,9 +18,14 @@ namespace Light { std::vector::iterator m_End; public: - LayerStack(); + static Scope Create(); + ~LayerStack(); + // #todo: should we keep this? + template + static inline void AttachLayer(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); } @@ -32,6 +37,8 @@ namespace Light { std::vector::reverse_iterator rend() { return m_Layers.rend(); } private: + LayerStack(); + void AttachLayerImpl(Layer* layer); void DetachLayerImpl(Layer* layer); }; diff --git a/Engine/src/Engine/Scene/Components.h b/Engine/src/Engine/Scene/Components.h index 338a8eb..f54ce85 100644 --- a/Engine/src/Engine/Scene/Components.h +++ b/Engine/src/Engine/Scene/Components.h @@ -8,6 +8,7 @@ namespace Light { class Texture; + // #todo: store a mat4 for transform struct TransformComponent { glm::vec2 position, size; @@ -24,13 +25,13 @@ namespace Light { struct SpriteRendererComponent { - std::shared_ptr texture; + Ref texture; SpriteRendererComponent() = default; SpriteRendererComponent(const SpriteRendererComponent&) = default; - SpriteRendererComponent(std::shared_ptr _texture) : texture(_texture) {} + SpriteRendererComponent(Ref _texture) : texture(_texture) {} - operator std::shared_ptr() { return texture; } + operator Ref() { return texture; } }; } \ No newline at end of file diff --git a/Engine/src/Engine/UserInterface/UserInterface.cpp b/Engine/src/Engine/UserInterface/UserInterface.cpp index 0af2a60..e1fde69 100644 --- a/Engine/src/Engine/UserInterface/UserInterface.cpp +++ b/Engine/src/Engine/UserInterface/UserInterface.cpp @@ -17,15 +17,15 @@ namespace Light { - UserInterface* UserInterface::Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext) + Scope UserInterface::Create(GLFWwindow* windowHandle, Ref sharedContext) { switch (GraphicsContext::GetGraphicsAPI()) { case GraphicsAPI::OpenGL: - return new glUserInterface(windowHandle); + return CreateScope(windowHandle); case GraphicsAPI::DirectX: LT_WIN( - return new dxUserInterface(windowHandle, std::dynamic_pointer_cast(sharedContext));) + return CreateScope(windowHandle, std::dynamic_pointer_cast(sharedContext));) default: LT_ENGINE_ASSERT(false, "UserInterface::Create: invalid/unsupported 'GraphicsAPI' {}", GraphicsContext::GetGraphicsAPI()); diff --git a/Engine/src/Engine/UserInterface/UserInterface.h b/Engine/src/Engine/UserInterface/UserInterface.h index a4669e3..f268a3f 100644 --- a/Engine/src/Engine/UserInterface/UserInterface.h +++ b/Engine/src/Engine/UserInterface/UserInterface.h @@ -12,7 +12,7 @@ namespace Light { class UserInterface { public: - static UserInterface* Create(GLFWwindow* windowHandle, std::shared_ptr sharedContext); + static Scope Create(GLFWwindow* windowHandle, Ref sharedContext); UserInterface(const UserInterface&) = delete; UserInterface& operator=(const UserInterface&) = delete; diff --git a/Engine/src/Engine/Utility/ResourceManager.cpp b/Engine/src/Engine/Utility/ResourceManager.cpp index 6200033..c02535f 100644 --- a/Engine/src/Engine/Utility/ResourceManager.cpp +++ b/Engine/src/Engine/Utility/ResourceManager.cpp @@ -11,12 +11,12 @@ namespace Light { ResourceManager* ResourceManager::s_Context = nullptr; - ResourceManager* ResourceManager::Create(std::shared_ptr sharedContext) + Scope ResourceManager::Create(Ref sharedContext) { - return new ResourceManager(sharedContext); + return MakeScope(new ResourceManager(sharedContext)); } - ResourceManager::ResourceManager(std::shared_ptr sharedContext) + ResourceManager::ResourceManager(Ref sharedContext) : m_SharedContext(sharedContext) { LT_ENGINE_ASSERT(!s_Context, "ResourceManager::ResourceManager: an instance of 'ResourceManager' already exists, do not construct this class!"); @@ -45,7 +45,7 @@ namespace Light { ResourceManager::ExtractShaderSource(psSource, delim); // create shader - m_Shaders[name] = std::shared_ptr(Shader::Create(vsSource, psSource, m_SharedContext)); + m_Shaders[name] = Ref(Shader::Create(vsSource, psSource, m_SharedContext)); } void ResourceManager::LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath) @@ -70,7 +70,7 @@ namespace Light { psSS << line << '\n'; // create shader - m_Shaders[name] = std::shared_ptr(Shader::Create(vsSS.str(), psSS.str(), m_SharedContext)); + m_Shaders[name] = Ref(Shader::Create(vsSS.str(), psSS.str(), m_SharedContext)); } void ResourceManager::LoadTextureImpl(const std::string& name, const std::string& path, unsigned int desiredComponents /* = 4u */) @@ -88,7 +88,7 @@ namespace Light { } // create texture - m_Textures[name] = std::shared_ptr(Texture::Create(width, height, components, pixels, m_SharedContext)); + m_Textures[name] = Ref(Texture::Create(width, height, components, pixels, m_SharedContext)); } void ResourceManager::ExtractShaderSource(std::string& src, const std::string& delim) diff --git a/Engine/src/Engine/Utility/ResourceManager.h b/Engine/src/Engine/Utility/ResourceManager.h index afa187c..243ea42 100644 --- a/Engine/src/Engine/Utility/ResourceManager.h +++ b/Engine/src/Engine/Utility/ResourceManager.h @@ -15,13 +15,13 @@ namespace Light { private: static ResourceManager* s_Context; - std::unordered_map> m_Shaders; - std::unordered_map> m_Textures; + std::unordered_map> m_Shaders; + std::unordered_map> m_Textures; - std::shared_ptr m_SharedContext; + Ref m_SharedContext; public: - static ResourceManager* Create(std::shared_ptr sharedContext); + static Scope Create(Ref sharedContext); // #todo: add geometry shader support static inline void CreateShader(const std::string& name, const std::string& vertexSource, const std::string& pixelSource) { s_Context->CreateShaderImpl(name, vertexSource, pixelSource); } @@ -29,11 +29,11 @@ namespace Light { static inline void LoadTexture(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u) { s_Context->LoadTextureImpl(name, path, desiredComponents); } - static inline std::shared_ptr GetShader(const std::string& name) { return s_Context->m_Shaders[name]; } - static inline std::shared_ptr GetTexture(const std::string& name) { return s_Context->m_Textures[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(std::shared_ptr sharedContext); + ResourceManager(Ref sharedContext); void CreateShaderImpl(const std::string& name, const std::string& vertexSource, const std::string& pixelSource); void LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath); diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp index ec77976..d4f494e 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.cpp @@ -5,7 +5,7 @@ namespace Light { - dxBlender::dxBlender(std::shared_ptr sharedContext) + dxBlender::dxBlender(Ref sharedContext) : m_Context(sharedContext) { // factor map diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h index c7d0e0d..4d07628 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBlender.h @@ -13,7 +13,7 @@ namespace Light { class dxBlender : public Blender { private: - std::shared_ptr m_Context; + Ref m_Context; std::unordered_map m_FactorMap; Microsoft::WRL::ComPtr m_BlendState; @@ -21,7 +21,7 @@ namespace Light { D3D11_BLEND_DESC m_Desc; public: - dxBlender(std::shared_ptr sharedContext); + dxBlender(Ref sharedContext); void Enable(BlendFactor srcFactor, BlendFactor dstFactor) override; void Disable() override; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp index 34f5686..5ba7493 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.cpp @@ -5,7 +5,7 @@ namespace Light { - dxConstantBuffer::dxConstantBuffer(ConstantBufferIndex index, unsigned int size, std::shared_ptr sharedContext) + dxConstantBuffer::dxConstantBuffer(ConstantBufferIndex index, unsigned int size, Ref sharedContext) : m_Context(sharedContext), m_Index((int)index) { D3D11_BUFFER_DESC bufferDesc = { }; @@ -38,7 +38,7 @@ namespace Light { } //* VERTEX_BUFFER *// - dxVertexBuffer::dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, std::shared_ptr sharedContext) + dxVertexBuffer::dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext) : m_Stride(stride), m_Context(sharedContext) { // buffer desc @@ -87,7 +87,7 @@ namespace Light { } //* INDEX_BUFFER *// - dxIndexBuffer::dxIndexBuffer(unsigned int* indices, unsigned int count, std::shared_ptr sharedContext) + dxIndexBuffer::dxIndexBuffer(unsigned int* indices, unsigned int count, Ref sharedContext) : m_Context(sharedContext) { // generate indices if not provided diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h index 989abfb..593c1a5 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxBuffers.h @@ -14,7 +14,7 @@ namespace Light { class dxConstantBuffer : public ConstantBuffer { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_Buffer; D3D11_MAPPED_SUBRESOURCE m_Map; @@ -22,7 +22,7 @@ namespace Light { unsigned int m_Index; public: - dxConstantBuffer(ConstantBufferIndex index, unsigned int size, std::shared_ptr sharedContext); + dxConstantBuffer(ConstantBufferIndex index, unsigned int size, Ref sharedContext); void Bind() override; @@ -34,7 +34,7 @@ namespace Light { class dxVertexBuffer : public VertexBuffer { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_Buffer; D3D11_MAPPED_SUBRESOURCE m_Map; @@ -42,7 +42,7 @@ namespace Light { unsigned int m_Stride; public: - dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, std::shared_ptr sharedContext); + dxVertexBuffer(float* vertices, unsigned int stride, unsigned int count, Ref sharedContext); ~dxVertexBuffer(); void* Map() override; @@ -56,12 +56,12 @@ namespace Light { class dxIndexBuffer : public IndexBuffer { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_Buffer; public: - dxIndexBuffer(unsigned int* indices, unsigned int count, std::shared_ptr sharedContext); + dxIndexBuffer(unsigned int* indices, unsigned int count, Ref sharedContext); ~dxIndexBuffer(); void Bind() override; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp index 71a4d06..0a9ed1a 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.cpp @@ -4,7 +4,7 @@ namespace Light { - dxFramebuffer::dxFramebuffer(const FramebufferSpecification& specification, std::shared_ptr sharedContext) + dxFramebuffer::dxFramebuffer(const FramebufferSpecification& specification, Ref sharedContext) : m_Specification(specification), m_Context(sharedContext) { HRESULT hr; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h index a8e2352..7ef5e87 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxFramebuffer.h @@ -13,7 +13,7 @@ namespace Light { class dxFramebuffer : public Framebuffer { private: - std::shared_ptr m_Context; + Ref m_Context; FramebufferSpecification m_Specification; @@ -24,7 +24,7 @@ namespace Light { Microsoft::WRL::ComPtr m_DepthStencilView; public: - dxFramebuffer(const FramebufferSpecification& specification, std::shared_ptr sharedContext); + dxFramebuffer(const FramebufferSpecification& specification, Ref sharedContext); inline void* GetColorAttachment() override { return (void*)m_ResourceView.Get(); } diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp index c51c59e..7a4277b 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp @@ -32,7 +32,7 @@ namespace Light { void dxGraphicsContext::SetupDeviceAndSwapChain(GLFWwindow* windowHandle) { - std::shared_ptr context = std::static_pointer_cast(m_SharedContext); + Ref context = std::static_pointer_cast(m_SharedContext); // swap chain desc DXGI_SWAP_CHAIN_DESC sd = { 0 }; @@ -87,7 +87,7 @@ namespace Light { void dxGraphicsContext::SetupRenderTargets() { - std::shared_ptr context = std::static_pointer_cast(m_SharedContext); + Ref context = std::static_pointer_cast(m_SharedContext); // set primitive topology context->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); @@ -106,7 +106,7 @@ namespace Light { void dxGraphicsContext::SetupDebugInterface() { #ifdef LIGHT_DEBUG - std::shared_ptr context = std::static_pointer_cast(m_SharedContext); + Ref context = std::static_pointer_cast(m_SharedContext); HRESULT hr; Microsoft::WRL::ComPtr debugInterface = nullptr; @@ -134,7 +134,7 @@ namespace Light { void dxGraphicsContext::LogDebugData() { - std::shared_ptr context = std::static_pointer_cast(m_SharedContext); + Ref context = std::static_pointer_cast(m_SharedContext); // locals IDXGIDevice* DXGIDevice; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp index 1c2c15d..12da7cc 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp @@ -4,7 +4,7 @@ namespace Light { - dxRenderCommand::dxRenderCommand(std::shared_ptr sharedContext) + dxRenderCommand::dxRenderCommand(Ref sharedContext) : m_Context(sharedContext) { } diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h index f0f2130..78800e5 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.h @@ -13,10 +13,10 @@ namespace Light { class dxRenderCommand : public RenderCommand { private: - std::shared_ptr m_Context; + Ref m_Context; public: - dxRenderCommand(std::shared_ptr sharedContext); + dxRenderCommand(Ref sharedContext); virtual void SwapBuffers() override; virtual void ClearBackBuffer(const glm::vec4& clearColor) override; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp index 1776666..2b77340 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.cpp @@ -6,7 +6,7 @@ namespace Light { - dxShader::dxShader(const std::string& vertexSource, const std::string& pixelSource, std::shared_ptr sharedContext) + dxShader::dxShader(const std::string& vertexSource, const std::string& pixelSource, Ref sharedContext) : m_Context(sharedContext) { Microsoft::WRL::ComPtr ps = nullptr, vsErr = nullptr, psErr = nullptr; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h index b8c93da..b7c915b 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxShader.h @@ -15,7 +15,7 @@ namespace Light { class dxShader : public Shader { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_VertexShader; Microsoft::WRL::ComPtr m_PixelShader; @@ -23,7 +23,7 @@ namespace Light { Microsoft::WRL::ComPtr m_VertexBlob; public: - dxShader(const std::string& vertexSource, const std::string& pixelSource, std::shared_ptr sharedContext); + dxShader(const std::string& vertexSource, const std::string& pixelSource, Ref sharedContext); ~dxShader(); void Bind() override; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp index c7840ff..ff34123 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.cpp @@ -4,7 +4,7 @@ namespace Light { - dxTexture::dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, std::shared_ptr sharedContext) + dxTexture::dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext) : m_Context(sharedContext) { // texture desc diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h index d49fb19..cdf954b 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxTexture.h @@ -13,14 +13,14 @@ namespace Light { class dxTexture : public Texture { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_Texture; Microsoft::WRL::ComPtr m_ResourceView; Microsoft::WRL::ComPtr m_SamplerState; public: - dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, std::shared_ptr sharedContext); + dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref sharedContext); void Bind(unsigned int slot = 0u) override; }; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp index ddb204b..3fcd04b 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.cpp @@ -12,7 +12,7 @@ namespace Light { - dxUserInterface::dxUserInterface(GLFWwindow* windowHandle, std::shared_ptr sharedContext) + dxUserInterface::dxUserInterface(GLFWwindow* windowHandle, Ref sharedContext) { // create context IMGUI_CHECKVERSION(); diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h index e69e27b..11c2476 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxUserInterface.h @@ -15,7 +15,7 @@ namespace Light { class dxUserInterface : public UserInterface { public: - dxUserInterface(GLFWwindow* windowHandle, std::shared_ptr sharedContext); + dxUserInterface(GLFWwindow* windowHandle, Ref sharedContext); ~dxUserInterface(); void Begin() override; diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp index d3badf4..63dc4ed 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.cpp @@ -6,7 +6,7 @@ namespace Light { - dxVertexLayout::dxVertexLayout(std::shared_ptr shader, const std::vector>& elements, std::shared_ptr sharedContext) + dxVertexLayout::dxVertexLayout(Ref shader, const std::vector>& elements, Ref sharedContext) : m_Context(sharedContext) { // occupy space for input elements @@ -26,7 +26,7 @@ namespace Light { 0u }); } - std::shared_ptr dxpShader = std::dynamic_pointer_cast(shader); + Ref dxpShader = std::dynamic_pointer_cast(shader); LT_ENGINE_ASSERT(dxpShader, "dxVertexLayout::dxVertexLayout: failed to cast 'Shader' to 'dxShader'"); // create input layout (vertex layout) diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h index fe28e5c..3ded273 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxVertexLayout.h @@ -14,12 +14,12 @@ namespace Light { class dxVertexLayout : public VertexLayout { private: - std::shared_ptr m_Context; + Ref m_Context; Microsoft::WRL::ComPtr m_InputLayout; public: - dxVertexLayout(std::shared_ptr shader, const std::vector>& elements, std::shared_ptr sharedContext); + dxVertexLayout(Ref shader, const std::vector>& elements, Ref sharedContext); ~dxVertexLayout(); void Bind() override; diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp index 576db51..6277904 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.cpp @@ -7,7 +7,7 @@ namespace Light { - glVertexLayout::glVertexLayout(std::shared_ptr buffer, const std::vector>& elements) + glVertexLayout::glVertexLayout(Ref buffer, const std::vector>& elements) { // check LT_ENGINE_ASSERT(std::dynamic_pointer_cast(buffer), "glVertexLayout::glVertexLayout: failed to cast 'VertexBuffer' to 'glVertexBuffer'"); diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h index 15f2c30..4d4f959 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glVertexLayout.h @@ -19,7 +19,7 @@ namespace Light { unsigned int m_ArrayID; public: - glVertexLayout(std::shared_ptr buffer, const std::vector>& elements); + glVertexLayout(Ref buffer, const std::vector>& elements); ~glVertexLayout(); void Bind() override; diff --git a/Engine/src/Platform/OS/Linux/lWindow.cpp b/Engine/src/Platform/OS/Linux/lWindow.cpp index 52ea6ec..b3518c7 100644 --- a/Engine/src/Platform/OS/Linux/lWindow.cpp +++ b/Engine/src/Platform/OS/Linux/lWindow.cpp @@ -12,9 +12,9 @@ namespace Light { - Window* Window::Create(std::function callback) + Scope Window::Create(std::function callback) { - return new lWindow(callback); + return CreateScope(callback); } lWindow::lWindow(std::function callback) @@ -37,7 +37,7 @@ namespace Light { BindGlfwEvents(); // create graphics contextG - m_GraphicsContext = std::unique_ptr(GraphicsContext::Create(GraphicsAPI::OpenGL, m_Handle)); + m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::OpenGL, m_Handle); LT_ENGINE_ASSERT(m_GraphicsContext, "lWindow::lWindow: failed to create 'GraphicsContext'"); } diff --git a/Engine/src/Platform/OS/Windows/wWindow.cpp b/Engine/src/Platform/OS/Windows/wWindow.cpp index 74cf5fb..77eb874 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.cpp +++ b/Engine/src/Platform/OS/Windows/wWindow.cpp @@ -12,9 +12,9 @@ namespace Light { - Window* Window::Create(std::function callback) + Scope Window::Create(std::function callback) { - return new wWindow(callback); + return CreateScope(callback); } wWindow::wWindow(std::function callback) @@ -37,7 +37,7 @@ namespace Light { BindGlfwEvents(); // create graphics context - m_GraphicsContext = std::unique_ptr(GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle)); + m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle); LT_ENGINE_ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'"); } diff --git a/Engine/src/Platform/OS/Windows/wWindow.h b/Engine/src/Platform/OS/Windows/wWindow.h index 5863116..57d8c93 100644 --- a/Engine/src/Platform/OS/Windows/wWindow.h +++ b/Engine/src/Platform/OS/Windows/wWindow.h @@ -13,7 +13,6 @@ namespace Light { class wWindow : public Window { private: - // #todo: don't handle Windows's window with glfw, create an HWND GLFWwindow* m_Handle = nullptr; std::function m_EventCallback; diff --git a/Mirror/src/MirrorApp.cpp b/Mirror/src/MirrorApp.cpp index 17a55ad..b5e4767 100644 --- a/Mirror/src/MirrorApp.cpp +++ b/Mirror/src/MirrorApp.cpp @@ -22,7 +22,7 @@ namespace Light { m_Window->SetProperties(properties); // Attach the sandbox layer - LayerStack::AttachLayer(new MirrorLayer("MirrorLayer")); + LayerStack::AttachLayer(("MirrorLayer")); } ~Mirror() diff --git a/Mirror/src/MirrorLayer.h b/Mirror/src/MirrorLayer.h index 3bf3e57..fe33618 100644 --- a/Mirror/src/MirrorLayer.h +++ b/Mirror/src/MirrorLayer.h @@ -13,9 +13,9 @@ namespace Light { glm::vec2 m_Direction; float m_Speed = 1000.0f; - std::shared_ptr m_Camera; + Ref m_Camera; - std::shared_ptr m_Framebuffer; + Ref m_Framebuffer; Scene m_Scene; diff --git a/Sandbox/src/SandboxLayer.h b/Sandbox/src/SandboxLayer.h index 642f2cd..21418b4 100644 --- a/Sandbox/src/SandboxLayer.h +++ b/Sandbox/src/SandboxLayer.h @@ -11,7 +11,7 @@ private: glm::vec2 m_Direction; float m_Speed = 1.2f; - std::shared_ptr m_Camera; + Light::Ref m_Camera; public: SandboxLayer(const std::string& name)