mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 16:35:36 +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
|
||||
|
||||
public ErrorHelper(GraphicsContext context)
|
||||
public ErrorHelper(IGraphicsContext context)
|
||||
{
|
||||
if (context == null)
|
||||
throw new GraphicsContextMissingException();
|
||||
|
||||
Context = context;
|
||||
Context = (GraphicsContext)context;
|
||||
Context.ResetErrors();
|
||||
}
|
||||
|
||||
|
|
|
@ -24592,7 +24592,7 @@ namespace OpenTK.Graphics
|
|||
#if DEBUG
|
||||
using (new ErrorHelper(GraphicsContext.CurrentContext))
|
||||
{
|
||||
GraphicsContext.CurrentContext.EnterBeginRegion();
|
||||
GraphicsContext.CurrentContext.ErrorChecking = false;
|
||||
#endif
|
||||
Delegates.glBegin((OpenTK.Graphics.BeginMode)mode);
|
||||
#if DEBUG
|
||||
|
@ -36110,7 +36110,7 @@ namespace OpenTK.Graphics
|
|||
#endif
|
||||
Delegates.glEnd();
|
||||
#if DEBUG
|
||||
GraphicsContext.CurrentContext.ExitBeginRegion();
|
||||
GraphicsContext.CurrentContext.ErrorChecking = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ namespace OpenTK.Graphics
|
|||
/// <summary>
|
||||
/// Gets the GraphicsContext that is current in the calling thread.
|
||||
/// </summary>
|
||||
public static GraphicsContext CurrentContext
|
||||
public static IGraphicsContext CurrentContext
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -240,29 +240,14 @@ namespace OpenTK.Graphics
|
|||
|
||||
#region --- Internal Members ---
|
||||
|
||||
bool inside_begin_region;
|
||||
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.
|
||||
// See http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html
|
||||
[Conditional("DEBUG")]
|
||||
internal void ResetErrors()
|
||||
{
|
||||
if (check_errors && !inside_begin_region)
|
||||
if (check_errors)
|
||||
{
|
||||
while (GL.GetError() != ErrorCode.NoError)
|
||||
{ }
|
||||
|
@ -273,7 +258,7 @@ namespace OpenTK.Graphics
|
|||
[Conditional("DEBUG")]
|
||||
internal void CheckErrors()
|
||||
{
|
||||
if (check_errors && !inside_begin_region)
|
||||
if (check_errors)
|
||||
{
|
||||
error_list.Clear();
|
||||
ErrorCode error;
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace OpenTK.Graphics
|
|||
/// <summary>
|
||||
/// Gets the GraphicsContext that owns this resource.
|
||||
/// </summary>
|
||||
GraphicsContext Context { get; }
|
||||
IGraphicsContext Context { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of this IGraphicsResource.
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace OpenTK.Graphics
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ namespace OpenTK.Graphics
|
|||
{
|
||||
#region Fields
|
||||
|
||||
GraphicsContext context;
|
||||
IGraphicsContext context;
|
||||
int id;
|
||||
int width, height;
|
||||
bool disposed;
|
||||
|
@ -250,7 +251,7 @@ namespace OpenTK.Graphics
|
|||
|
||||
#region IGraphicsResource.Context
|
||||
|
||||
GraphicsContext IGraphicsResource.Context { get { return context; } }
|
||||
IGraphicsContext IGraphicsResource.Context { get { return context; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -301,15 +302,17 @@ namespace OpenTK.Graphics
|
|||
{
|
||||
GL.DeleteTexture(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Print("[Warning] {0} leaked.", this);
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~Texture2D()
|
||||
{
|
||||
GraphicsContext context = (this as IGraphicsResource).Context;
|
||||
if (context != null)
|
||||
(context as IGraphicsContextInternal).RegisterForDisposal(this);
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue