4 ==============================================================================
5 Building the Simple DirectMedia Layer
for iOS 5.1+
6 ==============================================================================
8 Requirements: Mac OS X 10.8 or later and the iOS 7+ SDK.
12 2. Open SDL.xcodeproj (located
in Xcode-iOS/SDL)
in Xcode.
13 4. Select your desired
target, and hit build.
15 There are three build targets:
17 Build SDL as
a statically linked library
19 Build
a test
program (there are known test failures which are fine)
21 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.
24 ==============================================================================
25 Build SDL
for iOS from the command line
26 ==============================================================================
28 1. Follow step 1 above.
29 2. cd (PATH WHERE THE SDL CODE IS)/build-scripts
32 If everything goes fine, you should see
a build/ios directory, inside there
's
33 two directories "lib" and "include".
34 "include" contains a copy of the SDL headers that you'll need
for your project,
35 make sure to configure XCode to look
for headers there.
36 "lib" contains find
two files, libSDL2.a and libSDL2main.a, you have to add both
37 to your XCode project. These libraries contain three architectures
in them,
38 armv6
for legacy
devices, armv7, and i386 (
for the simulator).
39 By
default, iosbuild.sh will autodetect the SDK version you have installed
using
40 xcodebuild -showsdks, and build
for iOS >= 3.0, you can
override this behaviour
43 MIN_OS_VERSION=4.2 ./iosbuild.sh
45 ==============================================================================
46 Using the Simple DirectMedia Layer
for iOS
47 ==============================================================================
49 FIXME: This needs to be updated
for the latest methods
51 Here is the easiest method:
52 1. Build the SDL library (libSDL2.a) and the iPhone SDL Application template.
53 2. Install the iPhone SDL Application template
by copying it to
one of Xcode'
s template directories.
I recommend creating
a directory called "SDL"
in "/Developer/Platforms/iOS.platform/Developer/Library/Xcode/Project Templates/" and placing it there.
54 3. Start
a new project using the template. The project should be immediately ready for use with SDL.
56 Here is
a more manual method:
57 1. Create
a new iOS view based application.
58 2. Build the SDL static library (libSDL2.
a) for iOS and include them
in your project. Xcode will ignore the library that is not currently of the correct architecture, hence your app will work both on iOS and
in the iOS Simulator.
59 3. Include the SDL header files
in your project.
60 4. Remove the ApplicationDelegate.
h and ApplicationDelegate.
m files -- SDL for iOS provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically.
61 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.
63 ==============================================================================
65 ==============================================================================
69 created on an iPhone 6 will have
a size in screen coordinates of 375
x 667,
70 rather than
a size in pixels of 750 x 1334. All iOS apps are expected to
72 as this allows different iOS devices to have different pixel densities
73 (Retina versus non-Retina screens, etc.) without apps caring too much.
75 By default SDL will not use the full pixel density of the
screen on
80 will still be
in "
screen coordinates" rather than pixels, but the
window will
81 have
a much greater pixel density when the
device supports it, and the
83 whether raw OpenGL or the SDL_Render API is used) can be queried to determine
87 sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
90 no matter whether
a Retina
device is used or not.
92 ==============================================================================
93 Notes -- Application
events
94 ==============================================================================
96 On iOS the application goes through
a fixed life cycle and you will
get
99 not give you any processing
time after the
events are delivered.
145 int main(
int argc,
char *argv[])
155 ==============================================================================
156 Notes -- Accelerometer as Joystick
157 ==============================================================================
159 SDL
for iPhone supports polling the built
in accelerometer as
a joystick
device. For an example on how to
do this, see the accelerometer.c
in the demos directory.
163 ==============================================================================
165 ==============================================================================
167 Your SDL application for iOS uses OpenGL ES for video
by default.
169 OpenGL ES for iOS supports several display pixel
formats, such as RGBA8 and RGB565, which provide
a 32 bit and 16 bit
color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8
by setting each
color component to 8
bits in SDL_GL_SetAttribute().
175 OpenGL ES on iOS doesn'
t use the traditional system-
framebuffer setup provided
in other operating systems. Special care must be taken because of this:
178 - The drawable Framebuffer Object must be bound while rendering to the
screen and when
SDL_GL_SwapWindow() is called.
183 ==============================================================================
185 ==============================================================================
187 The SDL keyboard API has been extended to support on-screen keyboards:
190 -- enables
text events and reveals the onscreen keyboard.
193 -- disables
text events and hides the onscreen keyboard.
196 -- returns whether or not
text events are enabled (and the onscreen keyboard is visible)
199 ==============================================================================
200 Notes -- Reading and Writing files
201 ==============================================================================
203 Each application installed on iPhone resides
in a sandbox which includes its own Application Home directory. Your application may not
access files outside this directory.
205 Once your application is installed its directory tree looks like:
214 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".
216 More information on this subject is
available here:
219 ==============================================================================
220 Notes -- iPhone SDL limitations
221 ==============================================================================
229 Loading Shared Objects:
230 This is disabled
by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled
in SDL_config_iphoneos.
h.
232 ==============================================================================
234 ==============================================================================
236 Game Center integration might require 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:
240 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.
245 void ShowFrame(
void*)
247 ...
do event handling, frame logic and rendering ...
250 int main(
int argc,
char *argv[])
252 ... initialize game ...
270 ==============================================================================
271 Deploying to older versions of iOS
272 ==============================================================================
274 SDL supports deploying to older versions of iOS than are supported
by the latest version of Xcode, all the way back to iOS 6.1
276 In
order to
do that you need to download an older version of Xcode:
279 Open the
package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
281 Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
283 Open your project and set your deployment target to the desired version of iOS
285 Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
GLenum GLenum GLenum GLenum GLenum scale
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
EGLSetBlobFuncANDROID EGLGetBlobFuncANDROID get
EGLSurface EGLnsecsANDROID time
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
GLint GLint GLint GLint GLint x
GLfloat GLfloat GLfloat GLfloat h
static SDL_Event events[EVENT_BUF_SIZE]
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLfixed GLfixed GLint GLint order
GLuint GLint GLboolean GLint GLenum access
GLfixed GLfixed GLint GLint GLfixed points
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLsizei const GLuint *values GLsizei const GLuint const GLclampf *priorities GLfloat GLfloat GLfloat GLfloat w glReadPixels
static SDL_AudioDeviceID device
#define SDL_GL_SetAttribute
#define SDL_GetWindowSize
GLenum GLsizei GLsizei GLint * values
#define SDL_GL_GetDrawableSize
GLenum GLenum GLuint texture
#define SDL_StopTextInput
EGLImageKHR EGLint EGLint * handle
EGLSetBlobFuncANDROID set
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
static Uint32 callback(Uint32 interval, void *param)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
#define SDL_StartTextInput
#define GL_READ_FRAMEBUFFER
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define SDL_GetWindowWMInfo
#define SDL_IPHONE_MAX_GFORCE
GLint GLint GLsizei GLsizei GLsizei depth
#define SDL_JoystickGetAxis
static char text[MAX_TEXT_LENGTH]
EGLSurface EGLNativeWindowType * window
#define SDL_GetRendererOutputSize
#define SDL_SetEventFilter
The type used to identify a window.
GLbitfield GLuint program
EGLSurface EGLint attribute
GLboolean GLboolean GLboolean GLboolean a
#define SDL_IsTextInputActive
#define SDL_GL_SwapWindow
#define SDL_iPhoneSetAnimationCallback