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:
+3
-13
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user