From 4fc06760aa757bdeee2aa54a4844bf6e0cf0a8e8 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 28 Aug 2012 21:01:21 +0200 Subject: [PATCH] Fix dedicated server for Windows * the OpenAL function definitions mustn't include __declspec(dllimport) => fixed by pretending to compile OpenAL statically * glimp.cpp shouldn't be used in dedicated-only mode (as it was already the case on Linux and OSX) => No special handling for ID_DEDICATED needed in glimp.cpp, as it's not used anyway * add APIENTRY to every gl function in stub_gl.cpp for compatibility with windows headers and MSVC * remove GL/gl.h #include from win_local.h as it's not needed * in qgl.h, when building dedicated server for windows, redefine WINGDIAPI to nothing for SDL_opengl.h #include to get rid off __declspec(dllimport) by using #pragma push_macro and pop_macro, because our stub is no dll. Fixes https://github.com/dhewm/dhewm3/issues/39 --- CMakeLists.txt | 2 +- renderer/qgl.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e159bcb..60c6d27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -693,7 +693,6 @@ elseif(WIN32) set(src_sys_base sys/cpu.cpp sys/threads.cpp - sys/glimp.cpp sys/events.cpp sys/sys_local.cpp sys/win32/win_input.cpp @@ -705,6 +704,7 @@ elseif(WIN32) ) set(src_sys_core + sys/glimp.cpp ) else() set(src_sys_base diff --git a/renderer/qgl.h b/renderer/qgl.h index a05bf0e..68b020e 100644 --- a/renderer/qgl.h +++ b/renderer/qgl.h @@ -32,8 +32,25 @@ If you have questions concerning this license or the applicable additional terms #ifndef __QGL_H__ #define __QGL_H__ +#if defined( ID_DEDICATED ) && defined( _WIN32 ) +// to allow stubbing gl on windows, define WINGDIAPI to nothing - it would otherwise be +// extended to __declspec(dllimport) on MSVC (our stub is no dll.) + #ifdef WINGDIAPI + #pragma push_macro("WINGDIAPI") + #undef WINGDIAPI + #define WINGDIAPI + #endif +#endif + #include +#if defined( ID_DEDICATED ) && defined( _WIN32 ) +// restore WINGDIAPI + #ifdef WINGDIAPI + #pragma pop_macro("WINGDIAPI") + #endif +#endif + typedef void (*GLExtension_t)(void); #ifdef __cplusplus