diff --git a/Makefile b/Makefile index f585d030..b7b9ab69 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,6 @@ endif # Extra CFLAGS for SDL ifneq ($(OSTYPE), Windows) ifeq ($(OSTYPE), Darwin) -# TODO: set -I.../SDL2/ or /SDL/ SDLCFLAGS := else # not darwin ifeq ($(WITH_SDL2),yes) @@ -219,17 +218,24 @@ endif # Extra LDFLAGS for SDL ifeq ($(OSTYPE), Windows) -# TODO: SDL2 for win/osx +ifeq ($(WITH_SDL2),yes) +SDLLDFLAGS := -lSDL2 +else # not SDL2 SDLLDFLAGS := -lSDL +endif # SDL2 else ifeq ($(OSTYPE), Darwin) +ifeq ($(WITH_SDL2),yes) +SDLLDFLAGS := -framework SDL2 -framework OpenGL -framework Cocoa +else # not SDL2 SDLLDFLAGS := -framework SDL -framework OpenGL -framework Cocoa -else +endif # SDL2 +else # not Darwin/Win ifeq ($(WITH_SDL2),yes) SDLLDFLAGS := $(shell sdl2-config --libs) -else +else # not SDL2 SDLLDFLAGS := $(shell sdl-config --libs) -endif -endif +endif # SDL2 +endif # Darwin/Win # ---------- @@ -348,6 +354,10 @@ release/quake2.exe : CFLAGS += -DRETEXTURE release/quake2.exe : LDFLAGS += -ljpeg endif +ifeq ($(WITH_SDL2),yes) +release/quake2.exe : CFLAGS += -DSDL2 +endif + release/quake2.exe : LDFLAGS += -mwindows -lopengl32 else client: @@ -408,6 +418,10 @@ else release/quake2 : LDFLAGS += -ljpeg endif endif + +ifeq ($(WITH_SDL2),yes) +release/quake2 : CFLAGS += -DSDL2 +endif ifeq ($(OSTYPE), Darwin) ifeq ($(OSX_APP), yes) diff --git a/src/backends/sdl/input.c b/src/backends/sdl/input.c index 6399ffd0..b000c4de 100644 --- a/src/backends/sdl/input.c +++ b/src/backends/sdl/input.c @@ -29,13 +29,15 @@ #include "../../client/header/keyboard.h" #include "../generic/header/input.h" -#ifdef _WIN32 +#if defined(_WIN32) || defined(__APPLE__) +#ifdef SDL2 +#include +#else // SDL1.2 #include -#elif defined(__APPLE__) -#include -#else +#endif //SDL2 +#else // not _WIN32 || APPLE #include -#endif +#endif // _WIN32 || APPLE #if SDL_VERSION_ATLEAST(2, 0, 0) #define SDLK_KP0 SDLK_KP_0 diff --git a/src/backends/sdl/refresh.c b/src/backends/sdl/refresh.c index 3d7fdc12..9d9ed436 100644 --- a/src/backends/sdl/refresh.c +++ b/src/backends/sdl/refresh.c @@ -18,6 +18,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * + * ---------------------------------------------------------------------- + * CalculateGammaRamp() is derived from SDL2's SDL_CalculateGammaRamp() + * (C) 1997-2013 Sam Lantinga + * Published under zlib License: http://www.libsdl.org/license.php + * * ======================================================================= * * This file implements an OpenGL context via SDL @@ -32,13 +37,15 @@ #include #endif -#ifdef _WIN32 +#if defined(_WIN32) || defined(__APPLE__) +#ifdef SDL2 +#include +#else // SDL1.2 #include -#elif defined(__APPLE__) -#include -#else +#endif //SDL2 +#else // not _WIN32 || APPLE #include -#endif +#endif // _WIN32 || APPLE /* The window icon */ #include "icon/q2icon.xbm" diff --git a/src/backends/sdl/sound.c b/src/backends/sdl/sound.c index 6301c0e2..af152ac0 100644 --- a/src/backends/sdl/sound.c +++ b/src/backends/sdl/sound.c @@ -34,13 +34,15 @@ */ /* SDL includes */ -#ifdef _WIN32 +#if defined(_WIN32) || defined(__APPLE__) +#ifdef SDL2 +#include +#else // SDL1.2 #include -#elif defined(__APPLE__) -#include -#else +#endif //SDL2 +#else // not _WIN32 || APPLE #include -#endif +#endif // _WIN32 || APPLE /* Local includes */ #include "../../client/header/client.h" diff --git a/src/backends/unix/main.c b/src/backends/unix/main.c index 6da1a15f..680f7a6c 100644 --- a/src/backends/unix/main.c +++ b/src/backends/unix/main.c @@ -77,6 +77,12 @@ main(int argc, char **argv) #ifndef DEDICATED_ONLY printf("Client build options:\n"); +#ifdef SDL2 + printf(" + SDL2\n"); +#else + printf(" - SDL2 (using 1.2)\n"); +#endif + #ifdef CDA printf(" + CD audio\n"); #else diff --git a/src/backends/windows/system.c b/src/backends/windows/system.c index c179aae1..fc2479c5 100644 --- a/src/backends/windows/system.c +++ b/src/backends/windows/system.c @@ -712,6 +712,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifndef DEDICATED_ONLY printf("Client build options:\n"); +#ifdef SDL2 + printf(" + SDL2\n"); +#else + printf(" - SDL2 (using 1.2)\n"); +#endif #ifdef CDA printf(" + CD audio\n"); #else