* Source/OpenTK/Platform/Egl/EglContext.cs:
* Source/OpenTK/Graphics/GraphicsContext.cs: * Source/OpenTK/Graphics/IGraphicsContext.cs: * Source/OpenTK/Platform/MacOS/AglContext.cs: * Source/OpenTK/Platform/X11/X11GLContext.cs: * Source/OpenTK/Graphics/GraphicsContextBase.cs: * Source/OpenTK/Platform/Windows/WinGLContext.cs: * Source/OpenTK/Platform/Dummy/DummyGLContext.cs: Added IsDisposed property to IGraphicsContext and implemented in all context classes. Removed 'bool disposed' fields from these classes in favor of the new property.
This commit is contained in:
parent
0edbcae3b4
commit
2f5a0bfe3b
8 changed files with 38 additions and 18 deletions
|
@ -301,13 +301,23 @@ namespace OpenTK.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a System.Boolean indicating whether this Context is current in the calling thread.
|
/// Gets a <see cref="System.Boolean"/> indicating whether this instance is current in the calling thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsCurrent
|
public bool IsCurrent
|
||||||
{
|
{
|
||||||
get { return implementation.IsCurrent; }
|
get { return implementation.IsCurrent; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="System.Boolean"/> indicating whether this instance has been disposed.
|
||||||
|
/// It is an error to access any instance methods if this property returns true.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDisposed
|
||||||
|
{
|
||||||
|
get { return disposed && implementation.IsDisposed; }
|
||||||
|
private set { disposed = value; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether VSync is enabled.
|
/// Gets or sets a value indicating whether VSync is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -397,7 +407,7 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
void Dispose(bool manual)
|
void Dispose(bool manual)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!IsDisposed)
|
||||||
{
|
{
|
||||||
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
|
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
|
||||||
lock (context_lock)
|
lock (context_lock)
|
||||||
|
@ -410,7 +420,7 @@ namespace OpenTK.Graphics
|
||||||
if (implementation != null)
|
if (implementation != null)
|
||||||
implementation.Dispose();
|
implementation.Dispose();
|
||||||
}
|
}
|
||||||
disposed = true;
|
IsDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
bool disposed;
|
||||||
|
|
||||||
protected ContextHandle Handle;
|
protected ContextHandle Handle;
|
||||||
protected GraphicsMode Mode;
|
protected GraphicsMode Mode;
|
||||||
|
|
||||||
|
@ -50,6 +52,12 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
public abstract bool IsCurrent { get; }
|
public abstract bool IsCurrent { get; }
|
||||||
|
|
||||||
|
public bool IsDisposed
|
||||||
|
{
|
||||||
|
get { return disposed; }
|
||||||
|
protected set { disposed = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public abstract bool VSync { get; set; }
|
public abstract bool VSync { get; set; }
|
||||||
|
|
||||||
public virtual void Update(IWindowInfo window) { }
|
public virtual void Update(IWindowInfo window) { }
|
||||||
|
|
|
@ -31,10 +31,16 @@ namespace OpenTK.Graphics
|
||||||
void MakeCurrent(IWindowInfo window);
|
void MakeCurrent(IWindowInfo window);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a System.Boolean indicating whether the GraphicsContext is current in the calling thread.
|
/// Gets a <see cref="System.Boolean"/> indicating whether this instance is current in the calling thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsCurrent { get; }
|
bool IsCurrent { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="System.Boolean"/> indicating whether this instance has been disposed.
|
||||||
|
/// It is an error to access any instance methods if this property returns true.
|
||||||
|
/// </summary>
|
||||||
|
bool IsDisposed { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether VSyncing is enabled.
|
/// Gets or sets a value indicating whether VSyncing is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace OpenTK.Platform.Dummy
|
||||||
|
|
||||||
#region --- IDisposable Members ---
|
#region --- IDisposable Members ---
|
||||||
|
|
||||||
public override void Dispose() { }
|
public override void Dispose() { IsDisposed = true; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace OpenTK.Platform.Egl
|
||||||
EglWindowInfo WindowInfo;
|
EglWindowInfo WindowInfo;
|
||||||
EGLContext HandleAsEGLContext { get { return new EGLContext(Handle.Handle); } set { Handle = new ContextHandle(value.Handle.Value); } }
|
EGLContext HandleAsEGLContext { get { return new EGLContext(Handle.Handle); } set { Handle = new ContextHandle(value.Handle.Value); } }
|
||||||
bool vsync = true; // Default vsync value is defined as 1 (true) in EGL.
|
bool vsync = true; // Default vsync value is defined as 1 (true) in EGL.
|
||||||
bool disposed = false;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ namespace OpenTK.Platform.Egl
|
||||||
// thread?
|
// thread?
|
||||||
void Dispose(bool manual)
|
void Dispose(bool manual)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!IsDisposed)
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
|
@ -152,7 +151,7 @@ namespace OpenTK.Platform.Egl
|
||||||
{
|
{
|
||||||
Debug.Print("[Warning] {0}:{1} was not disposed.", this.GetType().Name, HandleAsEGLContext.Handle);
|
Debug.Print("[Warning] {0}:{1} was not disposed.", this.GetType().Name, HandleAsEGLContext.Handle);
|
||||||
}
|
}
|
||||||
disposed = true;
|
IsDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,8 +335,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
void Dispose(bool disposing)
|
void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
|
if (IsDisposed || Handle.Handle == IntPtr.Zero)
|
||||||
if (Handle.Handle == IntPtr.Zero)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.Print("Disposing of AGL context.");
|
Debug.Print("Disposing of AGL context.");
|
||||||
|
@ -370,6 +369,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
throw new MacOSException((OSStatus)Agl.GetError(), Agl.ErrorString(Agl.GetError()));
|
throw new MacOSException((OSStatus)Agl.GetError(), Agl.ErrorString(Agl.GetError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IsDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -32,8 +32,6 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
bool vsync_supported;
|
bool vsync_supported;
|
||||||
|
|
||||||
bool disposed;
|
|
||||||
|
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
static WinGLContext()
|
static WinGLContext()
|
||||||
|
@ -305,7 +303,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
private void Dispose(bool calledManually)
|
private void Dispose(bool calledManually)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!IsDisposed)
|
||||||
{
|
{
|
||||||
if (calledManually)
|
if (calledManually)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +314,7 @@ namespace OpenTK.Platform.Windows
|
||||||
Debug.Print("[Warning] OpenGL context {0} leaked. Did you forget to call IGraphicsContext.Dispose()?",
|
Debug.Print("[Warning] OpenGL context {0} leaked. Did you forget to call IGraphicsContext.Dispose()?",
|
||||||
Handle.Handle);
|
Handle.Handle);
|
||||||
}
|
}
|
||||||
disposed = true;
|
IsDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,6 @@ namespace OpenTK.Platform.X11
|
||||||
bool glx_loaded;
|
bool glx_loaded;
|
||||||
GraphicsMode graphics_mode;
|
GraphicsMode graphics_mode;
|
||||||
|
|
||||||
bool disposed;
|
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
public X11GLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shared, bool direct,
|
public X11GLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shared, bool direct,
|
||||||
|
@ -298,7 +296,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
private void Dispose(bool manuallyCalled)
|
private void Dispose(bool manuallyCalled)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!IsDisposed)
|
||||||
{
|
{
|
||||||
if (manuallyCalled)
|
if (manuallyCalled)
|
||||||
{
|
{
|
||||||
|
@ -312,7 +310,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
Debug.Print("[Warning] {0} leaked.", this.GetType().Name);
|
Debug.Print("[Warning] {0} leaked.", this.GetType().Name);
|
||||||
}
|
}
|
||||||
disposed = true;
|
IsDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue