author | Sam Lantinga <slouken@libsdl.org> |
Mon, 28 Mar 2011 20:56:28 -0700 | |
changeset 5523 | 6dc03727fadc |
parent 5520 | 09b500e0656d |
child 5527 | 9a03d2300486 |
permissions | -rw-r--r-- |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 |
SDL - Simple DirectMedia Layer |
5262 | 3 |
Copyright (C) 1997-2011 Sam Lantinga |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
This library is free software; you can redistribute it and/or |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 |
modify it under the terms of the GNU Lesser General Public |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
License as published by the Free Software Foundation; either |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
version 2.1 of the License, or (at your option) any later version. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 |
This library is distributed in the hope that it will be useful, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 |
Lesser General Public License for more details. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
You should have received a copy of the GNU Lesser General Public |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
License along with this library; if not, write to the Free Software |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
Sam Lantinga |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
slouken@libsdl.org |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
*/ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
#include "SDL_config.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
|
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
24 |
#include "SDL_syswm.h" |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "SDL_video.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
#include "SDL_mouse.h" |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
27 |
#include "SDL_assert.h" |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
#include "../SDL_sysvideo.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
#include "../SDL_pixels_c.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
#include "../../events/SDL_events_c.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
#include "SDL_uikitvideo.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
#include "SDL_uikitevents.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
#include "SDL_uikitwindow.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
#import "SDL_uikitappdelegate.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
#import "SDL_uikitopenglview.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
#include <Foundation/Foundation.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
|
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
41 |
@implementation SDL_uikitviewcontroller |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
42 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
43 |
- (id)initWithSDLWindow:(SDL_Window *)_window { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
44 |
[self init]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
45 |
self->window = _window; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
46 |
return self; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
47 |
} |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
48 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
49 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
50 |
return YES; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
51 |
} |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
52 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
53 |
- (void)loadView { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
54 |
// do nothing. |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
55 |
} |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
56 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
57 |
// Send a resized event when the orientation changes. |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
58 |
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
59 |
SDL_WindowData *data = self->window->driverdata; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
60 |
UIWindow *uiwindow = data->uiwindow; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
61 |
CGRect frame = [uiwindow frame]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
62 |
const CGSize size = frame.size; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
63 |
int w, h; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
64 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
65 |
switch (toInterfaceOrientation) { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
66 |
case UIInterfaceOrientationPortrait: |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
67 |
case UIInterfaceOrientationPortraitUpsideDown: |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
68 |
w = (size.width < size.height) ? size.width : size.height; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
69 |
h = (size.width > size.height) ? size.width : size.height; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
70 |
break; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
71 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
72 |
case UIInterfaceOrientationLandscapeLeft: |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
73 |
case UIInterfaceOrientationLandscapeRight: |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
74 |
w = (size.width > size.height) ? size.width : size.height; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
75 |
h = (size.width < size.height) ? size.width : size.height; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
76 |
break; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
77 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
78 |
default: |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
79 |
SDL_assert(0 && "Unexpected interface orientation!"); |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
80 |
return; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
81 |
} |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
82 |
frame.size.width = w; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
83 |
frame.size.height = h; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
84 |
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
85 |
} |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
86 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
87 |
@end |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
88 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
89 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
90 |
|
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
91 |
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
92 |
{ |
5246
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
93 |
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
94 |
UIScreen *uiscreen = (UIScreen *) display->driverdata; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
SDL_WindowData *data; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
96 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
/* Allocate the window data */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
data = (SDL_WindowData *)SDL_malloc(sizeof(*data)); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
if (!data) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
SDL_OutOfMemory(); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
data->uiwindow = uiwindow; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
104 |
data->viewcontroller = nil; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
105 |
data->view = nil; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
106 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
/* Fill in the SDL window with the window data */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
108 |
{ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
window->x = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
window->y = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
window->w = (int)uiwindow.frame.size.width; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
window->h = (int)uiwindow.frame.size.height; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
} |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
114 |
|
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
115 |
window->driverdata = data; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
116 |
|
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
117 |
// !!! FIXME: should we force this? Shouldn't specifying FULLSCREEN |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
118 |
// !!! FIXME: imply BORDERLESS? |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
119 |
window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
120 |
window->flags |= SDL_WINDOW_SHOWN; /* only one window on iOS, always shown */ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
|
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
122 |
// SDL_WINDOW_BORDERLESS controls whether status bar is hidden. |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
123 |
// This is only set if the window is on the main screen. Other screens |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
124 |
// just force the window to have the borderless flag. |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
125 |
if ([UIScreen mainScreen] != uiscreen) { |
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
126 |
window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable |
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
127 |
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
128 |
window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar. |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
129 |
} else { |
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
130 |
window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus |
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
131 |
|
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
132 |
if (window->flags & SDL_WINDOW_BORDERLESS) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
133 |
[UIApplication sharedApplication].statusBarHidden = YES; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
134 |
} else { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
135 |
[UIApplication sharedApplication].statusBarHidden = NO; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
136 |
} |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
137 |
|
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
138 |
const CGSize uisize = [[uiscreen currentMode] size]; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
139 |
const UIDeviceOrientation o = [[UIDevice currentDevice] orientation]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
140 |
const BOOL landscape = (o == UIDeviceOrientationLandscapeLeft) || |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
141 |
(o == UIDeviceOrientationLandscapeRight); |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
142 |
const BOOL rotate = ( ((window->w > window->h) && (!landscape)) || |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
143 |
((window->w < window->h) && (landscape)) ); |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
144 |
|
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
145 |
if (window->flags & SDL_WINDOW_RESIZABLE) { |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
146 |
// The View Controller will handle rotating the view when the |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
147 |
// device orientation changes. We expose these as resize events. |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
148 |
SDL_uikitviewcontroller *controller; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
149 |
controller = [SDL_uikitviewcontroller alloc]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
150 |
data->viewcontroller = [controller initWithSDLWindow:window]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
151 |
[data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle() |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
152 |
// !!! FIXME: if (rotate), force a "resize" right at the start |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
153 |
} else { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
154 |
// Rotate the view if we have to, but only on the main screen |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
155 |
// (presumably, an external display doesn't report orientation). |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
156 |
if (rotate) { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
157 |
#define D2R(x) (M_PI * (x) / 180.0) // degrees to radians. |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
158 |
[uiwindow setTransform:CGAffineTransformIdentity]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
159 |
[uiwindow setTransform:CGAffineTransformMakeRotation(D2R(90))]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
160 |
#undef D2R |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
161 |
} |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
162 |
} |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
163 |
} |
5518
f84dd424d514
iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
164 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
|
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
168 |
int |
5246
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
169 |
UIKit_CreateWindow(_THIS, SDL_Window *window) |
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
170 |
{ |
58265e606e4e
Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
171 |
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
172 |
UIScreen *uiscreen = (UIScreen *) display->driverdata; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
173 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
174 |
// SDL currently puts this window at the start of display's linked list. We rely on this. |
5251 | 175 |
SDL_assert(_this->windows == window); |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
176 |
|
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
177 |
/* We currently only handle a single window per display on iOS */ |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
178 |
if (window->next != NULL) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
179 |
SDL_SetError("Only one window allowed per display."); |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
180 |
return -1; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
181 |
} |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
182 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
183 |
// Non-mainscreen windows must be force to borderless, as there's no |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
184 |
// status bar there, and we want to get the right dimensions later in |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
185 |
// this function. |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
186 |
if ([UIScreen mainScreen] != uiscreen) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
187 |
window->flags |= SDL_WINDOW_BORDERLESS; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
188 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
189 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
190 |
// If monitor has a resolution of 0x0 (hasn't been explicitly set by the |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
191 |
// user, so it's in standby), try to force the display to a resolution |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
192 |
// that most closely matches the desired window size. |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
193 |
if (SDL_UIKit_supports_multiple_displays) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
194 |
const CGSize origsize = [[uiscreen currentMode] size]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
195 |
if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
196 |
if (display->num_display_modes == 0) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
197 |
_this->GetDisplayModes(_this, display); |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
198 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
199 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
200 |
int i; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
201 |
const SDL_DisplayMode *bestmode = NULL; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
202 |
for (i = display->num_display_modes; i >= 0; i--) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
203 |
const SDL_DisplayMode *mode = &display->display_modes[i]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
204 |
if ((mode->w >= window->w) && (mode->h >= window->h)) |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
205 |
bestmode = mode; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
206 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
207 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
208 |
if (bestmode) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
209 |
UIScreenMode *uimode = (UIScreenMode *) bestmode->driverdata; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
210 |
[uiscreen setCurrentMode:uimode]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
211 |
display->desktop_mode = *bestmode; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
212 |
display->current_mode = *bestmode; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
213 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
214 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
215 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
216 |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
217 |
/* ignore the size user requested, and make a fullscreen window */ |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
218 |
// !!! FIXME: can we have a smaller view? |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
219 |
UIWindow *uiwindow = [UIWindow alloc]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
220 |
if (window->flags & SDL_WINDOW_BORDERLESS) |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
221 |
uiwindow = [uiwindow initWithFrame:[uiscreen bounds]]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
222 |
else |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
223 |
uiwindow = [uiwindow initWithFrame:[uiscreen applicationFrame]]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
224 |
|
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
225 |
if (SDL_UIKit_supports_multiple_displays) { |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
226 |
[uiwindow setScreen:uiscreen]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
227 |
} |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
228 |
|
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
229 |
if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
[uiwindow release]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
return -1; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
232 |
} |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
233 |
|
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
234 |
return 1; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
235 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
|
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
238 |
void |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
239 |
UIKit_DestroyWindow(_THIS, SDL_Window * window) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
240 |
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
241 |
if (data) { |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5518
diff
changeset
|
242 |
[data->viewcontroller release]; |
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
243 |
[data->uiwindow release]; |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
244 |
SDL_free(data); |
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
3685
diff
changeset
|
245 |
window->driverdata = NULL; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3400
diff
changeset
|
246 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
|
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
249 |
SDL_bool |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
250 |
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
251 |
{ |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
252 |
UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
253 |
|
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
254 |
if (info->version.major <= SDL_MAJOR_VERSION) { |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
255 |
info->subsystem = SDL_SYSWM_UIKIT; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
256 |
info->info.uikit.window = uiwindow; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
257 |
return SDL_TRUE; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
258 |
} else { |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
259 |
SDL_SetError("Application not compiled with SDL %d.%d\n", |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
260 |
SDL_MAJOR_VERSION, SDL_MINOR_VERSION); |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
261 |
return SDL_FALSE; |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
262 |
} |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
263 |
} |
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
264 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
/* vi: set ts=4 sw=4 expandtab: */ |