Files
cuber/cuber.cpp
T
portersky e71c4d55cf refactor: split into static libraries and restructure scenes
- Create cbt_opengl static library for OpenGL abstraction
- Create cbt_scene static library for base scene class
- Create scenes_cube static library for cube scene
- Move scene base to cbt/ (utility), scenes to root scenes/
- Link libraries in dependency chain: cuber -> scenes -> cbt_scene -> cbt_opengl
2026-05-05 22:27:19 +02:00

60 lines
1.1 KiB
C++

#define GLFW_INCLUDE_NONE
#include "GLFW/glfw3.h"
#include "cbt/opengl/context.hpp"
#include "scenes/cube.hpp"
#include <csignal>
#include <asio.hpp>
auto main(int, char const*[]) -> int {
auto ctx = cbt::opengl::context("cuber", 1280, 720);
if (!ctx.valid()) {
return 1;
}
auto scn = cbt::scenes::cube();
if (!scn.init()) {
return 1;
}
// signal handling
asio::io_context io;
asio::signal_set signals(io, SIGINT, SIGTERM);
bool quit = false;
signals.async_wait([&](auto, auto) {
quit = true;
io.stop();
});
auto process_signals = [&]() -> void {
while (io.poll()) {}
};
// render loop
auto prev = std::chrono::steady_clock::now();
while (!ctx.should_close()) {
process_signals();
if (quit || glfwGetKey(ctx.raw(), GLFW_KEY_Q) == GLFW_PRESS) {
break;
}
auto now = std::chrono::steady_clock::now();
auto dt = std::chrono::duration<float>(now - prev).count();
prev = now;
scn.update(dt);
scn.render();
ctx.swap_buffers();
ctx.poll_events();
}
return 0;
}