From fefe8bacc7876e98209505f33852db5197afd154 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 11 May 2021 00:46:44 -0500 Subject: [PATCH] [nostalgia/core/userland] Cleanup --- src/nostalgia/core/userland/gfx_opengl.cpp | 22 +++++++------- src/nostalgia/core/userland/glutils.cpp | 18 ++++++------ src/nostalgia/core/userland/glutils.hpp | 34 +++++++++++----------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/nostalgia/core/userland/gfx_opengl.cpp b/src/nostalgia/core/userland/gfx_opengl.cpp index bd200f8b..1d39ffe1 100644 --- a/src/nostalgia/core/userland/gfx_opengl.cpp +++ b/src/nostalgia/core/userland/gfx_opengl.cpp @@ -30,10 +30,10 @@ constexpr auto BgVertexVboLength = BgVertexVboRows * BgVertexVboRowLength; constexpr auto BgVertexEboLength = 6; struct Background { - VertexArray vao; - Buffer vbo; - Buffer ebo; - Texture tex; + GLVertexArray vao; + GLBuffer vbo; + GLBuffer ebo; + GLTexture tex; bool enabled = false; bool updated = false; std::array bgVertices = {}; @@ -41,7 +41,7 @@ struct Background { }; struct GlImplData { - Program bgShader; + GLProgram bgShader; int64_t prevFpsCheckTime = 0; uint64_t draws = 0; std::array backgrounds; @@ -119,16 +119,16 @@ static void initBackgroundBufferObjects(Context *ctx, Background *bg) noexcept { } } -static VertexArray genVertexArrayObject() noexcept { +static GLVertexArray genVertexArrayObject() noexcept { GLuint vao = 0; glGenVertexArrays(1, &vao); - return VertexArray(vao); + return GLVertexArray(vao); } -static Buffer genBuffer() noexcept { +static GLBuffer genBuffer() noexcept { GLuint buff = 0; glGenBuffers(1, &buff); - return Buffer(buff); + return GLBuffer(buff); } static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg) noexcept { @@ -151,10 +151,10 @@ static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg) ox::bit_cast(2 * sizeof(float))); } -static Texture loadTexture(GLsizei w, GLsizei h, void *pixels) noexcept { +static GLTexture loadTexture(GLsizei w, GLsizei h, void *pixels) noexcept { GLuint texId = 0; glGenTextures(1, &texId); - Texture tex(texId); + GLTexture tex(texId); tex.width = w; tex.height = h; glActiveTexture(GL_TEXTURE0); diff --git a/src/nostalgia/core/userland/glutils.cpp b/src/nostalgia/core/userland/glutils.cpp index 68597a1c..4c165fb4 100644 --- a/src/nostalgia/core/userland/glutils.cpp +++ b/src/nostalgia/core/userland/glutils.cpp @@ -28,15 +28,15 @@ void deleteVertexArray(GLuint v) noexcept { glDeleteVertexArrays(1, &v); } -template struct GLobject; -template struct GLobject; -template struct GLobject; -template struct GLobject; -template struct GLobject; +template struct GLObject; +template struct GLObject; +template struct GLObject; +template struct GLObject; +template struct GLObject; [[nodiscard]] -static ox::Result buildShader(GLuint shaderType, const GLchar *src, const char *shaderName) noexcept { - Shader shader(glCreateShader(shaderType)); +static ox::Result buildShader(GLuint shaderType, const GLchar *src, const char *shaderName) noexcept { + GLShader shader(glCreateShader(shaderType)); glShaderSource(shader, 1, &src, nullptr); glCompileShader(shader); GLint status; @@ -51,10 +51,10 @@ static ox::Result buildShader(GLuint shaderType, const GLchar *src, cons } [[nodiscard]] -ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept { +ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept { oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad")); oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad")); - Program prgm(glCreateProgram()); + GLProgram prgm(glCreateProgram()); glAttachShader(prgm, vs); glAttachShader(prgm, fs); glLinkProgram(prgm); diff --git a/src/nostalgia/core/userland/glutils.hpp b/src/nostalgia/core/userland/glutils.hpp index 1b770d38..1dfd724a 100644 --- a/src/nostalgia/core/userland/glutils.hpp +++ b/src/nostalgia/core/userland/glutils.hpp @@ -47,26 +47,26 @@ struct TextureBase { template -struct GLobject: public Base { +struct GLObject: public Base { GLuint id = 0; - constexpr GLobject() noexcept = default; + constexpr GLObject() noexcept = default; - explicit constexpr GLobject(GLuint id) noexcept { + explicit constexpr GLObject(GLuint id) noexcept { this->id = id; } - constexpr GLobject(GLobject &&o) noexcept: Base(ox::move(o)) { + constexpr GLObject(GLObject &&o) noexcept: Base(ox::move(o)) { id = o.id; o.id = 0; } - ~GLobject() { + ~GLObject() { del(id); } - GLobject &operator=(GLobject &&o) noexcept { + GLObject &operator=(GLObject &&o) noexcept { if (this != &o) { del(id); Base::operator=(ox::move(o)); @@ -96,19 +96,19 @@ void deleteBuffer(GLuint b) noexcept; void deleteTexture(GLuint t) noexcept; void deleteVertexArray(GLuint v) noexcept; -extern template struct GLobject; -extern template struct GLobject; -extern template struct GLobject; -extern template struct GLobject; -extern template struct GLobject; +extern template struct GLObject; +extern template struct GLObject; +extern template struct GLObject; +extern template struct GLObject; +extern template struct GLObject; -using Buffer = GLobject; -using Shader = GLobject; -using Program = GLobject; -using Texture = GLobject; -using VertexArray = GLobject; +using GLBuffer = GLObject; +using GLShader = GLObject; +using GLProgram = GLObject; +using GLTexture = GLObject; +using GLVertexArray = GLObject; [[nodiscard]] -ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept; +ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept; }