3 #if SILICONSTUDIO_PLATFORM_IOS
6 using MonoTouch.CoreAnimation;
7 using MonoTouch.Foundation;
8 using MonoTouch.ObjCRuntime;
10 using OpenTK.Graphics.ES20;
11 using OpenTK.Platform.iPhoneOS;
12 using SiliconStudio.Paradox.Games;
13 using SiliconStudio.Paradox.UI;
15 namespace SiliconStudio.
Paradox.Starter
27 protected UIWindow MainWindow {
get;
private set; }
29 public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
32 throw new InvalidOperationException(
"Please set 'Game' to a valid instance of Game before calling this method.");
34 var bounds = UIScreen.MainScreen.Bounds;
37 MainWindow =
new UIWindow(bounds);
40 var paradoxGameView =
new iOSParadoxView(bounds) {ContentScaleFactor = UIScreen.MainScreen.Scale};
43 var paradoxGameController =
new ParadoxGameController { View = paradoxGameView };
46 var gameContext =
new GameContext(MainWindow, paradoxGameView, paradoxGameController);
49 UIApplication.SharedApplication.SetStatusBarHidden(
true,
false);
52 var navigationController =
new UINavigationController {NavigationBarHidden =
true};
53 navigationController.PushViewController(gameContext.GameViewController,
false);
54 MainWindow.RootViewController = navigationController;
57 MainWindow.MakeKeyAndVisible();
60 Game.Run(gameContext);
62 return Game.IsRunning;
68 [Register(
"iOSParadoxView")]
69 internal class iOSParadoxView : iPhoneOSGameView, IAnimatedGameView
71 CADisplayLink displayLink;
72 private bool isRunning;
79 protected override void CreateFrameBuffer()
81 base.CreateFrameBuffer();
85 uint depthRenderBuffer;
86 GL.GenRenderbuffers(1, out depthRenderBuffer);
87 GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, depthRenderBuffer);
90 GL.RenderbufferStorage(All.Renderbuffer, All.Depth24Stencil8Oes, (int)(Size.Width * Layer.ContentsScale), (int)(Size.Height * Layer.ContentsScale));
93 GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferSlot.DepthAttachment, RenderbufferTarget.Renderbuffer, depthRenderBuffer);
94 GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferSlot.StencilAttachment, RenderbufferTarget.Renderbuffer, depthRenderBuffer);
98 public static Class LayerClass()
100 return GetLayerClass();
103 public void StartAnimating()
110 var displayLink = UIScreen.MainScreen.CreateDisplayLink(
this,
new Selector(
"drawFrame"));
111 displayLink.FrameInterval = 0;
112 displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
113 this.displayLink = displayLink;
118 public void StopAnimating()
123 displayLink.Invalidate();
126 DestroyFrameBuffer();
134 OnRenderFrame(
new OpenTK.FrameEventArgs());
SiliconStudio.Core.Mathematics.RectangleF RectangleF