From 92ee2dba9e288cdb2693081820b9a3ad3792101d Mon Sep 17 00:00:00 2001 From: Vladislav Belov Date: Thu, 9 Jul 2026 22:53:30 +0200 Subject: [PATCH] Removes unused OGL legacy --- source/lib/ogl.cpp | 81 ------------------- source/lib/ogl.h | 72 ----------------- source/renderer/backend/gl/Buffer.h | 10 ++- source/renderer/backend/gl/Device.cpp | 7 +- source/renderer/backend/gl/Device.h | 8 +- .../backend/gl/DeviceCommandContext.h | 8 +- source/renderer/backend/gl/Framebuffer.cpp | 2 +- source/renderer/backend/gl/Framebuffer.h | 8 +- source/renderer/backend/gl/Mapping.h | 10 ++- source/renderer/backend/gl/ShaderProgram.h | 7 +- source/renderer/backend/gl/SwapChain.h | 8 +- source/renderer/backend/gl/Texture.h | 10 ++- 12 files changed, 65 insertions(+), 166 deletions(-) delete mode 100644 source/lib/ogl.cpp delete mode 100644 source/lib/ogl.h diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp deleted file mode 100644 index d5ff4bb3d7..0000000000 --- a/source/lib/ogl.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2026 Wildfire Games. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "precompiled.h" - -#include "ogl.h" - -#include "lib/config2.h" -#include "lib/debug.h" -#include "ps/CLogger.h" - -#include -#include - - -const char* ogl_GetErrorName(GLenum err) -{ -#define E(e) case e: return #e; - switch (err) - { - E(GL_INVALID_ENUM) - E(GL_INVALID_VALUE) - E(GL_INVALID_OPERATION) -#if !CONFIG2_GLES - E(GL_STACK_OVERFLOW) - E(GL_STACK_UNDERFLOW) -#endif - E(GL_OUT_OF_MEMORY) - E(GL_INVALID_FRAMEBUFFER_OPERATION) - default: return "Unknown GL error"; - } -#undef E -} - -static void dump_gl_error(GLenum err) -{ - debug_printf("OGL| %s (%04x)\n", ogl_GetErrorName(err), err); -} - -void ogl_WarnIfErrorLoc(const char *file, int line) -{ - // glGetError may return multiple errors, so we poll it in a loop. - // the debug_printf should only happen once (if this is set), though. - bool error_enountered = false; - GLenum first_error = 0; - - for(;;) - { - GLenum err = glGetError(); - if(err == GL_NO_ERROR) - break; - - if(!error_enountered) - first_error = err; - - error_enountered = true; - dump_gl_error(err); - } - - if(error_enountered) - debug_printf("%s:%d: OpenGL error(s) occurred: %s (%04x)\n", file, line, ogl_GetErrorName(first_error), (unsigned int)first_error); -} diff --git a/source/lib/ogl.h b/source/lib/ogl.h deleted file mode 100644 index 905fc03b10..0000000000 --- a/source/lib/ogl.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2026 Wildfire Games. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * OpenGL helper functions. - */ - -#ifndef INCLUDED_OGL -#define INCLUDED_OGL - -#include "lib/code_annotation.h" -#include "lib/config2.h" // CONFIG2_GLES - - -#if CONFIG2_GLES -# include "external_libraries/opengles2_wrapper.h" -#else -# include -#endif - -//----------------------------------------------------------------------------- -// errors - -/** - * raise a warning (break into the debugger) if an OpenGL error is pending. - * resets the OpenGL error state afterwards. - * - * when an error is reported, insert calls to this in a binary-search scheme - * to quickly narrow down the actual error location. - * - * reports a bogus invalid_operation error if called before OpenGL is - * initialized, so don't! - * - * disabled in release mode for efficiency and to avoid annoying errors. - **/ -extern void ogl_WarnIfErrorLoc(const char *file, int line); -#ifdef NDEBUG -# define ogl_WarnIfError() -#else -# define ogl_WarnIfError() ogl_WarnIfErrorLoc(__FILE__, __LINE__) -#endif - -/** -* get a name of the error. -* -* useful for debug. -* -* @return read-only C string of unspecified length containing -* the error's name. -**/ -extern const char* ogl_GetErrorName(GLenum err); - -#endif // INCLUDED_OGL diff --git a/source/renderer/backend/gl/Buffer.h b/source/renderer/backend/gl/Buffer.h index b59e7c5b16..a92db56b07 100644 --- a/source/renderer/backend/gl/Buffer.h +++ b/source/renderer/backend/gl/Buffer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,9 +18,15 @@ #ifndef INCLUDED_RENDERER_BACKEND_GL_BUFFER #define INCLUDED_RENDERER_BACKEND_GL_BUFFER -#include "lib/ogl.h" +#include "lib/config2.h" #include "renderer/backend/IBuffer.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include diff --git a/source/renderer/backend/gl/Device.cpp b/source/renderer/backend/gl/Device.cpp index fb36926110..4edcfecebe 100644 --- a/source/renderer/backend/gl/Device.cpp +++ b/source/renderer/backend/gl/Device.cpp @@ -24,7 +24,6 @@ #include "lib/config2.h" #include "lib/debug.h" #include "lib/external_libraries/libsdl.h" -#include "lib/ogl.h" #include "lib/secure_crt.h" #include "ps/CLogger.h" #include "ps/ConfigDB.h" @@ -41,6 +40,12 @@ #include "renderer/backend/gl/Texture.h" #include "scriptinterface/Object.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include #include diff --git a/source/renderer/backend/gl/Device.h b/source/renderer/backend/gl/Device.h index 399eef15a3..069803a644 100644 --- a/source/renderer/backend/gl/Device.h +++ b/source/renderer/backend/gl/Device.h @@ -18,7 +18,7 @@ #ifndef INCLUDED_RENDERER_BACKEND_GL_DEVICE #define INCLUDED_RENDERER_BACKEND_GL_DEVICE -#include "lib/ogl.h" +#include "lib/config2.h" #include "ps/CStr.h" #include "renderer/backend/Backend.h" #include "renderer/backend/IBuffer.h" @@ -27,6 +27,12 @@ #include "renderer/backend/ITexture.h" #include "renderer/backend/gl/DeviceForward.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include #include diff --git a/source/renderer/backend/gl/DeviceCommandContext.h b/source/renderer/backend/gl/DeviceCommandContext.h index c96cd79aea..5a2ee7b13f 100644 --- a/source/renderer/backend/gl/DeviceCommandContext.h +++ b/source/renderer/backend/gl/DeviceCommandContext.h @@ -19,13 +19,19 @@ #define INCLUDED_RENDERER_BACKEND_GL_DEVICECOMMANDCONTEXT #include "graphics/Color.h" -#include "lib/ogl.h" +#include "lib/config2.h" #include "lib/types.h" #include "renderer/backend/IBuffer.h" #include "renderer/backend/IDeviceCommandContext.h" #include "renderer/backend/IShaderProgram.h" #include "renderer/backend/PipelineState.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include #include diff --git a/source/renderer/backend/gl/Framebuffer.cpp b/source/renderer/backend/gl/Framebuffer.cpp index 43672732c6..1964b8c388 100644 --- a/source/renderer/backend/gl/Framebuffer.cpp +++ b/source/renderer/backend/gl/Framebuffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify diff --git a/source/renderer/backend/gl/Framebuffer.h b/source/renderer/backend/gl/Framebuffer.h index b15be87ce7..a44926ca87 100644 --- a/source/renderer/backend/gl/Framebuffer.h +++ b/source/renderer/backend/gl/Framebuffer.h @@ -19,9 +19,15 @@ #define INCLUDED_RENDERER_BACKEND_GL_FRAMEBUFFER #include "graphics/Color.h" -#include "lib/ogl.h" +#include "lib/config2.h" #include "renderer/backend/IFramebuffer.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include diff --git a/source/renderer/backend/gl/Mapping.h b/source/renderer/backend/gl/Mapping.h index e79145fbd9..c0a75fcbe3 100644 --- a/source/renderer/backend/gl/Mapping.h +++ b/source/renderer/backend/gl/Mapping.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,7 +18,13 @@ #ifndef INCLUDED_RENDERER_BACKEND_GL_MAPPING #define INCLUDED_RENDERER_BACKEND_GL_MAPPING -#include "lib/ogl.h" +#include "lib/config2.h" + +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif namespace Renderer::Backend { enum class BlendFactor; } namespace Renderer::Backend { enum class BlendOp; } diff --git a/source/renderer/backend/gl/ShaderProgram.h b/source/renderer/backend/gl/ShaderProgram.h index 1ee2409998..2e32df5f71 100644 --- a/source/renderer/backend/gl/ShaderProgram.h +++ b/source/renderer/backend/gl/ShaderProgram.h @@ -20,7 +20,6 @@ #include "lib/code_annotation.h" #include "lib/debug.h" -#include "lib/ogl.h" #include "ps/containers/StaticVector.h" #include "ps/CStr.h" #include "ps/CStrIntern.h" @@ -29,6 +28,12 @@ #include "renderer/backend/IBuffer.h" #include "renderer/backend/IShaderProgram.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include #include diff --git a/source/renderer/backend/gl/SwapChain.h b/source/renderer/backend/gl/SwapChain.h index b1f9c85a8f..87dcafd5da 100644 --- a/source/renderer/backend/gl/SwapChain.h +++ b/source/renderer/backend/gl/SwapChain.h @@ -18,10 +18,16 @@ #ifndef INCLUDED_RENDERER_BACKEND_GL_SWAPCHAIN #define INCLUDED_RENDERER_BACKEND_GL_SWAPCHAIN -#include "lib/ogl.h" +#include "lib/config2.h" #include "renderer/backend/gl/Framebuffer.h" #include "renderer/backend/ISwapChain.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include #include diff --git a/source/renderer/backend/gl/Texture.h b/source/renderer/backend/gl/Texture.h index 516418806e..af91009607 100644 --- a/source/renderer/backend/gl/Texture.h +++ b/source/renderer/backend/gl/Texture.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,10 +18,16 @@ #ifndef INCLUDED_RENDERER_BACKEND_GL_TEXTURE #define INCLUDED_RENDERER_BACKEND_GL_TEXTURE -#include "lib/ogl.h" +#include "lib/config2.h" #include "renderer/backend/Format.h" #include "renderer/backend/ITexture.h" +#if CONFIG2_GLES +#include "external_libraries/opengles2_wrapper.h" +#else +#include +#endif + #include #include