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
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include <string>
#define GLFW_INCLUDE_NONE
#include "GLFW/glfw3.h"
namespace cbt {
class window {
public:
explicit window(std::string title, int width, int height);
~window();
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_glfw_initialized = false;
static auto init_glfw() -> bool;
static auto terminate_glfw() -> void;
};
}