From a1e4e4b97cdbe3bba4e53efb70b149909f11202f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 2 May 2022 19:10:26 +0200 Subject: [PATCH] Minor cleanup --- src/graphics/core/device.h | 11 --- src/graphics/core/renderers.h | 3 - src/graphics/opengl33/gl33_device.h | 13 --- src/graphics/opengl33/gl33_ui_renderer.cpp | 9 --- src/graphics/opengl33/gl33_ui_renderer.h | 2 - src/graphics/opengl33/glutil.cpp | 94 ++++------------------ src/graphics/opengl33/glutil.h | 44 ---------- 7 files changed, 15 insertions(+), 161 deletions(-) diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index 272b692c..b10df506 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -192,17 +192,6 @@ enum FrustumPlane FRUSTUM_PLANE_FRONT | FRUSTUM_PLANE_BACK }; -/** - * \enum RenderTarget - * \brief Render targets for rendering to textures - */ -enum RenderTarget -{ - RENDER_TARGET_COLOR, - RENDER_TARGET_DEPTH, - RENDER_TARGET_STENCIL -}; - class CFrameBufferPixels { public: diff --git a/src/graphics/core/renderers.h b/src/graphics/core/renderers.h index a50b64bd..91f55600 100644 --- a/src/graphics/core/renderers.h +++ b/src/graphics/core/renderers.h @@ -73,9 +73,6 @@ public: //! Sets transparency mode virtual void SetTransparency(TransparencyMode mode) = 0; - //! Draws primitive - virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices) = 0; - virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) = 0; virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) = 0; virtual bool EndPrimitive() = 0; diff --git a/src/graphics/opengl33/gl33_device.h b/src/graphics/opengl33/gl33_device.h index 3aa28e4c..93fefa53 100644 --- a/src/graphics/opengl33/gl33_device.h +++ b/src/graphics/opengl33/gl33_device.h @@ -44,19 +44,6 @@ namespace Gfx enum class CullFace : unsigned char; enum class TransparencyMode : unsigned char; -//! Struct for dynamic buffers -struct DynamicBuffer -{ - //! Auxiliary VAO for rendering primitives with DrawPrimitive* - GLuint vao = 0; - //! Dynamic buffer - GLuint vbo = 0; - //! Dynamic buffer size - unsigned int size = 0; - //! Dynamic buffer offset - unsigned int offset = 0; -}; - class CGL33VertexBuffer : public CVertexBuffer { GLuint m_vao = 0; diff --git a/src/graphics/opengl33/gl33_ui_renderer.cpp b/src/graphics/opengl33/gl33_ui_renderer.cpp index 798333b5..b359879b 100644 --- a/src/graphics/opengl33/gl33_ui_renderer.cpp +++ b/src/graphics/opengl33/gl33_ui_renderer.cpp @@ -161,15 +161,6 @@ void CGL33UIRenderer::SetTransparency(TransparencyMode mode) m_device->SetTransparency(mode); } -void CGL33UIRenderer::DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices) -{ - auto ptr = BeginPrimitive(type, count); - - std::copy_n(vertices, count, ptr); - - EndPrimitive(); -} - Vertex2D* CGL33UIRenderer::BeginPrimitive(PrimitiveType type, int count) { return BeginPrimitives(type, 1, &count); diff --git a/src/graphics/opengl33/gl33_ui_renderer.h b/src/graphics/opengl33/gl33_ui_renderer.h index 82dc9022..2ff393b7 100644 --- a/src/graphics/opengl33/gl33_ui_renderer.h +++ b/src/graphics/opengl33/gl33_ui_renderer.h @@ -48,8 +48,6 @@ public: virtual void SetColor(const glm::vec4& color) override; virtual void SetTransparency(TransparencyMode mode) override; - virtual void DrawPrimitive(PrimitiveType type, int count, const Vertex2D* vertices) override; - virtual Vertex2D* BeginPrimitive(PrimitiveType type, int count) override; virtual Vertex2D* BeginPrimitives(PrimitiveType type, int drawCount, const int* counts) override; virtual bool EndPrimitive() override; diff --git a/src/graphics/opengl33/glutil.cpp b/src/graphics/opengl33/glutil.cpp index 95b78616..420ae236 100644 --- a/src/graphics/opengl33/glutil.cpp +++ b/src/graphics/opengl33/glutil.cpp @@ -35,9 +35,6 @@ namespace Gfx { -GLuint textureCoordinates[] = { GL_S, GL_T, GL_R, GL_Q }; -GLuint textureCoordGen[] = { GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R, GL_TEXTURE_GEN_Q }; - bool InitializeGLEW() { static bool glewInited = false; @@ -58,14 +55,6 @@ bool InitializeGLEW() return true; } -FramebufferSupport DetectFramebufferSupport() -{ - if (GetOpenGLVersion() >= 30) return FBS_ARB; - if (glewIsSupported("GL_ARB_framebuffer_object")) return FBS_ARB; - if (glewIsSupported("GL_EXT_framebuffer_object")) return FBS_EXT; - return FBS_NONE; -} - std::unique_ptr CreateDevice(const DeviceConfig &config, const std::string& name) { if (name == "default") return std::make_unique(config); @@ -228,61 +217,22 @@ std::string GetHardwareInfo(bool full) } // FBO support - FramebufferSupport framebuffer = DetectFramebufferSupport(); + result << "Framebuffer Object:\t\tsupported\n"; + result << " Type:\t\t\tCore/ARB\n"; - if (framebuffer == FBS_ARB) - { - result << "Framebuffer Object:\t\tsupported\n"; - result << " Type:\t\t\tCore/ARB\n"; + glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value); + result << " Max Renderbuffer Size:\t" << value << '\n'; - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value); - result << " Max Renderbuffer Size:\t" << value << '\n'; + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &value); + result << " Max Color Attachments:\t" << value << '\n'; - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &value); - result << " Max Color Attachments:\t" << value << '\n'; + result << "Multisampling:\t\tsupported\n"; - result << "Multisampling:\t\tsupported\n"; - - glGetIntegerv(GL_MAX_SAMPLES, &value); - result << " Max Framebuffer Samples:\t" << value << '\n'; - } - else if (framebuffer == FBS_EXT) - { - result << "Framebuffer Object:\tsupported\n"; - result << " Type:\tEXT\n"; - - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &value); - result << " Max Renderbuffer Size:\t" << value << '\n'; - - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &value); - result << " Max Color Attachments:\t" << value << '\n'; - - if (glewIsSupported("GL_EXT_framebuffer_multisample")) - { - result << "Multisampling:\tsupported\n"; - - glGetIntegerv(GL_MAX_SAMPLES_EXT, &value); - result << " Max Framebuffer Samples:\t" << value << '\n'; - } - } - else - { - result << "Framebuffer Object:\tunsupported\n"; - } + glGetIntegerv(GL_MAX_SAMPLES, &value); + result << " Max Framebuffer Samples:\t" << value << '\n'; // VBO support - if (glversion >= 15) - { - result << "VBO:\t\t\tsupported (core)\n"; - } - else if (glewIsSupported("GL_ARB_vertex_buffer_object")) - { - result << "VBO:\t\t\tsupported (ARB)\n"; - } - else - { - result << "VBO:\t\t\tunsupported\n"; - } + result << "VBO:\t\t\tsupported (core)\n"; return result.str(); } @@ -381,20 +331,6 @@ bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius return true; } -GLenum TranslateTextureCoordinate(int index) -{ - assert(index >= 0 && index < 4); - - return textureCoordinates[index]; -} - -GLenum TranslateTextureCoordinateGen(int index) -{ - assert(index >= 0 && index < 4); - - return textureCoordGen[index]; -} - GLenum TranslateType(Type type) { switch (type) @@ -424,9 +360,9 @@ std::string LoadSource(const std::string& path) PHYSFS_file* file = PHYSFS_openRead(path.c_str()); if (file == nullptr) { - CLogger::GetInstance().Error("Cannot read shader source file\n"); - CLogger::GetInstance().Error("Missing file \"%s\"\n", path); - return 0; + GetLogger()->Error("Cannot read shader source file\n"); + GetLogger()->Error("Missing file \"%s\"\n", path); + return {}; } size_t len = PHYSFS_fileLength(file); @@ -479,8 +415,8 @@ GLint LoadShader(GLint type, const char* filename) PHYSFS_file *file = PHYSFS_openRead(filename); if (file == nullptr) { - CLogger::GetInstance().Error("Cannot read shader source file\n"); - CLogger::GetInstance().Error("Missing file \"%s\"\n", filename); + GetLogger()->Error("Cannot read shader source file\n"); + GetLogger()->Error("Missing file \"%s\"\n", filename); return 0; } diff --git a/src/graphics/opengl33/glutil.h b/src/graphics/opengl33/glutil.h index d9fe44b4..601a626d 100644 --- a/src/graphics/opengl33/glutil.h +++ b/src/graphics/opengl33/glutil.h @@ -38,17 +38,8 @@ struct SDL_Surface; namespace Gfx { -enum FramebufferSupport -{ - FBS_NONE, - FBS_EXT, - FBS_ARB, -}; - bool InitializeGLEW(); -FramebufferSupport DetectFramebufferSupport(); - //! Creates OpenGL device std::unique_ptr CreateDevice(const DeviceConfig &config, const std::string& name); @@ -82,10 +73,6 @@ GLenum TranslateGfxCompFunc(CompFunc func); bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius); -GLenum TranslateTextureCoordinate(int index); - -GLenum TranslateTextureCoordinateGen(int index); - GLenum TranslateType(Type type); std::string GetLastShaderError(); @@ -129,35 +116,4 @@ private: std::unique_ptr GetGLFrameBufferPixels(const glm::ivec2& size); -struct UniformLocations -{ - // Uniforms - //! Projection matrix - GLint projectionMatrix = -1; - //! View matrix - GLint viewMatrix = -1; - //! Model matrix - GLint modelMatrix = -1; - //! Shadow matrix - GLint shadowMatrix = -1; - //! Normal matrix - GLint normalMatrix = -1; - //! Camera position - GLint cameraPosition = -1; - - //! Primary texture sampler - GLint primaryTexture = -1; - //! Secondary texture sampler - GLint secondaryTexture = -1; - - //! true enables texture - GLint textureEnabled[3] = {}; - - // Alpha test parameters - //! true enables alpha test - GLint alphaTestEnabled = -1; - //! Alpha test reference value - GLint alphaReference = -1; -}; - } // namespace Gfx