#2 - Static linking & dependency reduction

This commit is contained in:
Martin Slachta
2026-08-04 21:18:46 +02:00
parent a097f4d4b0
commit 2f0662e2bb
21 changed files with 86 additions and 767 deletions
+1
View File
@@ -27,6 +27,7 @@ target_link_libraries(${PROJECT_NAME}
tw::quicr
loft::common
loft::base
${LIBDECOR_LIB}
loft_window
loft::render_graph
tw::protocol
+128
View File
@@ -0,0 +1,128 @@
#pragma once
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_keycode.h>
#include <imgui_impl_sdl3.h>
#include <Window.hpp>
#include "common.hpp"
#include "debug/ComponentGui.hpp"
#include "imgui.h"
namespace tw::io {
class InputManager {
private:
lft::win::Window* m_window;
bool m_is_quit;
float m_velocity_x;
float m_velocity_y;
bool m_is_jumping;
bool m_is_pressed[4];
float m_motion_x;
float m_motion_y;
public:
GET(m_is_quit, is_quit);
float axis_y() const {
float result = 0.0f;
if(m_is_pressed[0]) {
result += 1.0f;
} if(m_is_pressed[1]) {
result -= 1.0f;
}
return result;
}
float axis_x() const {
float result = 0.0f;
if(m_is_pressed[2]) {
result += 1.0f;
} if(m_is_pressed[3]) {
result -= 1.0f;
}
return result;
}
GET(m_motion_x, motion_x);
GET(m_motion_y, motion_y);
InputManager(lft::win::Window* window) :
m_window(window),
m_is_quit(false)
{
m_is_pressed[0] = m_is_pressed[1] = m_is_pressed[2] = m_is_pressed[3] = false;
}
void update() {
SDL_Event event;
m_motion_x = 0.0f;
m_motion_y = 0.0f;
while(m_window->poll_event(&event)) {
ImGui_ImplSDL3_ProcessEvent(&event);
switch(event.type) {
case SDL_EVENT_QUIT:
m_is_quit = true;
break;
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP: {
switch(event.key.key) {
case SDLK_W:
m_is_pressed[0] = event.key.down;
break;
case SDLK_S:
m_is_pressed[1] = event.key.down;
break;
case SDLK_A:
m_is_pressed[2] = event.key.down;
break;
case SDLK_D:
m_is_pressed[3] = event.key.down;
break;
}
} break;
case SDL_EVENT_MOUSE_MOTION:
m_motion_x = event.motion.xrel;
m_motion_y = event.motion.yrel;
break;
}
}
}
};
class InputState {
public:
};
}
namespace tw::dbg {
template<>
class ComponentGui<tw::io::InputManager> {
public:
void draw(tw::io::InputManager* instance) {
ImGui::SeparatorText("Character Body Component");
float motion[2] = {instance->motion_x(), instance->motion_y()};
ImGui::InputFloat2("Motion", motion);
float axis[2] = {instance->axis_x(), instance->axis_y()};
ImGui::InputFloat2("Axis", axis);
}
};
}
+2 -3
View File
@@ -10,7 +10,7 @@
#include "imgui.h"
#include "imgui_impl_vulkan.h"
#include "imgui_impl_sdl2.h"
#include "imgui_impl_sdl3.h"
#include "implot.h"
#include "implot_internal.h"
@@ -18,7 +18,6 @@
#include "spdlog/spdlog.h"
#include <SDL_events.h>
#include <glm/glm.hpp>
#include <tracy/Tracy.hpp>
#include <memory>
@@ -105,7 +104,7 @@ void Runtime::run() {
}
ImGui_ImplVulkan_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
m_input_manager.update();