style: move public members first in class declarations

- Reorder all class headers to put public interface before private members
- Document convention in AGENTS.md
This commit is contained in:
2026-05-05 22:30:56 +02:00
parent e71c4d55cf
commit b6adb7c23a
8 changed files with 34 additions and 26 deletions
+1
View File
@@ -44,6 +44,7 @@ to the custom scripts instead of system-installed packages.
- `auto` for obvious types (e.g. `auto main(...) -> int`) - `auto` for obvious types (e.g. `auto main(...) -> int`)
- **East const** (e.g. `char const*` not `const char*`) - **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&`) - **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 only for system headers (std, OS, etc.)
- `""` includes for third-party dependencies (e.g. `fmt`, `nlohmann/json`) - `""` includes for third-party dependencies (e.g. `fmt`, `nlohmann/json`)
- **Naming:** `snake_case` for variables, functions, and classes - **Naming:** `snake_case` for variables, functions, and classes
+4 -3
View File
@@ -15,9 +15,6 @@ enum class buffer_type {
}; };
class buffer { class buffer {
GLuint m_id = 0;
buffer_type m_type = buffer_type::vertex;
public: public:
buffer(); buffer();
explicit buffer(buffer_type type); explicit buffer(buffer_type type);
@@ -36,6 +33,10 @@ public:
auto upload_dynamic(void const* data, size_t size) -> void; auto upload_dynamic(void const* data, size_t size) -> void;
auto id() const -> GLuint; auto id() const -> GLuint;
auto valid() const -> bool; auto valid() const -> bool;
private:
GLuint m_id = 0;
buffer_type m_type = buffer_type::vertex;
}; };
} }
+9 -8
View File
@@ -8,14 +8,6 @@
namespace cbt::opengl { namespace cbt::opengl {
class context { 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: public:
explicit context(std::string title, int width, int height); explicit context(std::string title, int width, int height);
~context(); ~context();
@@ -25,6 +17,15 @@ public:
auto swap_buffers() -> void; auto swap_buffers() -> void;
auto poll_events() -> void; auto poll_events() -> void;
auto raw() const -> GLFWwindow*; 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;
}; };
} }
+3 -2
View File
@@ -16,14 +16,15 @@ struct descriptor_binding {
}; };
class descriptor_set { class descriptor_set {
std::vector<descriptor_binding> m_bindings;
public: public:
descriptor_set(); descriptor_set();
auto add_texture(texture tex, GLuint unit = 0) -> void; auto add_texture(texture tex, GLuint unit = 0) -> void;
auto add_buffer(buffer buf, GLuint unit = 0) -> void; auto add_buffer(buffer buf, GLuint unit = 0) -> void;
auto bind_all() -> void; auto bind_all() -> void;
auto count() const -> size_t; auto count() const -> size_t;
private:
std::vector<descriptor_binding> m_bindings;
}; };
} }
+3 -2
View File
@@ -7,8 +7,6 @@
namespace cbt::opengl { namespace cbt::opengl {
class shader { class shader {
GLuint m_id = 0;
public: public:
shader(); shader();
~shader(); ~shader();
@@ -26,6 +24,9 @@ public:
auto unuse() const -> void; auto unuse() const -> void;
auto id() const -> GLuint; auto id() const -> GLuint;
auto valid() const -> bool; auto valid() const -> bool;
private:
GLuint m_id = 0;
}; };
} }
+4 -3
View File
@@ -30,9 +30,6 @@ enum class texture_type {
}; };
class texture { class texture {
GLuint m_id = 0;
texture_target m_target = texture_target::_2d;
public: public:
texture(); texture();
explicit texture(texture_target target); explicit texture(texture_target target);
@@ -52,6 +49,10 @@ public:
auto generate_mipmaps() -> void; auto generate_mipmaps() -> void;
auto id() const -> GLuint; auto id() const -> GLuint;
auto valid() const -> bool; auto valid() const -> bool;
private:
GLuint m_id = 0;
texture_target m_target = texture_target::_2d;
}; };
} }
+3 -2
View File
@@ -5,8 +5,6 @@
namespace cbt::opengl { namespace cbt::opengl {
class vao { class vao {
GLuint m_id = 0;
public: public:
vao(); vao();
~vao(); ~vao();
@@ -21,6 +19,9 @@ public:
auto unbind() const -> void; auto unbind() const -> void;
auto id() const -> GLuint; auto id() const -> GLuint;
auto valid() const -> bool; auto valid() const -> bool;
private:
GLuint m_id = 0;
}; };
} }
+7 -6
View File
@@ -11,6 +11,13 @@
namespace cbt::scenes { namespace cbt::scenes {
class cube final : public scene { 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::shader m_prog;
opengl::buffer m_vbo; opengl::buffer m_vbo;
opengl::vao m_vao; opengl::vao m_vao;
@@ -23,12 +30,6 @@ class cube final : public scene {
auto build_mesh() -> void; auto build_mesh() -> void;
auto build_shader() -> bool; auto build_shader() -> bool;
public:
cube();
auto init() -> bool override;
auto update(float delta_time) -> void override;
auto render() -> void override;
}; };
} }