1818
1919#pragma once
2020
21+ #include < filesystem>
22+
2123#if defined(WIN32)
22- #include <GL/gl .h>
24+ #include < gl/GL .h>
2325#else
24- #include " SDL_opengl.h"
26+ #include < SDL_opengl.h>
2527#endif
2628
29+ #include " descent.h"
2730#include " module.h"
2831
2932#if defined(WIN32)
@@ -220,14 +223,14 @@ static module OpenGLDLLInst;
220223static void *__SDL_mod_GetSymbol (const char *funcStr) {
221224 void *retVal = NULL ;
222225
223- mprintf (0 , "Looking up GL function [%s]..." , funcStr );
226+ mprintf (0 , " Looking up GL function [%s]... " , funcStr);
224227
225228 retVal = SDL_GL_GetProcAddress (funcStr);
226229
227230 if (retVal == NULL )
228231 fprintf (stderr, " Could not find GL symbol [%s]!\n\n " , funcStr);
229232 else {
230- mprintf (0 , "Found at (%p)." , retVal );
233+ mprintf (0 , " Found at (%p).\n " , retVal);
231234 } // else
232235
233236 return (retVal);
@@ -237,19 +240,16 @@ static void *__SDL_mod_GetSymbol(const char *funcStr) {
237240#define mod_GetSymbol (x, funcStr, y ) __SDL_mod_GetSymbol(funcStr)
238241/* ***************** WARNING: NASTY HACK! ***********************/
239242
240-
241- #ifdef __LINUX__
242- extern char * __orig_pwd ;
243243extern char loadedLibrary[_MAX_PATH];
244- #endif
244+
245245module *LoadOpenGLDLL (const char *dllname) {
246246 mprintf (0 , " Loading OpenGL dll...\n " );
247- #ifdef __LINUX__
248- char * tmp = getcwd ( NULL , 0 );
249- chdir ( __orig_pwd );
250- int rc = SDL_GL_LoadLibrary (dllname [0 ] ? dllname : NULL );
251- chdir (tmp );
252- free ( tmp );
247+
248+ std::filesystem::path tmp = std::filesystem::current_path ( );
249+ std::filesystem::current_path (orig_pwd );
250+ int rc = SDL_GL_LoadLibrary (dllname[0 ] ? dllname : nullptr );
251+ std::filesystem::current_path (tmp);
252+
253253 if (rc < 0 ) {
254254 const char *sdlErr = SDL_GetError ();
255255 mprintf (0 , " OpenGL: Couldn't open library [%s].\n " , dllname[0 ] ? dllname : " system default" );
@@ -259,13 +259,6 @@ module *LoadOpenGLDLL(const char *dllname) {
259259
260260 strcpy (loadedLibrary, dllname);
261261
262- #else
263- if (!mod_LoadModule (& OpenGLDLLInst , dllname , MODF_LAZY | MODF_GLOBAL )) {
264- int err = mod_GetLastError ();
265- mprintf (0 , "Couldn't open module called %s\n" , dllname );
266- return NULL ;
267- }
268- #endif
269262
270263 dglAlphaFunc = (glAlphaFunc_fp)mod_GetSymbol (&OpenGLDLLInst, " glAlphaFunc" , 255 );
271264 if (!dglAlphaFunc)
0 commit comments