From cb379d7d2013754487ecf7e067c8f1cf4fbd3c55 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Fri, 27 Dec 2024 15:33:06 +0100 Subject: [PATCH] Define SDL_FUNCTION_POINTER_IS_VOID_POINTER --- Descent3/sdlmain.cpp | 2 +- renderer/HardwareOpenGL.cpp | 3 +++ renderer/dyna_gl.h | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Descent3/sdlmain.cpp b/Descent3/sdlmain.cpp index c4756a0f..66e18c3c 100644 --- a/Descent3/sdlmain.cpp +++ b/Descent3/sdlmain.cpp @@ -245,7 +245,7 @@ int main(int argc, char *argv[]) { #endif int rc = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO); - if (rc != 0) { + if (!rc) { LOG_FATAL.printf("SDL: SDL_Init() failed: %d: %s!", rc, SDL_GetError()); return (0); } diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index 91429666..78a410df 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -22,6 +22,9 @@ #include #include #include + +// TODO: Use SDL_FunctionPointer properly instead +#define SDL_FUNCTION_POINTER_IS_VOID_POINTER #include #if defined(WIN32) diff --git a/renderer/dyna_gl.h b/renderer/dyna_gl.h index 5d4db591..239db980 100644 --- a/renderer/dyna_gl.h +++ b/renderer/dyna_gl.h @@ -87,11 +87,12 @@ private: extern char loadedLibrary[_MAX_PATH]; static module OpenGLDLLInst; -static std::vector> inits_; + +static std::vector> inits_; static void LoadGLFnPtrs() { for (auto &[ptr, name, optional] : inits_) { - ptr = SDL_GL_GetProcAddress(name.data()); - if (!ptr && !optional) { + *ptr = SDL_GL_GetProcAddress(name.data()); + if (!*ptr && !optional) { throw std::runtime_error(std::string{"failed to find "} + name.data()); } } @@ -100,7 +101,7 @@ static void LoadGLFnPtrs() { template FnPtr::FnPtr(std::string_view name, bool optional) : fn_{} { - inits_.push_back(std::make_tuple(reinterpret_cast(&fn_), name, optional)); + inits_.push_back(std::make_tuple(reinterpret_cast(&fn_), name, optional)); } static module *LoadOpenGLDLL(const char *dllname) {