diff --git a/AGENTS.md b/AGENTS.md index 7479557..3241488 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,6 +44,7 @@ to the custom scripts instead of system-installed packages. - `auto` for obvious types (e.g. `auto main(...) -> int`) - **East const** (e.g. `char const*` not `const char*`) - **Trailing return type** for all function definitions, including operators (e.g. `auto operator=(T&&) noexcept -> T&`) +- **Public members first** in class declarations, private members at the bottom - `<>` includes only for system headers (std, OS, etc.) - `""` includes for third-party dependencies (e.g. `fmt`, `nlohmann/json`) - **Naming:** `snake_case` for variables, functions, and classes diff --git a/cbt/opengl/buffer.hpp b/cbt/opengl/buffer.hpp index 5dbd631..5655bc9 100644 --- a/cbt/opengl/buffer.hpp +++ b/cbt/opengl/buffer.hpp @@ -15,9 +15,6 @@ enum class buffer_type { }; class buffer { - GLuint m_id = 0; - buffer_type m_type = buffer_type::vertex; - public: buffer(); explicit buffer(buffer_type type); @@ -36,6 +33,10 @@ public: auto upload_dynamic(void const* data, size_t size) -> void; auto id() const -> GLuint; auto valid() const -> bool; + +private: + GLuint m_id = 0; + buffer_type m_type = buffer_type::vertex; }; } diff --git a/cbt/opengl/context.hpp b/cbt/opengl/context.hpp index 69b6aab..d26f744 100644 --- a/cbt/opengl/context.hpp +++ b/cbt/opengl/context.hpp @@ -8,14 +8,6 @@ namespace cbt::opengl { class context { - GLFWwindow* m_window = nullptr; - bool m_initialized = false; - - static auto init() -> bool; - static auto terminate() -> void; - static auto setup_gl() -> bool; - static auto print_info() -> void; - public: explicit context(std::string title, int width, int height); ~context(); @@ -25,6 +17,15 @@ public: auto swap_buffers() -> void; auto poll_events() -> void; auto raw() const -> GLFWwindow*; + +private: + GLFWwindow* m_window = nullptr; + bool m_initialized = false; + + static auto init() -> bool; + static auto terminate() -> void; + static auto setup_gl() -> bool; + static auto print_info() -> void; }; } diff --git a/cbt/opengl/descriptor.hpp b/cbt/opengl/descriptor.hpp index b380154..f147247 100644 --- a/cbt/opengl/descriptor.hpp +++ b/cbt/opengl/descriptor.hpp @@ -16,14 +16,15 @@ struct descriptor_binding { }; class descriptor_set { - std::vector m_bindings; - public: descriptor_set(); auto add_texture(texture tex, GLuint unit = 0) -> void; auto add_buffer(buffer buf, GLuint unit = 0) -> void; auto bind_all() -> void; auto count() const -> size_t; + +private: + std::vector m_bindings; }; } diff --git a/cbt/opengl/shader.hpp b/cbt/opengl/shader.hpp index 5864a5a..cd9db0b 100644 --- a/cbt/opengl/shader.hpp +++ b/cbt/opengl/shader.hpp @@ -7,8 +7,6 @@ namespace cbt::opengl { class shader { - GLuint m_id = 0; - public: shader(); ~shader(); @@ -26,6 +24,9 @@ public: auto unuse() const -> void; auto id() const -> GLuint; auto valid() const -> bool; + +private: + GLuint m_id = 0; }; } diff --git a/cbt/opengl/texture.hpp b/cbt/opengl/texture.hpp index 6329074..e10a7e8 100644 --- a/cbt/opengl/texture.hpp +++ b/cbt/opengl/texture.hpp @@ -30,9 +30,6 @@ enum class texture_type { }; class texture { - GLuint m_id = 0; - texture_target m_target = texture_target::_2d; - public: texture(); explicit texture(texture_target target); @@ -52,6 +49,10 @@ public: auto generate_mipmaps() -> void; auto id() const -> GLuint; auto valid() const -> bool; + +private: + GLuint m_id = 0; + texture_target m_target = texture_target::_2d; }; } diff --git a/cbt/opengl/vao.hpp b/cbt/opengl/vao.hpp index ca07609..838d166 100644 --- a/cbt/opengl/vao.hpp +++ b/cbt/opengl/vao.hpp @@ -5,8 +5,6 @@ namespace cbt::opengl { class vao { - GLuint m_id = 0; - public: vao(); ~vao(); @@ -21,6 +19,9 @@ public: auto unbind() const -> void; auto id() const -> GLuint; auto valid() const -> bool; + +private: + GLuint m_id = 0; }; } diff --git a/scenes/cube.hpp b/scenes/cube.hpp index 8884087..66069d9 100644 --- a/scenes/cube.hpp +++ b/scenes/cube.hpp @@ -11,6 +11,13 @@ namespace cbt::scenes { class cube final : public scene { +public: + cube(); + auto init() -> bool override; + auto update(float delta_time) -> void override; + auto render() -> void override; + +private: opengl::shader m_prog; opengl::buffer m_vbo; opengl::vao m_vao; @@ -23,12 +30,6 @@ class cube final : public scene { auto build_mesh() -> void; auto build_shader() -> bool; - -public: - cube(); - auto init() -> bool override; - auto update(float delta_time) -> void override; - auto render() -> void override; }; }