Initial Log

This commit is contained in:
Light3039 2021-06-01 11:23:41 +04:30
parent 4678a7dbf6
commit cefe62be9f
12 changed files with 61 additions and 34 deletions

View file

@ -27,8 +27,14 @@ namespace Light {
void Application::GameLoop()
{
// check
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())
{
// Events

View file

@ -28,7 +28,7 @@ namespace Light {
public:
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
{
@ -48,7 +48,7 @@ namespace Light {
public:
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
{

View file

@ -53,7 +53,6 @@ namespace Light {
LT_ENGINE_ASSERT(s_Context->m_RenderCommand, "GraphicsContext::Create: RenderCommand creation failed");
LT_ENGINE_ASSERT(s_Context->m_UserInterface, "GraphicsContext::Create: UserInterface creation failed");
return s_Context;
}

View file

@ -10,6 +10,8 @@ namespace Light {
class RenderCommand;
class UserInterface;
class WindowResizedEvent;
enum class GraphicsAPI
{
Default = 0,
@ -32,12 +34,16 @@ namespace Light {
GraphicsAPI m_GraphicsAPI;
public:
static GraphicsContext* Create(GraphicsAPI api, GLFWwindow* windowHandle);
GraphicsContext(const GraphicsContext&) = delete;
GraphicsContext& operator=(const GraphicsContext&) = delete;
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; }
@ -47,6 +53,7 @@ namespace Light {
protected:
GraphicsContext() = default;
};
}

View file

@ -11,6 +11,8 @@ namespace Light {
class UserInterface
{
public:
static UserInterface* Create(GLFWwindow* windowHandle);
UserInterface(const UserInterface&) = delete;
UserInterface operator=(const UserInterface&) = delete;
@ -21,7 +23,8 @@ namespace Light {
virtual void Begin() = 0;
virtual void End() = 0;
static UserInterface* Create(GLFWwindow* windowHandle);
virtual void LogDebugData() = 0;
protected:
UserInterface() = default;
};

View file

@ -9,6 +9,8 @@
#include "Graphics/VertexLayout.h"
#include "UserInterface/UserInterface.h"
#include "Events/WindowEvents.h"
#include "Utility/Stringifier.h"
#include <glad/glad.h>
@ -26,10 +28,21 @@ namespace Light {
"glGraphicsContext::glGraphicsContext: gladLoadGLLoader: failed to initialize opengl context");
SetDebugMessageCallback();
}
LT_ENGINE_INFO("glGraphicsContext:");
void glGraphicsContext::OnWindowResize(const WindowResizedEvent& event)
{
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(" Renderer: {}", glGetString(GL_RENDERER));
LT_ENGINE_INFO(" Version: {}", glGetString(GL_VERSION));
LT_ENGINE_INFO("________________________________________");
}
void glGraphicsContext::SetDebugMessageCallback()

View file

@ -7,6 +7,8 @@ struct GLFWwindow;
namespace Light {
class WindowResizedEvent;
class glGraphicsContext : public GraphicsContext
{
private:
@ -15,6 +17,10 @@ namespace Light {
public:
glGraphicsContext(GLFWwindow* windowHandle);
virtual void OnWindowResize(const WindowResizedEvent& event) override;
virtual void LogDebugData() override;
private:
void SetDebugMessageCallback();
};

View file

@ -1,4 +1,4 @@
#include "ltpch.h"
#include "ltpch.h"
#include "glUserInterface.h"
#include <imgui.h>
@ -42,4 +42,13 @@ namespace Light {
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("________________________________________");
}
}

View file

@ -13,6 +13,8 @@ namespace Light {
void Begin() override;
void End() override;
virtual void LogDebugData() override;
};
}

View file

@ -48,6 +48,8 @@ namespace Light {
{
case EventType::WindowClosed:
b_Open = false;
case EventType::WindowResized:
m_GraphicsContext->OnWindowResize((const WindowResizedEvent&)event);
}
}

View file

@ -4,13 +4,13 @@ Size=400,400
Collapsed=0
[Window][Dear ImGui Demo]
Pos=-3,0
Size=524,134
Collapsed=1
Pos=-3,-1
Size=243,295
Collapsed=0
[Window][Dear ImGui Metrics/Debugger]
Pos=-5,16
Size=525,114
Pos=-1,859
Size=359,115
Collapsed=0
[Table][0xC9935533,3]

View file

@ -5,24 +5,4 @@ class SandboxLayer : public Light::Layer
public:
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; }
};