too tired to think

This commit is contained in:
Erris
2026-01-31 10:27:40 +01:00
parent 5a25ab5f5f
commit 7b4950dda0
20 changed files with 160 additions and 92 deletions

View File

@@ -2,6 +2,7 @@
#define OPEN_ENGINE_HPP #define OPEN_ENGINE_HPP
#include "open_engine/core.hpp" #include "open_engine/core.hpp"
#include "open_engine/ref_scope.hpp"
#include "open_engine/application.hpp" #include "open_engine/application.hpp"
#include "open_engine/logging.hpp" #include "open_engine/logging.hpp"
#include "open_engine/events/key_event.hpp" #include "open_engine/events/key_event.hpp"
@@ -10,6 +11,7 @@
#include "open_engine/renderer/renderer.hpp" #include "open_engine/renderer/renderer.hpp"
#include "open_engine/core/time.hpp" #include "open_engine/core/time.hpp"
#include "open_engine/input/input_system.hpp" #include "open_engine/input/input_system.hpp"
#include "open_engine/input/mouse_codes.hpp"
#include "open_engine/input/keycodes.hpp" #include "open_engine/input/keycodes.hpp"
#include "open_engine/renderer/buffer.hpp" #include "open_engine/renderer/buffer.hpp"
#include "open_engine/renderer/shader.hpp" #include "open_engine/renderer/shader.hpp"

View File

@@ -1,13 +1,14 @@
#ifndef APPLICATION_HPP #ifndef APPLICATION_HPP
#define APPLICATION_HPP #define APPLICATION_HPP
#include "open_engine/core.hpp"
#include "open_engine/events/application_event.hpp" #include "open_engine/events/application_event.hpp"
#include "open_engine/imgui/imgui_layer.hpp" #include "open_engine/imgui/imgui_layer.hpp"
#include "open_engine/window/window.hpp" #include "open_engine/window/window.hpp"
#include "open_engine/layer_stack.hpp" #include "open_engine/layer_stack.hpp"
#include "open_engine/layer.hpp" #include "open_engine/layer.hpp"
int main(int argc, char **argv);
namespace OpenEngine { namespace OpenEngine {
class Application class Application
{ {
@@ -15,8 +16,6 @@ namespace OpenEngine {
Application(); Application();
~Application(); ~Application();
void Run();
virtual void OnEvent(Event& event); virtual void OnEvent(Event& event);
void QueueLayerPush(Ref<Layer> layer); void QueueLayerPush(Ref<Layer> layer);
@@ -30,9 +29,11 @@ namespace OpenEngine {
inline void StopRunning() { running = false; }; inline void StopRunning() { running = false; };
private: private:
void Run();
bool OnWindowClose(WindowCloseEvent& event); bool OnWindowClose(WindowCloseEvent& event);
bool OnWindowResize(WindowResizeEvent& event); bool OnWindowResize(WindowResizeEvent& event);
private:
inline static Application* instance; inline static Application* instance;
bool running = true; bool running = true;
@@ -40,6 +41,8 @@ namespace OpenEngine {
Ref<ImGuiLayer> imgui_layer; Ref<ImGuiLayer> imgui_layer;
LayerStack layer_stack; LayerStack layer_stack;
friend int ::main(int argc, char **argv);
}; };
// Is defined by client // Is defined by client

View File

@@ -3,8 +3,6 @@
#include "open_engine/instrumentor.hpp" #include "open_engine/instrumentor.hpp"
#include <memory>
#ifdef OE_ENABLE_ASSERTS #ifdef OE_ENABLE_ASSERTS
#include <signal.h> #include <signal.h>
#define OE_ASSERT(x, ...) { if (!(x)) { OE_ERROR("Assertion Failed: {0}", __VA_ARGS__); raise(SIGTRAP); } } #define OE_ASSERT(x, ...) { if (!(x)) { OE_ERROR("Assertion Failed: {0}", __VA_ARGS__); raise(SIGTRAP); } }
@@ -18,22 +16,4 @@
#define BIND_EVENT_FN(function) std::bind(&function, this, std::placeholders::_1) #define BIND_EVENT_FN(function) std::bind(&function, this, std::placeholders::_1)
namespace OpenEngine {
template<typename T>
using Scope = std::unique_ptr<T>;
template<typename T, typename ... Args>
constexpr Scope<T> CreateScope(Args&& ... args)
{
return std::make_unique<T>(std::forward<Args>(args)...);
}
template<typename T>
using Ref = std::shared_ptr<T>;
template<typename T, typename ... Args>
constexpr Ref<T> CreateRef(Args&& ... args)
{
return std::make_shared<T>(std::forward<Args>(args)...);
}
}
#endif // CORE_HPP #endif // CORE_HPP

View File

@@ -1,7 +1,7 @@
#ifndef ENTRY_POINT_HPP #ifndef ENTRY_POINT_HPP
#define ENTRY_POINT_HPP #define ENTRY_POINT_HPP
#include "open_engine/instrumentor.hpp" #include "open_engine/core.hpp"
#include "open_engine/application.hpp" #include "open_engine/application.hpp"
#include "open_engine/logging.hpp" #include "open_engine/logging.hpp"

View File

@@ -1,6 +1,10 @@
#ifndef INSTRUMENTOR_HPP #ifndef INSTRUMENTOR_HPP
#define INSTRUMENTOR_HPP #define INSTRUMENTOR_HPP
#include "open_engine/logging.hpp"
#include <mutex>
#include <sstream>
#include <string> #include <string>
#include <chrono> #include <chrono>
#include <algorithm> #include <algorithm>
@@ -8,11 +12,15 @@
#include <thread> #include <thread>
namespace OpenEngine { namespace OpenEngine {
using FloatingPointMicroseconds = std::chrono::duration<double, std::micro>;
struct ProfileResult struct ProfileResult
{ {
std::string name; std::string name;
long long start, end; FloatingPointMicroseconds start;
uint32_t thread_id; std::chrono::microseconds elapsed_time;
std::thread::id thread_id;
}; };
struct InstrumentationSession struct InstrumentationSession
@@ -30,45 +38,53 @@ namespace OpenEngine {
void BeginSession(const char* name, const std::string& filepath = "results.json") void BeginSession(const char* name, const std::string& filepath = "results.json")
{ {
std::lock_guard lock(mutex);
if (current_session) {
if (Logger::GetCoreLogger())
OE_CORE_ERROR("Instrumentor::BeginSession({}), when session {} already exists", name, current_session->name);
InternalEndSession();
}
output_stream.open(filepath); output_stream.open(filepath);
WriteHeader(); if(output_stream.is_open()) {
current_session = new InstrumentationSession(name);
WriteHeader();
} else {
if (Logger::GetCoreLogger())
OE_CORE_ERROR("Instrumentor could not open results file: {}", filepath);
}
}; };
void EndSession() void EndSession()
{ {
WriteFooter(); std::lock_guard lock(mutex);
output_stream.flush(); InternalEndSession();
output_stream.close();
profile_count = 0;
}; };
void WriteProfile(const ProfileResult& result) void WriteProfile(const ProfileResult& result)
{ {
if (profile_count++ > 0) std::stringstream json;
output_stream << ",";
std::string name = result.name; std::string name = result.name;
std::replace(name.begin(), name.end(), '"', '\''); std::replace(name.begin(), name.end(), '"', '\'');
output_stream << "{"; json << std::setprecision(3) << std::fixed;
output_stream << "\"cat\":\"function\","; json << ",{";
output_stream << "\"dur\":" << (result.end - result.start) << ','; json << "\"cat\":\"function\",";
output_stream << "\"name\":\"" << name << "\","; json << "\"dur\":" << (result.elapsed_time.count()) << ',';
output_stream << "\"ph\":\"X\","; json << "\"name\":\"" << name << "\",";
output_stream << "\"pid\":0,"; json << "\"ph\":\"X\",";
output_stream << "\"tid\":" << result.thread_id << ","; json << "\"pid\":0,";
output_stream << "\"ts\":" << result.start; json << "\"tid\":" << result.thread_id << ",";
output_stream << "}"; json << "\"ts\":" << result.start.count();
}; json << "}";
void WriteHeader() std::lock_guard lock(mutex);
{
output_stream << "{\"otherData\": {},\"traceEvents\":[";
};
void WriteFooter() if (current_session) {
{ output_stream << json.str();
output_stream << "]}"; output_stream.flush();
}
}; };
static Instrumentor& Get() static Instrumentor& Get()
@@ -78,11 +94,32 @@ namespace OpenEngine {
}; };
private: private:
void WriteHeader()
{
output_stream << "{\"otherData\": {},\"traceEvents\":[{}";
};
void WriteFooter()
{
output_stream << "]}";
};
void InternalEndSession() {
if (current_session) {
WriteFooter();
output_stream.close();
delete current_session;
current_session = nullptr;
}
}
Instrumentor() Instrumentor()
{ {
}; };
private: private:
std::mutex mutex;
InstrumentationSession* current_session = nullptr;
std::ofstream output_stream; std::ofstream output_stream;
int profile_count = 0; int profile_count = 0;
}; };
@@ -106,11 +143,12 @@ namespace OpenEngine {
{ {
auto end_timepoint = std::chrono::high_resolution_clock::now(); auto end_timepoint = std::chrono::high_resolution_clock::now();
long long start = std::chrono::time_point_cast<std::chrono::microseconds>(start_timepoint).time_since_epoch().count(); auto start = FloatingPointMicroseconds{start_timepoint.time_since_epoch()};
long long end = std::chrono::time_point_cast<std::chrono::microseconds>(end_timepoint).time_since_epoch().count(); auto elapsed_time = std::chrono::time_point_cast<std::chrono::microseconds>(end_timepoint).time_since_epoch()
- std::chrono::time_point_cast<std::chrono::microseconds>(start_timepoint).time_since_epoch();
uint32_t thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id()); uint32_t thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
Instrumentor::Get().WriteProfile({ name, start, end, thread_id }); Instrumentor::Get().WriteProfile({ name, start, elapsed_time, std::this_thread::get_id() });
stopped = true; stopped = true;
}; };

View File

@@ -1,12 +1,14 @@
#ifndef LOGGING_HPP #ifndef LOGGING_HPP
#define LOGGING_HPP #define LOGGING_HPP
#include "open_engine/core.hpp" #include "open_engine/ref_scope.hpp"
#include <spdlog/logger.h> #include <spdlog/logger.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <string> #include <string>
namespace OpenEngine { namespace OpenEngine {
spdlog::level::level_enum stringToLogLevel(std::string level_str); spdlog::level::level_enum stringToLogLevel(std::string level_str);
int setupMultisinkLogger(const std::string &file_path); int setupMultisinkLogger(const std::string &file_path);

View File

@@ -18,7 +18,7 @@ namespace OpenEngine {
void OnEvent(Event& e); void OnEvent(Event& e);
const OrthographicCamera& GetCamera() const { return camera; }; const OrthographicCamera& GetCamera() const { return camera; };
OrthographicCamera GetCamera() { return camera;}; OrthographicCamera& GetCamera() { return camera; };
float GetZoom() const { return zoom; } float GetZoom() const { return zoom; }
void SetZoom(float level) { zoom = level; }; void SetZoom(float level) { zoom = level; };

View File

@@ -0,0 +1,24 @@
#ifndef REF_SCOPE_HPP
#define REF_SCOPE_HPP
#include <memory>
namespace OpenEngine {
template<typename T>
using Scope = std::unique_ptr<T>;
template<typename T, typename ... Args>
constexpr Scope<T> CreateScope(Args&& ... args)
{
return std::make_unique<T>(std::forward<Args>(args)...);
}
template<typename T>
using Ref = std::shared_ptr<T>;
template<typename T, typename ... Args>
constexpr Ref<T> CreateRef(Args&& ... args)
{
return std::make_shared<T>(std::forward<Args>(args)...);
}
}
#endif // REF_SCOPE_HPP

View File

@@ -2,8 +2,9 @@
#define RENDER_COMMAND_HPP #define RENDER_COMMAND_HPP
#include "open_engine/core.hpp" #include "open_engine/core.hpp"
#include "open_engine/renderer/renderer_api.hpp"
#include "open_engine/opengl/opengl_renderer_api.hpp" #include "open_engine/opengl/opengl_renderer_api.hpp"
#include "open_engine/renderer/renderer_api.hpp"
#include "open_engine/ref_scope.hpp"
#include <cstdint> #include <cstdint>

View File

@@ -1,13 +1,20 @@
#ifndef RENDERER2D_HPP #ifndef RENDERER2D_HPP
#define RENDERER2D_HPP #define RENDERER2D_HPP
#include "open_engine/core.hpp"
#include "open_engine/orthographic_camera.hpp" #include "open_engine/orthographic_camera.hpp"
#include "open_engine/renderer/texture.hpp" #include "open_engine/renderer/texture.hpp"
#include "open_engine/ref_scope.hpp"
#include <glm/fwd.hpp> #include <glm/fwd.hpp>
namespace OpenEngine { namespace OpenEngine {
struct Transform
{
glm::vec3 position = {0.0f, 0.0f, 0.0f};
glm::vec3 size = {1.0f, 1.0f, 1.0f};
float rotation = 0.0f;
};
class Renderer2D class Renderer2D
{ {
public: public:
@@ -17,10 +24,8 @@ namespace OpenEngine {
static void BeginScene(const OrthographicCamera& camera); static void BeginScene(const OrthographicCamera& camera);
static void EndScene(); static void EndScene();
static void DrawQuad(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color); static void DrawQuad(const Transform& transform_data, const glm::vec4& color);
static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color); static void DrawQuad(const Transform& transform_data, const Ref<Texture2D>& texture, float tiling_factor = 1.0f);
static void DrawQuad(const glm::vec2& position, const glm::vec2& size, const Ref<Texture2D>& texture);
static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const Ref<Texture2D>& texture);
}; };
} }

View File

@@ -1,7 +1,7 @@
#ifndef SHADER_HPP #ifndef SHADER_HPP
#define SHADER_HPP #define SHADER_HPP
#include <unordered_map> #include <open_engine/ref_scope.hpp>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <string> #include <string>

View File

@@ -8,7 +8,6 @@
#include <input/input_system.hpp> #include <input/input_system.hpp>
#include <imgui/imgui_layer.hpp> #include <imgui/imgui_layer.hpp>
#include <renderer/renderer.hpp> #include <renderer/renderer.hpp>
#include <instrumentor.hpp>
#include <core/time.hpp> #include <core/time.hpp>
#include <imgui.h> #include <imgui.h>

View File

@@ -332,7 +332,7 @@ namespace OpenEngine {
{ {
OE_PROFILE_FUNCTION(); OE_PROFILE_FUNCTION();
static bool show = true; static bool show = false;
if (show) if (show)
ImGui::ShowDemoWindow(&show); ImGui::ShowDemoWindow(&show);
} }

View File

@@ -1,5 +1,6 @@
#include <pch.hpp> #include <pch.hpp>
#include <core.hpp>
#include <logging.hpp> #include <logging.hpp>
#include <spdlog/sinks/stdout_color_sinks.h> #include <spdlog/sinks/stdout_color_sinks.h>

View File

@@ -1,5 +1,6 @@
#include <pch.hpp> #include <pch.hpp>
#include <core.hpp>
#include <opengl/opengl_buffer.hpp> #include <opengl/opengl_buffer.hpp>
#include <glad/glad.h> #include <glad/glad.h>

View File

@@ -1,5 +1,6 @@
#include <pch.hpp> #include <pch.hpp>
#include <core.hpp>
#include <opengl/opengl_context.hpp> #include <opengl/opengl_context.hpp>
#include <logging.hpp> #include <logging.hpp>

View File

@@ -30,7 +30,7 @@ namespace OpenEngine {
{ {
OE_PROFILE_FUNCTION(); OE_PROFILE_FUNCTION();
#ifdef OE_DEBUG #ifdef OE_DEBUG_TOOLS
glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(OpenGLMessageCallback, nullptr); glDebugMessageCallback(OpenGLMessageCallback, nullptr);

View File

@@ -2,10 +2,12 @@
#include <opengl/opengl_shader.hpp> #include <opengl/opengl_shader.hpp>
#include <core.hpp>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include <logging.hpp> #include <logging.hpp>
#include <glad/glad.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glad/glad.h>
#include <alloca.h> #include <alloca.h>
#include <cstddef> #include <cstddef>
#include <fstream> #include <fstream>
@@ -194,30 +196,44 @@ namespace OpenEngine {
void OpenGLShader::SetBool(const std::string &name, bool value) const void OpenGLShader::SetBool(const std::string &name, bool value) const
{ {
OE_PROFILE_FUNCTION();
UploadBool(name, value); UploadBool(name, value);
} }
void OpenGLShader::SetInt(const std::string &name, int value) const void OpenGLShader::SetInt(const std::string &name, int value) const
{ {
OE_PROFILE_FUNCTION();
UploadInt(name, value); UploadInt(name, value);
} }
void OpenGLShader::SetFloat(const std::string &name, float value) const void OpenGLShader::SetFloat(const std::string &name, float value) const
{ {
OE_PROFILE_FUNCTION();
UploadFloat(name, value); UploadFloat(name, value);
} }
void OpenGLShader::SetMat4(const std::string &name, const glm::mat4& value) const void OpenGLShader::SetMat4(const std::string &name, const glm::mat4& value) const
{ {
OE_PROFILE_FUNCTION();
UploadMat4(name, value); UploadMat4(name, value);
} }
void OpenGLShader::SetVec2(const std::string &name, const glm::vec2& value) const void OpenGLShader::SetVec2(const std::string &name, const glm::vec2& value) const
{ {
OE_PROFILE_FUNCTION();
UploadVec2(name, value); UploadVec2(name, value);
} }
void OpenGLShader::SetVec3(const std::string &name, const glm::vec3& value) const void OpenGLShader::SetVec3(const std::string &name, const glm::vec3& value) const
{ {
OE_PROFILE_FUNCTION();
UploadVec3(name, value); UploadVec3(name, value);
} }
void OpenGLShader::SetVec4(const std::string &name, const glm::vec4& value) const void OpenGLShader::SetVec4(const std::string &name, const glm::vec4& value) const
{ {
OE_PROFILE_FUNCTION();
UploadVec4(name, value); UploadVec4(name, value);
} }

View File

@@ -1,3 +1,5 @@
#include <filesystem>
#include <glm/trigonometric.hpp>
#include <pch.hpp> #include <pch.hpp>
#include <renderer/buffer.hpp> #include <renderer/buffer.hpp>
@@ -73,49 +75,43 @@ namespace OpenEngine {
renderer_data->texture_shader->Bind(); renderer_data->texture_shader->Bind();
renderer_data->texture_shader->SetMat4("u_ViewProjection", camera.GetViewProjectionMatrix()); renderer_data->texture_shader->SetMat4("u_ViewProjection", camera.GetViewProjectionMatrix());
renderer_data->texture_shader->SetMat4("u_ViewProjection", camera.GetViewProjectionMatrix());
} }
void Renderer2D::EndScene() void Renderer2D::EndScene()
{ {
} }
void Renderer2D::DrawQuad(const glm::vec2& position, const glm::vec2& size, const Ref<Texture2D>& texture) void Renderer2D::DrawQuad(const Transform& transform_data, const Ref<Texture2D>& texture, float tiling_factor)
{
OE_PROFILE_FUNCTION();
DrawQuad(glm::vec3(position, 0.0f), size, texture);
}
void Renderer2D::DrawQuad(const glm::vec3& position, const glm::vec2& size, const Ref<Texture2D>& texture)
{ {
OE_PROFILE_FUNCTION(); OE_PROFILE_FUNCTION();
renderer_data->texture_shader->SetVec4("u_Color", glm::vec4(1.0f)); renderer_data->texture_shader->SetVec4("u_Color", glm::vec4(1.0f));
renderer_data->texture_shader->SetFloat("u_TilingFactor", tiling_factor);
texture->Bind(); texture->Bind();
glm::mat4 transform = glm::translate(glm::mat4(1.0f), position) * glm::mat4 transform = glm::translate(glm::mat4(1.0f), transform_data.position)
glm::scale(glm::mat4(1.0f), {size.x, size.y, 1.0f}); * ((transform_data.rotation != 0) ?
glm::rotate(glm::mat4(1.0f), glm::radians(transform_data.rotation), {0.0f, 0.0f, 1.0f})
: 1.0f)
* glm::scale(glm::mat4(1.0f), transform_data.size);
renderer_data->texture_shader->SetMat4("u_Transform", transform); renderer_data->texture_shader->SetMat4("u_Transform", transform);
renderer_data->vertex_array->Bind(); renderer_data->vertex_array->Bind();
RenderCommand::DrawIndexed(renderer_data->vertex_array); RenderCommand::DrawIndexed(renderer_data->vertex_array);
} }
void Renderer2D::DrawQuad(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color) void Renderer2D::DrawQuad(const Transform& transform_data, const glm::vec4& color)
{
OE_PROFILE_FUNCTION();
DrawQuad(glm::vec3(position, 0.0f), size, color);
}
void Renderer2D::DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color)
{ {
OE_PROFILE_FUNCTION(); OE_PROFILE_FUNCTION();
renderer_data->texture_shader->SetVec4("u_Color", color); renderer_data->texture_shader->SetVec4("u_Color", color);
renderer_data->white_texture->Bind(); renderer_data->white_texture->Bind();
glm::mat4 transform = glm::translate(glm::mat4(1.0f), position) * glm::mat4 transform = glm::translate(glm::mat4(1.0f), transform_data.position)
glm::scale(glm::mat4(1.0f), {size.x, size.y, 1.0f}); * ((transform_data.rotation != 0) ?
glm::rotate(glm::mat4(1.0f), glm::radians(transform_data.rotation), {0.0f, 0.0f, 1.0f})
: 1.0f)
* glm::scale(glm::mat4(1.0f), transform_data.size);
renderer_data->texture_shader->SetMat4("u_Transform", transform); renderer_data->texture_shader->SetMat4("u_Transform", transform);
renderer_data->vertex_array->Bind(); renderer_data->vertex_array->Bind();

View File

@@ -8,7 +8,6 @@
#include <events/mouse_event.hpp> #include <events/mouse_event.hpp>
#include <renderer/renderer.hpp> #include <renderer/renderer.hpp>
#include <events/key_event.hpp> #include <events/key_event.hpp>
#include <instrumentor.hpp>
#include <logging.hpp> #include <logging.hpp>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@@ -103,19 +102,19 @@ namespace OpenEngine {
switch (action) { switch (action) {
case GLFW_PRESS: case GLFW_PRESS:
{ {
KeyPressedEvent event(key, scancode, 0, mods); KeyPressedEvent event(static_cast<KeyCode>(key), scancode, 0, mods);
data.event_callback(event); data.event_callback(event);
break; break;
} }
case GLFW_RELEASE: case GLFW_RELEASE:
{ {
KeyReleasedEvent event(key, scancode, mods); KeyReleasedEvent event(static_cast<KeyCode>(key), scancode, mods);
data.event_callback(event); data.event_callback(event);
break; break;
} }
case GLFW_REPEAT: case GLFW_REPEAT:
{ {
KeyPressedEvent event(key, scancode, 1, mods); KeyPressedEvent event(static_cast<KeyCode>(key), scancode, 1, mods);
data.event_callback(event); data.event_callback(event);
break; break;
} }
@@ -126,7 +125,7 @@ namespace OpenEngine {
{ {
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window); WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
KeyTypedEvent event(keycode); KeyTypedEvent event(static_cast<KeyCode>(keycode));
data.event_callback(event); data.event_callback(event);
}); });
@@ -137,13 +136,13 @@ namespace OpenEngine {
switch (action) { switch (action) {
case GLFW_PRESS: case GLFW_PRESS:
{ {
MouseButtonPressedEvent event(button); MouseButtonPressedEvent event(static_cast<MouseCode>(button));
data.event_callback(event); data.event_callback(event);
break; break;
} }
case GLFW_RELEASE: case GLFW_RELEASE:
{ {
MouseButtonReleasedEvent event(button); MouseButtonReleasedEvent event(static_cast<MouseCode>(button));
data.event_callback(event); data.event_callback(event);
break; break;
} }