Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
- index 42303e3..1a969e4 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
- @@ -111,13 +111,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
- share_group = [view.context sharegroup];
- }
- - /* construct our view, passing in SDL's OpenGL configuration data */
- - CGRect frame;
- - if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
- - frame = [displaydata->uiscreen bounds];
- - } else {
- - frame = [displaydata->uiscreen applicationFrame];
- - }
- + /* construct our view, passing in SDL's OpenGL configuration data
- + * In order to have the accurate size in real pixels,
- + * we need to take the scaling (retina display) into account.
- + */
- + CGRect frame = CGRectMake(0, 0,
- + window->w / displaymodedata->scale,
- + window->h / displaymodedata->scale);
- view = [[SDL_uikitopenglview alloc] initWithFrame: frame
- scale: displaymodedata->scale
- retainBacking: _this->gl_config.retained_backing
- @@ -136,10 +136,9 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
- data->view = view;
- view->viewcontroller = data->viewcontroller;
- if (view->viewcontroller != nil) {
- - [view->viewcontroller setView:view];
- + view->viewcontroller.screenView = view;
- [view->viewcontroller retain];
- }
- - [uiwindow addSubview: view];
- /* The view controller needs to be the root in order to control rotation on iOS 6.0 */
- if (uiwindow.rootViewController == nil) {
- @@ -165,7 +164,7 @@ void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
- /* the delegate has retained the view, this will release him */
- SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
- if (view->viewcontroller) {
- - UIWindow *uiwindow = (UIWindow *)view.superview;
- + UIWindow *uiwindow = (UIWindow *)view.window;
- if (uiwindow.rootViewController == view->viewcontroller) {
- uiwindow.rootViewController = nil;
- }
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
- index 5c163c9..1074d3e 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
- @@ -125,9 +125,6 @@
- glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
- /* end create buffers */
- -
- - self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
- - self.autoresizesSubviews = YES;
- }
- return self;
- }
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
- index e8d595d..0d06a57 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
- @@ -26,9 +26,11 @@
- @interface SDL_uikitviewcontroller : UIViewController {
- @private
- SDL_Window *window;
- + UIView *screenView;
- }
- @property (readwrite) SDL_Window *window;
- +@property (nonatomic,retain) UIView *screenView;
- - (id)initWithSDLWindow:(SDL_Window *)_window;
- - (void)loadView;
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- index 447b80b..0a151ee 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- @@ -37,6 +37,7 @@
- @implementation SDL_uikitviewcontroller
- @synthesize window;
- +@synthesize screenView;
- - (id)initWithSDLWindow:(SDL_Window *)_window
- {
- @@ -49,13 +50,44 @@
- return self;
- }
- +- (void)dealloc
- +{
- + self.screenView = nil;
- + [super dealloc];
- +}
- +
- - (void)loadView
- {
- - /* do nothing. */
- + self.view = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
- + self.view.backgroundColor = [UIColor blueColor];
- +}
- +
- +- (void)setScreenView:(UIView *)_screenView
- +{
- + if (screenView != nil) {
- + [screenView removeFromSuperview];
- + [screenView release];
- + }
- + screenView = [_screenView retain];
- + [self.view addSubview:screenView];
- + [self adjustScreenView];
- +}
- +
- +- (void)adjustScreenView
- +{
- + if (screenView == nil)
- + return;
- +
- + float scalex =self.view.frame.size.width/screenView.bounds.size.width;
- + float scaley = self.view.frame.size.height/screenView.bounds.size.height;
- +
- + screenView.transform = CGAffineTransformMakeScale(scalex, scaley);
- + screenView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
- }
- - (void)viewDidLayoutSubviews
- {
- + [self adjustScreenView];
- if (self->window->flags & SDL_WINDOW_RESIZABLE) {
- SDL_WindowData *data = self->window->driverdata;
- SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- index a1dd1a9..71ba74a 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- @@ -61,7 +61,8 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
- data->view = nil;
- /* Fill in the SDL window with the window data */
- - {
- + if (0) { /* Don't do this because we want to honor the window size
- + * request from apps */
- window->x = 0;
- window->y = 0;
- --
- 2.7.4
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
- index d5430be..80b176b 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
- @@ -22,8 +22,11 @@
- #import <UIKit/UIKit.h>
- @interface SDLUIKitDelegate : NSObject<UIApplicationDelegate> {
- + UIWindow *window;
- }
- +@property (nonatomic, retain) UIWindow *window;
- +
- + (id) sharedAppDelegate;
- + (NSString *)getAppDelegateClassName;
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
- index a9924fb..8f9b858 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
- @@ -161,6 +161,7 @@ SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldVa
- @implementation SDLUIKitDelegate
- +@synthesize window;
- /* convenience method */
- + (id) sharedAppDelegate
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
- index f890b7a..f5d2f7a 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
- @@ -411,6 +411,7 @@ void _uikit_keyboard_set_height(int height) {
- }
- void _uikit_keyboard_init() {
- +#if 0
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- NSOperationQueue *queue = [NSOperationQueue mainQueue];
- [center addObserverForName:UIKeyboardWillShowNotification
- @@ -437,6 +438,7 @@ void _uikit_keyboard_init() {
- _uikit_keyboard_set_height(0);
- }
- ];
- +#endif
- }
- void
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- index 71ba74a..5c65463 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
- @@ -196,7 +196,8 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
- /* !!! FIXME: can we have a smaller view? */
- UIWindow *uiwindow = [UIWindow alloc];
- uiwindow = [uiwindow initWithFrame:[data->uiscreen bounds]];
- -
- + [[[UIApplication sharedApplication] delegate] setWindow:uiwindow];
- +
- /* put the window on an external display if appropriate. This implicitly
- * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
- * main display, where we land by default, as that would eat the
- diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- index 0a151ee..5755032 100644
- --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
- @@ -78,11 +78,12 @@
- if (screenView == nil)
- return;
- - float scalex =self.view.frame.size.width/screenView.bounds.size.width;
- - float scaley = self.view.frame.size.height/screenView.bounds.size.height;
- -
- + float availWidth = self.view.bounds.size.width;
- + float availHeight = self.view.bounds.size.height;
- + float scalex = availWidth/screenView.bounds.size.width;
- + float scaley = availHeight/screenView.bounds.size.height;
- screenView.transform = CGAffineTransformMakeScale(scalex, scaley);
- - screenView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
- + screenView.center = CGPointMake(availWidth/2, availHeight/2);
- }
- - (void)viewDidLayoutSubviews
- --
- 2.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement