3 #if SILICONSTUDIO_PLATFORM_IOS
5 using System.Diagnostics;
7 using OpenTK.Platform.iPhoneOS;
8 using SiliconStudio.Paradox.Graphics;
11 namespace SiliconStudio.
Paradox.Games
16 internal class GameWindowiOS : GameWindow
18 private bool hasBeenInitialized;
19 private iPhoneOSGameView gameForm;
20 private WindowHandle nativeWindow;
30 public override void BeginScreenDeviceChange(
bool willBeFullScreen)
35 public override void EndScreenDeviceChange(
int clientWidth,
int clientHeight)
40 protected internal override void SetSupportedOrientations(
DisplayOrientation orientations)
45 internal override bool CanHandle(GameContext gameContext)
47 return gameContext.ContextType == AppContextType.iOS;
50 internal override void Initialize(GameContext gameContext)
52 GameContext = gameContext;
54 gameForm = gameContext.GameView;
57 gameForm.Load += gameForm_Load;
58 gameForm.Unload += gameForm_Unload;
59 gameForm.RenderFrame += gameForm_RenderFrame;
61 gameForm.ContextRenderingApi = MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2;
62 gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
66 var width = gameContext.RequestedWidth;
69 width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
72 var height = gameContext.RequestedHeight;
75 height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
78 gameForm.Size =
new Size(width, height);
83 void gameForm_Load(
object sender,
EventArgs e)
85 hasBeenInitialized =
false;
88 void gameForm_Unload(
object sender,
EventArgs e)
90 if (hasBeenInitialized)
93 hasBeenInitialized =
false;
97 void gameForm_RenderFrame(
object sender, OpenTK.FrameEventArgs e)
99 if (InitCallback != null)
107 if (!hasBeenInitialized)
110 hasBeenInitialized =
true;
114 internal override void Run()
116 Debug.Assert(InitCallback != null);
117 Debug.Assert(RunCallback != null);
119 if (gameForm.GraphicsContext != null)
121 throw new NotImplementedException(
"Only supports not yet initialized iPhoneOSGameView.");
124 var view = gameForm as IAnimatedGameView;
127 view.StartAnimating();
143 return gameForm.Visible;
147 gameForm.Visible = value;
151 protected override void SetTitle(
string title)
153 gameForm.Title = title;
156 internal override void Resize(
int width,
int height)
158 gameForm.Size =
new Size(width, height);
161 public override bool IsBorderLess
172 public override bool AllowUserResizing
187 return new Rectangle(0, 0, (
int)(gameForm.Size.Width * gameForm.ContentScaleFactor), (
int)(gameForm.Size.Height * gameForm.ContentScaleFactor));
195 return DisplayOrientation.Default;
199 public override bool IsMinimized
203 return gameForm.WindowState == OpenTK.WindowState.Minimized;
207 public override bool IsMouseVisible
209 get {
return false; }
213 protected override void Destroy()
215 if (gameForm != null)
217 GraphicsDevice.UnbindGraphicsContext(gameForm.GraphicsContext);
219 var view = gameForm as IAnimatedGameView;
222 view.StopAnimating();
AppContextType
Type of a GameContext.
HRESULT Resize(_In_ const Image &srcImage, _In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage &image)
ComponentBase.Destroy() event.
DisplayOrientation
Describes the orientation of the display.
System.Windows.Shapes.Rectangle Rectangle