Maintenance
This commit is contained in:
parent
d4a9a0366f
commit
ab92d8abc2
33 changed files with 193 additions and 113 deletions
|
@ -50,7 +50,7 @@ project "Engine"
|
||||||
--- Filters ---
|
--- Filters ---
|
||||||
-- windows
|
-- windows
|
||||||
filter "system:windows"
|
filter "system:windows"
|
||||||
defines "LT_PLATFORM_WINDOWS"
|
defines "LIGHT_PLATFORM_WINDOWS"
|
||||||
systemversion "latest"
|
systemversion "latest"
|
||||||
staticruntime "On"
|
staticruntime "On"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "Core/Logger.h"
|
#include "Core/Logger.h"
|
||||||
|
|
||||||
#if defined(LT_PLATFORM_WINDOWS)
|
#if defined(LIGHT_PLATFORM_WINDOWS)
|
||||||
#define LT_BUILD_PLATFORM "Windows"
|
#define LT_BUILD_PLATFORM "Windows"
|
||||||
#elif defined(LT_PLATFORM_LINUX)
|
#elif defined(LT_PLATFORM_LINUX)
|
||||||
#error "Unsupported platform: UNIX"
|
#error "Unsupported platform: UNIX"
|
||||||
|
|
|
@ -4,49 +4,60 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
#include "Events/MouseEvents.h"
|
#include "Events/Event.h"
|
||||||
|
|
||||||
#include <typeinfo>
|
#include "Graphics/GraphicsContext.h"
|
||||||
#include <functional>
|
#include "Graphics/RenderCommand.h"
|
||||||
|
|
||||||
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
{
|
{
|
||||||
Logger::Initialize();
|
Logger::Initialize();
|
||||||
|
|
||||||
m_Window = std::unique_ptr<Window>(Window::Create({ "Title", 800u, 600u, false }, std::bind(&Application::OnEvent, this , std::placeholders::_1)));
|
m_Window = std::unique_ptr<Window>(Window::Create({ "Title", 800u, 600u, false }, std::bind(&Application::OnEvent, this , std::placeholders::_1)));
|
||||||
|
|
||||||
LT_ENGINE_INFO("Initialized Logger");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
|
LT_ENGINE_INFO("Application::~Application: Terminating Application");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::GameLoop()
|
void Application::GameLoop()
|
||||||
{
|
{
|
||||||
while (m_Window->IsOpen())
|
while (m_Window->IsOpen())
|
||||||
{
|
{
|
||||||
|
// Events
|
||||||
m_Window->PollEvents();
|
m_Window->PollEvents();
|
||||||
|
|
||||||
|
// Rendering
|
||||||
m_Window->GetGfxContext()->GetRenderCommand()->SwapBuffers();
|
m_Window->GetGfxContext()->GetRenderCommand()->SwapBuffers();
|
||||||
m_Window->GetGfxContext()->GetRenderCommand()->ClearBackBuffer();
|
m_Window->GetGfxContext()->GetRenderCommand()->ClearBackBuffer();
|
||||||
|
|
||||||
m_Window->GetGfxContext()->GetUserInterface()->Begin();
|
// Update
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// UserInterface
|
||||||
|
m_Window->GetGfxContext()->GetUserInterface()->Begin();
|
||||||
m_Window->GetGfxContext()->GetUserInterface()->End();
|
m_Window->GetGfxContext()->GetUserInterface()->End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::OnEvent(const Event& event)
|
void Application::OnEvent(const Event& event)
|
||||||
{
|
{
|
||||||
|
// Window
|
||||||
if (event.HasCategory(WindowEventCategory))
|
if (event.HasCategory(WindowEventCategory))
|
||||||
m_Window->OnEvent(event);
|
m_Window->OnEvent(event);
|
||||||
|
|
||||||
|
// UserInterface
|
||||||
if (event.HasCategory(InputEventCategory))
|
if (event.HasCategory(InputEventCategory))
|
||||||
m_Window->GetGfxContext()->GetUserInterface()->OnInput(event);
|
m_Window->GetGfxContext()->GetUserInterface()->OnInput(event);
|
||||||
|
|
||||||
|
// Input
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Layers
|
||||||
m_LayerStack.OnEvent(event);
|
m_LayerStack.OnEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,23 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Events/Event.h"
|
|
||||||
|
|
||||||
#include "Layer/LayerStack.h"
|
#include "Layer/LayerStack.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
|
class Event;
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Window> m_Window = nullptr;
|
std::unique_ptr<Window> m_Window = nullptr;
|
||||||
LayerStack m_LayerStack;
|
LayerStack m_LayerStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Application(const Application&) = delete;
|
||||||
|
Application& operator=(const Application&) = delete;
|
||||||
|
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
void GameLoop();
|
void GameLoop();
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
std::shared_ptr<spdlog::logger> Logger::s_EngineLogger;
|
std::shared_ptr<spdlog::logger> Logger::s_EngineLogger = nullptr;
|
||||||
std::shared_ptr<spdlog::logger> Logger::s_ClientLogger;
|
std::shared_ptr<spdlog::logger> Logger::s_ClientLogger = nullptr;
|
||||||
|
|
||||||
void Light::Logger::Initialize()
|
void Light::Logger::Initialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
// TODO: File logger
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
|
@ -40,7 +38,10 @@ namespace Light {
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static std::shared_ptr<spdlog::logger> s_EngineLogger, s_ClientLogger;
|
static std::shared_ptr<spdlog::logger> s_EngineLogger, s_ClientLogger;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Logger() = delete;
|
||||||
|
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
||||||
static inline std::shared_ptr<spdlog::logger> GetEngineLogger() { return s_EngineLogger; }
|
static inline std::shared_ptr<spdlog::logger> GetEngineLogger() { return s_EngineLogger; }
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Events/Event.h"
|
|
||||||
|
|
||||||
#include "Graphics/GraphicsContext.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class Event;
|
||||||
|
class GraphicsContext;
|
||||||
|
|
||||||
struct WindowProperties
|
struct WindowProperties
|
||||||
{
|
{
|
||||||
std::string title;
|
std::string title;
|
||||||
|
@ -22,7 +19,11 @@ namespace Light {
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<GraphicsContext> m_GraphicsContext;
|
std::unique_ptr<GraphicsContext> m_GraphicsContext;
|
||||||
bool b_Open;
|
bool b_Open;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Window(const Window&) = delete;
|
||||||
|
Window& operator=(const Window&) = delete;
|
||||||
|
|
||||||
virtual ~Window() = default;
|
virtual ~Window() = default;
|
||||||
|
|
||||||
inline GraphicsContext* GetGfxContext() { return m_GraphicsContext.get(); }
|
inline GraphicsContext* GetGfxContext() { return m_GraphicsContext.get(); }
|
||||||
|
@ -38,6 +39,9 @@ namespace Light {
|
||||||
virtual inline void* GetNativeHandle() = 0;
|
virtual inline void* GetNativeHandle() = 0;
|
||||||
|
|
||||||
static Window* Create(const WindowProperties& properties, std::function<void(Event&)> callback);
|
static Window* Create(const WindowProperties& properties, std::function<void(Event&)> callback);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Window() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef LT_PLATFORM_WINDOWS
|
#ifdef LIGHT_PLATFORM_WINDOWS
|
||||||
|
|
||||||
// To be defined in client project
|
// To be defined in client project
|
||||||
extern Light::Application* Light::CreateApplication();
|
extern Light::Application* Light::CreateApplication();
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
enum class EventType
|
enum class EventType
|
||||||
|
@ -13,8 +9,8 @@ namespace Light {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
// input
|
// input
|
||||||
MouseMoved, WheelScrolled, ButtonPressed, ButtonReleased, // mouse
|
MouseMoved, WheelScrolled, ButtonPressed, ButtonReleased,
|
||||||
KeyPressed, KeyReleased, // keyboard
|
KeyPressed, KeyReleased,
|
||||||
|
|
||||||
// window
|
// window
|
||||||
WindowMoved, WindowResized, WindowClosed, WindowLostFocus, WindowGainFocus,
|
WindowMoved, WindowResized, WindowClosed, WindowLostFocus, WindowGainFocus,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
|
@ -1,29 +1,45 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "GraphicsContext.h"
|
#include "GraphicsContext.h"
|
||||||
|
|
||||||
#include "OpenGL/glGraphicsContext.h"
|
#include "OpenGL/glGraphicsContext.h"
|
||||||
|
|
||||||
|
#include "RenderCommand.h"
|
||||||
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
GraphicsContext* GraphicsContext::s_Context = nullptr;
|
GraphicsContext* GraphicsContext::s_Context = nullptr;
|
||||||
|
|
||||||
GraphicsContext* GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle)
|
GraphicsContext* GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle)
|
||||||
{
|
{
|
||||||
|
// terminate gfx context dependent classes
|
||||||
|
if (s_Context)
|
||||||
|
{
|
||||||
|
s_Context->m_RenderCommand.reset();
|
||||||
|
s_Context->m_UserInterface.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// create gfx context
|
||||||
switch (api)
|
switch (api)
|
||||||
{
|
{
|
||||||
case Light::GraphicsAPI::Default:
|
case Light::GraphicsAPI::Default:
|
||||||
case Light::GraphicsAPI::OpenGL:
|
case Light::GraphicsAPI::OpenGL:
|
||||||
s_Context = new glGraphicsContext(windowHandle);
|
s_Context = new glGraphicsContext(windowHandle);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
// TODO: ASSERT
|
||||||
|
}
|
||||||
|
|
||||||
|
// create gfx context dependent classes
|
||||||
|
if (s_Context)
|
||||||
|
{
|
||||||
s_Context->m_RenderCommand = std::unique_ptr<RenderCommand>(RenderCommand::Create(windowHandle));
|
s_Context->m_RenderCommand = std::unique_ptr<RenderCommand>(RenderCommand::Create(windowHandle));
|
||||||
s_Context->m_UserInterface = std::unique_ptr<UserInterface>(UserInterface::Create(windowHandle));
|
s_Context->m_UserInterface = std::unique_ptr<UserInterface>(UserInterface::Create(windowHandle));
|
||||||
// ...Renderer
|
// ...Renderer
|
||||||
// ...UserInterface...
|
// ...UserInterface...
|
||||||
|
|
||||||
return s_Context;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return nullptr; // TODO: Add ASSERT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return s_Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "RenderCommand.h"
|
|
||||||
|
|
||||||
#include "UserInterface/UserInterface.h"
|
struct GLFWwindow;
|
||||||
|
|
||||||
struct GLFWwindow {};
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class RenderCommand;
|
||||||
|
class UserInterface;
|
||||||
|
|
||||||
enum class GraphicsAPI
|
enum class GraphicsAPI
|
||||||
{
|
{
|
||||||
Default, OpenGL // TODO: Add DirectX, Vulkan, Metal.
|
Default, OpenGL // TODO: Add DirectX, Vulkan, Metal.
|
||||||
|
@ -22,10 +22,14 @@ namespace Light {
|
||||||
|
|
||||||
std::unique_ptr<RenderCommand> m_RenderCommand;
|
std::unique_ptr<RenderCommand> m_RenderCommand;
|
||||||
std::unique_ptr<UserInterface> m_UserInterface;
|
std::unique_ptr<UserInterface> m_UserInterface;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GraphicsAPI m_GraphicsAPI;
|
GraphicsAPI m_GraphicsAPI;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
GraphicsContext(const GraphicsContext&) = delete;
|
||||||
|
GraphicsContext& operator=(const GraphicsContext&) = delete;
|
||||||
|
|
||||||
virtual ~GraphicsContext() = default;
|
virtual ~GraphicsContext() = default;
|
||||||
|
|
||||||
static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle);
|
static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle);
|
||||||
|
@ -34,6 +38,9 @@ namespace Light {
|
||||||
|
|
||||||
inline RenderCommand* GetRenderCommand() { return m_RenderCommand.get(); }
|
inline RenderCommand* GetRenderCommand() { return m_RenderCommand.get(); }
|
||||||
inline UserInterface* GetUserInterface() { return m_UserInterface.get(); }
|
inline UserInterface* GetUserInterface() { return m_UserInterface.get(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GraphicsContext() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "RenderCommand.h"
|
#include "RenderCommand.h"
|
||||||
|
#include "OpenGL/glRenderCommand.h"
|
||||||
|
|
||||||
#include "GraphicsContext.h"
|
#include "GraphicsContext.h"
|
||||||
|
|
||||||
#include "OpenGL/glRenderCommand.h"
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
RenderCommand* RenderCommand::Create(GLFWwindow* windowHandle)
|
RenderCommand* RenderCommand::Create(GLFWwindow* windowHandle)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Base.h"
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
@ -8,13 +10,21 @@ namespace Light {
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
static RenderCommand* Create(GLFWwindow* windowHandle);
|
RenderCommand(const RenderCommand&) = delete;
|
||||||
|
RenderCommand& operator=(const RenderCommand&) = delete;
|
||||||
|
|
||||||
|
virtual ~RenderCommand() = default;
|
||||||
|
|
||||||
virtual void SwapBuffers() = 0;
|
virtual void SwapBuffers() = 0;
|
||||||
virtual void ClearBackBuffer() = 0;
|
virtual void ClearBackBuffer() = 0;
|
||||||
|
|
||||||
virtual void Draw(unsigned int count) = 0;
|
virtual void Draw(unsigned int count) = 0;
|
||||||
virtual void DrawIndexed(unsigned int count) = 0;
|
virtual void DrawIndexed(unsigned int count) = 0;
|
||||||
|
|
||||||
|
static RenderCommand* Create(GLFWwindow* windowHandle);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RenderCommand() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
7
Engine/src/Engine/Graphics/Shader.cpp
Normal file
7
Engine/src/Engine/Graphics/Shader.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "ltpch.h"
|
||||||
|
#include "Shader.h"
|
||||||
|
|
||||||
|
namespace Light {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
20
Engine/src/Engine/Graphics/Shader.h
Normal file
20
Engine/src/Engine/Graphics/Shader.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Light {
|
||||||
|
|
||||||
|
class Shader
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
static Shader* Create();
|
||||||
|
|
||||||
|
virtual ~Shader() = default;
|
||||||
|
|
||||||
|
virtual void Bind() = 0;
|
||||||
|
virtual void UnBind() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Shader() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -2,14 +2,22 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Events/MouseEvents.h"
|
|
||||||
#include "Events/KeyboardEvents.h"
|
|
||||||
#include "Events/WindowEvents.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class MouseMovedEvent;
|
||||||
|
class ButtonPressedEvent;
|
||||||
|
class ButtonReleasedEvent;
|
||||||
|
class WheelScrolledEvent;
|
||||||
|
|
||||||
|
class KeyPressedEvent;
|
||||||
|
class KeyReleasedEvent;
|
||||||
|
|
||||||
|
class WindowClosedEvent;
|
||||||
|
class WindowResizedEvent;
|
||||||
|
class WindowMovedEvent;
|
||||||
|
class WindowLostFocusEvent;
|
||||||
|
class WindowGainFocusEvent;
|
||||||
|
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -43,27 +51,4 @@ namespace Light {
|
||||||
virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; }
|
virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestLayer : public Layer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TestLayer(const std::string& name): Layer(name) {}
|
|
||||||
|
|
||||||
// Mouse events
|
|
||||||
virtual bool OnMouseMoved(const MouseMovedEvent& event) override { LT_ENGINE_TRACE("{}", event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnButtonPressed(const ButtonPressedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnButtonReleased(const ButtonReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWheelScrolled(const WheelScrolledEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
|
|
||||||
// Keyboard events
|
|
||||||
virtual bool OnKeyPressed(const KeyPressedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnKeyReleased(const KeyReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
|
|
||||||
// Window events
|
|
||||||
virtual bool OnWindowClosed(const WindowClosedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowResized(const WindowResizedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowMoved(const WindowMovedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowLostFocus(const WindowLostFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,12 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "LayerStack.h"
|
#include "LayerStack.h"
|
||||||
|
|
||||||
#include <functional>
|
#include "Layer.h"
|
||||||
|
|
||||||
|
#include "Events/Event.h"
|
||||||
|
#include "Events/MouseEvents.h"
|
||||||
|
#include "Events/KeyboardEvents.h"
|
||||||
|
#include "Events/WindowEvents.h"
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Layer.h"
|
|
||||||
|
|
||||||
#include "Events/Event.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class Layer;
|
||||||
|
class Event;
|
||||||
|
|
||||||
class LayerStack
|
class LayerStack
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -38,7 +35,6 @@ namespace Light {
|
||||||
private:
|
private:
|
||||||
void AttachLayerImpl(Layer* layer);
|
void AttachLayerImpl(Layer* layer);
|
||||||
void DetatchLayerImpl(Layer* layer);
|
void DetatchLayerImpl(Layer* layer);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
|
|
||||||
#include "Graphics/GraphicsContext.h"
|
|
||||||
#include "OpenGL/glUserInterface.h"
|
#include "OpenGL/glUserInterface.h"
|
||||||
|
|
||||||
#include "Events/KeyboardEvents.h"
|
#include "Graphics/GraphicsContext.h"
|
||||||
|
|
||||||
|
#include "Events/Event.h"
|
||||||
#include "Events/MouseEvents.h"
|
#include "Events/MouseEvents.h"
|
||||||
|
#include "Events/KeyboardEvents.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,28 @@
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Events/Event.h"
|
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class Event;
|
||||||
|
|
||||||
class UserInterface
|
class UserInterface
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
public:
|
public:
|
||||||
static UserInterface* Create(GLFWwindow* windowHandle);
|
UserInterface(const UserInterface&) = delete;
|
||||||
|
UserInterface operator=(const UserInterface&) = delete;
|
||||||
|
|
||||||
|
virtual ~UserInterface() = default;
|
||||||
|
|
||||||
void OnInput(const Event& inputEvent);
|
void OnInput(const Event& inputEvent);
|
||||||
|
|
||||||
virtual void Begin() = 0;
|
virtual void Begin() = 0;
|
||||||
virtual void End() = 0;
|
virtual void End() = 0;
|
||||||
|
|
||||||
|
static UserInterface* Create(GLFWwindow* windowHandle);
|
||||||
|
protected:
|
||||||
|
UserInterface() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,30 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// Core
|
||||||
|
#include "Core/Application.h"
|
||||||
|
#include "Core/Window.h"
|
||||||
|
#include "Core/Logger.h"
|
||||||
|
|
||||||
|
// Events
|
||||||
#include "Events/Event.h"
|
#include "Events/Event.h"
|
||||||
#include "Events/KeyboardEvents.h"
|
#include "Events/KeyboardEvents.h"
|
||||||
#include "Events/MouseEvents.h"
|
#include "Events/MouseEvents.h"
|
||||||
|
#include "Events/WindowEvents.h"
|
||||||
|
|
||||||
#include "Core/Application.h"
|
// Graphics
|
||||||
#include "Core/Logger.h"
|
#include "Graphics/GraphicsContext.h"
|
||||||
|
#include "Graphics/RenderCommand.h"
|
||||||
|
|
||||||
|
// Layer
|
||||||
|
#include "Layer/Layer.h"
|
||||||
|
#include "Layer/LayerStack.h"
|
||||||
|
|
||||||
|
// UserInterface
|
||||||
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
|
// Base
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "EntryPoint.h"
|
|
||||||
|
#ifdef LIGHT_ENTRY_POINT
|
||||||
|
#include "EntryPoint.h"
|
||||||
|
#endif
|
|
@ -1,6 +1,10 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "glGraphicsContext.h"
|
#include "glGraphicsContext.h"
|
||||||
|
|
||||||
|
// Required for forward declaration
|
||||||
|
#include "Graphics/RenderCommand.h"
|
||||||
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "Graphics/RenderCommand.h"
|
#include "Graphics/RenderCommand.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
class glRenderCommand : public RenderCommand
|
class glRenderCommand : public RenderCommand
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GLFWwindow* m_WindowHandle;
|
GLFWwindow* m_WindowHandle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
glRenderCommand(GLFWwindow* windowHandle);
|
glRenderCommand(GLFWwindow* windowHandle);
|
||||||
|
|
||||||
|
@ -20,5 +20,4 @@ namespace Light {
|
||||||
void DrawIndexed(unsigned int count) override;
|
void DrawIndexed(unsigned int count) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,6 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "glUserInterface.h"
|
#include "glUserInterface.h"
|
||||||
|
|
||||||
#include "Events/KeyboardEvents.h"
|
|
||||||
#include "Events/MouseEvents.h"
|
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_impl_glfw.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
|
|
|
@ -3,13 +3,10 @@
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "UserInterface/UserInterface.h"
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
#include "Events/Event.h"
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
class glUserInterface : public UserInterface
|
class glUserInterface : public UserInterface
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
public:
|
public:
|
||||||
glUserInterface(GLFWwindow* windowHandle);
|
glUserInterface(GLFWwindow* windowHandle);
|
||||||
~glUserInterface();
|
~glUserInterface();
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "wWindow.h"
|
#include "wWindow.h"
|
||||||
|
|
||||||
#include "Events/KeyboardEvents.h"
|
#include "Events/Event.h"
|
||||||
#include "Events/MouseEvents.h"
|
#include "Events/MouseEvents.h"
|
||||||
|
#include "Events/KeyboardEvents.h"
|
||||||
#include "Events/WindowEvents.h"
|
#include "Events/WindowEvents.h"
|
||||||
|
|
||||||
#include "Graphics/GraphicsContext.h"
|
#include "Graphics/GraphicsContext.h"
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
Window* Window::Create(const WindowProperties& properties, std::function<void(Event&)> callback)
|
Window* Window::Create(const WindowProperties& properties, std::function<void(Event&)> callback)
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define GLFW_INCLUDE_NONE
|
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
#include "Core/Window.h"
|
#include "Core/Window.h"
|
||||||
|
|
||||||
#include "Events/Event.h"
|
struct GLFWwindow;
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class Event;
|
||||||
|
|
||||||
class wWindow : public Window
|
class wWindow : public Window
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -20,6 +16,7 @@ namespace Light {
|
||||||
WindowProperties m_Properties;
|
WindowProperties m_Properties;
|
||||||
|
|
||||||
std::function<void(Event&)> m_EventCallback;
|
std::function<void(Event&)> m_EventCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wWindow(const WindowProperties& properties, std::function<void(Event&)> callback);
|
wWindow(const WindowProperties& properties, std::function<void(Event&)> callback);
|
||||||
|
|
||||||
|
@ -32,6 +29,7 @@ namespace Light {
|
||||||
virtual unsigned int GetHeight() override;
|
virtual unsigned int GetHeight() override;
|
||||||
|
|
||||||
virtual inline void* GetNativeHandle() override { return m_Handle; }
|
virtual inline void* GetNativeHandle() override { return m_Handle; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void BindGlfwEvents();
|
void BindGlfwEvents();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,8 +4,8 @@ Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=248,45
|
Pos=276,-1
|
||||||
Size=550,536
|
Size=521,536
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Table][0xC9935533,3]
|
[Table][0xC9935533,3]
|
||||||
|
|
|
@ -47,7 +47,7 @@ project "Sandbox"
|
||||||
--- Filters ---
|
--- Filters ---
|
||||||
-- windows
|
-- windows
|
||||||
filter "system:windows"
|
filter "system:windows"
|
||||||
defines "LT_PLATFORM_WINDOWS"
|
defines "LIGHT_PLATFORM_WINDOWS"
|
||||||
systemversion "latest"
|
systemversion "latest"
|
||||||
staticruntime "On"
|
staticruntime "On"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define LIGHT_ENTRY_POINT
|
||||||
#include <LightEngine.h>
|
#include <LightEngine.h>
|
||||||
|
|
||||||
#include "SandboxLayer.h"
|
#include "SandboxLayer.h"
|
||||||
|
|
Loading…
Add table
Reference in a new issue