From 63692ced174ce1894c9221edc9231ed8af48dc05 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Mar 2020 15:25:37 -0400 Subject: [PATCH] class names to PascalCase --- vis/include/cgl/buffer.hpp | 18 +++++++++--------- vis/include/cgl/error.hpp | 18 +++++++++--------- vis/include/cgl/pipeline.hpp | 12 ++++++------ vis/include/cgl/program.hpp | 14 +++++++------- vis/include/cgl/shader.hpp | 30 +++++++++++++++--------------- vis/include/cgl/shaderprogram.hpp | 26 +++++++++++++------------- vis/include/cgl/vertexarray.hpp | 14 +++++++------- vis/src/main.cpp | 10 +++++----- 8 files changed, 71 insertions(+), 71 deletions(-) diff --git a/vis/include/cgl/buffer.hpp b/vis/include/cgl/buffer.hpp index e69a9f2..57b0977 100644 --- a/vis/include/cgl/buffer.hpp +++ b/vis/include/cgl/buffer.hpp @@ -6,31 +6,31 @@ namespace cgl { template - class buffer { + class Buffer { GLuint id{}; public: - buffer() { + Buffer() { glCreateBuffers(1, &id); } - buffer(const T &data, GLenum usage = GL_STATIC_DRAW) - : buffer() { + Buffer(const T &data, GLenum usage = GL_STATIC_DRAW) + : Buffer() { put(data, usage); } - buffer(const std::vector &data, GLenum usage = GL_STATIC_DRAW) - : buffer() { + Buffer(const std::vector &data, GLenum usage = GL_STATIC_DRAW) + : Buffer() { put(data, usage); } - buffer(buffer &) = delete; + Buffer(Buffer &) = delete; - buffer(buffer &&o) noexcept { + Buffer(Buffer &&o) noexcept { id = std::exchange(o.id, 0); }; - ~buffer() { + ~Buffer() { glDeleteBuffers(1, &id); id = 0; } diff --git a/vis/include/cgl/error.hpp b/vis/include/cgl/error.hpp index 48840b4..147c360 100644 --- a/vis/include/cgl/error.hpp +++ b/vis/include/cgl/error.hpp @@ -5,24 +5,24 @@ #include namespace cgl { - class gl_error : public std::domain_error { + class GlError : public std::domain_error { public: - explicit gl_error(const std::string &arg) : domain_error(arg) {} + explicit GlError(const std::string &arg) : domain_error(arg) {} - explicit gl_error(const char *string) : domain_error(string) {} + explicit GlError(const char *string) : domain_error(string) {} }; - class shader_error : public gl_error { + class ShaderError : public GlError { public: - explicit shader_error(const std::string &arg) : gl_error(arg) {} + explicit ShaderError(const std::string &arg) : GlError(arg) {} - explicit shader_error(const char *string) : gl_error(string) {} + explicit ShaderError(const char *string) : GlError(string) {} }; - class program_error : public gl_error { + class ProgramError : public GlError { public: - explicit program_error(const std::string &arg) : gl_error(arg) {} + explicit ProgramError(const std::string &arg) : GlError(arg) {} - explicit program_error(const char *string) : gl_error(string) {} + explicit ProgramError(const char *string) : GlError(string) {} }; } \ No newline at end of file diff --git a/vis/include/cgl/pipeline.hpp b/vis/include/cgl/pipeline.hpp index c9d9105..0175cfd 100644 --- a/vis/include/cgl/pipeline.hpp +++ b/vis/include/cgl/pipeline.hpp @@ -49,32 +49,32 @@ namespace cgl{ return std::string(buffer); } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_VERTEX_SHADER_BIT, pgm); return *this; } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_TESS_CONTROL_SHADER_BIT, pgm); return *this; } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_TESS_EVALUATION_SHADER_BIT, pgm); return *this; } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_GEOMETRY_SHADER_BIT, pgm); return *this; } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_FRAGMENT_SHADER_BIT, pgm); return *this; } - pipeline &stage(const shaderprogram &pgm) { + pipeline &stage(const ShaderProgram &pgm) { glUseProgramStages(id, GL_COMPUTE_SHADER_BIT, pgm); return *this; } diff --git a/vis/include/cgl/program.hpp b/vis/include/cgl/program.hpp index c9aa3a4..4d382f7 100644 --- a/vis/include/cgl/program.hpp +++ b/vis/include/cgl/program.hpp @@ -11,22 +11,22 @@ #include namespace cgl { - class program { + class Program { protected: GLuint id{}; public: - program() { + Program() { id = glCreateProgram(); } - program(program &) = delete; + Program(Program &) = delete; - program(program &&o) noexcept { + Program(Program &&o) noexcept { id = std::exchange(o.id, 0); }; - ~program() { + ~Program() { glDeleteProgram(id); } @@ -48,12 +48,12 @@ namespace cgl { } template - void attach(const shader &sh) { + void attach(const Shader &sh) { glAttachShader(id, sh); } template - void detach(const shader &sh) { + void detach(const Shader &sh) { glDetachShader(id, sh); } diff --git a/vis/include/cgl/shader.hpp b/vis/include/cgl/shader.hpp index bce89a0..2bb1829 100644 --- a/vis/include/cgl/shader.hpp +++ b/vis/include/cgl/shader.hpp @@ -11,33 +11,33 @@ namespace cgl { template - class shader { + class Shader { protected: GLuint id{}; public: - shader() { + Shader() { id = glCreateShader(mode); } - shader(const std::string &src) : shader() { + Shader(const std::string &src) : Shader() { set_source(src); if (!compile()) - throw shader_error(get_info_log()); + throw ShaderError(get_info_log()); } - static shader file(const std::string &name) { - return shader(utilReadFile(name)); + static Shader file(const std::string &name) { + return Shader(utilReadFile(name)); } - shader(shader &) = delete; + Shader(Shader &) = delete; - shader(shader &&o) noexcept { + Shader(Shader &&o) noexcept { id = std::exchange(o.id, 0); }; - ~shader() { + ~Shader() { glDeleteShader(id); } @@ -70,11 +70,11 @@ namespace cgl { }; namespace sh { - using vert = shader; - using tcs = shader; - using tes = shader; - using geom = shader; - using frag = shader; - using comp = shader; + using vert = Shader; + using tcs = Shader; + using tes = Shader; + using geom = Shader; + using frag = Shader; + using comp = Shader; } } diff --git a/vis/include/cgl/shaderprogram.hpp b/vis/include/cgl/shaderprogram.hpp index 3aacf9f..c411790 100644 --- a/vis/include/cgl/shaderprogram.hpp +++ b/vis/include/cgl/shaderprogram.hpp @@ -13,34 +13,34 @@ namespace cgl{ template - class shaderprogram : public program { + class ShaderProgram : public Program { public: - shaderprogram() : program() { + ShaderProgram() : Program() { glProgramParameteri(id, GL_PROGRAM_SEPARABLE, GL_TRUE); } - shaderprogram(const std::string &src) : shaderprogram() { - shader sh(src); + ShaderProgram(const std::string &src) : ShaderProgram() { + Shader sh(src); attach(sh); if (!link()) - throw shader_error(get_info_log()); + throw ShaderError(get_info_log()); detach(sh); } - static shaderprogram file(const std::string &name) { - return shaderprogram(utilReadFile(name)); + static ShaderProgram file(const std::string &name) { + return ShaderProgram(utilReadFile(name)); } }; namespace pgm { - using vert = shaderprogram; - using tcs = shaderprogram; - using tes = shaderprogram; - using geom = shaderprogram; - using frag = shaderprogram; - using comp = shaderprogram; + using vert = ShaderProgram; + using tcs = ShaderProgram; + using tes = ShaderProgram; + using geom = ShaderProgram; + using frag = ShaderProgram; + using comp = ShaderProgram; } } \ No newline at end of file diff --git a/vis/include/cgl/vertexarray.hpp b/vis/include/cgl/vertexarray.hpp index fa00b2e..e9275e7 100644 --- a/vis/include/cgl/vertexarray.hpp +++ b/vis/include/cgl/vertexarray.hpp @@ -10,21 +10,21 @@ #include namespace cgl { - class vertexarray { + class VertexArray { GLuint id{}; public: - vertexarray() { + VertexArray() { glCreateVertexArrays(1, &id); } - vertexarray(vertexarray &) = delete; + VertexArray(VertexArray &) = delete; - vertexarray(vertexarray &&o) noexcept { + VertexArray(VertexArray &&o) noexcept { id = std::exchange(o.id, 0); } - ~vertexarray() { + ~VertexArray() { glDeleteVertexArrays(1, &id); id = 0; } @@ -42,7 +42,7 @@ namespace cgl { template void pointer( GLuint index, - const buffer &buf, + const Buffer &buf, unsigned size, GLenum type, bool normalized = false, @@ -59,7 +59,7 @@ namespace cgl { template void ipointer( GLuint index, - const buffer &buf, + const Buffer &buf, unsigned size, GLenum type, unsigned stride = 0 diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 5e817dd..232e3d1 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -33,9 +33,9 @@ struct Matrices { template struct Drawable { GLenum mode{}; - cgl::vertexarray vao{}; - cgl::buffer> ibo{}; - cgl::buffer vbo{}; + cgl::VertexArray vao{}; + cgl::Buffer> ibo{}; + cgl::Buffer vbo{}; Drawable(GLenum mode) : mode(mode), vao(), ibo(), vbo() {} @@ -179,10 +179,10 @@ void run(GLFWwindow *window) { slices.vao.ipointer(0, slices.ibo, 4, GL_UNSIGNED_INT); slices.vao.pointer(1, slices.vbo, 3, GL_FLOAT); - auto vbo = cgl::buffer(points(group)); + auto vbo = cgl::Buffer(points(group)); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, vbo); - auto ubo = cgl::buffer(); + auto ubo = cgl::Buffer(); glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo); while (!glfwWindowShouldClose(window)) {