mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 05:25:31 +00:00
GraphicsContext.GetCurrentContext now returns an IGraphicsContext instead of a GraphicsContext.
Fixed Texture2D finalizer. Removed GraphicsContext.[Enter|Exit]BeginRegion(). GL.Begin|End now calls IGraphicsContext.ErrorChecking = false.
This commit is contained in:
parent
7df9a448d6
commit
efdaf64476
|
@ -51,12 +51,12 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
public ErrorHelper(GraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
|
||||||
Context = context;
|
Context = (GraphicsContext)context;
|
||||||
Context.ResetErrors();
|
Context.ResetErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24592,7 +24592,7 @@ namespace OpenTK.Graphics
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
using (new ErrorHelper(GraphicsContext.CurrentContext))
|
using (new ErrorHelper(GraphicsContext.CurrentContext))
|
||||||
{
|
{
|
||||||
GraphicsContext.CurrentContext.EnterBeginRegion();
|
GraphicsContext.CurrentContext.ErrorChecking = false;
|
||||||
#endif
|
#endif
|
||||||
Delegates.glBegin((OpenTK.Graphics.BeginMode)mode);
|
Delegates.glBegin((OpenTK.Graphics.BeginMode)mode);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -36110,7 +36110,7 @@ namespace OpenTK.Graphics
|
||||||
#endif
|
#endif
|
||||||
Delegates.glEnd();
|
Delegates.glEnd();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
GraphicsContext.CurrentContext.ExitBeginRegion();
|
GraphicsContext.CurrentContext.ErrorChecking = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ namespace OpenTK.Graphics
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the GraphicsContext that is current in the calling thread.
|
/// Gets the GraphicsContext that is current in the calling thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GraphicsContext CurrentContext
|
public static IGraphicsContext CurrentContext
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -240,29 +240,14 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
#region --- Internal Members ---
|
#region --- Internal Members ---
|
||||||
|
|
||||||
bool inside_begin_region;
|
|
||||||
List<ErrorCode> error_list = new List<ErrorCode>();
|
List<ErrorCode> error_list = new List<ErrorCode>();
|
||||||
|
|
||||||
// Indicates that we entered a GL.Begin() - GL.End() region.
|
|
||||||
[Conditional("DEBUG")]
|
|
||||||
internal void EnterBeginRegion()
|
|
||||||
{
|
|
||||||
inside_begin_region = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indicates that we left a GL.Begin() - GL.End() region.
|
|
||||||
[Conditional("DEBUG")]
|
|
||||||
internal void ExitBeginRegion()
|
|
||||||
{
|
|
||||||
inside_begin_region = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve all OpenGL errors to clear the error list.
|
// Retrieve all OpenGL errors to clear the error list.
|
||||||
// See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html
|
// See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
internal void ResetErrors()
|
internal void ResetErrors()
|
||||||
{
|
{
|
||||||
if (check_errors && !inside_begin_region)
|
if (check_errors)
|
||||||
{
|
{
|
||||||
while (GL.GetError() != ErrorCode.NoError)
|
while (GL.GetError() != ErrorCode.NoError)
|
||||||
{ }
|
{ }
|
||||||
|
@ -273,7 +258,7 @@ namespace OpenTK.Graphics
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
internal void CheckErrors()
|
internal void CheckErrors()
|
||||||
{
|
{
|
||||||
if (check_errors && !inside_begin_region)
|
if (check_errors)
|
||||||
{
|
{
|
||||||
error_list.Clear();
|
error_list.Clear();
|
||||||
ErrorCode error;
|
ErrorCode error;
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace OpenTK.Graphics
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the GraphicsContext that owns this resource.
|
/// Gets the GraphicsContext that owns this resource.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
GraphicsContext Context { get; }
|
IGraphicsContext Context { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Id of this IGraphicsResource.
|
/// Gets the Id of this IGraphicsResource.
|
||||||
|
|
|
@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Graphics
|
namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
GraphicsContext context;
|
IGraphicsContext context;
|
||||||
int id;
|
int id;
|
||||||
int width, height;
|
int width, height;
|
||||||
bool disposed;
|
bool disposed;
|
||||||
|
@ -250,7 +251,7 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
#region IGraphicsResource.Context
|
#region IGraphicsResource.Context
|
||||||
|
|
||||||
GraphicsContext IGraphicsResource.Context { get { return context; } }
|
IGraphicsContext IGraphicsResource.Context { get { return context; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -301,15 +302,17 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
GL.DeleteTexture(id);
|
GL.DeleteTexture(id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("[Warning] {0} leaked.", this);
|
||||||
|
}
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Texture2D()
|
~Texture2D()
|
||||||
{
|
{
|
||||||
GraphicsContext context = (this as IGraphicsResource).Context;
|
Dispose(false);
|
||||||
if (context != null)
|
|
||||||
(context as IGraphicsContextInternal).RegisterForDisposal(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue