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**
|
- **4-space indentation**
|
||||||
- **No semicolons after closing braces** for namespaces/classes
|
- **No semicolons after closing braces** for namespaces/classes
|
||||||
- `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*`)
|
||||||
- `<>` 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
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ auto buffer::unbind() const -> void {
|
|||||||
glBindBuffer(static_cast<GLenum>(m_type), 0);
|
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();
|
bind();
|
||||||
glBufferData(static_cast<GLenum>(m_type), size, data, GL_STATIC_DRAW);
|
glBufferData(static_cast<GLenum>(m_type), size, data, GL_STATIC_DRAW);
|
||||||
unbind();
|
unbind();
|
||||||
@@ -55,7 +55,7 @@ auto buffer::upload(std::vector<uint8_t> data) -> void {
|
|||||||
upload(data.data(), data.size());
|
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();
|
bind();
|
||||||
glBufferData(static_cast<GLenum>(m_type), size, data, GL_DYNAMIC_DRAW);
|
glBufferData(static_cast<GLenum>(m_type), size, data, GL_DYNAMIC_DRAW);
|
||||||
unbind();
|
unbind();
|
||||||
|
|||||||
@@ -23,17 +23,17 @@ public:
|
|||||||
explicit buffer(buffer_type type);
|
explicit buffer(buffer_type type);
|
||||||
~buffer();
|
~buffer();
|
||||||
|
|
||||||
buffer(const buffer&) = delete;
|
buffer(buffer const&) = delete;
|
||||||
buffer& operator=(const buffer&) = delete;
|
buffer& operator=(buffer const&) = delete;
|
||||||
|
|
||||||
buffer(buffer&& other) noexcept;
|
buffer(buffer&& other) noexcept;
|
||||||
buffer& operator=(buffer&& other) noexcept;
|
buffer& operator=(buffer&& other) noexcept;
|
||||||
|
|
||||||
auto bind() const -> void;
|
auto bind() const -> void;
|
||||||
auto unbind() 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(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 id() const -> GLuint;
|
||||||
auto valid() const -> bool;
|
auto valid() const -> bool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ auto context::setup_gl() -> bool {
|
|||||||
|
|
||||||
auto context::print_info() -> void {
|
auto context::print_info() -> void {
|
||||||
fmt::print("OpenGL Info:\n");
|
fmt::print("OpenGL Info:\n");
|
||||||
fmt::print(" vendor | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_VENDOR))));
|
fmt::print(" vendor | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_VENDOR))));
|
||||||
fmt::print(" renderer| {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_RENDERER))));
|
fmt::print(" renderer| {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_RENDERER))));
|
||||||
fmt::print(" version | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
|
fmt::print(" version | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_VERSION))));
|
||||||
fmt::print(" glsl | {}\n", std::string_view(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION))));
|
fmt::print(" glsl | {}\n", std::string_view(reinterpret_cast<char const*>(glGetString(GL_SHADING_LANGUAGE_VERSION))));
|
||||||
fmt::print("\n");
|
fmt::print("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ shader& shader::operator=(shader&& other) noexcept {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto shader::compile_vertex(const char* source) -> bool {
|
auto shader::compile_vertex(char const* source) -> bool {
|
||||||
auto vert = glCreateShader(GL_VERTEX_SHADER);
|
auto vert = glCreateShader(GL_VERTEX_SHADER);
|
||||||
glShaderSource(vert, 1, &source, nullptr);
|
glShaderSource(vert, 1, &source, nullptr);
|
||||||
glCompileShader(vert);
|
glCompileShader(vert);
|
||||||
@@ -55,7 +55,7 @@ auto shader::compile_vertex(const char* source) -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto shader::compile_fragment(const char* source) -> bool {
|
auto shader::compile_fragment(char const* source) -> bool {
|
||||||
auto frag = glCreateShader(GL_FRAGMENT_SHADER);
|
auto frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
glShaderSource(frag, 1, &source, nullptr);
|
glShaderSource(frag, 1, &source, nullptr);
|
||||||
glCompileShader(frag);
|
glCompileShader(frag);
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ public:
|
|||||||
shader();
|
shader();
|
||||||
~shader();
|
~shader();
|
||||||
|
|
||||||
shader(const shader&) = delete;
|
shader(shader const&) = delete;
|
||||||
shader& operator=(const shader&) = delete;
|
shader& operator=(shader const&) = delete;
|
||||||
|
|
||||||
shader(shader&& other) noexcept;
|
shader(shader&& other) noexcept;
|
||||||
shader& operator=(shader&& other) noexcept;
|
shader& operator=(shader&& other) noexcept;
|
||||||
|
|
||||||
auto compile_vertex(const char* source) -> bool;
|
auto compile_vertex(char const* source) -> bool;
|
||||||
auto compile_fragment(const char* source) -> bool;
|
auto compile_fragment(char const* source) -> bool;
|
||||||
auto link() -> bool;
|
auto link() -> bool;
|
||||||
auto use() const -> void;
|
auto use() const -> void;
|
||||||
auto unuse() const -> void;
|
auto unuse() const -> void;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ auto texture::unbind() -> void {
|
|||||||
glBindTexture(static_cast<GLenum>(m_target), 0);
|
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();
|
bind();
|
||||||
glTexImage2D(static_cast<GLenum>(m_target), 0,
|
glTexImage2D(static_cast<GLenum>(m_target), 0,
|
||||||
static_cast<GLenum>(format), width, height, 0,
|
static_cast<GLenum>(format), width, height, 0,
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ public:
|
|||||||
explicit texture(texture_target target);
|
explicit texture(texture_target target);
|
||||||
~texture();
|
~texture();
|
||||||
|
|
||||||
texture(const texture&) = delete;
|
texture(texture const&) = delete;
|
||||||
texture& operator=(const texture&) = delete;
|
texture& operator=(texture const&) = delete;
|
||||||
|
|
||||||
texture(texture&& other) noexcept;
|
texture(texture&& other) noexcept;
|
||||||
texture& operator=(texture&& other) noexcept;
|
texture& operator=(texture&& other) noexcept;
|
||||||
|
|
||||||
auto bind(GLuint unit = 0) -> void;
|
auto bind(GLuint unit = 0) -> void;
|
||||||
auto unbind() -> 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_filter(GLenum min_filter, GLenum mag_filter) -> void;
|
||||||
auto set_wrap(GLenum wrap_s, GLenum wrap_t) -> void;
|
auto set_wrap(GLenum wrap_s, GLenum wrap_t) -> void;
|
||||||
auto generate_mipmaps() -> void;
|
auto generate_mipmaps() -> void;
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ public:
|
|||||||
vao();
|
vao();
|
||||||
~vao();
|
~vao();
|
||||||
|
|
||||||
vao(const vao&) = delete;
|
vao(vao const&) = delete;
|
||||||
vao& operator=(const vao&) = delete;
|
vao& operator=(vao const&) = delete;
|
||||||
|
|
||||||
vao(vao&& other) noexcept;
|
vao(vao&& other) noexcept;
|
||||||
vao& operator=(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
|
// compile shader
|
||||||
auto prog = cbt::opengl::shader();
|
auto prog = cbt::opengl::shader();
|
||||||
|
|
||||||
const char* vert_src = R"glsl(
|
char const* vert_src = R"glsl(
|
||||||
#version 410 core
|
#version 410 core
|
||||||
layout(location = 0) in vec3 a_pos;
|
layout(location = 0) in vec3 a_pos;
|
||||||
layout(location = 1) in vec3 a_color;
|
layout(location = 1) in vec3 a_color;
|
||||||
@@ -30,7 +30,7 @@ auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
|
|||||||
}
|
}
|
||||||
)glsl";
|
)glsl";
|
||||||
|
|
||||||
const char* frag_src = R"glsl(
|
char const* frag_src = R"glsl(
|
||||||
#version 410 core
|
#version 410 core
|
||||||
in vec3 v_color;
|
in vec3 v_color;
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|||||||
Reference in New Issue
Block a user