Add fastgltf, mouse capture

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-12-06 20:11:59 +02:00
parent 7b8f432623
commit f0e8af534d
7 changed files with 47 additions and 10 deletions

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "thirdparty/smath"]
path = thirdparty/smath
url = https://github.com/slendidev/smath.git
[submodule "subprojects/fastgltf"]
path = subprojects/fastgltf
url = https://github.com/spnda/fastgltf.git

View File

@@ -4,9 +4,18 @@ project('vr-compositor', 'cpp',
'cpp_std=c++26',
'warning_level=everything',
'werror=true',
]
],
subproject_dir: 'subprojects',
)
cmake = import('cmake')
fastgltf_opts = cmake.subproject_options()
fastgltf_opts.set_override_option('cpp_std', 'c++23')
fastgltf_opts.set_override_option('warning_level', '0')
fastgltf_opts.set_override_option('werror', 'false')
fastgltf = cmake.subproject('fastgltf', options: fastgltf_opts)
cc = meson.get_compiler('cpp')
wayland_dep = dependency('wayland-server')
@@ -22,6 +31,7 @@ imgui_src = files(
'thirdparty/imgui/backends/imgui_impl_vulkan.cpp',
'thirdparty/imgui/backends/imgui_impl_sdl3.cpp',
)
fastgltf_dep = fastgltf.dependency('fastgltf')
vkbootstrap_dev = get_option('vkbootstrap_dev')
vkbootstrap_lib = get_option('vkbootstrap_lib')
@@ -49,6 +59,7 @@ add_project_arguments(
'-Wno-old-style-cast',
'-Wno-implicit-int-float-conversion',
'-Wno-implicit-float-conversion',
'-Wno-c++98-compat',
],
language : 'cpp'
)
@@ -104,6 +115,7 @@ exe = executable('vr-compositor',
vkbootstrap_dep,
zlib_dep,
sdl3_dep,
fastgltf_dep,
],
cpp_args: [
'--embed-dir=' + join_paths(meson.project_build_root(), 'shaders')

View File

@@ -33,6 +33,8 @@ Application::Application()
m_renderer = std::make_unique<VulkanRenderer>(m_window, m_logger);
mouse_captured(true);
m_logger.info("App init done!");
}
@@ -71,6 +73,11 @@ auto Application::run() -> void
SDL_GetWindowSize(m_window, &width, &height);
m_renderer->resize(static_cast<uint32_t>(width),
static_cast<uint32_t>(height));
} else if (e.type == SDL_EVENT_KEY_DOWN && e.key.repeat == false) {
if (e.key.key == SDLK_F11 && e.key.mod & SDL_KMOD_LCTRL) {
mouse_captured(!mouse_captured());
m_show_imgui = mouse_captured();
}
}
ImGui_ImplSDL3_ProcessEvent(&e);
@@ -81,6 +88,7 @@ auto Application::run() -> void
ImGui::NewFrame();
if (m_show_imgui) {
ImGui::ShowDemoWindow();
ImGui::SetNextWindowSize({ 100, 50 });
@@ -93,6 +101,7 @@ auto Application::run() -> void
ImGui::Text("%s", std::format("FPS: {:.2f}", fps).c_str());
}
ImGui::PopStyleColor();
}
ImGui::Render();
@@ -100,4 +109,11 @@ auto Application::run() -> void
}
}
auto Application::mouse_captured(bool new_state) -> void
{
SDL_CaptureMouse(new_state);
m_mouse_captured = new_state;
}
} // namespace Lunar

View File

@@ -17,6 +17,9 @@ struct Application {
~Application();
auto run() -> void;
auto mouse_captured(bool new_state) -> void;
auto mouse_captured() const -> bool { return m_mouse_captured; }
auto toggle_mouse_captured() -> void { mouse_captured(!m_mouse_captured); }
private:
SDL_Window *m_window { nullptr };
@@ -24,6 +27,8 @@ private:
std::unique_ptr<VulkanRenderer> m_renderer;
bool m_running { true };
bool m_mouse_captured { false };
bool m_show_imgui { false };
};
} // namespace Lunar

0
subprojects/.wraplock Normal file
View File

1
subprojects/fastgltf Submodule

Submodule subprojects/fastgltf added at d3d6ee651f

0
thirdparty/.wraplock vendored Normal file
View File