refactor: separate window from opengl::context

Extract GLFW window management into a dedicated cbt::window
class (new files in cbt/). The opengl::context now only
handles GLAD setup and context activation (no more window
creation or GLFW init/terminate).

Updated main loop in cuber.cpp, CMakeLists.txt (to build
the new source), and AGENTS.md (docs + source layout).

Addresses the design note in context.cpp about mixing
concerns.
This commit is contained in:
2026-05-05 23:37:19 +02:00
parent 7a81b30d32
commit 22d2bb1c40
7 changed files with 140 additions and 93 deletions
+3 -13
View File
@@ -1,29 +1,19 @@
#pragma once
#include <string>
#define GLFW_INCLUDE_NONE
#include "GLFW/glfw3.h"
#include "cbt/window.hpp"
namespace cbt::opengl {
class context {
public:
explicit context(std::string title, int width, int height);
explicit context(window const& win);
~context();
auto should_close() const -> bool;
auto valid() const -> bool;
auto swap_buffers() -> void;
auto poll_events() -> void;
auto raw() const -> GLFWwindow*;
private:
GLFWwindow* m_window = nullptr;
bool m_initialized = false;
bool m_valid = false;
static auto init() -> bool;
static auto terminate() -> void;
static auto setup_gl() -> bool;
static auto print_info() -> void;
};