Skip to content

Commit

Permalink
WinRT: merged with SDL 2.0.1 codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Oct 28, 2013
2 parents e64e3d8 + f570eff commit 69c5d21
Show file tree
Hide file tree
Showing 343 changed files with 12,731 additions and 7,244 deletions.
1 change: 1 addition & 0 deletions .hgignore
Expand Up @@ -76,6 +76,7 @@ test/testnative
test/testoverlay2
test/testplatform
test/testpower
test/testfilesystem
test/testrelative
test/testrendercopyex
test/testrendertarget
Expand Down
23 changes: 21 additions & 2 deletions Android.mk
Expand Up @@ -33,6 +33,7 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
Expand All @@ -41,9 +42,27 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/test/*.c))

LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid

include $(BUILD_SHARED_LIBRARY)

###########################
#
# SDL static library
#
###########################

LOCAL_MODULE := SDL2_static

LOCAL_MODULE_FILENAME := libSDL2

LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c

LOCAL_LDLIBS :=
LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid

include $(BUILD_STATIC_LIBRARY)
39 changes: 35 additions & 4 deletions CMakeLists.txt
Expand Up @@ -29,9 +29,9 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 0)
set(SDL_MICRO_VERSION 0)
set(SDL_MICRO_VERSION 1)
set(SDL_INTERFACE_AGE 0)
set(SDL_BINARY_AGE 0)
set(SDL_BINARY_AGE 1)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")

# Calculate a libtool-like version number
Expand Down Expand Up @@ -172,7 +172,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)

set(SDL_SUBSYSTEMS
Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
File Loadso CPUinfo)
File Loadso CPUinfo Filesystem)
foreach(_SUB ${SDL_SUBSYSTEMS})
string(TOUPPER ${_SUB} _OPT)
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
Expand Down Expand Up @@ -714,6 +714,13 @@ if(UNIX AND NOT APPLE)
endif(LINUX)
endif(SDL_POWER)

if(SDL_FILESYSTEM)
set(SDL_FILESYSTEM_UNIX 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
endif(SDL_FILESYSTEM)

if(SDL_TIMERS)
set(SDL_TIMER_UNIX 1)
file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
Expand Down Expand Up @@ -814,6 +821,13 @@ elseif(WINDOWS)
set(HAVE_SDL_POWER TRUE)
endif(SDL_POWER)

if(SDL_FILESYSTEM)
set(SDL_FILESYSTEM_WINDOWS 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesytem/windows/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
endif(SDL_FILESYSTEM)

# Libraries for Win32 native and MinGW
list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)

Expand Down Expand Up @@ -924,6 +938,13 @@ elseif(APPLE)
set(SDL_FRAMEWORK_IOKIT 1)
endif()

if(SDL_FILESYSTEM)
set(SDL_FILESYSTEM_COCOA 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
endif()

# Actually load the frameworks at the end so we don't duplicate include.
if(SDL_FRAMEWORK_COCOA)
find_library(COCOA_LIBRARY Cocoa)
Expand Down Expand Up @@ -973,6 +994,11 @@ elseif(BEOS)
set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
set(HAVE_SDL_VIDEO TRUE)

set(SDL_FILESYSTEM_BEOS 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/beos/*.cc)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)

if(VIDEO_OPENGL)
# TODO: Use FIND_PACKAGE(OpenGL) instead
set(SDL_VIDEO_OPENGL 1)
Expand Down Expand Up @@ -1008,8 +1034,13 @@ endif(NOT HAVE_SDL_HAPTIC)
if(NOT HAVE_SDL_LOADSO)
set(SDL_LOADSO_DISABLED 1)
file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
endif(NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_FILESYSTEM)
set(SDL_FILESYSTEM_DISABLED 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
endif(NOT HAVE_SDL_FILESYSTEM)

# We always need to have threads and timers around
if(NOT HAVE_SDL_THREADS)
Expand Down
2 changes: 2 additions & 0 deletions CREDITS.txt
Expand Up @@ -21,6 +21,8 @@ Thanks to everyone who made this possible, including:

* Pierre-Loup Griffais for his deep knowledge of OpenGL drivers.

* Julian Winter for the SDL 2.0 website.

* Sheena Smith for many months of great work on the SDL wiki creating the API documentation and style guides.

* Paul Hunkin for his port of SDL to Android during the Google Summer of Code 2010.
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Expand Up @@ -54,6 +54,7 @@ HDRS = \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
SDL_filesystem.h \
SDL_gamecontroller.h \
SDL_gesture.h \
SDL_haptic.h \
Expand Down
1 change: 1 addition & 0 deletions Makefile.minimal
Expand Up @@ -19,6 +19,7 @@ SOURCES = \
src/joystick/dummy/*.c \
src/loadso/dummy/*.c \
src/power/*.c \
src/filesystem/dummy/*.c \
src/render/*.c \
src/render/software/*.c \
src/stdlib/*.c \
Expand Down
2 changes: 1 addition & 1 deletion Makefile.pandora
Expand Up @@ -19,7 +19,7 @@ SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \
./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \
./src/atomic/linux/*.c \
./src/atomic/linux/*.c ./src/filesystem/unix/*.c \
./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c


Expand Down
1 change: 1 addition & 0 deletions Makefile.psp
Expand Up @@ -31,6 +31,7 @@ OBJS= src/SDL.o \
src/joystick/psp/SDL_sysjoystick.o \
src/power/SDL_power.o \
src/power/psp/SDL_syspower.o \
src/filesystem/dummy/SDL_sysfilesystem.o \
src/render/SDL_render.o \
src/render/SDL_yuv_sw.o \
src/render/psp/SDL_render_psp.o \
Expand Down
50 changes: 49 additions & 1 deletion README-android.txt
Expand Up @@ -38,7 +38,33 @@ src/main/android/SDL_android_main.c
Building an app
================================================================================

Instructions:
For simple projects you can use the script located at build-scripts/androidbuild.sh

There's two ways of using it:

androidbuild.sh com.yourcompany.yourapp < sources.list
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c

sources.list should be a text file with a source file name in each line
Filenames should be specified relative to the current directory, for example if
you are in the build-scripts directory and want to create the testgles.c test, you'll
run:

./androidbuild.sh org.libsdl.testgles ../test/testgles.c

One limitation of this script is that all sources provided will be aggregated into
a single directory, thus all your source files should have a unique name.

Once the project is complete the script will tell you where the debug APK is located.
If you want to create a signed release APK, you can use the project created by this
utility to generate it.

Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
done in the build directory for the app!


For more complex projects, follow these instructions:

1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project.
2. Move or symlink this SDL directory into the <project>/jni directory
Expand Down Expand Up @@ -84,6 +110,28 @@ android-project/
on this implementation.


================================================================================
Build an app with static linking of libSDL
================================================================================

This build uses the Android NDK module system.

Instructions:
1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project.
2. Rename <project>/jni/src/Android_static.mk to <project>/jni/src/Android.mk
(overwrite the existing one)
3. Edit <project>/jni/src/Android.mk to include your source files
4. create and export an environment variable named NDK_MODULE_PATH that points
to the parent directory of this SDL directory. e.g.:

export NDK_MODULE_PATH="$PWD"/..

5. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
System.loadLibrary("SDL2") line 42.
6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source


================================================================================
Customizing your application name
================================================================================
Expand Down
36 changes: 36 additions & 0 deletions README-macosx.txt
Expand Up @@ -29,6 +29,42 @@ gcc to make this easy is provided in test/gcc-fat.sh
To use the library once it's built, you essential have two possibilities:
use the traditional autoconf/automake/make method, or use Xcode.

==============================================================================
Caveats for using SDL with Mac OS X
==============================================================================

Some things you have to be aware of when using SDL on Mac OS X:

- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
SDL will not register its own. This means that SDL will not terminate using
SDL_Quit if it receives a termination request, it will terminate like a
normal app, and it will not send a SDL_DROPFILE when you request to open a
file with the app. To solve these issues, put the following code in your
NSApplicationDelegate implementation:

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}

return NSTerminateCancel;
}

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_DROPFILE;
event.drop.file = SDL_strdup([filename UTF8String]);
return (SDL_PushEvent(&event) > 0);
}

return NO;
}

==============================================================================
Using the Simple DirectMedia Layer with a traditional Makefile
==============================================================================
Expand Down

0 comments on commit 69c5d21

Please sign in to comment.