README.iOS
changeset 8314 24f2de48557b
parent 8311 40f2e97c4051
parent 6589 46d985073364
child 8340 e470405f3ae9
     1.1 --- a/README.iOS	Sat Sep 01 09:17:34 2012 -0400
     1.2 +++ b/README.iOS	Mon Oct 15 21:14:13 2012 -0400
     1.3 @@ -115,17 +115,48 @@
     1.4  ==============================================================================
     1.5  
     1.6  Windows:
     1.7 -	Full-size, single window applications only.  You cannot create multi-window SDL applications for iPhone OS.  The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow the flag SDL_WINDOW_BORDERLESS).  Presently, landscape mode is not supported.
     1.8 -
     1.9 -Video:
    1.10 -	For real time frame-rates, you are advised to use strictly SDL 2.0 video calls.  Using compatibility video calls uploads an OpenGL texture for each frame drawn, and this operation is excruciatingly slow.
    1.11 +	Full-size, single window applications only.  You cannot create multi-window SDL applications for iPhone OS.  The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow the flag SDL_WINDOW_BORDERLESS).
    1.12  
    1.13  Textures:
    1.14 -	SDL for iPhone Textures supports only SDL_PIXELFORMAT_ABGR8888 and SDL_PIXELFORMAT_RGB24 pixel formats.  This is because texture support in SDL for iPhone is done through OpenGL ES, which supports fewer pixel formats than OpenGL, will not re-order pixel data for you, and has no support for color-paletted formats (without extensions).
    1.15 -
    1.16 -Audio:
    1.17 -	SDL for iPhone does not yet support audio input.
    1.18 +	The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
    1.19  
    1.20  Loading Shared Objects:
    1.21  	This is disabled by default since it seems to break the terms of the iPhone SDK agreement.  It can be re-enabled in SDL_config_iphoneos.h.
    1.22  
    1.23 +==============================================================================
    1.24 +Game Center 
    1.25 +==============================================================================
    1.26 +
    1.27 +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:
    1.28 +    
    1.29 +int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
    1.30 +
    1.31 +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.
    1.32 +
    1.33 +e.g.
    1.34 +
    1.35 +extern "C"
    1.36 +void ShowFrame(void*)
    1.37 +{
    1.38 +    ... do event handling, frame logic and rendering
    1.39 +}
    1.40 +
    1.41 +int main(int argc, char *argv[])
    1.42 +{
    1.43 +   ... initialize game ...
    1.44 +
    1.45 +#if __IPHONEOS__
    1.46 +        // Initialize the Game Center for scoring and matchmaking
    1.47 +        InitGameCenter();
    1.48 +
    1.49 +        // Set up the game to run in the window animation callback on iOS
    1.50 +        // so that Game Center and so forth works correctly.
    1.51 +        SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
    1.52 +#else
    1.53 +        while ( running ) {
    1.54 +                ShowFrame(0);
    1.55 +                DelayFrame();
    1.56 +        }
    1.57 +#endif
    1.58 +        return 0;
    1.59 +}