style: switch to east const across the codebase
- const T* -> T const* in all headers and implementations - const T& -> T const& for copy constructor/operator= deletes - update AGENTS.md to document east const convention
This commit is contained in:
@@ -42,6 +42,7 @@ to the custom scripts instead of system-installed packages.
|
||||
- **4-space indentation**
|
||||
- **No semicolons after closing braces** for namespaces/classes
|
||||
- `auto` for obvious types (e.g. `auto main(...) -> int`)
|
||||
- **East const** (e.g. `char const*` not `const char*`)
|
||||
- `<>` 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
|
||||
|
||||
@@ -45,7 +45,7 @@ auto buffer::unbind() const -> void {
|
||||
glBindBuffer(static_cast<GLenum>(m_type), 0);
|
||||
}
|
||||
|
||||
auto buffer::upload(const void* data, size_t size) -> void {
|
||||
auto buffer::upload(void const* data, size_t size) -> void {
|
||||
bind();
|
||||
glBufferData(static_cast<GLenum>(m_type), size, data, GL_STATIC_DRAW);
|
||||
unbind();
|
||||
@@ -55,7 +55,7 @@ auto buffer::upload(std::vector<uint8_t> data) -> void {
|
||||
upload(data.data(), data.size());
|
||||
}
|
||||
|
||||
auto buffer::upload_dynamic(const void* data, size_t size) -> void {
|
||||
auto buffer::upload_dynamic(void const* data, size_t size) -> void {
|
||||
bind();
|
||||
glBufferData(static_cast<GLenum>(m_type), size, data, GL_DYNAMIC_DRAW);
|
||||
unbind();
|
||||
|
||||
@@ -23,17 +23,17 @@ public:
|
||||
explicit buffer(buffer_type type);
|
||||
~buffer();
|
||||
|
||||
buffer(const buffer&) = delete;
|
||||
buffer& operator=(const buffer&) = delete;
|
||||
buffer(buffer const&) = delete;
|
||||
buffer& operator=(buffer const&) = delete;
|
||||
|
||||
buffer(buffer&& other) noexcept;
|
||||
buffer& operator=(buffer&& other) noexcept;
|
||||
|
||||
auto bind() const -> void;
|
||||
auto unbind() const -> void;
|
||||
auto upload(const void* data, size_t size) -> void;
|
||||
auto upload(void const* data, size_t size) -> void;
|
||||
auto upload(std::vector<uint8_t> data) -> void;
|
||||
auto upload_dynamic(const void* data, size_t size) -> void;
|
||||
auto upload_dynamic(void const* data, size_t size) -> void;
|
||||
auto id() const -> GLuint;
|
||||
auto valid() const -> bool;
|
||||
};
|
||||
|
||||
@@ -33,10 +33,10 @@ auto context::setup_gl() -> bool {
|
||||
|
||||
auto context::print_info() -> void {
|
||||
fmt::print("OpenGL Info:\n");
|
||||
fmt::print(" vendor | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_VENDOR))));
|
||||
fmt::print(" renderer| {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_RENDERER))));
|
||||
fmt::print(" version | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
|
||||
fmt::print(" glsl | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION))));
|
||||
fmt::print(" vendor | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_VENDOR))));
|
||||
fmt::print(" renderer| {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_RENDERER))));
|
||||
fmt::print(" version | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_VERSION))));
|
||||
fmt::print(" glsl | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_SHADING_LANGUAGE_VERSION))));
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ shader& shader::operator=(shader&& other) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto shader::compile_vertex(const char* source) -> bool {
|
||||
auto shader::compile_vertex(char const* source) -> bool {
|
||||
auto vert = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vert, 1, &source, nullptr);
|
||||
glCompileShader(vert);
|
||||
@@ -55,7 +55,7 @@ auto shader::compile_vertex(const char* source) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto shader::compile_fragment(const char* source) -> bool {
|
||||
auto shader::compile_fragment(char const* source) -> bool {
|
||||
auto frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(frag, 1, &source, nullptr);
|
||||
glCompileShader(frag);
|
||||
|
||||
@@ -13,14 +13,14 @@ public:
|
||||
shader();
|
||||
~shader();
|
||||
|
||||
shader(const shader&) = delete;
|
||||
shader& operator=(const shader&) = delete;
|
||||
shader(shader const&) = delete;
|
||||
shader& operator=(shader const&) = delete;
|
||||
|
||||
shader(shader&& other) noexcept;
|
||||
shader& operator=(shader&& other) noexcept;
|
||||
|
||||
auto compile_vertex(const char* source) -> bool;
|
||||
auto compile_fragment(const char* source) -> bool;
|
||||
auto compile_vertex(char const* source) -> bool;
|
||||
auto compile_fragment(char const* source) -> bool;
|
||||
auto link() -> bool;
|
||||
auto use() const -> void;
|
||||
auto unuse() const -> void;
|
||||
|
||||
@@ -46,7 +46,7 @@ auto texture::unbind() -> void {
|
||||
glBindTexture(static_cast<GLenum>(m_target), 0);
|
||||
}
|
||||
|
||||
auto texture::upload(const void* data, int width, int height, texture_format format, texture_type type) -> void {
|
||||
auto texture::upload(void const* data, int width, int height, texture_format format, texture_type type) -> void {
|
||||
bind();
|
||||
glTexImage2D(static_cast<GLenum>(m_target), 0,
|
||||
static_cast<GLenum>(format), width, height, 0,
|
||||
|
||||
@@ -38,15 +38,15 @@ public:
|
||||
explicit texture(texture_target target);
|
||||
~texture();
|
||||
|
||||
texture(const texture&) = delete;
|
||||
texture& operator=(const texture&) = delete;
|
||||
texture(texture const&) = delete;
|
||||
texture& operator=(texture const&) = delete;
|
||||
|
||||
texture(texture&& other) noexcept;
|
||||
texture& operator=(texture&& other) noexcept;
|
||||
|
||||
auto bind(GLuint unit = 0) -> void;
|
||||
auto unbind() -> void;
|
||||
auto upload(const void* data, int width, int height, texture_format format, texture_type type) -> void;
|
||||
auto upload(void const* data, int width, int height, texture_format format, texture_type type) -> void;
|
||||
auto set_filter(GLenum min_filter, GLenum mag_filter) -> void;
|
||||
auto set_wrap(GLenum wrap_s, GLenum wrap_t) -> void;
|
||||
auto generate_mipmaps() -> void;
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ public:
|
||||
vao();
|
||||
~vao();
|
||||
|
||||
vao(const vao&) = delete;
|
||||
vao& operator=(const vao&) = delete;
|
||||
vao(vao const&) = delete;
|
||||
vao& operator=(vao const&) = delete;
|
||||
|
||||
vao(vao&& other) noexcept;
|
||||
vao& operator=(vao&& other) noexcept;
|
||||
|
||||
@@ -19,7 +19,7 @@ auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
|
||||
// compile shader
|
||||
auto prog = cbt::opengl::shader();
|
||||
|
||||
const char* vert_src = R"glsl(
|
||||
char const* vert_src = R"glsl(
|
||||
#version 410 core
|
||||
layout(location = 0) in vec3 a_pos;
|
||||
layout(location = 1) in vec3 a_color;
|
||||
@@ -30,7 +30,7 @@ auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
|
||||
}
|
||||
)glsl";
|
||||
|
||||
const char* frag_src = R"glsl(
|
||||
char const* frag_src = R"glsl(
|
||||
#version 410 core
|
||||
in vec3 v_color;
|
||||
out vec4 frag_color;
|
||||
|
||||
Reference in New Issue
Block a user