diff --git a/gfx/context/ioseagl_ctx.m b/gfx/context/ioseagl_ctx.c similarity index 75% rename from gfx/context/ioseagl_ctx.m rename to gfx/context/ioseagl_ctx.c index b82a4ac19f..a445113f24 100644 --- a/gfx/context/ioseagl_ctx.m +++ b/gfx/context/ioseagl_ctx.c @@ -26,42 +26,6 @@ #include "../shader_glsl.h" #endif -#import "../../ios/RetroArch/ViewController.h" - -static GLKView *gl_view; -static float screen_scale; - -// Objective-C interface used to interact with the GLES context and display. -@interface ViewController () - -@property (strong, nonatomic) EAGLContext *context; -@property (strong, nonatomic) GLKView *view; - -@end - -@implementation ViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - self.view = [[GLKView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) context:self.context]; - - [EAGLContext setCurrentContext:self.context]; - - gl_view = self.view; - screen_scale = [[UIScreen mainScreen] scale]; -} - -- (void)dealloc -{ - if ([EAGLContext currentContext] == self.context) [EAGLContext setCurrentContext:nil]; -} - -@end - - // C interface static void gfx_ctx_set_swap_interval(unsigned interval) { @@ -75,8 +39,8 @@ static void gfx_ctx_destroy(void) static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) { - *width = gl_view.bounds.size.width * screen_scale; - *height = gl_view.bounds.size.height * screen_scale; + extern void get_game_view_size(unsigned *, unsigned *); + get_game_view_size(width, height); } static bool gfx_ctx_init(void) @@ -86,8 +50,8 @@ static bool gfx_ctx_init(void) static void gfx_ctx_swap_buffers(void) { - [gl_view setNeedsDisplay]; - [gl_view bindDrawable]; + extern void flip_game_view(); + flip_game_view(); } static void gfx_ctx_check_window(bool *quit, diff --git a/ios/RetroArch.xcodeproj/project.pbxproj b/ios/RetroArch.xcodeproj/project.pbxproj index b5c4f94bcc..fd4c42e748 100644 --- a/ios/RetroArch.xcodeproj/project.pbxproj +++ b/ios/RetroArch.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 9629797716C3CD2400E6DCE0 /* dirlist.m in Sources */ = {isa = PBXBuildFile; fileRef = 9629797616C3CD2400E6DCE0 /* dirlist.m */; }; + 962979ED16C3E86F00E6DCE0 /* gameview.m in Sources */ = {isa = PBXBuildFile; fileRef = 962979EB16C3E86F00E6DCE0 /* gameview.m */; }; + 962979EF16C3EA3E00E6DCE0 /* ioseagl_ctx.c in Sources */ = {isa = PBXBuildFile; fileRef = 962979EE16C3EA3E00E6DCE0 /* ioseagl_ctx.c */; }; 968A572A16C2A06800BE12F8 /* test.img in Resources */ = {isa = PBXBuildFile; fileRef = 968A572816C2A06800BE12F8 /* test.img */; }; 96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; }; 96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; }; @@ -70,7 +72,6 @@ 96AFAFAD16C1EEE9009DE44C /* sinc.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAEF716C1DC73009DE44C /* sinc.c */; }; 96AFAFD416C1FBC0009DE44C /* input_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFC916C1FBC0009DE44C /* input_common.c */; }; 96AFAFD716C1FBC0009DE44C /* null.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCD16C1FBC0009DE44C /* null.c */; }; - 96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */; }; 96CF014F16C2BB9E00ABF9C9 /* libretro.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 96CF014A16C2BA1900ABF9C9 /* libretro.dylib */; }; 96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCE16C1FBC0009DE44C /* overlay.c */; }; 96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 96CF015B16C2F72900ABF9C9 /* ios_input.c */; }; @@ -79,6 +80,9 @@ /* Begin PBXFileReference section */ 9629797516C3CD2400E6DCE0 /* dirlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dirlist.h; sourceTree = ""; }; 9629797616C3CD2400E6DCE0 /* dirlist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = dirlist.m; sourceTree = ""; }; + 962979EB16C3E86F00E6DCE0 /* gameview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = gameview.m; sourceTree = ""; }; + 962979EC16C3E86F00E6DCE0 /* gameview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gameview.h; sourceTree = ""; }; + 962979EE16C3EA3E00E6DCE0 /* ioseagl_ctx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ioseagl_ctx.c; sourceTree = ""; }; 968A572816C2A06800BE12F8 /* test.img */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.img; sourceTree = ""; }; 96AFAE2516C1D4EA009DE44C /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96AFAE2916C1D4EA009DE44C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -95,7 +99,6 @@ 96AFAE3F16C1D4EA009DE44C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 96AFAE4116C1D4EA009DE44C /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 96AFAE4316C1D4EA009DE44C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; - 96AFAE4916C1D4EA009DE44C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 96AFAE4D16C1D4EA009DE44C /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; 96AFAE5016C1D4EA009DE44C /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; 96AFAE9D16C1D9A9009DE44C /* autosave.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = autosave.c; path = ../autosave.c; sourceTree = ""; }; @@ -265,7 +268,6 @@ 96AFAFD016C1FBC0009DE44C /* sdl_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_input.c; sourceTree = ""; }; 96AFAFD116C1FBC0009DE44C /* sdl_joypad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_joypad.c; sourceTree = ""; }; 96AFAFD216C1FBC0009DE44C /* x11_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = x11_input.c; sourceTree = ""; }; - 96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ioseagl_ctx.m; sourceTree = ""; }; 96CF014A16C2BA1900ABF9C9 /* libretro.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libretro.dylib; sourceTree = ""; }; 96CF015B16C2F72900ABF9C9 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = ""; }; /* End PBXFileReference section */ @@ -325,9 +327,10 @@ 96AFAE3316C1D4EA009DE44C /* RetroArch */ = { isa = PBXGroup; children = ( + 962979EB16C3E86F00E6DCE0 /* gameview.m */, + 962979EC16C3E86F00E6DCE0 /* gameview.h */, 96AFAE3C16C1D4EA009DE44C /* AppDelegate.h */, 96AFAE3D16C1D4EA009DE44C /* AppDelegate.m */, - 96AFAE4916C1D4EA009DE44C /* ViewController.h */, 96AFAE4C16C1D4EA009DE44C /* ViewController_iPhone.xib */, 96AFAE4F16C1D4EA009DE44C /* ViewController_iPad.xib */, 96AFAE3416C1D4EA009DE44C /* Supporting Files */, @@ -543,7 +546,7 @@ 96AFAF3216C1E00A009DE44C /* context */ = { isa = PBXGroup; children = ( - 96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */, + 962979EE16C3EA3E00E6DCE0 /* ioseagl_ctx.c */, 96AFAF3316C1E00A009DE44C /* androidegl_ctx.c */, 96AFAF3416C1E00A009DE44C /* drm_egl_ctx.c */, 96AFAF3516C1E00A009DE44C /* glx_ctx.c */, @@ -775,10 +778,11 @@ 96AFAFAD16C1EEE9009DE44C /* sinc.c in Sources */, 96AFAFD416C1FBC0009DE44C /* input_common.c in Sources */, 96AFAFD716C1FBC0009DE44C /* null.c in Sources */, - 96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */, 96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */, 96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */, 9629797716C3CD2400E6DCE0 /* dirlist.m in Sources */, + 962979ED16C3E86F00E6DCE0 /* gameview.m in Sources */, + 962979EF16C3EA3E00E6DCE0 /* ioseagl_ctx.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/RetroArch/AppDelegate.h b/ios/RetroArch/AppDelegate.h index afcb44d684..2f02605b45 100644 --- a/ios/RetroArch/AppDelegate.h +++ b/ios/RetroArch/AppDelegate.h @@ -13,6 +13,6 @@ @property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) ViewController *viewController; +@property (strong, nonatomic) UIViewController *viewController; @end diff --git a/ios/RetroArch/AppDelegate.m b/ios/RetroArch/AppDelegate.m index c1604507bb..e75697e695 100644 --- a/ios/RetroArch/AppDelegate.m +++ b/ios/RetroArch/AppDelegate.m @@ -7,7 +7,7 @@ #import "AppDelegate.h" -#import "ViewController.h" +#import "gameview.h" #include "general.h" @@ -101,9 +101,9 @@ extern int16_t IOS_full_x, IOS_full_y; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) - self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; + self.viewController = [[game_view alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; else - self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; + self.viewController = [[game_view alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; diff --git a/ios/RetroArch/ViewController.h b/ios/RetroArch/gameview.h similarity index 77% rename from ios/RetroArch/ViewController.h rename to ios/RetroArch/gameview.h index 77f2dfafb3..5b82589110 100644 --- a/ios/RetroArch/ViewController.h +++ b/ios/RetroArch/gameview.h @@ -8,6 +8,6 @@ #import #import -@interface ViewController : UIViewController +@interface game_view : UIViewController @end diff --git a/ios/RetroArch/gameview.m b/ios/RetroArch/gameview.m new file mode 100644 index 0000000000..5fdf82d3f7 --- /dev/null +++ b/ios/RetroArch/gameview.m @@ -0,0 +1,61 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#import "gameview.h" + +static GLKView *gl_view; +static float screen_scale; + +@interface game_view () + +@property (strong, nonatomic) EAGLContext *context; +@property (strong, nonatomic) GLKView *view; + +@end + +@implementation game_view + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + self.view = [[GLKView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) context:self.context]; + + [EAGLContext setCurrentContext:self.context]; + + gl_view = self.view; + screen_scale = [[UIScreen mainScreen] scale]; +} + +- (void)dealloc +{ + if ([EAGLContext currentContext] == self.context) [EAGLContext setCurrentContext:nil]; +} + +@end + +void flip_game_view() +{ + [gl_view setNeedsDisplay]; + [gl_view bindDrawable]; +} + +void get_game_view_size(unsigned *width, unsigned *height) +{ + *width = gl_view.bounds.size.width * screen_scale; + *height = gl_view.bounds.size.height * screen_scale; +}