Skip to content

Commit

Permalink
Fix dedicated server for Windows
Browse files Browse the repository at this point in the history
* 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 #39
  • Loading branch information
DanielGibson committed Nov 12, 2012
1 parent 1f25568 commit 105fdb0
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 343 deletions.
2 changes: 1 addition & 1 deletion neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -705,6 +704,7 @@ elseif(WIN32)
)

set(src_sys_core
sys/glimp.cpp
)
else()
set(src_sys_base
Expand Down
17 changes: 17 additions & 0 deletions neo/renderer/qgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SDL_opengl.h>

#if defined( ID_DEDICATED ) && defined( _WIN32 )
// restore WINGDIAPI
#ifdef WINGDIAPI
#pragma pop_macro("WINGDIAPI")
#endif
#endif

typedef void (*GLExtension_t)(void);

#ifdef __cplusplus
Expand Down
7 changes: 7 additions & 0 deletions neo/sound/snd_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ If you have questions concerning this license or the applicable additional terms
#ifndef __SND_LOCAL_H__
#define __SND_LOCAL_H__

#ifdef ID_DEDICATED
// stub-only mode: AL_API and ALC_API shouldn't refer to any dll-stuff
// because the implemenations are in openal_stub.cpp
// this is ensured by defining AL_LIBTYPE_STATIC before including the AL headers
#define AL_LIBTYPE_STATIC
#endif

#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
Expand Down
4 changes: 0 additions & 4 deletions neo/sys/glimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ GLExtension_t GLimp_ExtensionPointer(const char *name) {
}

void GLimp_GrabInput(int flags) {
#if defined(ID_DEDICATED)
return;
#else
bool grab = flags & GRAB_ENABLE;

if (grab && (flags & GRAB_REENABLE))
Expand All @@ -314,5 +311,4 @@ void GLimp_GrabInput(int flags) {
SDL_ShowCursor(flags & GRAB_HIDECURSOR ? SDL_DISABLE : SDL_ENABLE);
SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
#endif
#endif
}
Loading

0 comments on commit 105fdb0

Please sign in to comment.