mirror of https://github.com/encounter/SDL.git
Fixed markdown formatting in READMEs.
This commit is contained in:
parent
c5aa0d8081
commit
6d9dbf5e1e
|
@ -18,9 +18,9 @@ Joystick support is available for API level >=12 devices.
|
||||||
|
|
||||||
- Android applications are Java-based, optionally with parts written in C
|
- Android applications are Java-based, optionally with parts written in C
|
||||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||||
the SDL library
|
the SDL library
|
||||||
- This means that your application C code must be placed inside an Android
|
- This means that your application C code must be placed inside an Android
|
||||||
Java project, along with some C support code that communicates with Java
|
Java project, along with some C support code that communicates with Java
|
||||||
- This eventually produces a standard Android .apk package
|
- This eventually produces a standard Android .apk package
|
||||||
|
|
||||||
The Android Java code implements an "Activity" and can be found in:
|
The Android Java code implements an "Activity" and can be found in:
|
||||||
|
@ -42,15 +42,15 @@ For simple projects you can use the script located at build-scripts/androidbuild
|
||||||
|
|
||||||
There's two ways of using it:
|
There's two ways of using it:
|
||||||
|
|
||||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
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
|
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
|
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
|
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||||
run:
|
run:
|
||||||
|
|
||||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||||
|
|
||||||
One limitation of this script is that all sources provided will be aggregated into
|
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.
|
a single directory, thus all your source files should have a unique name.
|
||||||
|
@ -74,7 +74,9 @@ For more complex projects, follow these instructions:
|
||||||
If you want to use the Eclipse IDE, skip to the Eclipse section below.
|
If you want to use the Eclipse IDE, skip to the Eclipse section below.
|
||||||
|
|
||||||
5. Create <project>/local.properties and use that to point to the Android SDK directory, by writing a line with the following form:
|
5. Create <project>/local.properties and use that to point to the Android SDK directory, by writing a line with the following form:
|
||||||
sdk.dir=PATH_TO_ANDROID_SDK
|
|
||||||
|
sdk.dir=PATH_TO_ANDROID_SDK
|
||||||
|
|
||||||
6. Run 'ant debug' in android/project. This compiles the .java and eventually
|
6. Run 'ant debug' in android/project. This compiles the .java and eventually
|
||||||
creates a .apk with the native code embedded
|
creates a .apk with the native code embedded
|
||||||
7. 'ant debug install' will push the apk to the device or emulator (if connected)
|
7. 'ant debug install' will push the apk to the device or emulator (if connected)
|
||||||
|
@ -125,7 +127,7 @@ Instructions:
|
||||||
4. create and export an environment variable named NDK_MODULE_PATH that points
|
4. create and export an environment variable named NDK_MODULE_PATH that points
|
||||||
to the parent directory of this SDL directory. e.g.:
|
to the parent directory of this SDL directory. e.g.:
|
||||||
|
|
||||||
export NDK_MODULE_PATH="$PWD"/..
|
export NDK_MODULE_PATH="$PWD"/..
|
||||||
|
|
||||||
5. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
|
5. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
|
||||||
System.loadLibrary("SDL2").
|
System.loadLibrary("SDL2").
|
||||||
|
@ -142,7 +144,7 @@ To customize your application name, edit AndroidManifest.xml and replace
|
||||||
Then create a Java class extending SDLActivity and place it in a directory
|
Then create a Java class extending SDLActivity and place it in a directory
|
||||||
under src matching your package, e.g.
|
under src matching your package, e.g.
|
||||||
|
|
||||||
src/com/gamemaker/game/MyGame.java
|
src/com/gamemaker/game/MyGame.java
|
||||||
|
|
||||||
Here's an example of a minimal class file:
|
Here's an example of a minimal class file:
|
||||||
|
|
||||||
|
@ -184,9 +186,9 @@ standard functions in SDL_rwops.h.
|
||||||
|
|
||||||
There are also a few Android specific functions that allow you to get other
|
There are also a few Android specific functions that allow you to get other
|
||||||
useful paths for saving and loading data:
|
useful paths for saving and loading data:
|
||||||
SDL_AndroidGetInternalStoragePath()
|
* SDL_AndroidGetInternalStoragePath()
|
||||||
SDL_AndroidGetExternalStorageState()
|
* SDL_AndroidGetExternalStorageState()
|
||||||
SDL_AndroidGetExternalStoragePath()
|
* SDL_AndroidGetExternalStoragePath()
|
||||||
|
|
||||||
See SDL_system.h for more details on these functions.
|
See SDL_system.h for more details on these functions.
|
||||||
|
|
||||||
|
@ -228,6 +230,7 @@ under iOS, if the OS can not restore your GL context it will just kill your app)
|
||||||
|
|
||||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||||
a look here: http://developer.android.com/guide/practices/jni.html
|
a look here: http://developer.android.com/guide/practices/jni.html
|
||||||
|
|
||||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||||
do so by creating them using SDL functions. This way, the required attach/detach
|
do so by creating them using SDL functions. This way, the required attach/detach
|
||||||
handling is managed by SDL automagically. If you have threads created by other
|
handling is managed by SDL automagically. If you have threads created by other
|
||||||
|
@ -242,7 +245,8 @@ detach it.
|
||||||
|
|
||||||
You can use STL in your project by creating an Application.mk file in the jni
|
You can use STL in your project by creating an Application.mk file in the jni
|
||||||
folder and adding the following line:
|
folder and adding the following line:
|
||||||
APP_STL := stlport_static
|
|
||||||
|
APP_STL := stlport_static
|
||||||
|
|
||||||
For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
|
For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
|
||||||
|
|
||||||
|
@ -293,39 +297,39 @@ You can create and run an emulator from the Eclipse IDE:
|
||||||
|
|
||||||
You can see if adb can see any devices with the following command:
|
You can see if adb can see any devices with the following command:
|
||||||
|
|
||||||
adb devices
|
adb devices
|
||||||
|
|
||||||
You can see the output of log messages on the default device with:
|
You can see the output of log messages on the default device with:
|
||||||
|
|
||||||
adb logcat
|
adb logcat
|
||||||
|
|
||||||
You can push files to the device with:
|
You can push files to the device with:
|
||||||
|
|
||||||
adb push local_file remote_path_and_file
|
adb push local_file remote_path_and_file
|
||||||
|
|
||||||
You can push files to the SD Card at /sdcard, for example:
|
You can push files to the SD Card at /sdcard, for example:
|
||||||
|
|
||||||
adb push moose.dat /sdcard/moose.dat
|
adb push moose.dat /sdcard/moose.dat
|
||||||
|
|
||||||
You can see the files on the SD card with a shell command:
|
You can see the files on the SD card with a shell command:
|
||||||
|
|
||||||
adb shell ls /sdcard/
|
adb shell ls /sdcard/
|
||||||
|
|
||||||
You can start a command shell on the default device with:
|
You can start a command shell on the default device with:
|
||||||
|
|
||||||
adb shell
|
adb shell
|
||||||
|
|
||||||
You can remove the library files of your project (and not the SDL lib files) with:
|
You can remove the library files of your project (and not the SDL lib files) with:
|
||||||
|
|
||||||
ndk-build clean
|
ndk-build clean
|
||||||
|
|
||||||
You can do a build with the following command:
|
You can do a build with the following command:
|
||||||
|
|
||||||
ndk-build
|
ndk-build
|
||||||
|
|
||||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||||
|
|
||||||
ndk-build V=1
|
ndk-build V=1
|
||||||
|
|
||||||
If your application crashes in native code, you can use addr2line to convert the
|
If your application crashes in native code, you can use addr2line to convert the
|
||||||
addresses in the stack trace to lines in your code.
|
addresses in the stack trace to lines in your code.
|
||||||
|
@ -345,7 +349,7 @@ For example, if your crash looks like this:
|
||||||
You can see that there's a crash in the C library being called from the main code.
|
You can see that there's a crash in the C library being called from the main code.
|
||||||
I run addr2line with the debug version of my code:
|
I run addr2line with the debug version of my code:
|
||||||
|
|
||||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||||
|
|
||||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||||
000014bc
|
000014bc
|
||||||
|
@ -360,7 +364,8 @@ You can add logging to your code to help show what's happening:
|
||||||
|
|
||||||
If you need to build without optimization turned on, you can create a file called
|
If you need to build without optimization turned on, you can create a file called
|
||||||
"Application.mk" in the jni directory, with the following line in it:
|
"Application.mk" in the jni directory, with the following line in it:
|
||||||
APP_OPTIM := debug
|
|
||||||
|
APP_OPTIM := debug
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
@ -370,7 +375,7 @@ APP_OPTIM := debug
|
||||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||||
Valgrind has support for Android out of the box, just grab code using:
|
Valgrind has support for Android out of the box, just grab code using:
|
||||||
|
|
||||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||||
|
|
||||||
... and follow the instructions in the file README.android to build it.
|
... and follow the instructions in the file README.android to build it.
|
||||||
|
|
||||||
|
@ -389,15 +394,15 @@ application with it, changing org.libsdl.app to your package identifier:
|
||||||
|
|
||||||
Then push it to the device:
|
Then push it to the device:
|
||||||
|
|
||||||
adb push start_valgrind_app /data/local
|
adb push start_valgrind_app /data/local
|
||||||
|
|
||||||
and make it executable:
|
and make it executable:
|
||||||
|
|
||||||
adb shell chmod 755 /data/local/start_valgrind_app
|
adb shell chmod 755 /data/local/start_valgrind_app
|
||||||
|
|
||||||
and tell Android to use the script to launch your application:
|
and tell Android to use the script to launch your application:
|
||||||
|
|
||||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||||
|
|
||||||
If the setprop command says "could not set property", it's likely that
|
If the setprop command says "could not set property", it's likely that
|
||||||
your package name is too long and you should make it shorter by changing
|
your package name is too long and you should make it shorter by changing
|
||||||
|
@ -408,11 +413,11 @@ You can monitor the startup process with the logcat command above, and
|
||||||
when it's done (or even while it's running) you can grab the valgrind
|
when it's done (or even while it's running) you can grab the valgrind
|
||||||
output file:
|
output file:
|
||||||
|
|
||||||
adb pull /sdcard/valgrind.log
|
adb pull /sdcard/valgrind.log
|
||||||
|
|
||||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||||
|
|
||||||
adb shell setprop wrap.org.libsdl.app ""
|
adb shell setprop wrap.org.libsdl.app ""
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Why is API level 10 the minimum required?
|
Why is API level 10 the minimum required?
|
||||||
|
|
|
@ -11,11 +11,12 @@ without complication.
|
||||||
While still experimental, the build system should be usable on the following
|
While still experimental, the build system should be usable on the following
|
||||||
platforms:
|
platforms:
|
||||||
|
|
||||||
* FreeBSD
|
* FreeBSD
|
||||||
* Linux
|
* Linux
|
||||||
* VS.NET 2010
|
* VS.NET 2010
|
||||||
* MinGW and Msys
|
* MinGW and Msys
|
||||||
* OS X with support for XCode
|
* OS X with support for XCode
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Usage
|
Usage
|
||||||
|
@ -23,9 +24,9 @@ Usage
|
||||||
|
|
||||||
Assuming the source for SDL is located at ~/sdl
|
Assuming the source for SDL is located at ~/sdl
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ../sdl
|
cmake ../sdl
|
||||||
|
|
||||||
This will build the static and dynamic versions of SDL in the ~/build directory.
|
This will build the static and dynamic versions of SDL in the ~/build directory.
|
||||||
|
|
|
@ -11,9 +11,9 @@ Supports:
|
||||||
|
|
||||||
What you need:
|
What you need:
|
||||||
|
|
||||||
DirectFB 1.0.1, 1.2.x, 1.3.0
|
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||||
Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||||
Mesa 7.0.x - optional for OpenGL
|
* Mesa 7.0.x - optional for OpenGL
|
||||||
|
|
||||||
/etc/directfbrc
|
/etc/directfbrc
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,18 @@ SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch dev
|
||||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||||
|
|
||||||
event.dgesture.touchId - the Id of the touch used to record the gesture.
|
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||||
event.dgesture.gestureId - the unique id of the recorded gesture.
|
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||||
|
|
||||||
|
|
||||||
Performing:
|
Performing:
|
||||||
-----------
|
-----------
|
||||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||||
|
|
||||||
event.dgesture.touchId - the Id of the touch which performed the gesture.
|
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||||
event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||||
event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||||
event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||||
|
|
||||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ Multi Gestures
|
||||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||||
|
|
||||||
event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||||
event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||||
event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||||
event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||||
event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||||
event.mgesture.numFingers - the number of fingers used in the gesture.
|
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
|
@ -9,7 +9,7 @@ at the Mercurial website ( http://mercurial.selenic.com/ ) for more
|
||||||
information on using hg, where you can also download software for
|
information on using hg, where you can also download software for
|
||||||
Mac OS X, Windows, and Unix systems.
|
Mac OS X, Windows, and Unix systems.
|
||||||
|
|
||||||
hg clone http://hg.libsdl.org/SDL
|
hg clone http://hg.libsdl.org/SDL
|
||||||
|
|
||||||
If you are building SDL with an IDE, you will need to copy the file
|
If you are building SDL with an IDE, you will need to copy the file
|
||||||
include/SDL_config.h.default to include/SDL_config.h before building.
|
include/SDL_config.h.default to include/SDL_config.h before building.
|
||||||
|
@ -18,7 +18,6 @@ If you are building SDL via configure, you will need to run autogen.sh
|
||||||
before running configure.
|
before running configure.
|
||||||
|
|
||||||
There is a web interface to the subversion repository at:
|
There is a web interface to the subversion repository at:
|
||||||
|
|
||||||
http://hg.libsdl.org/SDL/
|
http://hg.libsdl.org/SDL/
|
||||||
|
|
||||||
There is an RSS feed available at that URL, for those that want to
|
There is an RSS feed available at that URL, for those that want to
|
||||||
|
|
|
@ -14,11 +14,12 @@ Instructions:
|
||||||
There are three build targets:
|
There are three build targets:
|
||||||
- libSDL.a:
|
- libSDL.a:
|
||||||
Build SDL as a statically linked library
|
Build SDL as a statically linked library
|
||||||
- testsdl
|
- testsdl:
|
||||||
Build a test program (there are known test failures which are fine)
|
Build a test program (there are known test failures which are fine)
|
||||||
- Template:
|
- Template:
|
||||||
Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
|
Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Build SDL for iOS from the command line
|
Build SDL for iOS from the command line
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -57,6 +58,7 @@ Here is a more manual method:
|
||||||
4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically.
|
4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically.
|
||||||
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code.
|
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code.
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Notes -- Application events
|
Notes -- Application events
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -148,11 +150,14 @@ The SDL keyboard API has been extended to support on-screen keyboards:
|
||||||
|
|
||||||
void SDL_StartTextInput()
|
void SDL_StartTextInput()
|
||||||
-- enables text events and reveals the onscreen keyboard.
|
-- enables text events and reveals the onscreen keyboard.
|
||||||
|
|
||||||
void SDL_StopTextInput()
|
void SDL_StopTextInput()
|
||||||
-- disables text events and hides the onscreen keyboard.
|
-- disables text events and hides the onscreen keyboard.
|
||||||
|
|
||||||
SDL_bool SDL_IsTextInputActive()
|
SDL_bool SDL_IsTextInputActive()
|
||||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Notes -- Reading and Writing files
|
Notes -- Reading and Writing files
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -161,12 +166,12 @@ Each application installed on iPhone resides in a sandbox which includes its own
|
||||||
|
|
||||||
Once your application is installed its directory tree looks like:
|
Once your application is installed its directory tree looks like:
|
||||||
|
|
||||||
MySDLApp Home/
|
MySDLApp Home/
|
||||||
MySDLApp.app
|
MySDLApp.app
|
||||||
Documents/
|
Documents/
|
||||||
Library/
|
Library/
|
||||||
Preferences/
|
Preferences/
|
||||||
tmp/
|
tmp/
|
||||||
|
|
||||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||||
|
|
||||||
|
@ -192,7 +197,7 @@ Game Center
|
||||||
|
|
||||||
Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||||
|
|
||||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||||
|
|
||||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||||
|
|
||||||
|
@ -201,7 +206,7 @@ e.g.
|
||||||
extern "C"
|
extern "C"
|
||||||
void ShowFrame(void*)
|
void ShowFrame(void*)
|
||||||
{
|
{
|
||||||
... do event handling, frame logic and rendering
|
... do event handling, frame logic and rendering ...
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -209,17 +214,17 @@ e.g.
|
||||||
... initialize game ...
|
... initialize game ...
|
||||||
|
|
||||||
#if __IPHONEOS__
|
#if __IPHONEOS__
|
||||||
// Initialize the Game Center for scoring and matchmaking
|
// Initialize the Game Center for scoring and matchmaking
|
||||||
InitGameCenter();
|
InitGameCenter();
|
||||||
|
|
||||||
// Set up the game to run in the window animation callback on iOS
|
// Set up the game to run in the window animation callback on iOS
|
||||||
// so that Game Center and so forth works correctly.
|
// so that Game Center and so forth works correctly.
|
||||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||||
#else
|
#else
|
||||||
while ( running ) {
|
while ( running ) {
|
||||||
ShowFrame(0);
|
ShowFrame(0);
|
||||||
DelayFrame();
|
DelayFrame();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,28 +45,29 @@ Some things you have to be aware of when using SDL on Mac OS X:
|
||||||
file with the app. To solve these issues, put the following code in your
|
file with the app. To solve these issues, put the following code in your
|
||||||
NSApplicationDelegate implementation:
|
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;
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||||
}
|
{
|
||||||
|
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
return NSTerminateCancel;
|
||||||
{
|
}
|
||||||
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;
|
- (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
|
Using the Simple DirectMedia Layer with a traditional Makefile
|
||||||
|
|
|
@ -3,8 +3,8 @@ Native Client
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
* Native Client SDK (https://developer.chrome.com/native-client),
|
* Native Client SDK (https://developer.chrome.com/native-client),
|
||||||
(tested with Pepper version 33 or higher).
|
(tested with Pepper version 33 or higher).
|
||||||
|
|
||||||
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
||||||
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
||||||
|
@ -91,9 +91,9 @@ To be able to save into the directory "/save/" (like backup of game) :
|
||||||
|
|
||||||
And add to manifest.json :
|
And add to manifest.json :
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"unlimitedStorage"
|
"unlimitedStorage"
|
||||||
]
|
]
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
TODO - Known Issues
|
TODO - Known Issues
|
||||||
|
|
|
@ -8,27 +8,27 @@ Officially supported platforms
|
||||||
==============================
|
==============================
|
||||||
(code compiles, and thoroughly tested for release)
|
(code compiles, and thoroughly tested for release)
|
||||||
==============================
|
==============================
|
||||||
Windows XP/Vista/7/8
|
* Windows XP/Vista/7/8
|
||||||
Mac OS X 10.5+
|
* Mac OS X 10.5+
|
||||||
Linux 2.6+
|
* Linux 2.6+
|
||||||
iOS 5.1.1+
|
* iOS 5.1.1+
|
||||||
Android 2.3.3+
|
* Android 2.3.3+
|
||||||
|
|
||||||
Unofficially supported platforms
|
Unofficially supported platforms
|
||||||
================================
|
================================
|
||||||
(code compiles, but not thoroughly tested)
|
(code compiles, but not thoroughly tested)
|
||||||
================================
|
================================
|
||||||
FreeBSD
|
* FreeBSD
|
||||||
NetBSD
|
* NetBSD
|
||||||
OpenBSD
|
* OpenBSD
|
||||||
Solaris
|
* Solaris
|
||||||
|
|
||||||
Platforms supported by volunteers
|
Platforms supported by volunteers
|
||||||
=================================
|
=================================
|
||||||
Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
|
* Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
|
||||||
PSP - maintained by 527721088@qq.com
|
* PSP - maintained by 527721088@qq.com
|
||||||
Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
|
* Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
|
||||||
NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>
|
* NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>
|
||||||
|
|
||||||
Platforms that need maintainers
|
Platforms that need maintainers
|
||||||
===============================
|
===============================
|
||||||
|
|
|
@ -15,6 +15,7 @@ Raspbian (other Linux distros may work as well).
|
||||||
* Input (mouse/keyboard/joystick) via EVDEV
|
* Input (mouse/keyboard/joystick) via EVDEV
|
||||||
* Hotplugging of input devices via UDEV
|
* Hotplugging of input devices via UDEV
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Raspbian Build Dependencies
|
Raspbian Build Dependencies
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
@ -20,18 +20,18 @@ Events
|
||||||
SDL_FINGERDOWN:
|
SDL_FINGERDOWN:
|
||||||
Sent when a finger (or stylus) is placed on a touch device.
|
Sent when a finger (or stylus) is placed on a touch device.
|
||||||
Fields:
|
Fields:
|
||||||
event.tfinger.touchId - the Id of the touch device.
|
* event.tfinger.touchId - the Id of the touch device.
|
||||||
event.tfinger.fingerId - the Id of the finger which just went down.
|
* event.tfinger.fingerId - the Id of the finger which just went down.
|
||||||
event.tfinger.x - the x coordinate of the touch (0..1)
|
* event.tfinger.x - the x coordinate of the touch (0..1)
|
||||||
event.tfinger.y - the y coordinate of the touch (0..1)
|
* event.tfinger.y - the y coordinate of the touch (0..1)
|
||||||
event.tfinger.pressure - the pressure of the touch (0..1)
|
* event.tfinger.pressure - the pressure of the touch (0..1)
|
||||||
|
|
||||||
SDL_FINGERMOTION:
|
SDL_FINGERMOTION:
|
||||||
Sent when a finger (or stylus) is moved on the touch device.
|
Sent when a finger (or stylus) is moved on the touch device.
|
||||||
Fields:
|
Fields:
|
||||||
Same as SDL_FINGERDOWN but with additional:
|
Same as SDL_FINGERDOWN but with additional:
|
||||||
event.tfinger.dx - change in x coordinate during this motion event.
|
* event.tfinger.dx - change in x coordinate during this motion event.
|
||||||
event.tfinger.dy - change in y coordinate during this motion event.
|
* event.tfinger.dy - change in y coordinate during this motion event.
|
||||||
|
|
||||||
SDL_FINGERUP:
|
SDL_FINGERUP:
|
||||||
Sent when a finger (or stylus) is lifted from the touch device.
|
Sent when a finger (or stylus) is lifted from the touch device.
|
||||||
|
@ -70,11 +70,12 @@ A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it
|
||||||
As a result, be very careful to check for NULL return values.
|
As a result, be very careful to check for NULL return values.
|
||||||
|
|
||||||
A SDL_Finger has the following fields:
|
A SDL_Finger has the following fields:
|
||||||
>x,y,pressure:
|
* x,y,pressure:
|
||||||
The current coordinates of the touch.
|
The current coordinates of the touch.
|
||||||
>pressure:
|
* pressure:
|
||||||
The pressure of the touch.
|
The pressure of the touch.
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Notes
|
Notes
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
Loading…
Reference in New Issue