This commit is contained in:
Pcornat 2026-09-24 19:20:35 +02:00
commit 25278cb496
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD

View file

@ -24,7 +24,9 @@ namespace gui {
glfwMakeContextCurrent(wwindow.get()); glfwMakeContextCurrent(wwindow.get());
glfwSetFramebufferSizeCallback(wwindow.get(), glfwSetFramebufferSizeCallback(wwindow.get(),
framebufferCallback != nullptr ? framebufferCallback : internalFramebufferCallback); framebufferCallback != nullptr
? framebufferCallback
: internalFramebufferCallback);
glfwSwapInterval(1); // VSync on glfwSwapInterval(1); // VSync on
glfwSetKeyCallback(wwindow.get(), key_callback); glfwSetKeyCallback(wwindow.get(), key_callback);
@ -50,31 +52,33 @@ namespace gui {
void Window::key_callback(GLFWwindow *window, const int key, const int scancode, const int action, const int mods) { void Window::key_callback(GLFWwindow *window, const int key, const int scancode, const int action, const int mods) {
auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window)); auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window));
std::ranges::for_each(*modules, std::ranges::for_each(*modules,
[=](modulesType::reference item) { item.second->key_callback(key, scancode, action, mods); }); [=](modulesType::reference item) {
item.second->key_callback(key, scancode, action, mods);
});
} }
void Window::cursor_position_callback(GLFWwindow *window, const double xpos, const double ypos) { void Window::cursor_position_callback(GLFWwindow *window, const double xpos, const double ypos) {
auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window)); auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window));
std::ranges::for_each(*modules, std::ranges::for_each(*modules,
[=](modulesType::reference item) { item.second->cursor_position_callback(xpos, ypos); }); [=](modulesType::reference item) { item.second->cursor_position_callback(xpos, ypos); });
} }
void Window::scroll_callback(GLFWwindow *window, const double xoffset, const double yoffset) { void Window::scroll_callback(GLFWwindow *window, const double xoffset, const double yoffset) {
auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window)); auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window));
std::ranges::for_each(*modules, std::ranges::for_each(*modules,
[=](modulesType::reference item) { item.second->scroll_callback(xoffset, yoffset); }); [=](modulesType::reference item) { item.second->scroll_callback(xoffset, yoffset); });
} }
void Window::window_size_callback(GLFWwindow *window, const int width, const int height) { void Window::window_size_callback(GLFWwindow *window, const int width, const int height) {
auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window)); auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window));
std::ranges::for_each(*modules, std::ranges::for_each(*modules,
[=](modulesType::reference item) { item.second->window_size(width, height); }); [=](modulesType::reference item) { item.second->window_size(width, height); });
} }
void Window::window_pos_callback(GLFWwindow *window, const int xpos, const int ypos) { void Window::window_pos_callback(GLFWwindow *window, const int xpos, const int ypos) {
auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window)); auto *modules = static_cast<modulesType *>(glfwGetWindowUserPointer(window));
std::ranges::for_each(*modules, std::ranges::for_each(*modules,
[=](modulesType::reference item) { item.second->window_pos(xpos, ypos); }); [=](modulesType::reference item) { item.second->window_pos(xpos, ypos); });
} }
void Window::add_module(data::BasicData &module) { void Window::add_module(data::BasicData &module) {