Skip to content

Commit

Permalink
Upgrade to SDL 2.0.4
Browse files Browse the repository at this point in the history
SDL now no longer uses the C runtime, so apparently a single .lib works across different MSVC Versions and toolsets.
  • Loading branch information
mrwonko committed Mar 20, 2016
1 parent f6d4a7f commit 1e60c42
Show file tree
Hide file tree
Showing 84 changed files with 18,740 additions and 13,815 deletions.
17 changes: 6 additions & 11 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,17 @@ if(BuildSPEngine OR BuildJK2SPEngine)
endif()

if(UseInternalSDL2)
if(MSVC14)
set(MSVC_SUFFIX "_2015")
else()
set(MSVC_SUFFIX "")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(SPEngineLibraries
${SPEngineLibraries}
${OpenJKLibDir}/SDL2/lib/x86${MSVC_SUFFIX}/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x86${MSVC_SUFFIX}/SDL2.lib
${OpenJKLibDir}/SDL2/lib/x86/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x86/SDL2.lib
)
else()
set(SPEngineLibraries
${SPEngineLibraries}
${OpenJKLibDir}/SDL2/lib/x64${MSVC_SUFFIX}/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x64${MSVC_SUFFIX}/SDL2.lib
${OpenJKLibDir}/SDL2/lib/x64/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x64/SDL2.lib
)
endif()

Expand Down Expand Up @@ -380,11 +375,11 @@ if(BuildSPEngine OR BuildJK2SPEngine)
if(UseInternalSDL2)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(SPEngineExtraInstallFiles
${OpenJKLibDir}/SDL2/bin/x86${MSVC_SUFFIX}/SDL2.dll
${OpenJKLibDir}/SDL2/bin/x86/SDL2.dll
)
else()
set(SPEngineExtraInstallFiles
${OpenJKLibDir}/SDL2/bin/x64${MSVC_SUFFIX}/SDL2.dll
${OpenJKLibDir}/SDL2/bin/x64/SDL2.dll
)
endif()
endif()
Expand Down
17 changes: 6 additions & 11 deletions codemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,22 +374,17 @@ if(BuildMPEngine)
endif()

if(UseInternalSDL2)
if(MSVC14)
set(MSVC_SUFFIX "_2015")
else()
set(MSVC_SUFFIX "")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(MPEngineLibraries
${MPEngineLibraries}
${OpenJKLibDir}/SDL2/lib/x86${MSVC_SUFFIX}/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x86${MSVC_SUFFIX}/SDL2.lib
${OpenJKLibDir}/SDL2/lib/x86/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x86/SDL2.lib
)
else()
set(MPEngineLibraries
${MPEngineLibraries}
${OpenJKLibDir}/SDL2/lib/x64${MSVC_SUFFIX}/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x64${MSVC_SUFFIX}/SDL2.lib
${OpenJKLibDir}/SDL2/lib/x64/SDL2main.lib
${OpenJKLibDir}/SDL2/lib/x64/SDL2.lib
)
endif()

Expand Down Expand Up @@ -562,11 +557,11 @@ if(BuildMPEngine)
if(UseInternalSDL2)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(MPEngineExtraInstallFiles
${OpenJKLibDir}/SDL2/bin/x86${MSVC_SUFFIX}/SDL2.dll
${OpenJKLibDir}/SDL2/bin/x86/SDL2.dll
)
else()
set(MPEngineExtraInstallFiles
${OpenJKLibDir}/SDL2/bin/x64${MSVC_SUFFIX}/SDL2.dll
${OpenJKLibDir}/SDL2/bin/x64/SDL2.dll
)
endif()
endif()
Expand Down
Binary file removed lib/SDL2/bin/x64_2015/SDL2.dll
Binary file not shown.
Binary file removed lib/SDL2/bin/x86_2015/SDL2.dll
Binary file not shown.
47 changes: 8 additions & 39 deletions lib/SDL2/include/SDL.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
Copyright (C) 1997-2016 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand All @@ -25,41 +25,6 @@
* Main include header for the SDL library
*/

/**
* \mainpage Simple DirectMedia Layer (SDL)
*
* http://www.libsdl.org/
*
* \section intro_sec Introduction
*
* Simple DirectMedia Layer is a cross-platform development library designed
* to provide low level access to audio, keyboard, mouse, joystick, and
* graphics hardware via OpenGL and Direct3D. It is used by video playback
* software, emulators, and popular games including Valve's award winning
* catalog and many Humble Bundle games.
*
* SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
* Support for other platforms may be found in the source code.
*
* SDL is written in C, works natively with C++, and there are bindings
* available for several other languages, including C# and Python.
*
* This library is distributed under the zlib license, which can be found
* in the file "COPYING.txt".
*
* The best way to learn how to use SDL is to check out the header files in
* the "include" subdirectory and the programs in the "test" subdirectory.
* The header files and test programs are well commented and always up to date.
* More documentation and FAQs are available online at:
* http://wiki.libsdl.org/
*
* If you need help with the library, or just want to discuss SDL related
* issues, you can join the developers mailing list:
* http://www.libsdl.org/mailing-list.php
*
* Enjoy!
* Sam Lantinga ([email protected])
*/

#ifndef _SDL_H
#define _SDL_H
Expand Down Expand Up @@ -114,7 +79,7 @@ extern "C" {
#define SDL_INIT_HAPTIC 0x00001000
#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
#define SDL_INIT_EVENTS 0x00004000
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */
#define SDL_INIT_EVERYTHING ( \
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
Expand All @@ -123,13 +88,17 @@ extern "C" {

/**
* This function initializes the subsystems specified by \c flags
* Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
* signal handlers for some commonly ignored fatal signals (like SIGSEGV).
*/
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);

/**
* This function initializes specific SDL subsystems
*
* Subsystem initialization is ref-counted, you must call
* SDL_QuitSubSystem for each SDL_InitSubSystem to correctly
* shutdown a subsystem manually (or call SDL_Quit to force shutdown).
* If a subsystem is already loaded then this call will
* increase the ref-count and return.
*/
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);

Expand Down
45 changes: 25 additions & 20 deletions lib/SDL2/include/SDL_assert.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
Copyright (C) 1997-2016 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down Expand Up @@ -51,7 +51,7 @@ assert can have unique static variables associated with it.
/* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak()
#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
#elif (!defined(__NACL__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif defined(HAVE_SIGNAL_H)
#include <signal.h>
Expand Down Expand Up @@ -86,8 +86,10 @@ This also solves the problem of...
disable assertions.
*/

/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
this condition isn't constant. And looks like an owl's face! */
#ifdef _MSC_VER /* stupid /W4 warnings. */
#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
#else
#define SDL_NULL_WHILE_LOOP_CONDITION (0)
#endif
Expand All @@ -102,23 +104,23 @@ typedef enum
SDL_ASSERTION_ABORT, /**< Terminate the program. */
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
} SDL_assert_state;
} SDL_AssertState;

typedef struct SDL_assert_data
typedef struct SDL_AssertData
{
int always_ignore;
unsigned int trigger_count;
const char *condition;
const char *filename;
int linenum;
const char *function;
const struct SDL_assert_data *next;
} SDL_assert_data;
const struct SDL_AssertData *next;
} SDL_AssertData;

#if (SDL_ASSERT_LEVEL > 0)

/* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *,
const char *, int)
#if defined(__clang__)
Expand All @@ -141,16 +143,13 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
#define SDL_enabled_assert(condition) \
do { \
while ( !(condition) ) { \
static struct SDL_assert_data assert_data = { \
static struct SDL_AssertData sdl_assert_data = { \
0, 0, #condition, 0, 0, 0, 0 \
}; \
const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
SDL_FUNCTION, \
SDL_FILE, \
SDL_LINE); \
if (state == SDL_ASSERTION_RETRY) { \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \
} else if (state == SDL_ASSERTION_BREAK) { \
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
SDL_TriggerBreakpoint(); \
} \
break; /* not retrying. */ \
Expand Down Expand Up @@ -184,8 +183,8 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
#define SDL_assert_always(condition) SDL_enabled_assert(condition)


typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
const SDL_assert_data* data, void* userdata);
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
const SDL_AssertData* data, void* userdata);

/**
* \brief Set an application-defined assertion handler.
Expand All @@ -202,7 +201,7 @@ typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
*
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
*
* \return SDL_assert_state value of how to handle the assertion failure.
* \return SDL_AssertState value of how to handle the assertion failure.
*
* \param handler Callback function, called when an assertion fails.
* \param userdata A pointer passed to the callback as-is.
Expand Down Expand Up @@ -249,7 +248,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
* The proper way to examine this data looks something like this:
*
* <code>
* const SDL_assert_data *item = SDL_GetAssertionReport();
* const SDL_AssertData *item = SDL_GetAssertionReport();
* while (item) {
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
* item->condition, item->function, item->filename,
Expand All @@ -262,7 +261,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
* \return List of all assertions.
* \sa SDL_ResetAssertionReport
*/
extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);

/**
* \brief Reset the list of all assertion failures.
Expand All @@ -273,6 +272,12 @@ extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
*/
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);


/* these had wrong naming conventions until 2.0.4. Please update your app! */
#define SDL_assert_state SDL_AssertState
#define SDL_assert_data SDL_AssertData


/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
Expand Down
12 changes: 10 additions & 2 deletions lib/SDL2/include/SDL_atomic.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
Copyright (C) 1997-2016 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down Expand Up @@ -122,7 +122,8 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
void _ReadWriteBarrier(void);
#pragma intrinsic(_ReadWriteBarrier)
#define SDL_CompilerBarrier() _ReadWriteBarrier()
#elif defined(__GNUC__)
#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
#else
#define SDL_CompilerBarrier() \
Expand Down Expand Up @@ -169,10 +170,17 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire();
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory")
#endif /* __GNUC__ && __arm__ */
#else
#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */
#include <mbarrier.h>
#define SDL_MemoryBarrierRelease() __machine_rel_barrier()
#define SDL_MemoryBarrierAcquire() __machine_acq_barrier()
#else
/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */
#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
#endif
#endif

/**
* \brief A type representing an atomic integer value. It is a struct
Expand Down
Loading

0 comments on commit 1e60c42

Please sign in to comment.