From 614bc2504319f09184850ca376f609c5bccdac89 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Tue, 18 Oct 2022 11:57:40 +0100 Subject: [PATCH] clean up opengl headers --- demo/demo/main.cpp | 1 - fggl/gfx/ogl/types.cpp | 4 +- fggl/gfx/ogl4/canvas.cpp | 4 +- fggl/gfx/ogl4/debug.cpp | 2 +- fggl/gfx/ogl4/models.cpp | 13 +++--- include/fggl/gfx/ogl/compat.hpp | 72 -------------------------------- include/fggl/gfx/ogl/types.hpp | 6 +-- include/fggl/gfx/ogl4/models.hpp | 4 +- 8 files changed, 16 insertions(+), 90 deletions(-) delete mode 100644 include/fggl/gfx/ogl/compat.hpp diff --git a/demo/demo/main.cpp b/demo/demo/main.cpp index 37b95f6..d9c0587 100644 --- a/demo/demo/main.cpp +++ b/demo/demo/main.cpp @@ -34,7 +34,6 @@ #include "fggl/gfx/atlas.hpp" #include "fggl/display/glfw/window.hpp" -#include "fggl/gfx/ogl/compat.hpp" #include "fggl/platform/paths.hpp" diff --git a/fggl/gfx/ogl/types.cpp b/fggl/gfx/ogl/types.cpp index 16bf58d..2753c28 100644 --- a/fggl/gfx/ogl/types.cpp +++ b/fggl/gfx/ogl/types.cpp @@ -115,7 +115,7 @@ namespace fggl::gfx::ogl { #endif } - void VertexArray::drawElements(const ElementBuffer &buff, Primative drawType, std::size_t size) { + void VertexArray::drawElements(const ElementBuffer &buff, Primitive drawType, std::size_t size) { bind(); #ifndef FGGL_I_BOUND @@ -130,7 +130,7 @@ namespace fggl::gfx::ogl { #endif } - void VertexArray::draw(Primative drawType, int first, std::size_t count) { + void VertexArray::draw(Primitive drawType, int first, std::size_t count) { glDrawArrays((GLenum) drawType, first, count); } diff --git a/fggl/gfx/ogl4/canvas.cpp b/fggl/gfx/ogl4/canvas.cpp index ca3f430..95aa89a 100644 --- a/fggl/gfx/ogl4/canvas.cpp +++ b/fggl/gfx/ogl4/canvas.cpp @@ -137,7 +137,7 @@ namespace fggl::gfx::ogl4 { shader.setUniformMtx(shader.uniform("projection"), projMat); // draw elements - m_vao.drawElements(m_indexList, ogl::Primative::TRIANGLE, mesh.indexList.size()); + m_vao.drawElements(m_indexList, ogl::Primitive::TRIANGLE, mesh.indexList.size()); // cleanup glUseProgram(0); @@ -214,7 +214,7 @@ namespace fggl::gfx::ogl4 { m_vertexList.replace(verts.size(), verts.data()); m_vao.bind(); - m_vao.draw(ogl::Primative::TRIANGLE, 0, verts.size()); + m_vao.draw(ogl::Primitive::TRIANGLE, 0, verts.size()); penPos.x += (metrics.advance >> 6); } diff --git a/fggl/gfx/ogl4/debug.cpp b/fggl/gfx/ogl4/debug.cpp index cf0d8cc..dd0b11e 100644 --- a/fggl/gfx/ogl4/debug.cpp +++ b/fggl/gfx/ogl4/debug.cpp @@ -55,7 +55,7 @@ namespace fggl::gfx::ogl4 { m_lineVbo.bind(); m_lineVbo.replace<dd::DrawVertex>(count, lines); - m_lineVao.draw(ogl::Primative::LINE, 0, count); + m_lineVao.draw(ogl::Primitive::LINE, 0, count); glUseProgram(0); glBindVertexArray(0); diff --git a/fggl/gfx/ogl4/models.cpp b/fggl/gfx/ogl4/models.cpp index 189ccec..b70131b 100644 --- a/fggl/gfx/ogl4/models.cpp +++ b/fggl/gfx/ogl4/models.cpp @@ -19,11 +19,10 @@ #include "fggl/gfx/ogl4/models.hpp" #include "fggl/data/heightmap.hpp" +#include "fggl/debug/logging.hpp" #include "fggl/gfx/camera.hpp" #include "fggl/gfx/phong.hpp" -#include <spdlog/spdlog.h> - namespace fggl::gfx::ogl4 { static std::shared_ptr<ogl::ArrayBuffer> setupArrayBuffer(std::shared_ptr<ogl::VertexArray> &vao, @@ -61,7 +60,7 @@ namespace fggl::gfx::ogl4 { modelComp.elements = elementBuffer; modelComp.pipeline = shader; modelComp.elementCount = mesh.indexCount(); - modelComp.drawType = ogl::Primative::TRIANGLE; + modelComp.drawType = ogl::Primitive::TRIANGLE; } StaticModel* StaticModelRenderer::uploadMesh(assets::AssetGUID guid, const data::Mesh &mesh, bool allowCache) { @@ -79,7 +78,7 @@ namespace fggl::gfx::ogl4 { modelAsset->vertexData = setupArrayBuffer(modelAsset->vao, mesh.vertexList()); modelAsset->elements = setupIndexBuffer(modelAsset->vao, mesh.indexList()); modelAsset->elementCount = mesh.indexCount(); - modelAsset->drawType = ogl::Primative::TRIANGLE; + modelAsset->drawType = ogl::Primitive::TRIANGLE; // if caching is enabled, then use the cache if ( allowCache ) { @@ -102,7 +101,7 @@ namespace fggl::gfx::ogl4 { modelAsset->vertices = setupArrayBuffer(modelAsset->vao, mesh.vertexList()); modelAsset->elements = setupIndexBuffer(modelAsset->vao, mesh.indexList()); modelAsset->elementCount = mesh.indexCount(); - modelAsset->drawType = ogl::Primative::TRIANGLE; + modelAsset->drawType = ogl::Primitive::TRIANGLE; return m_assets->set(meshName, modelAsset); } @@ -149,7 +148,7 @@ namespace fggl::gfx::ogl4 { // we know this is a triangle strip with a restart vertex... // FIXME the model should be telling us this... - modelComp.drawType = ogl::Primative::TRIANGLE_STRIP; + modelComp.drawType = ogl::Primitive::TRIANGLE_STRIP; modelComp.restartIndex = heightMapMesh.restartVertex; // no active model, we need to resolve/load one. @@ -341,7 +340,7 @@ namespace fggl::gfx::ogl4 { // if there are no cameras, we can't do anything... if (cameras.empty()) { - spdlog::warn("asked to render static models, but there were no cameras"); + debug::warning("asked to render static models, but there were no cameras"); return; } diff --git a/include/fggl/gfx/ogl/compat.hpp b/include/fggl/gfx/ogl/compat.hpp deleted file mode 100644 index 7159477..0000000 --- a/include/fggl/gfx/ogl/compat.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of FGGL. - * - * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any - * later version. - * - * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with FGGL. - * If not, see <https://www.gnu.org/licenses/>. - */ - -#ifndef FGGL_GFX_OGL_COMPAT_HPP -#define FGGL_GFX_OGL_COMPAT_HPP -/** - * Legacy/Direct OpenGL calls. - * - * This shouldn't be exposed to the demo app, but the ECS we're using isn't smart enouph to allow us to - * abstract this yet. It's next thing on the list, but this branch is about cleaning up OpenGL not about - * extending our ECS. - * - * Should be removed when the engine has suitable abstractions in place. - */ - -#include <functional> - -#include <fggl/gfx/ogl/shader.hpp> -#include <fggl/gfx/ogl/renderer.hpp> - -#include <fggl/gfx/common.hpp> -#include <fggl/gfx/camera.hpp> - -#include <utility> -#include <fggl/input/camera_input.hpp> -#include <fggl/data/heightmap.hpp> - -#include "fggl/gfx/phong.hpp" - -namespace fggl::gfx { - - // - // fake module support - allows us to still RAII - // - /*struct SceneUtils : ecs3::Module { - - SceneUtils() = default; - - [[nodiscard]] - std::string name() const override { - return "gfx::scene"; - } - - void onLoad(ecs3::ModuleManager &manager, ecs3::TypeRegistry &types) override { - // mesh dependencies - types.make<math::Transform>(); - types.make<data::StaticMesh>(); - types.make<data::HeightMap>(); - - types.make<gfx::PhongMaterial>(); - - // camera dependencies - types.make<fggl::gfx::Camera>(); - types.make<fggl::input::FreeCamKeys>(); - } - - };*/ - -} - -#endif diff --git a/include/fggl/gfx/ogl/types.hpp b/include/fggl/gfx/ogl/types.hpp index 2d082d2..6e237b2 100644 --- a/include/fggl/gfx/ogl/types.hpp +++ b/include/fggl/gfx/ogl/types.hpp @@ -327,7 +327,7 @@ namespace fggl::gfx::ogl { UINT_PACKED_F = GL_UNSIGNED_INT_10F_11F_11F_REV }; - enum class Primative { + enum class Primitive { POINT = GL_POINT, LINE = GL_LINES, LINE_STRIP = GL_LINE_STRIP, @@ -512,8 +512,8 @@ namespace fggl::gfx::ogl { void setAttribute(const ArrayBuffer &buffer, GLuint idx, AttributeI &attr, bool normalized); void setAttributeI(const ArrayBuffer &buffer, GLuint idx, AttributeI &attr); - void drawElements(const ElementBuffer &buff, Primative drawType, std::size_t size); - void draw(Primative drawType, int first, std::size_t count); + void drawElements(const ElementBuffer &buff, Primitive drawType, std::size_t size); + void draw(Primitive drawType, int first, std::size_t count); }; // paranoid functions diff --git a/include/fggl/gfx/ogl4/models.hpp b/include/fggl/gfx/ogl4/models.hpp index 625f0f0..6a8beb1 100644 --- a/include/fggl/gfx/ogl4/models.hpp +++ b/include/fggl/gfx/ogl4/models.hpp @@ -40,7 +40,7 @@ namespace fggl::gfx::ogl4 { std::shared_ptr<ogl::ElementBuffer> elements; std::shared_ptr<ogl::ArrayBuffer> vertices; std::size_t elementCount; - ogl::Primative drawType = ogl::Primative::TRIANGLE; + ogl::Primitive drawType = ogl::Primitive::TRIANGLE; std::size_t restartIndex = NO_RESTART_IDX; }; @@ -62,7 +62,7 @@ namespace fggl::gfx::ogl4 { std::shared_ptr<ogl::ArrayBuffer> vertexData; std::size_t elementCount; - ogl::Primative drawType; + ogl::Primitive drawType; std::size_t restartIndex = NO_RESTART_IDX; }; -- GitLab