Add -DSDL2 for Win32/OSX support (untested), print SDL2 usage on startup

The quake2 binary now gets -DSDL2 in the CFLAGS, so Win32/OSX can
use different #include paths accordingly.
This is also (ab)used to print which SDL version is used on startup.
Don't use this for anything else, use
#if SDL_VERSION_ATLEAST(2, 0, 0)
instead.

I haven't tested building on/for Win32 or OSX, there may be more
work to do.

Furthermore I added Copyright-Info about CalculateGammaRamp()
in refresh.c (it's from SDL2)
This commit is contained in:
Daniel Gibson 2013-09-01 14:19:33 +02:00
parent 628dff77a8
commit d1ca122955
6 changed files with 57 additions and 21 deletions

View File

@ -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)

View File

@ -29,13 +29,15 @@
#include "../../client/header/keyboard.h"
#include "../generic/header/input.h"
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else // SDL1.2
#include <SDL/SDL.h>
#elif defined(__APPLE__)
#include <SDL/SDL.h>
#else
#endif //SDL2
#else // not _WIN32 || APPLE
#include <SDL.h>
#endif
#endif // _WIN32 || APPLE
#if SDL_VERSION_ATLEAST(2, 0, 0)
#define SDLK_KP0 SDLK_KP_0

View File

@ -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 <slouken@libsdl.org>
* Published under zlib License: http://www.libsdl.org/license.php
*
* =======================================================================
*
* This file implements an OpenGL context via SDL
@ -32,13 +37,15 @@
#include <GL/gl.h>
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else // SDL1.2
#include <SDL/SDL.h>
#elif defined(__APPLE__)
#include <SDL/SDL.h>
#else
#endif //SDL2
#else // not _WIN32 || APPLE
#include <SDL.h>
#endif
#endif // _WIN32 || APPLE
/* The window icon */
#include "icon/q2icon.xbm"

View File

@ -34,13 +34,15 @@
*/
/* SDL includes */
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else // SDL1.2
#include <SDL/SDL.h>
#elif defined(__APPLE__)
#include <SDL/SDL.h>
#else
#endif //SDL2
#else // not _WIN32 || APPLE
#include <SDL.h>
#endif
#endif // _WIN32 || APPLE
/* Local includes */
#include "../../client/header/client.h"

View File

@ -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

View File

@ -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