author | Ryan C. Gordon <icculus@icculus.org> |
Fri, 12 Jul 2013 23:32:54 -0400 | |
changeset 7424 | 1644ff584b17 |
parent 7423 | dfe7ad02f008 |
child 7425 | e918739b115e |
permissions | -rw-r--r-- |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
2 |
Simple DirectMedia Layer |
6885 | 3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
5262 | 4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
7 |
arising from the use of this software. |
5262 | 8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
11 |
freely, subject to the following restrictions: |
5262 | 12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
5262 | 20 |
*/ |
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
21 |
#include "SDL_config.h" |
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
22 |
|
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
23 |
#if SDL_VIDEO_DRIVER_UIKIT |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "SDL_uikitopengles.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
#include "SDL_uikitopenglview.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
#include "SDL_uikitappdelegate.h" |
6518
42948831d16e
Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
28 |
#include "SDL_uikitmodes.h" |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
#include "SDL_uikitwindow.h" |
6321
71fa3d8976a3
Fixed includes for Objective C
Sam Lantinga <slouken@libsdl.org>
parents:
6267
diff
changeset
|
30 |
#include "../SDL_sysvideo.h" |
4490
06c7423f8c60
Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents:
4488
diff
changeset
|
31 |
#include "../../events/SDL_keyboard_c.h" |
06c7423f8c60
Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents:
4488
diff
changeset
|
32 |
#include "../../events/SDL_mouse_c.h" |
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
33 |
#include "../../power/uikit/SDL_syspower.h" |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
#include "SDL_loadso.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
#include <dlfcn.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 |
static int UIKit_GL_Initialize(_THIS); |
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 |
void * |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
UIKit_GL_GetProcAddress(_THIS, const char *proc) |
6001
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
41 |
{ |
5131 | 42 |
/* Look through all SO's for the proc symbol. Here's why: |
43 |
-Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator. |
|
44 |
-We don't know that the path won't change in the future. |
|
45 |
*/ |
|
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
46 |
return dlsym(RTLD_DEFAULT, proc); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
/* |
5131 | 50 |
note that SDL_GL_Delete context makes it current without passing the window |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
*/ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
{ |
5131 | 54 |
if (context) { |
55 |
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; |
|
56 |
[data->view setCurrentContext]; |
|
57 |
} |
|
58 |
else { |
|
59 |
[EAGLContext setCurrentContext: nil]; |
|
60 |
} |
|
6001
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
61 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
int |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
UIKit_GL_LoadLibrary(_THIS, const char *path) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
{ |
6001
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
68 |
/* |
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
69 |
shouldn't be passing a path into this function |
5131 | 70 |
why? Because we've already loaded the library |
71 |
and because the SDK forbids loading an external SO |
|
72 |
*/ |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
if (path != NULL) { |
7037
3fedf1f25b94
Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
74 |
return SDL_SetError("iPhone GL Load Library just here for compatibility"); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
{ |
6088
eedb8e10ac22
Fix iOS build when SDL_POWER_UIKIT isn't defined.
Ryan C. Gordon <icculus@icculus.org>
parents:
6044
diff
changeset
|
81 |
#if SDL_POWER_UIKIT |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7190
diff
changeset
|
82 |
/* Check once a frame to see if we should turn off the battery monitor. */ |
4444
42e1092225f9
Implemented SDL power APIs for iPhoneOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
2859
diff
changeset
|
83 |
SDL_UIKit_UpdateBatteryMonitoring(); |
6003
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
84 |
#endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
|
5131 | 86 |
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; |
6001
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
87 |
|
5131 | 88 |
if (nil == data->view) { |
89 |
return; |
|
90 |
} |
|
91 |
[data->view swapBuffers]; |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
|
7190
11612d544fcd
Added mobile application events, with implementations for iOS and Android
Sam Lantinga <slouken@libsdl.org>
parents:
7037
diff
changeset
|
93 |
/* You need to pump events in order for the OS to make changes visible. |
11612d544fcd
Added mobile application events, with implementations for iOS and Android
Sam Lantinga <slouken@libsdl.org>
parents:
7037
diff
changeset
|
94 |
We don't pump events here because we don't want iOS application events |
11612d544fcd
Added mobile application events, with implementations for iOS and Android
Sam Lantinga <slouken@libsdl.org>
parents:
7037
diff
changeset
|
95 |
(low memory, terminate, etc.) to happen inside low level rendering. |
11612d544fcd
Added mobile application events, with implementations for iOS and Android
Sam Lantinga <slouken@libsdl.org>
parents:
7037
diff
changeset
|
96 |
*/ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
{ |
5131 | 101 |
SDL_uikitopenglview *view; |
102 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
|
6267
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
103 |
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); |
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
104 |
SDL_DisplayData *displaydata = display->driverdata; |
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
105 |
SDL_DisplayModeData *displaymodedata = display->current_mode.driverdata; |
5131 | 106 |
UIWindow *uiwindow = data->uiwindow; |
7423
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
107 |
EAGLSharegroup *share_group = nil; |
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
108 |
|
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
109 |
if (_this->gl_config.share_with_current_context) { |
7424 | 110 |
share_group = [((SDL_uikitopenglview *) SDL_GL_GetCurrentContext()) sharegroup]; |
7423
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
111 |
} |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
|
4446
8b03a20b320f
Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents:
4444
diff
changeset
|
113 |
/* construct our view, passing in SDL's OpenGL configuration data */ |
6439
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
114 |
CGRect frame; |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
115 |
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
116 |
frame = [displaydata->uiscreen bounds]; |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
117 |
} else { |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
118 |
frame = [displaydata->uiscreen applicationFrame]; |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
119 |
} |
fbbd640d7867
Fixed touch coordinates with the new UI bounds calculation
Sam Lantinga <slouken@libsdl.org>
parents:
6437
diff
changeset
|
120 |
view = [[SDL_uikitopenglview alloc] initWithFrame: frame |
6267
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
121 |
scale: displaymodedata->scale |
6003
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
122 |
retainBacking: _this->gl_config.retained_backing |
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
123 |
rBits: _this->gl_config.red_size |
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
124 |
gBits: _this->gl_config.green_size |
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
125 |
bBits: _this->gl_config.blue_size |
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
126 |
aBits: _this->gl_config.alpha_size |
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
127 |
depthBits: _this->gl_config.depth_size |
6021
a4bf2a9b0fd0
Added stencil buffer support on iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
6003
diff
changeset
|
128 |
stencilBits: _this->gl_config.stencil_size |
7423
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
129 |
majorVersion: _this->gl_config.major_version |
dfe7ad02f008
Implement SDL_GL_SHARE_WITH_CURRENT_CONTEXT for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
7285
diff
changeset
|
130 |
shareGroup: share_group]; |
6179
a83eb92704f3
Fixed bug 1342 - SDL_CreateRenderer creates OpenGL ES 2.0 renderer in iPhone 3G using default index (-1)
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
131 |
if (!view) { |
a83eb92704f3
Fixed bug 1342 - SDL_CreateRenderer creates OpenGL ES 2.0 renderer in iPhone 3G using default index (-1)
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
132 |
return NULL; |
a83eb92704f3
Fixed bug 1342 - SDL_CreateRenderer creates OpenGL ES 2.0 renderer in iPhone 3G using default index (-1)
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
133 |
} |
6001
3ae3d1e58d59
Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
5535
diff
changeset
|
134 |
|
5131 | 135 |
data->view = view; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
136 |
view->viewcontroller = data->viewcontroller; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
137 |
if (view->viewcontroller != nil) { |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
138 |
[view->viewcontroller setView:view]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
139 |
[view->viewcontroller retain]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
140 |
} |
6521
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
141 |
[uiwindow addSubview: view]; |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7190
diff
changeset
|
142 |
|
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7190
diff
changeset
|
143 |
/* The view controller needs to be the root in order to control rotation on iOS 6.0 */ |
6451
52e5a05ca795
Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
6439
diff
changeset
|
144 |
if (uiwindow.rootViewController == nil) { |
52e5a05ca795
Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
6439
diff
changeset
|
145 |
uiwindow.rootViewController = view->viewcontroller; |
52e5a05ca795
Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
6439
diff
changeset
|
146 |
} |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
147 |
|
6521
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
148 |
if (UIKit_GL_MakeCurrent(_this, window, view) < 0) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
UIKit_GL_DeleteContext(_this, view); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
return NULL; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
} |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
152 |
|
5131 | 153 |
/* Make this window the current mouse focus for touch input */ |
6267
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
154 |
if (displaydata->uiscreen == [UIScreen mainScreen]) { |
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
155 |
SDL_SetMouseFocus(window); |
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
156 |
SDL_SetKeyboardFocus(window); |
ed2cf4669e55
* On iOS, fix support for the case where [UIScreen scale] is not 1.0 (retina)
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
6179
diff
changeset
|
157 |
} |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4446
diff
changeset
|
158 |
|
5131 | 159 |
return view; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 |
void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
{ |
5131 | 164 |
/* the delegate has retained the view, this will release him */ |
165 |
SDL_uikitopenglview *view = (SDL_uikitopenglview *)context; |
|
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
166 |
if (view->viewcontroller) { |
6521
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
167 |
UIWindow *uiwindow = (UIWindow *)view.superview; |
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
168 |
if (uiwindow.rootViewController == view->viewcontroller) { |
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
169 |
uiwindow.rootViewController = nil; |
f36bbe0a10c9
Remove the viewcontroller from the window when he OpenGL context is destroyed
Sam Lantinga <slouken@libsdl.org>
parents:
6518
diff
changeset
|
170 |
} |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
171 |
[view->viewcontroller setView:nil]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
172 |
[view->viewcontroller release]; |
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
173 |
} |
5131 | 174 |
[view removeFromSuperview]; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5363
diff
changeset
|
175 |
[view release]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
178 |
#endif /* SDL_VIDEO_DRIVER_UIKIT */ |
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6021
diff
changeset
|
179 |
|
5132 | 180 |
/* vi: set ts=4 sw=4 expandtab: */ |