mirror of https://github.com/encounter/SDL.git
Fixed doxygen warning and markdown formatting.
This commit is contained in:
parent
b33d2b7371
commit
53cf64b09d
|
@ -144,18 +144,19 @@ 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:
|
||||||
--- MyGame.java --------------------------
|
|
||||||
package com.gamemaker.game;
|
|
||||||
|
|
||||||
import org.libsdl.app.SDLActivity;
|
--- MyGame.java --------------------------
|
||||||
|
package com.gamemaker.game;
|
||||||
/*
|
|
||||||
* A sample wrapper class that just calls SDLActivity
|
import org.libsdl.app.SDLActivity;
|
||||||
*/
|
|
||||||
|
/*
|
||||||
public class MyGame extends SDLActivity { }
|
* A sample wrapper class that just calls SDLActivity
|
||||||
|
*/
|
||||||
------------------------------------------
|
|
||||||
|
public class MyGame extends SDLActivity { }
|
||||||
|
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||||
class, .e.g. "MyGame"
|
class, .e.g. "MyGame"
|
||||||
|
@ -320,15 +321,16 @@ 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.
|
||||||
|
|
||||||
For example, if your crash looks like this:
|
For example, if your crash looks like this:
|
||||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
|
||||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||||
|
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||||
|
|
||||||
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:
|
||||||
|
@ -364,11 +366,12 @@ export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x8
|
||||||
|
|
||||||
Once valgrind is built, you can create a wrapper script to launch your
|
Once valgrind is built, you can create a wrapper script to launch your
|
||||||
application with it, changing org.libsdl.app to your package identifier:
|
application with it, changing org.libsdl.app to your package identifier:
|
||||||
--- start_valgrind_app -------------------
|
|
||||||
#!/system/bin/sh
|
--- start_valgrind_app -------------------
|
||||||
export TMPDIR=/data/data/org.libsdl.app
|
#!/system/bin/sh
|
||||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
export TMPDIR=/data/data/org.libsdl.app
|
||||||
------------------------------------------
|
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -68,56 +68,56 @@ not give you any processing time after the events are delivered.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||||
{
|
|
||||||
switch (event->type)
|
|
||||||
{
|
{
|
||||||
case SDL_APP_TERMINATING:
|
switch (event->type)
|
||||||
/* Terminate the app.
|
{
|
||||||
Shut everything down before returning from this function.
|
case SDL_APP_TERMINATING:
|
||||||
*/
|
/* Terminate the app.
|
||||||
return 0;
|
Shut everything down before returning from this function.
|
||||||
case SDL_APP_LOWMEMORY:
|
*/
|
||||||
/* You will get this when your app is paused and iOS wants more memory.
|
return 0;
|
||||||
Release as much memory as possible.
|
case SDL_APP_LOWMEMORY:
|
||||||
*/
|
/* You will get this when your app is paused and iOS wants more memory.
|
||||||
return 0;
|
Release as much memory as possible.
|
||||||
case SDL_APP_WILLENTERBACKGROUND:
|
*/
|
||||||
/* Prepare your app to go into the background. Stop loops, etc.
|
return 0;
|
||||||
This gets called when the user hits the home button, or gets a call.
|
case SDL_APP_WILLENTERBACKGROUND:
|
||||||
*/
|
/* Prepare your app to go into the background. Stop loops, etc.
|
||||||
return 0;
|
This gets called when the user hits the home button, or gets a call.
|
||||||
case SDL_APP_DIDENTERBACKGROUND:
|
*/
|
||||||
/* This will get called if the user accepted whatever sent your app to the background.
|
return 0;
|
||||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
case SDL_APP_DIDENTERBACKGROUND:
|
||||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
/* This will get called if the user accepted whatever sent your app to the background.
|
||||||
Your app is NOT active at this point.
|
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||||
*/
|
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||||
return 0;
|
Your app is NOT active at this point.
|
||||||
case SDL_APP_WILLENTERFOREGROUND:
|
*/
|
||||||
/* This call happens when your app is coming back to the foreground.
|
return 0;
|
||||||
Restore all your state here.
|
case SDL_APP_WILLENTERFOREGROUND:
|
||||||
*/
|
/* This call happens when your app is coming back to the foreground.
|
||||||
return 0;
|
Restore all your state here.
|
||||||
case SDL_APP_DIDENTERFOREGROUND:
|
*/
|
||||||
/* Restart your loops here.
|
return 0;
|
||||||
Your app is interactive and getting CPU again.
|
case SDL_APP_DIDENTERFOREGROUND:
|
||||||
*/
|
/* Restart your loops here.
|
||||||
return 0;
|
Your app is interactive and getting CPU again.
|
||||||
default:
|
*/
|
||||||
/* No special processing, add it to the event queue */
|
return 0;
|
||||||
return 1;
|
default:
|
||||||
|
/* No special processing, add it to the event queue */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||||
|
|
||||||
|
... run your main loop
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
|
||||||
|
|
||||||
... run your main loop
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -198,28 +198,28 @@ This will set up the given function to be called back on the animation callback,
|
||||||
|
|
||||||
e.g.
|
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[])
|
||||||
{
|
{
|
||||||
... 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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue