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