mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-25 03:46:53 +00:00
Merge pull request #607 from Nihlus/purge-regions-mobile
Correct mobile projects for StyleCop compliance.
This commit is contained in:
commit
6ea763c821
|
@ -9,7 +9,7 @@ namespace OpenTK.Graphics.ES11
|
||||||
public sealed partial class GL : GraphicsBindingsBase
|
public sealed partial class GL : GraphicsBindingsBase
|
||||||
{
|
{
|
||||||
#if IPHONE
|
#if IPHONE
|
||||||
const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
private const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
||||||
#else
|
#else
|
||||||
private const string Library = "GLESv1_CM";
|
private const string Library = "GLESv1_CM";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenTK.Graphics.ES20
|
||||||
public sealed partial class GL : GraphicsBindingsBase
|
public sealed partial class GL : GraphicsBindingsBase
|
||||||
{
|
{
|
||||||
#if IPHONE
|
#if IPHONE
|
||||||
const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
private const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
||||||
#else
|
#else
|
||||||
private const string Library = "libGLESv2.dll";
|
private const string Library = "libGLESv2.dll";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenTK.Graphics.ES30
|
||||||
public sealed partial class GL : GraphicsBindingsBase
|
public sealed partial class GL : GraphicsBindingsBase
|
||||||
{
|
{
|
||||||
#if IPHONE
|
#if IPHONE
|
||||||
const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
private const string Library = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
|
||||||
#else
|
#else
|
||||||
private const string Library = "libGLESv2.dll";
|
private const string Library = "libGLESv2.dll";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -86,25 +86,25 @@ namespace OpenTK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// System.Xml.XmlIgnoreAttribute
|
// System.Xml.XmlIgnoreAttribute
|
||||||
class XmlIgnoreAttribute : Attribute
|
internal class XmlIgnoreAttribute : Attribute
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.ComponentModel.EditorBrowrableAttribute
|
// System.ComponentModel.EditorBrowrableAttribute
|
||||||
class EditorBrowsableAttribute : Attribute
|
internal class EditorBrowsableAttribute : Attribute
|
||||||
{
|
{
|
||||||
public EditorBrowsableAttribute(EditorBrowsableState state) { }
|
public EditorBrowsableAttribute(EditorBrowsableState state) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.ComponentModel.EditorBrowsableState
|
// System.ComponentModel.EditorBrowsableState
|
||||||
enum EditorBrowsableState
|
internal enum EditorBrowsableState
|
||||||
{
|
{
|
||||||
Always = 0,
|
Always = 0,
|
||||||
Never = 1,
|
Never = 1,
|
||||||
Advanced = 2,
|
Advanced = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
class RegistryKey
|
internal class RegistryKey
|
||||||
{
|
{
|
||||||
public RegistryKey OpenSubKey(string name)
|
public RegistryKey OpenSubKey(string name)
|
||||||
{
|
{
|
||||||
|
@ -117,14 +117,14 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Registry
|
internal class Registry
|
||||||
{
|
{
|
||||||
public static readonly RegistryKey LocalMachine = new RegistryKey();
|
public static readonly RegistryKey LocalMachine = new RegistryKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PointF : IEquatable<PointF>
|
public struct PointF : IEquatable<PointF>
|
||||||
{
|
{
|
||||||
float x, y;
|
private float x, y;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new PointF instance.
|
/// Constructs a new PointF instance.
|
||||||
|
@ -227,7 +227,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is PointF)
|
if (obj is PointF)
|
||||||
|
{
|
||||||
return Equals((PointF)obj);
|
return Equals((PointF)obj);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +265,7 @@ namespace OpenTK
|
||||||
|
|
||||||
public struct SizeF : IEquatable<SizeF>
|
public struct SizeF : IEquatable<SizeF>
|
||||||
{
|
{
|
||||||
float width, height;
|
private float width, height;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new SizeF instance.
|
/// Constructs a new SizeF instance.
|
||||||
|
@ -286,7 +288,9 @@ namespace OpenTK
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (width < 0)
|
if (width < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
width = value;
|
width = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +304,9 @@ namespace OpenTK
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
height = value;
|
height = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +359,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is SizeF)
|
if (obj is SizeF)
|
||||||
|
{
|
||||||
return Equals((SizeF)obj);
|
return Equals((SizeF)obj);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -389,8 +397,8 @@ namespace OpenTK
|
||||||
|
|
||||||
public struct RectangleF : IEquatable<RectangleF>
|
public struct RectangleF : IEquatable<RectangleF>
|
||||||
{
|
{
|
||||||
PointF location;
|
private PointF location;
|
||||||
SizeF size;
|
private SizeF size;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new RectangleF instance.
|
/// Constructs a new RectangleF instance.
|
||||||
|
@ -578,7 +586,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is RectangleF)
|
if (obj is RectangleF)
|
||||||
|
{
|
||||||
return Equals((RectangleF)obj);
|
return Equals((RectangleF)obj);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +625,7 @@ namespace OpenTK
|
||||||
|
|
||||||
public sealed class Icon : IDisposable
|
public sealed class Icon : IDisposable
|
||||||
{
|
{
|
||||||
IntPtr handle;
|
private IntPtr handle;
|
||||||
|
|
||||||
public Icon(Icon icon, int width, int height)
|
public Icon(Icon icon, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -655,8 +665,8 @@ namespace OpenTK
|
||||||
|
|
||||||
public sealed class Bitmap : Image
|
public sealed class Bitmap : Image
|
||||||
{
|
{
|
||||||
int width;
|
private int width;
|
||||||
int height;
|
private int height;
|
||||||
|
|
||||||
public Bitmap() { }
|
public Bitmap() { }
|
||||||
|
|
||||||
|
@ -789,7 +799,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Color))
|
if (!(obj is Color))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return Equals((Color)obj);
|
return Equals((Color)obj);
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1549,7 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class BitmapData
|
internal sealed class BitmapData
|
||||||
{
|
{
|
||||||
internal BitmapData(int width, int height, int stride)
|
internal BitmapData(int width, int height, int stride)
|
||||||
{
|
{
|
||||||
|
@ -1552,7 +1564,7 @@ namespace OpenTK
|
||||||
public int Stride { get; private set; }
|
public int Stride { get; private set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImageLockMode
|
internal enum ImageLockMode
|
||||||
{
|
{
|
||||||
ReadOnly,
|
ReadOnly,
|
||||||
WriteOnly,
|
WriteOnly,
|
||||||
|
@ -1560,16 +1572,16 @@ namespace OpenTK
|
||||||
UserInputBuffer
|
UserInputBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PixelFormat
|
internal enum PixelFormat
|
||||||
{
|
{
|
||||||
Format32bppArgb
|
Format32bppArgb
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImageFormat {
|
internal enum ImageFormat {
|
||||||
Png
|
Png
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class SystemEvents
|
internal sealed class SystemEvents
|
||||||
{
|
{
|
||||||
public static event EventHandler DisplaySettingsChanged;
|
public static event EventHandler DisplaySettingsChanged;
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1590,7 @@ namespace OpenTK
|
||||||
// Need a different namespace to avoid clash with OpenTK.Graphics.
|
// Need a different namespace to avoid clash with OpenTK.Graphics.
|
||||||
namespace OpenTK.Minimal
|
namespace OpenTK.Minimal
|
||||||
{
|
{
|
||||||
sealed class Graphics : IDisposable
|
internal sealed class Graphics : IDisposable
|
||||||
{
|
{
|
||||||
public static Graphics FromImage(OpenTK.Image img)
|
public static Graphics FromImage(OpenTK.Image img)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin, Inc.
|
* Copyright (c) 2011 Xamarin, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Android
|
namespace OpenTK.Platform.Android
|
||||||
{
|
{
|
||||||
class AndroidDisplayDeviceDriver : IDisplayDeviceDriver
|
internal class AndroidDisplayDeviceDriver : IDisplayDeviceDriver
|
||||||
{
|
{
|
||||||
static DisplayDevice dev;
|
private static DisplayDevice dev;
|
||||||
static AndroidDisplayDeviceDriver ()
|
static AndroidDisplayDeviceDriver ()
|
||||||
{
|
{
|
||||||
dev = new DisplayDevice ();
|
dev = new DisplayDevice ();
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin, Inc.
|
* Copyright (c) 2011 Xamarin, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Android
|
namespace OpenTK.Platform.Android
|
||||||
{
|
{
|
||||||
sealed class AndroidFactory : PlatformFactoryBase
|
internal sealed class AndroidFactory : PlatformFactoryBase
|
||||||
{
|
{
|
||||||
#region IPlatformFactory Members
|
|
||||||
|
|
||||||
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
AndroidWindow android_win = (AndroidWindow)window;
|
AndroidWindow android_win = (AndroidWindow)window;
|
||||||
|
@ -60,7 +56,5 @@ namespace OpenTK.Platform.Android
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin Inc.
|
* Copyright (c) 2011 Xamarin Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -34,28 +32,28 @@ namespace OpenTK.Platform.Android
|
||||||
[Register ("opentk_1_1/platform/android/AndroidGameView")]
|
[Register ("opentk_1_1/platform/android/AndroidGameView")]
|
||||||
public partial class AndroidGameView : GameViewBase, ISurfaceHolderCallback
|
public partial class AndroidGameView : GameViewBase, ISurfaceHolderCallback
|
||||||
{
|
{
|
||||||
bool disposed;
|
private bool disposed;
|
||||||
System.Timers.Timer timer;
|
private System.Timers.Timer timer;
|
||||||
Java.Util.Timer j_timer;
|
private Java.Util.Timer j_timer;
|
||||||
ISurfaceHolder mHolder;
|
private ISurfaceHolder mHolder;
|
||||||
GLCalls gl;
|
private GLCalls gl;
|
||||||
AndroidWindow windowInfo;
|
private AndroidWindow windowInfo;
|
||||||
Object ticking = new Object ();
|
private Object ticking = new Object ();
|
||||||
bool stopped = true;
|
private bool stopped = true;
|
||||||
bool renderOn = false;
|
private bool renderOn = false;
|
||||||
bool sizeChanged = false;
|
private bool sizeChanged = false;
|
||||||
bool requestRender = false;
|
private bool requestRender = false;
|
||||||
bool autoSetContextOnRenderFrame = true;
|
private bool autoSetContextOnRenderFrame = true;
|
||||||
bool renderOnUIThread = true;
|
private bool renderOnUIThread = true;
|
||||||
bool callMakeCurrent = false;
|
private bool callMakeCurrent = false;
|
||||||
CancellationTokenSource source;
|
private CancellationTokenSource source;
|
||||||
Task renderTask;
|
private Task renderTask;
|
||||||
Thread renderingThread;
|
private Thread renderingThread;
|
||||||
ManualResetEvent pauseSignal;
|
private ManualResetEvent pauseSignal;
|
||||||
global::Android.Graphics.Rect surfaceRect;
|
private global::Android.Graphics.Rect surfaceRect;
|
||||||
Size size;
|
private Size size;
|
||||||
System.Diagnostics.Stopwatch stopWatch;
|
private System.Diagnostics.Stopwatch stopWatch;
|
||||||
double tick = 0;
|
private double tick = 0;
|
||||||
|
|
||||||
[Register (".ctor", "(Landroid/content/Context;)V", "")]
|
[Register (".ctor", "(Landroid/content/Context;)V", "")]
|
||||||
public AndroidGameView (Context context) : base (context)
|
public AndroidGameView (Context context) : base (context)
|
||||||
|
@ -204,7 +202,7 @@ namespace OpenTK.Platform.Android
|
||||||
GraphicsContext.SwapBuffers ();
|
GraphicsContext.SwapBuffers ();
|
||||||
}
|
}
|
||||||
|
|
||||||
double updates;
|
private double updates;
|
||||||
public override void Run ()
|
public override void Run ()
|
||||||
{
|
{
|
||||||
EnsureUndisposed ();
|
EnsureUndisposed ();
|
||||||
|
@ -250,19 +248,18 @@ namespace OpenTK.Platform.Android
|
||||||
ResumeThread ();
|
ResumeThread ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Private
|
private void LoadInternal (EventArgs e)
|
||||||
void LoadInternal (EventArgs e)
|
|
||||||
{
|
{
|
||||||
OnLoad (e);
|
OnLoad (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnloadInternal (EventArgs e)
|
private void UnloadInternal (EventArgs e)
|
||||||
{
|
{
|
||||||
OnUnload (e);
|
OnUnload (e);
|
||||||
DestroyFrameBuffer ();
|
DestroyFrameBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderFrameInternal (FrameEventArgs e)
|
private void RenderFrameInternal (FrameEventArgs e)
|
||||||
{
|
{
|
||||||
#if TIMING
|
#if TIMING
|
||||||
Mark ();
|
Mark ();
|
||||||
|
@ -304,7 +301,7 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void UpdateFrameInternal (FrameEventArgs e)
|
private void UpdateFrameInternal (FrameEventArgs e)
|
||||||
{
|
{
|
||||||
if (!ReadyToRender)
|
if (!ReadyToRender)
|
||||||
return;
|
return;
|
||||||
|
@ -312,19 +309,19 @@ namespace OpenTK.Platform.Android
|
||||||
OnUpdateFrame (e);
|
OnUpdateFrame (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnsureUndisposed ()
|
private void EnsureUndisposed ()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
throw new ObjectDisposedException ("");
|
throw new ObjectDisposedException ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertContext ()
|
private void AssertContext ()
|
||||||
{
|
{
|
||||||
if (GraphicsContext == null)
|
if (GraphicsContext == null)
|
||||||
throw new InvalidOperationException ("Operation requires a GraphicsContext, which hasn't been created yet.");
|
throw new InvalidOperationException ("Operation requires a GraphicsContext, which hasn't been created yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateSurface()
|
private void CreateSurface()
|
||||||
{
|
{
|
||||||
if (GraphicsContext == null)
|
if (GraphicsContext == null)
|
||||||
{
|
{
|
||||||
|
@ -340,13 +337,13 @@ namespace OpenTK.Platform.Android
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroySurface()
|
private void DestroySurface()
|
||||||
{
|
{
|
||||||
log("DestroySurface");
|
log("DestroySurface");
|
||||||
windowInfo.DestroySurface();
|
windowInfo.DestroySurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateContext ()
|
private void CreateContext ()
|
||||||
{
|
{
|
||||||
log ("CreateContext");
|
log ("CreateContext");
|
||||||
|
|
||||||
|
@ -357,7 +354,7 @@ namespace OpenTK.Platform.Android
|
||||||
GraphicsContext = new GraphicsContext(GraphicsMode, WindowInfo, (int)ContextRenderingApi, 0, GraphicsContextFlags.Embedded);
|
GraphicsContext = new GraphicsContext(GraphicsMode, WindowInfo, (int)ContextRenderingApi, 0, GraphicsContextFlags.Embedded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyContext ()
|
private void DestroyContext ()
|
||||||
{
|
{
|
||||||
if (GraphicsContext != null) {
|
if (GraphicsContext != null) {
|
||||||
GraphicsContext.Dispose ();
|
GraphicsContext.Dispose ();
|
||||||
|
@ -365,11 +362,11 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int restartCounter = 0;
|
private int restartCounter = 0;
|
||||||
public int RenderThreadRestartRetries { get; set; }
|
public int RenderThreadRestartRetries { get; set; }
|
||||||
public Exception RenderThreadException;
|
public Exception RenderThreadException;
|
||||||
|
|
||||||
void StartThread ()
|
private void StartThread ()
|
||||||
{
|
{
|
||||||
log ("StartThread");
|
log ("StartThread");
|
||||||
|
|
||||||
|
@ -444,7 +441,7 @@ namespace OpenTK.Platform.Android
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopThread ()
|
private void StopThread ()
|
||||||
{
|
{
|
||||||
log ("StopThread");
|
log ("StopThread");
|
||||||
restartCounter = 0;
|
restartCounter = 0;
|
||||||
|
@ -461,7 +458,7 @@ namespace OpenTK.Platform.Android
|
||||||
if (stopWatch != null) stopWatch.Stop ();
|
if (stopWatch != null) stopWatch.Stop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PauseThread ()
|
private void PauseThread ()
|
||||||
{
|
{
|
||||||
log ("PauseThread");
|
log ("PauseThread");
|
||||||
restartCounter = 0;
|
restartCounter = 0;
|
||||||
|
@ -472,7 +469,7 @@ namespace OpenTK.Platform.Android
|
||||||
renderOn = false;
|
renderOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResumeThread ()
|
private void ResumeThread ()
|
||||||
{
|
{
|
||||||
log ("ResumeThread");
|
log ("ResumeThread");
|
||||||
restartCounter = 0;
|
restartCounter = 0;
|
||||||
|
@ -486,19 +483,19 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadyToRender {
|
private bool ReadyToRender {
|
||||||
get { return windowInfo.HasSurface && renderOn && !stopped; }
|
get { return windowInfo.HasSurface && renderOn && !stopped; }
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime prevUpdateTime;
|
private DateTime prevUpdateTime;
|
||||||
DateTime prevRenderTime;
|
private DateTime prevRenderTime;
|
||||||
DateTime curUpdateTime;
|
private DateTime curUpdateTime;
|
||||||
DateTime curRenderTime;
|
private DateTime curRenderTime;
|
||||||
FrameEventArgs updateEventArgs = new FrameEventArgs();
|
private FrameEventArgs updateEventArgs = new FrameEventArgs();
|
||||||
FrameEventArgs renderEventArgs = new FrameEventArgs();
|
private FrameEventArgs renderEventArgs = new FrameEventArgs();
|
||||||
|
|
||||||
// this method is called on the main thread if RenderOnUIThread is true
|
// this method is called on the main thread if RenderOnUIThread is true
|
||||||
void RunIteration (CancellationToken token)
|
private void RunIteration (CancellationToken token)
|
||||||
{
|
{
|
||||||
if (token.IsCancellationRequested)
|
if (token.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
@ -541,9 +538,6 @@ namespace OpenTK.Platform.Android
|
||||||
global::Android.Util.Log.Debug ("AndroidGameView", String.Format("width:{0} height:{1} size:{2} surfaceRect:{3}", Width, Height, size, surfaceRect));
|
global::Android.Util.Log.Debug ("AndroidGameView", String.Format("width:{0} height:{1} size:{2} surfaceRect:{3}", Width, Height, size, surfaceRect));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
|
|
||||||
public bool AutoSetContextOnRenderFrame {
|
public bool AutoSetContextOnRenderFrame {
|
||||||
|
@ -564,7 +558,7 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCalls GLCalls {
|
private GLCalls GLCalls {
|
||||||
get {
|
get {
|
||||||
if (gl == null || gl.Version != ContextRenderingApi)
|
if (gl == null || gl.Version != ContextRenderingApi)
|
||||||
gl = GLCalls.GetGLCalls (ContextRenderingApi);
|
gl = GLCalls.GetGLCalls (ContextRenderingApi);
|
||||||
|
@ -572,7 +566,7 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphicsContext Context {
|
private IGraphicsContext Context {
|
||||||
get { return GraphicsContext; }
|
get { return GraphicsContext; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +588,7 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLVersion api;
|
private GLVersion api;
|
||||||
public GLVersion ContextRenderingApi
|
public GLVersion ContextRenderingApi
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
|
@ -670,6 +664,5 @@ namespace OpenTK.Platform.Android
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin, Inc.
|
* Copyright (c) 2011 Xamarin, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -18,8 +16,7 @@ using OpenTK.Graphics;
|
||||||
using OpenTK.Platform.Egl;
|
using OpenTK.Platform.Egl;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Android {
|
namespace OpenTK.Platform.Android {
|
||||||
|
internal class AndroidGraphicsContext : EglContext
|
||||||
class AndroidGraphicsContext : EglContext
|
|
||||||
{
|
{
|
||||||
public AndroidGraphicsContext(GraphicsMode mode, EglWindowInfo window, IGraphicsContext sharedContext,
|
public AndroidGraphicsContext(GraphicsMode mode, EglWindowInfo window, IGraphicsContext sharedContext,
|
||||||
int major, int minor, GraphicsContextFlags flags)
|
int major, int minor, GraphicsContextFlags flags)
|
||||||
|
@ -41,8 +38,8 @@ namespace OpenTK.Platform.Android {
|
||||||
|
|
||||||
public class AndroidWindow : IWindowInfo, IDisposable
|
public class AndroidWindow : IWindowInfo, IDisposable
|
||||||
{
|
{
|
||||||
bool disposed;
|
private bool disposed;
|
||||||
WeakReference refHolder;
|
private WeakReference refHolder;
|
||||||
private EglWindowInfo eglWindowInfo;
|
private EglWindowInfo eglWindowInfo;
|
||||||
|
|
||||||
// Get native window from surface
|
// Get native window from surface
|
||||||
|
@ -132,15 +129,13 @@ namespace OpenTK.Platform.Android {
|
||||||
eglWindowInfo.TerminateDisplay();
|
eglWindowInfo.TerminateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
|
|
||||||
public void Dispose ()
|
public void Dispose ()
|
||||||
{
|
{
|
||||||
Dispose (true);
|
Dispose (true);
|
||||||
GC.SuppressFinalize (this);
|
GC.SuppressFinalize (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispose (bool disposing)
|
private void Dispose (bool disposing)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +152,5 @@ namespace OpenTK.Platform.Android {
|
||||||
{
|
{
|
||||||
Dispose (false);
|
Dispose (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin, Inc.
|
* Copyright (c) 2011 Xamarin, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin, Inc.
|
* Copyright (c) 2011 Xamarin, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
@ -21,7 +19,7 @@ using ES30 = OpenTK.Graphics.ES30;
|
||||||
|
|
||||||
namespace OpenTK
|
namespace OpenTK
|
||||||
{
|
{
|
||||||
sealed class GLCalls
|
internal sealed class GLCalls
|
||||||
{
|
{
|
||||||
public GLVersion Version;
|
public GLVersion Version;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2011 Xamarin Inc.
|
* Copyright (c) 2011 Xamarin Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -89,8 +87,6 @@ namespace OpenTK
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IGameWindow implementation
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs before the run loop starts.
|
/// Occurs before the run loop starts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -454,9 +450,6 @@ namespace OpenTK
|
||||||
/// invoked on it.
|
/// invoked on it.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public abstract void SwapBuffers ();
|
public abstract void SwapBuffers ();
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region INativeWindow implementation
|
|
||||||
|
|
||||||
/// <summary>This member is not supported.</summary>
|
/// <summary>This member is not supported.</summary>
|
||||||
/// <value>To be added.</value>
|
/// <value>To be added.</value>
|
||||||
|
@ -1193,7 +1186,5 @@ namespace OpenTK
|
||||||
add { throw new NotSupportedException(); }
|
add { throw new NotSupportedException(); }
|
||||||
remove { throw new NotSupportedException(); }
|
remove { throw new NotSupportedException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,10 @@ namespace OpenTK.Platform
|
||||||
Embedded = Default;
|
Embedded = Default;
|
||||||
}
|
}
|
||||||
#if IPHONE
|
#if IPHONE
|
||||||
else if (Configuration.RunningOnIOS) Embedded = new iPhoneOS.iPhoneFactory();
|
else if (Configuration.RunningOnIOS)
|
||||||
|
{
|
||||||
|
Embedded = new iPhoneOS.iPhoneFactory();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
else if (Egl.Egl.IsSupported)
|
else if (Egl.Egl.IsSupported)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,9 +5,9 @@ using OpenTK.Platform;
|
||||||
|
|
||||||
namespace OpenTK.Platform.iPhoneOS
|
namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
class AndroidDisplayDeviceDriver : IDisplayDeviceDriver
|
internal class AndroidDisplayDeviceDriver : IDisplayDeviceDriver
|
||||||
{
|
{
|
||||||
static DisplayDevice dev;
|
private static DisplayDevice dev;
|
||||||
static AndroidDisplayDeviceDriver()
|
static AndroidDisplayDeviceDriver()
|
||||||
{
|
{
|
||||||
dev = new DisplayDevice();
|
dev = new DisplayDevice();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#region License
|
|
||||||
//
|
//
|
||||||
// The Open Toolkit Library License
|
// The Open Toolkit Library License
|
||||||
//
|
//
|
||||||
|
@ -7,7 +6,7 @@
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
// in the Software without restriction, including without limitation the rights to
|
// in the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do
|
// the Software, and to permit persons to whom the Software is furnished to do
|
||||||
// so, subject to the following conditions:
|
// so, subject to the following conditions:
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -36,10 +34,8 @@ using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.iPhoneOS
|
namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
class iPhoneFactory : PlatformFactoryBase
|
internal class iPhoneFactory : PlatformFactoryBase
|
||||||
{
|
{
|
||||||
#region IPlatformFactory Members
|
|
||||||
|
|
||||||
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
return new iPhoneOS.iPhoneOSGraphicsContext(mode, window, shareContext, major, minor, flags);
|
return new iPhoneOS.iPhoneOSGraphicsContext(mode, window, shareContext, major, minor, flags);
|
||||||
|
@ -56,7 +52,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
EAGLContext c = EAGLContext.CurrentContext;
|
EAGLContext c = EAGLContext.CurrentContext;
|
||||||
IntPtr h = IntPtr.Zero;
|
IntPtr h = IntPtr.Zero;
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
{
|
||||||
h = c.Handle;
|
h = c.Handle;
|
||||||
|
}
|
||||||
return new ContextHandle(h);
|
return new ContextHandle(h);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -85,7 +83,5 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2009 Novell, Inc.
|
* Copyright (c) 2009 Novell, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
|
@ -6,7 +5,6 @@
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
// Copyright 2011 Xamarin Inc. All rights reserved.
|
// Copyright 2011 Xamarin Inc. All rights reserved.
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -32,7 +30,7 @@ using ES30 = OpenTK.Graphics.ES30;
|
||||||
|
|
||||||
namespace OpenTK.Platform.iPhoneOS
|
namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
sealed class GLCalls {
|
internal sealed class GLCalls {
|
||||||
public delegate void glBindFramebuffer(All target, int framebuffer);
|
public delegate void glBindFramebuffer(All target, int framebuffer);
|
||||||
public delegate void glBindRenderbuffer(All target, int renderbuffer);
|
public delegate void glBindRenderbuffer(All target, int renderbuffer);
|
||||||
public delegate void glDeleteFramebuffers(int n, ref int framebuffers);
|
public delegate void glDeleteFramebuffers(int n, ref int framebuffers);
|
||||||
|
@ -71,7 +69,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
throw new ArgumentException("api");
|
throw new ArgumentException("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLCalls CreateES1()
|
private static GLCalls CreateES1()
|
||||||
{
|
{
|
||||||
return new GLCalls() {
|
return new GLCalls() {
|
||||||
BindFramebuffer = (t, f) => ES11.GL.Oes.BindFramebuffer(t, f),
|
BindFramebuffer = (t, f) => ES11.GL.Oes.BindFramebuffer(t, f),
|
||||||
|
@ -90,7 +88,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLCalls CreateES2()
|
private static GLCalls CreateES2()
|
||||||
{
|
{
|
||||||
return new GLCalls() {
|
return new GLCalls() {
|
||||||
BindFramebuffer = (t, f) => ES20.GL.BindFramebuffer((ES20.FramebufferTarget) t, f),
|
BindFramebuffer = (t, f) => ES20.GL.BindFramebuffer((ES20.FramebufferTarget) t, f),
|
||||||
|
@ -109,7 +107,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLCalls CreateES3()
|
private static GLCalls CreateES3()
|
||||||
{
|
{
|
||||||
return new GLCalls() {
|
return new GLCalls() {
|
||||||
BindFramebuffer = (t, f) => ES30.GL.BindFramebuffer((ES30.FramebufferTarget) t, f),
|
BindFramebuffer = (t, f) => ES30.GL.BindFramebuffer((ES30.FramebufferTarget) t, f),
|
||||||
|
@ -129,7 +127,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITimeSource {
|
internal interface ITimeSource {
|
||||||
void Suspend ();
|
void Suspend ();
|
||||||
void Resume ();
|
void Resume ();
|
||||||
|
|
||||||
|
@ -137,19 +135,21 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
}
|
}
|
||||||
|
|
||||||
[Register]
|
[Register]
|
||||||
class CADisplayLinkTimeSource : NSObject, ITimeSource {
|
internal class CADisplayLinkTimeSource : NSObject, ITimeSource {
|
||||||
const string selectorName = "runIteration:";
|
private const string selectorName = "runIteration:";
|
||||||
static Selector selRunIteration = new Selector (selectorName);
|
private static Selector selRunIteration = new Selector (selectorName);
|
||||||
|
|
||||||
iPhoneOSGameView view;
|
private iPhoneOSGameView view;
|
||||||
CADisplayLink displayLink;
|
private CADisplayLink displayLink;
|
||||||
|
|
||||||
public CADisplayLinkTimeSource (iPhoneOSGameView view, int frameInterval)
|
public CADisplayLinkTimeSource (iPhoneOSGameView view, int frameInterval)
|
||||||
{
|
{
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
if (displayLink != null)
|
if (displayLink != null)
|
||||||
|
{
|
||||||
displayLink.Invalidate ();
|
displayLink.Invalidate ();
|
||||||
|
}
|
||||||
|
|
||||||
displayLink = CADisplayLink.Create (this, selRunIteration);
|
displayLink = CADisplayLink.Create (this, selRunIteration);
|
||||||
displayLink.FrameInterval = frameInterval;
|
displayLink.FrameInterval = frameInterval;
|
||||||
|
@ -177,18 +177,17 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
|
|
||||||
[Export (selectorName)]
|
[Export (selectorName)]
|
||||||
[Preserve (Conditional = true)]
|
[Preserve (Conditional = true)]
|
||||||
void RunIteration (NSObject parameter)
|
private void RunIteration (NSObject parameter)
|
||||||
{
|
{
|
||||||
view.RunIteration (null);
|
view.RunIteration (null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NSTimerTimeSource : ITimeSource {
|
internal class NSTimerTimeSource : ITimeSource {
|
||||||
|
private TimeSpan timeout;
|
||||||
|
private NSTimer timer;
|
||||||
|
|
||||||
TimeSpan timeout;
|
private iPhoneOSGameView view;
|
||||||
NSTimer timer;
|
|
||||||
|
|
||||||
iPhoneOSGameView view;
|
|
||||||
|
|
||||||
public NSTimerTimeSource (iPhoneOSGameView view, double updatesPerSecond)
|
public NSTimerTimeSource (iPhoneOSGameView view, double updatesPerSecond)
|
||||||
{
|
{
|
||||||
|
@ -211,7 +210,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
public void Resume ()
|
public void Resume ()
|
||||||
{
|
{
|
||||||
if (timeout != new TimeSpan (-1))
|
if (timeout != new TimeSpan (-1))
|
||||||
|
{
|
||||||
timer = NSTimer.CreateRepeatingScheduledTimer (timeout, view.RunIteration);
|
timer = NSTimer.CreateRepeatingScheduledTimer (timeout, view.RunIteration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invalidate ()
|
public void Invalidate ()
|
||||||
|
@ -225,19 +226,19 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
|
|
||||||
public class iPhoneOSGameView : UIView, IGameWindow
|
public class iPhoneOSGameView : UIView, IGameWindow
|
||||||
{
|
{
|
||||||
bool suspended;
|
private bool suspended;
|
||||||
bool disposed;
|
private bool disposed;
|
||||||
|
|
||||||
int framebuffer, renderbuffer;
|
private int framebuffer, renderbuffer;
|
||||||
|
|
||||||
GLCalls gl;
|
private GLCalls gl;
|
||||||
|
|
||||||
ITimeSource timesource;
|
private ITimeSource timesource;
|
||||||
System.Diagnostics.Stopwatch stopwatch;
|
private System.Diagnostics.Stopwatch stopwatch;
|
||||||
TimeSpan prevUpdateTime;
|
private TimeSpan prevUpdateTime;
|
||||||
TimeSpan prevRenderTime;
|
private TimeSpan prevRenderTime;
|
||||||
|
|
||||||
IWindowInfo windowInfo = Utilities.CreateDummyWindowInfo();
|
private IWindowInfo windowInfo = Utilities.CreateDummyWindowInfo();
|
||||||
|
|
||||||
[Export("initWithCoder:")]
|
[Export("initWithCoder:")]
|
||||||
public iPhoneOSGameView(NSCoder coder)
|
public iPhoneOSGameView(NSCoder coder)
|
||||||
|
@ -259,19 +260,23 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
return new Class (typeof (CAEAGLLayer));
|
return new Class (typeof (CAEAGLLayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertValid()
|
private void AssertValid()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException("");
|
throw new ObjectDisposedException("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertContext()
|
private void AssertContext()
|
||||||
{
|
{
|
||||||
if (GraphicsContext == null)
|
if (GraphicsContext == null)
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Operation requires a GraphicsContext, which hasn't been created yet.");
|
throw new InvalidOperationException("Operation requires a GraphicsContext, which hasn't been created yet.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAGLRenderingAPI api;
|
private EAGLRenderingAPI api;
|
||||||
public EAGLRenderingAPI ContextRenderingApi {
|
public EAGLRenderingAPI ContextRenderingApi {
|
||||||
get {
|
get {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
|
@ -280,7 +285,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
set {
|
set {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
if (GraphicsContext != null)
|
if (GraphicsContext != null)
|
||||||
|
{
|
||||||
throw new NotSupportedException("Can't change RenderingApi after GraphicsContext is constructed.");
|
throw new NotSupportedException("Can't change RenderingApi after GraphicsContext is constructed.");
|
||||||
|
}
|
||||||
this.api = value;
|
this.api = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,18 +299,22 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
if (GraphicsContext != null) {
|
if (GraphicsContext != null) {
|
||||||
iPhoneOSGraphicsContext c = GraphicsContext as iPhoneOSGraphicsContext;
|
iPhoneOSGraphicsContext c = GraphicsContext as iPhoneOSGraphicsContext;
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
{
|
||||||
return c.EAGLContext;
|
return c.EAGLContext;
|
||||||
|
}
|
||||||
var i = GraphicsContext as IGraphicsContextInternal;
|
var i = GraphicsContext as IGraphicsContextInternal;
|
||||||
IGraphicsContext ic = i == null ? null : i.Implementation;
|
IGraphicsContext ic = i == null ? null : i.Implementation;
|
||||||
c = ic as iPhoneOSGraphicsContext;
|
c = ic as iPhoneOSGraphicsContext;
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
{
|
||||||
return c.EAGLContext;
|
return c.EAGLContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retainedBacking;
|
private bool retainedBacking;
|
||||||
public bool LayerRetainsBacking {
|
public bool LayerRetainsBacking {
|
||||||
get {
|
get {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
|
@ -312,12 +323,14 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
set {
|
set {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
if (GraphicsContext != null)
|
if (GraphicsContext != null)
|
||||||
|
{
|
||||||
throw new NotSupportedException("Can't change LayerRetainsBacking after GraphicsContext is constructed.");
|
throw new NotSupportedException("Can't change LayerRetainsBacking after GraphicsContext is constructed.");
|
||||||
|
}
|
||||||
retainedBacking = value;
|
retainedBacking = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString colorFormat;
|
private NSString colorFormat;
|
||||||
public NSString LayerColorFormat {
|
public NSString LayerColorFormat {
|
||||||
get {
|
get {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
|
@ -326,7 +339,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
set {
|
set {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
if (GraphicsContext != null)
|
if (GraphicsContext != null)
|
||||||
|
{
|
||||||
throw new NotSupportedException("Can't change LayerColorFormat after GraphicsContext is constructed.");
|
throw new NotSupportedException("Can't change LayerColorFormat after GraphicsContext is constructed.");
|
||||||
|
}
|
||||||
colorFormat = value;
|
colorFormat = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,13 +356,15 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
|
|
||||||
public bool AutoResize {get; set;}
|
public bool AutoResize {get; set;}
|
||||||
|
|
||||||
UIViewController GetViewController()
|
private UIViewController GetViewController()
|
||||||
{
|
{
|
||||||
UIResponder r = this;
|
UIResponder r = this;
|
||||||
while (r != null) {
|
while (r != null) {
|
||||||
var c = r as UIViewController;
|
var c = r as UIViewController;
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
{
|
||||||
return c;
|
return c;
|
||||||
|
}
|
||||||
r = r.NextResponder;
|
r = r.NextResponder;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -358,7 +375,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
AssertValid();
|
AssertValid();
|
||||||
var c = GetViewController();
|
var c = GetViewController();
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
{
|
||||||
return c.Title;
|
return c.Title;
|
||||||
|
}
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
@ -371,7 +390,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +400,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = TitleChanged;
|
var h = TitleChanged;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, EventArgs.Empty);
|
h (this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool INativeWindow.Focused {
|
bool INativeWindow.Focused {
|
||||||
|
@ -404,7 +427,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = VisibleChanged;
|
var h = VisibleChanged;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, EventArgs.Empty);
|
h (this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool INativeWindow.Exists {
|
bool INativeWindow.Exists {
|
||||||
|
@ -427,7 +452,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
#else
|
#else
|
||||||
if (c != null && c.WantsFullScreenLayout)
|
if (c != null && c.WantsFullScreenLayout)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
return WindowState.Fullscreen;
|
return WindowState.Fullscreen;
|
||||||
|
}
|
||||||
return WindowState.Normal;
|
return WindowState.Normal;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
@ -454,7 +481,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = WindowStateChanged;
|
var h = WindowStateChanged;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, EventArgs.Empty);
|
h (this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual WindowBorder WindowBorder {
|
public virtual WindowBorder WindowBorder {
|
||||||
|
@ -475,7 +504,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
set {throw new NotSupportedException();}
|
set {throw new NotSupportedException();}
|
||||||
}
|
}
|
||||||
|
|
||||||
Size size;
|
private Size size;
|
||||||
public Size Size {
|
public Size Size {
|
||||||
get {
|
get {
|
||||||
AssertValid();
|
AssertValid();
|
||||||
|
@ -494,7 +523,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = Resize;
|
var h = Resize;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int INativeWindow.X {
|
int INativeWindow.X {
|
||||||
|
@ -531,7 +562,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
AssertValid();
|
AssertValid();
|
||||||
if (LayerColorFormat == null)
|
if (LayerColorFormat == null)
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Set the LayerColorFormat property to an EAGLColorFormat value before calling Run().");
|
throw new InvalidOperationException("Set the LayerColorFormat property to an EAGLColorFormat value before calling Run().");
|
||||||
|
}
|
||||||
|
|
||||||
CAEAGLLayer eaglLayer = (CAEAGLLayer) Layer;
|
CAEAGLLayer eaglLayer = (CAEAGLLayer) Layer;
|
||||||
eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys (
|
eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys (
|
||||||
|
@ -573,16 +606,22 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
AssertContext();
|
AssertContext();
|
||||||
EAGLContext oldContext = EAGLContext.CurrentContext;
|
EAGLContext oldContext = EAGLContext.CurrentContext;
|
||||||
if (!GraphicsContext.IsCurrent)
|
if (!GraphicsContext.IsCurrent)
|
||||||
|
{
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
gl.DeleteFramebuffers (1, ref framebuffer);
|
gl.DeleteFramebuffers (1, ref framebuffer);
|
||||||
gl.DeleteRenderbuffers (1, ref renderbuffer);
|
gl.DeleteRenderbuffers (1, ref renderbuffer);
|
||||||
framebuffer = renderbuffer = 0;
|
framebuffer = renderbuffer = 0;
|
||||||
|
|
||||||
if (oldContext != EAGLContext)
|
if (oldContext != EAGLContext)
|
||||||
|
{
|
||||||
EAGLContext.SetCurrentContext(oldContext);
|
EAGLContext.SetCurrentContext(oldContext);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
EAGLContext.SetCurrentContext(null);
|
EAGLContext.SetCurrentContext(null);
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsContext.Dispose();
|
GraphicsContext.Dispose();
|
||||||
GraphicsContext = null;
|
GraphicsContext = null;
|
||||||
|
@ -608,7 +647,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
CreateFrameBuffer(eaglLayer);
|
CreateFrameBuffer(eaglLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateFrameBuffer(CAEAGLLayer eaglLayer)
|
private void CreateFrameBuffer(CAEAGLLayer eaglLayer)
|
||||||
{
|
{
|
||||||
int oldRenderbuffer = 1;
|
int oldRenderbuffer = 1;
|
||||||
gl.GetInteger(All.RenderbufferBindingOes, out oldRenderbuffer);
|
gl.GetInteger(All.RenderbufferBindingOes, out oldRenderbuffer);
|
||||||
|
@ -646,33 +685,45 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = Closed;
|
var h = Closed;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (timesource != null)
|
if (timesource != null)
|
||||||
|
{
|
||||||
timesource.Invalidate ();
|
timesource.Invalidate ();
|
||||||
|
}
|
||||||
timesource = null;
|
timesource = null;
|
||||||
if (stopwatch != null)
|
if (stopwatch != null)
|
||||||
|
{
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
}
|
||||||
stopwatch = null;
|
stopwatch = null;
|
||||||
DestroyFrameBuffer();
|
DestroyFrameBuffer();
|
||||||
}
|
}
|
||||||
base.Dispose (disposing);
|
base.Dispose (disposing);
|
||||||
disposed = true;
|
disposed = true;
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
{
|
||||||
OnDisposed(EventArgs.Empty);
|
OnDisposed(EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDisposed(EventArgs e)
|
protected virtual void OnDisposed(EventArgs e)
|
||||||
{
|
{
|
||||||
var h = Disposed;
|
var h = Disposed;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void INativeWindow.ProcessEvents()
|
void INativeWindow.ProcessEvents()
|
||||||
|
@ -694,7 +745,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
base.LayoutSubviews ();
|
base.LayoutSubviews ();
|
||||||
if (GraphicsContext == null)
|
if (GraphicsContext == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var bounds = Bounds;
|
var bounds = Bounds;
|
||||||
if (AutoResize && (Math.Round(bounds.Width) != Size.Width ||
|
if (AutoResize && (Math.Round(bounds.Width) != Size.Width ||
|
||||||
|
@ -719,8 +772,8 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
GraphicsContext.SwapBuffers();
|
GraphicsContext.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
WeakReference frameBufferWindow;
|
private WeakReference frameBufferWindow;
|
||||||
WeakReference frameBufferLayer;
|
private WeakReference frameBufferLayer;
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
@ -730,17 +783,21 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
public void Run (double updatesPerSecond)
|
public void Run (double updatesPerSecond)
|
||||||
{
|
{
|
||||||
if (updatesPerSecond < 0.0)
|
if (updatesPerSecond < 0.0)
|
||||||
|
{
|
||||||
throw new ArgumentException ("updatesPerSecond");
|
throw new ArgumentException ("updatesPerSecond");
|
||||||
|
}
|
||||||
|
|
||||||
if (updatesPerSecond == 0.0) {
|
if (updatesPerSecond == 0.0) {
|
||||||
RunWithFrameInterval (1);
|
RunWithFrameInterval (1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timesource != null)
|
|
||||||
timesource.Invalidate ();
|
|
||||||
|
|
||||||
timesource = new NSTimerTimeSource (this, updatesPerSecond);
|
if (timesource != null)
|
||||||
|
{
|
||||||
|
timesource.Invalidate ();
|
||||||
|
}
|
||||||
|
|
||||||
|
timesource = new NSTimerTimeSource (this, updatesPerSecond);
|
||||||
|
|
||||||
CreateFrameBuffer ();
|
CreateFrameBuffer ();
|
||||||
OnLoad (EventArgs.Empty);
|
OnLoad (EventArgs.Empty);
|
||||||
|
@ -756,21 +813,25 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
public void RunWithFrameInterval (int frameInterval)
|
public void RunWithFrameInterval (int frameInterval)
|
||||||
{
|
{
|
||||||
AssertValid ();
|
AssertValid ();
|
||||||
|
|
||||||
if (frameInterval < 1)
|
if (frameInterval < 1)
|
||||||
|
{
|
||||||
throw new ArgumentException ("frameInterval");
|
throw new ArgumentException ("frameInterval");
|
||||||
|
}
|
||||||
|
|
||||||
if (timesource != null)
|
if (timesource != null)
|
||||||
timesource.Invalidate ();
|
{
|
||||||
|
timesource.Invalidate ();
|
||||||
|
}
|
||||||
|
|
||||||
timesource = new CADisplayLinkTimeSource (this, frameInterval);
|
timesource = new CADisplayLinkTimeSource (this, frameInterval);
|
||||||
|
|
||||||
CreateFrameBuffer ();
|
CreateFrameBuffer ();
|
||||||
OnLoad (EventArgs.Empty);
|
OnLoad (EventArgs.Empty);
|
||||||
Start ();
|
Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start ()
|
private void Start ()
|
||||||
{
|
{
|
||||||
prevUpdateTime = TimeSpan.Zero;
|
prevUpdateTime = TimeSpan.Zero;
|
||||||
prevRenderTime = TimeSpan.Zero;
|
prevRenderTime = TimeSpan.Zero;
|
||||||
|
@ -788,18 +849,22 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
OnUnload(EventArgs.Empty);
|
OnUnload(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Suspend ()
|
private void Suspend ()
|
||||||
{
|
{
|
||||||
if (timesource != null)
|
if (timesource != null)
|
||||||
|
{
|
||||||
timesource.Suspend ();
|
timesource.Suspend ();
|
||||||
|
}
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
suspended = true;
|
suspended = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resume ()
|
private void Resume ()
|
||||||
{
|
{
|
||||||
if (timesource != null)
|
if (timesource != null)
|
||||||
|
{
|
||||||
timesource.Resume ();
|
timesource.Resume ();
|
||||||
|
}
|
||||||
stopwatch.Start();
|
stopwatch.Start();
|
||||||
suspended = false;
|
suspended = false;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +898,7 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
// otherwise, use kCGImageAlphaPremultipliedLast
|
// otherwise, use kCGImageAlphaPremultipliedLast
|
||||||
using (var data_provider = new CGDataProvider (data, 0, data.Length)) {
|
using (var data_provider = new CGDataProvider (data, 0, data.Length)) {
|
||||||
using (var colorspace = CGColorSpace.CreateDeviceRGB ()) {
|
using (var colorspace = CGColorSpace.CreateDeviceRGB ()) {
|
||||||
using (var iref = new CGImage (width, height, 8, 32, width * 4, colorspace,
|
using (var iref = new CGImage (width, height, 8, 32, width * 4, colorspace,
|
||||||
(CGImageAlphaInfo) ((int) CGBitmapFlags.ByteOrder32Big | (int) CGImageAlphaInfo.PremultipliedLast),
|
(CGImageAlphaInfo) ((int) CGBitmapFlags.ByteOrder32Big | (int) CGImageAlphaInfo.PremultipliedLast),
|
||||||
data_provider, null, true, CGColorRenderingIntent.Default)) {
|
data_provider, null, true, CGColorRenderingIntent.Default)) {
|
||||||
|
|
||||||
|
@ -869,7 +934,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
public override void WillMoveToWindow(UIWindow window)
|
public override void WillMoveToWindow(UIWindow window)
|
||||||
{
|
{
|
||||||
if (window == null && !suspended)
|
if (window == null && !suspended)
|
||||||
|
{
|
||||||
Suspend();
|
Suspend();
|
||||||
|
}
|
||||||
else if (window != null && suspended) {
|
else if (window != null && suspended) {
|
||||||
if (frameBufferLayer != null && ((CALayer)frameBufferLayer.Target) != Layer ||
|
if (frameBufferLayer != null && ((CALayer)frameBufferLayer.Target) != Layer ||
|
||||||
frameBufferWindow != null && ((UIWindow)frameBufferWindow.Target) != window) {
|
frameBufferWindow != null && ((UIWindow)frameBufferWindow.Target) != window) {
|
||||||
|
@ -882,8 +949,8 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameEventArgs updateEventArgs = new FrameEventArgs();
|
private FrameEventArgs updateEventArgs = new FrameEventArgs();
|
||||||
FrameEventArgs renderEventArgs = new FrameEventArgs();
|
private FrameEventArgs renderEventArgs = new FrameEventArgs();
|
||||||
|
|
||||||
internal void RunIteration (NSTimer timer)
|
internal void RunIteration (NSTimer timer)
|
||||||
{
|
{
|
||||||
|
@ -910,7 +977,9 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
{
|
{
|
||||||
var h = Load;
|
var h = Load;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnUnload(EventArgs e)
|
protected virtual void OnUnload(EventArgs e)
|
||||||
|
@ -918,21 +987,27 @@ namespace OpenTK.Platform.iPhoneOS
|
||||||
var h = Unload;
|
var h = Unload;
|
||||||
DestroyFrameBuffer();
|
DestroyFrameBuffer();
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnUpdateFrame(FrameEventArgs e)
|
protected virtual void OnUpdateFrame(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
var h = UpdateFrame;
|
var h = UpdateFrame;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnRenderFrame(FrameEventArgs e)
|
protected virtual void OnRenderFrame(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
var h = RenderFrame;
|
var h = RenderFrame;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
|
{
|
||||||
h (this, e);
|
h (this, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event EventHandler<EventArgs> INativeWindow.Move {
|
event EventHandler<EventArgs> INativeWindow.Move {
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
#region --- License ---
|
|
||||||
/* Licensed under the MIT/X11 license.
|
/* Licensed under the MIT/X11 license.
|
||||||
* Copyright (c) 2009 Novell, Inc.
|
* Copyright (c) 2009 Novell, Inc.
|
||||||
* Copyright 2013 Xamarin Inc
|
* Copyright 2013 Xamarin Inc
|
||||||
* This notice may not be removed from any source distribution.
|
* This notice may not be removed from any source distribution.
|
||||||
* See license.txt for licensing detailed licensing details.
|
* See license.txt for licensing detailed licensing details.
|
||||||
*/
|
*/
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -15,8 +13,7 @@ using OpenGLES;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.iPhoneOS {
|
namespace OpenTK.Platform.iPhoneOS {
|
||||||
|
internal class iPhoneOSGraphicsContext : EmbeddedGraphicsContext
|
||||||
class iPhoneOSGraphicsContext : EmbeddedGraphicsContext
|
|
||||||
{
|
{
|
||||||
public EAGLContext EAGLContext {get; private set;}
|
public EAGLContext EAGLContext {get; private set;}
|
||||||
|
|
||||||
|
@ -33,13 +30,21 @@ namespace OpenTK.Platform.iPhoneOS {
|
||||||
|
|
||||||
EAGLRenderingAPI version = 0;
|
EAGLRenderingAPI version = 0;
|
||||||
if (major == 1 && minor == 1)
|
if (major == 1 && minor == 1)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES1;
|
version = EAGLRenderingAPI.OpenGLES1;
|
||||||
|
}
|
||||||
else if (major == 2 && minor == 0)
|
else if (major == 2 && minor == 0)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES2;
|
version = EAGLRenderingAPI.OpenGLES2;
|
||||||
|
}
|
||||||
else if (major == 3 && minor == 0)
|
else if (major == 3 && minor == 0)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES3;
|
version = EAGLRenderingAPI.OpenGLES3;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));
|
throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));
|
||||||
|
}
|
||||||
|
|
||||||
if (handle.Handle == IntPtr.Zero) {
|
if (handle.Handle == IntPtr.Zero) {
|
||||||
EAGLContext = shared != null && shared.EAGLContext != null
|
EAGLContext = shared != null && shared.EAGLContext != null
|
||||||
|
@ -60,13 +65,21 @@ namespace OpenTK.Platform.iPhoneOS {
|
||||||
|
|
||||||
EAGLRenderingAPI version = 0;
|
EAGLRenderingAPI version = 0;
|
||||||
if (major == 1 && minor == 1)
|
if (major == 1 && minor == 1)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES1;
|
version = EAGLRenderingAPI.OpenGLES1;
|
||||||
|
}
|
||||||
else if (major == 2 && minor == 0)
|
else if (major == 2 && minor == 0)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES2;
|
version = EAGLRenderingAPI.OpenGLES2;
|
||||||
|
}
|
||||||
else if (major == 3 && minor == 0)
|
else if (major == 3 && minor == 0)
|
||||||
|
{
|
||||||
version = EAGLRenderingAPI.OpenGLES3;
|
version = EAGLRenderingAPI.OpenGLES3;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));
|
throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));
|
||||||
|
}
|
||||||
|
|
||||||
EAGLContext = shared != null && shared.EAGLContext != null
|
EAGLContext = shared != null && shared.EAGLContext != null
|
||||||
? new EAGLContext(version, shared.EAGLContext.ShareGroup)
|
? new EAGLContext(version, shared.EAGLContext.ShareGroup)
|
||||||
|
@ -77,13 +90,17 @@ namespace OpenTK.Platform.iPhoneOS {
|
||||||
public override void SwapBuffers()
|
public override void SwapBuffers()
|
||||||
{
|
{
|
||||||
if (!EAGLContext.PresentRenderBuffer((uint) OpenTK.Graphics.ES11.All.RenderbufferOes))
|
if (!EAGLContext.PresentRenderBuffer((uint) OpenTK.Graphics.ES11.All.RenderbufferOes))
|
||||||
|
{
|
||||||
throw new InvalidOperationException ("EAGLContext.PresentRenderbuffer failed.");
|
throw new InvalidOperationException ("EAGLContext.PresentRenderbuffer failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void MakeCurrent(IWindowInfo window)
|
public override void MakeCurrent(IWindowInfo window)
|
||||||
{
|
{
|
||||||
if (!EAGLContext.SetCurrentContext(window != null ? EAGLContext : null))
|
if (!EAGLContext.SetCurrentContext(window != null ? EAGLContext : null))
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Unable to change current EAGLContext.");
|
throw new InvalidOperationException("Unable to change current EAGLContext.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsCurrent
|
public override bool IsCurrent
|
||||||
|
@ -111,7 +128,9 @@ namespace OpenTK.Platform.iPhoneOS {
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
if (EAGLContext != null)
|
if (EAGLContext != null)
|
||||||
|
{
|
||||||
EAGLContext.Dispose();
|
EAGLContext.Dispose();
|
||||||
|
}
|
||||||
EAGLContext = null;
|
EAGLContext = null;
|
||||||
}
|
}
|
||||||
IsDisposed = true;
|
IsDisposed = true;
|
||||||
|
|
Loading…
Reference in a new issue