Initial Log
This commit is contained in:
parent
4678a7dbf6
commit
cefe62be9f
12 changed files with 61 additions and 34 deletions
|
@ -27,8 +27,14 @@ namespace Light {
|
||||||
|
|
||||||
void Application::GameLoop()
|
void Application::GameLoop()
|
||||||
{
|
{
|
||||||
|
// check
|
||||||
LT_ENGINE_ASSERT(!m_LayerStack.IsEmpty(), "Application::GameLoop: Layerstack is empty");
|
LT_ENGINE_ASSERT(!m_LayerStack.IsEmpty(), "Application::GameLoop: Layerstack is empty");
|
||||||
|
|
||||||
|
// Log some data
|
||||||
|
m_Window->GetGfxContext()->LogDebugData();
|
||||||
|
m_Window->GetGfxContext()->GetUserInterface()->LogDebugData();
|
||||||
|
|
||||||
|
// GAMELOOP //
|
||||||
while (m_Window->IsOpen())
|
while (m_Window->IsOpen())
|
||||||
{
|
{
|
||||||
// Events
|
// Events
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Light {
|
||||||
public:
|
public:
|
||||||
WindowMovedEvent(int x, int y): m_Position(x, y) {}
|
WindowMovedEvent(int x, int y): m_Position(x, y) {}
|
||||||
|
|
||||||
const glm::ivec2& GetPosition() { return m_Position; }
|
const glm::ivec2& GetPosition() const{ return m_Position; }
|
||||||
|
|
||||||
virtual std::string GetInfoLog() const override
|
virtual std::string GetInfoLog() const override
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ namespace Light {
|
||||||
public:
|
public:
|
||||||
WindowResizedEvent(int width, int height): m_Size(width, height) {}
|
WindowResizedEvent(int width, int height): m_Size(width, height) {}
|
||||||
|
|
||||||
const glm::ivec2& GetSize() { return m_Size; }
|
const glm::ivec2& GetSize() const { return m_Size; }
|
||||||
|
|
||||||
virtual std::string GetInfoLog() const override
|
virtual std::string GetInfoLog() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ namespace Light {
|
||||||
LT_ENGINE_ASSERT(s_Context->m_RenderCommand, "GraphicsContext::Create: RenderCommand creation failed");
|
LT_ENGINE_ASSERT(s_Context->m_RenderCommand, "GraphicsContext::Create: RenderCommand creation failed");
|
||||||
LT_ENGINE_ASSERT(s_Context->m_UserInterface, "GraphicsContext::Create: UserInterface creation failed");
|
LT_ENGINE_ASSERT(s_Context->m_UserInterface, "GraphicsContext::Create: UserInterface creation failed");
|
||||||
|
|
||||||
|
|
||||||
return s_Context;
|
return s_Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ namespace Light {
|
||||||
class RenderCommand;
|
class RenderCommand;
|
||||||
class UserInterface;
|
class UserInterface;
|
||||||
|
|
||||||
|
class WindowResizedEvent;
|
||||||
|
|
||||||
enum class GraphicsAPI
|
enum class GraphicsAPI
|
||||||
{
|
{
|
||||||
Default = 0,
|
Default = 0,
|
||||||
|
@ -32,12 +34,16 @@ namespace Light {
|
||||||
GraphicsAPI m_GraphicsAPI;
|
GraphicsAPI m_GraphicsAPI;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle);
|
||||||
|
|
||||||
GraphicsContext(const GraphicsContext&) = delete;
|
GraphicsContext(const GraphicsContext&) = delete;
|
||||||
GraphicsContext& operator=(const GraphicsContext&) = delete;
|
GraphicsContext& operator=(const GraphicsContext&) = delete;
|
||||||
|
|
||||||
virtual ~GraphicsContext() = default;
|
virtual ~GraphicsContext() = default;
|
||||||
|
|
||||||
static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle);
|
virtual void OnWindowResize(const WindowResizedEvent& event) = 0;
|
||||||
|
|
||||||
|
virtual void LogDebugData() = 0;
|
||||||
|
|
||||||
static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; }
|
static inline GraphicsAPI GetGraphicsAPI() { return s_Context->m_GraphicsAPI; }
|
||||||
|
|
||||||
|
@ -47,6 +53,7 @@ namespace Light {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GraphicsContext() = default;
|
GraphicsContext() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,6 +11,8 @@ namespace Light {
|
||||||
class UserInterface
|
class UserInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static UserInterface* Create(GLFWwindow* windowHandle);
|
||||||
|
|
||||||
UserInterface(const UserInterface&) = delete;
|
UserInterface(const UserInterface&) = delete;
|
||||||
UserInterface operator=(const UserInterface&) = delete;
|
UserInterface operator=(const UserInterface&) = delete;
|
||||||
|
|
||||||
|
@ -21,7 +23,8 @@ namespace Light {
|
||||||
virtual void Begin() = 0;
|
virtual void Begin() = 0;
|
||||||
virtual void End() = 0;
|
virtual void End() = 0;
|
||||||
|
|
||||||
static UserInterface* Create(GLFWwindow* windowHandle);
|
virtual void LogDebugData() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UserInterface() = default;
|
UserInterface() = default;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "Graphics/VertexLayout.h"
|
#include "Graphics/VertexLayout.h"
|
||||||
#include "UserInterface/UserInterface.h"
|
#include "UserInterface/UserInterface.h"
|
||||||
|
|
||||||
|
#include "Events/WindowEvents.h"
|
||||||
|
|
||||||
#include "Utility/Stringifier.h"
|
#include "Utility/Stringifier.h"
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
@ -26,10 +28,21 @@ namespace Light {
|
||||||
"glGraphicsContext::glGraphicsContext: gladLoadGLLoader: failed to initialize opengl context");
|
"glGraphicsContext::glGraphicsContext: gladLoadGLLoader: failed to initialize opengl context");
|
||||||
|
|
||||||
SetDebugMessageCallback();
|
SetDebugMessageCallback();
|
||||||
|
}
|
||||||
|
|
||||||
LT_ENGINE_INFO("glGraphicsContext:");
|
void glGraphicsContext::OnWindowResize(const WindowResizedEvent& event)
|
||||||
LT_ENGINE_INFO(" Renderer: {}", glGetString(GL_RENDERER));
|
{
|
||||||
|
glViewport(0, 0, event.GetSize().x, event.GetSize().y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void glGraphicsContext::LogDebugData()
|
||||||
|
{
|
||||||
|
LT_ENGINE_INFO("________________________________________");
|
||||||
|
LT_ENGINE_INFO("GraphicsContext::");
|
||||||
|
LT_ENGINE_INFO(" API : OpenGL");
|
||||||
LT_ENGINE_INFO(" Version : {}", glGetString(GL_VERSION));
|
LT_ENGINE_INFO(" Version : {}", glGetString(GL_VERSION));
|
||||||
|
LT_ENGINE_INFO(" Renderer: {}", glGetString(GL_RENDERER));
|
||||||
|
LT_ENGINE_INFO("________________________________________");
|
||||||
}
|
}
|
||||||
|
|
||||||
void glGraphicsContext::SetDebugMessageCallback()
|
void glGraphicsContext::SetDebugMessageCallback()
|
||||||
|
|
|
@ -7,6 +7,8 @@ struct GLFWwindow;
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
|
class WindowResizedEvent;
|
||||||
|
|
||||||
class glGraphicsContext : public GraphicsContext
|
class glGraphicsContext : public GraphicsContext
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -15,6 +17,10 @@ namespace Light {
|
||||||
public:
|
public:
|
||||||
glGraphicsContext(GLFWwindow* windowHandle);
|
glGraphicsContext(GLFWwindow* windowHandle);
|
||||||
|
|
||||||
|
virtual void OnWindowResize(const WindowResizedEvent& event) override;
|
||||||
|
|
||||||
|
virtual void LogDebugData() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetDebugMessageCallback();
|
void SetDebugMessageCallback();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "ltpch.h"
|
#include "ltpch.h"
|
||||||
#include "glUserInterface.h"
|
#include "glUserInterface.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
@ -42,4 +42,13 @@ namespace Light {
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glUserInterface::LogDebugData()
|
||||||
|
{
|
||||||
|
LT_ENGINE_INFO("________________________________________");
|
||||||
|
LT_ENGINE_INFO("UserInterface::");
|
||||||
|
LT_ENGINE_INFO(" API : ImGui");
|
||||||
|
LT_ENGINE_INFO(" Version: {}", ImGui::GetVersion());
|
||||||
|
LT_ENGINE_INFO("________________________________________");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,6 +13,8 @@ namespace Light {
|
||||||
|
|
||||||
void Begin() override;
|
void Begin() override;
|
||||||
void End() override;
|
void End() override;
|
||||||
|
|
||||||
|
virtual void LogDebugData() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,6 +48,8 @@ namespace Light {
|
||||||
{
|
{
|
||||||
case EventType::WindowClosed:
|
case EventType::WindowClosed:
|
||||||
b_Open = false;
|
b_Open = false;
|
||||||
|
case EventType::WindowResized:
|
||||||
|
m_GraphicsContext->OnWindowResize((const WindowResizedEvent&)event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=-3,0
|
Pos=-3,-1
|
||||||
Size=524,134
|
Size=243,295
|
||||||
Collapsed=1
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Dear ImGui Metrics/Debugger]
|
[Window][Dear ImGui Metrics/Debugger]
|
||||||
Pos=-5,16
|
Pos=-1,859
|
||||||
Size=525,114
|
Size=359,115
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Table][0xC9935533,3]
|
[Table][0xC9935533,3]
|
||||||
|
|
|
@ -5,24 +5,4 @@ class SandboxLayer : public Light::Layer
|
||||||
public:
|
public:
|
||||||
SandboxLayer(const std::string& name): Light::Layer(name) {}
|
SandboxLayer(const std::string& name): Light::Layer(name) {}
|
||||||
|
|
||||||
// Mouse events
|
|
||||||
virtual bool OnMouseMoved(const Light::MouseMovedEvent& event) override { LT_ENGINE_TRACE("{}", event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnButtonPressed(const Light::ButtonPressedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnButtonReleased(const Light::ButtonReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWheelScrolled(const Light::WheelScrolledEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
|
|
||||||
// Keyboard events
|
|
||||||
virtual bool OnKeyPressed(const Light::KeyPressedEvent& event) override
|
|
||||||
{
|
|
||||||
LT_ENGINE_TRACE(event.GetInfoLog());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual bool OnKeyReleased(const Light::KeyReleasedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
|
|
||||||
// Window events
|
|
||||||
virtual bool OnWindowClosed(const Light::WindowClosedEvent& event) override { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowResized(const Light::WindowResizedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowMoved(const Light::WindowMovedEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowLostFocus(const Light::WindowLostFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
virtual bool OnWindowGainFocus(const Light::WindowGainFocusEvent& event) { LT_ENGINE_TRACE(event.GetInfoLog()); return false; }
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue