mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 16:25:26 +00:00
Moved and renamed OpenTK.GLContext to OpenTK.Graphics.GraphicsContext.
This commit is contained in:
parent
210abb6ab6
commit
5b9991cba3
|
@ -20,7 +20,7 @@ namespace Examples.Tests
|
||||||
{
|
{
|
||||||
public class S01_Call_Performance : IExample
|
public class S01_Call_Performance : IExample
|
||||||
{
|
{
|
||||||
GLContext context;
|
GraphicsContext context;
|
||||||
const int num_calls = 1000000;
|
const int num_calls = 1000000;
|
||||||
float[] v = new float[] { 0.0f, 0.0f };
|
float[] v = new float[] { 0.0f, 0.0f };
|
||||||
public static int dummy_variable = 0;
|
public static int dummy_variable = 0;
|
||||||
|
@ -29,7 +29,7 @@ namespace Examples.Tests
|
||||||
{
|
{
|
||||||
using (Form f = new Form())
|
using (Form f = new Form())
|
||||||
{
|
{
|
||||||
context = new GLContext(new OpenTK.DisplayMode(), new OpenTK.Platform.WindowInfo(f));
|
context = new GraphicsContext(new OpenTK.DisplayMode(), new OpenTK.Platform.WindowInfo(f));
|
||||||
context.CreateContext();
|
context.CreateContext();
|
||||||
|
|
||||||
Trace.WriteLine(String.Format("Number of calls: {0}", num_calls));
|
Trace.WriteLine(String.Format("Number of calls: {0}", num_calls));
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Examples.WinForms
|
||||||
public partial class W03_Extensions : Form
|
public partial class W03_Extensions : Form
|
||||||
{
|
{
|
||||||
//GLControl glControl = new GLControl();
|
//GLControl glControl = new GLControl();
|
||||||
GLContext context;
|
GraphicsContext context;
|
||||||
Type glClass;
|
Type glClass;
|
||||||
Type delegatesClass;
|
Type delegatesClass;
|
||||||
Type importsClass;
|
Type importsClass;
|
||||||
|
@ -48,7 +48,7 @@ namespace Examples.WinForms
|
||||||
{
|
{
|
||||||
Application.Idle -= StartAsync;
|
Application.Idle -= StartAsync;
|
||||||
|
|
||||||
context = new GLContext(new DisplayMode(), new OpenTK.Platform.WindowInfo(this));
|
context = new GraphicsContext(new DisplayMode(), new OpenTK.Platform.WindowInfo(this));
|
||||||
context.CreateContext();
|
context.CreateContext();
|
||||||
|
|
||||||
//while (!glControl.Created)
|
//while (!glControl.Created)
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace OpenTK
|
||||||
#region public class ContextExistsException : ApplicationException
|
#region public class ContextExistsException : ApplicationException
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This exception is thrown when a GLContext property cannot be changed after creation.
|
/// This exception is thrown when a GraphicsContext property cannot be changed after creation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ContextExistsException : ApplicationException
|
public class ContextExistsException : ApplicationException
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace OpenTK
|
||||||
#region public IGraphicsContext Context
|
#region public IGraphicsContext Context
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an interface to the underlying GLContext used by this GLControl.
|
/// Gets an interface to the underlying GraphicsContext used by this GLControl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public IGraphicsContext Context
|
public IGraphicsContext Context
|
||||||
|
@ -145,10 +145,10 @@ namespace OpenTK
|
||||||
// TODO: Remove for 0.3.15
|
// TODO: Remove for 0.3.15
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the DisplayMode of the GLContext attached to this GLControl.
|
/// Gets the DisplayMode of the GraphicsContext attached to this GLControl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// You cannot change the DisplayMode of an existing GLContext.
|
/// You cannot change the DisplayMode of an existing GraphicsContext.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public DisplayMode Mode
|
public DisplayMode Mode
|
||||||
{
|
{
|
||||||
|
@ -189,7 +189,7 @@ namespace OpenTK
|
||||||
#region public void CreateContext()
|
#region public void CreateContext()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a GLContext and attaches it to this GLControl.
|
/// Creates a GraphicsContext and attaches it to this GLControl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateContext()
|
public void CreateContext()
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ namespace OpenTK
|
||||||
// have a different colordepth from the parent. To combat this, we do not set a
|
// have a different colordepth from the parent. To combat this, we do not set a
|
||||||
// specific depth for the DisplayMode - we let the driver select one instead.
|
// specific depth for the DisplayMode - we let the driver select one instead.
|
||||||
//display_mode.ColorFormat = new ColorMode(0);
|
//display_mode.ColorFormat = new ColorMode(0);
|
||||||
context = new GLContext(display_mode, info);
|
context = new GraphicsContext(display_mode, info);
|
||||||
idle = new PlatformIdle(info);
|
idle = new PlatformIdle(info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -218,9 +218,9 @@ namespace OpenTK
|
||||||
#region public void DestroyContext()
|
#region public void DestroyContext()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Destroys the GLContext attached to this GLControl.
|
/// Destroys the GraphicsContext attached to this GLControl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="NullReferenceException">Occurs when no GLContext is attached.</exception>
|
/// <exception cref="NullReferenceException">Occurs when no GraphicsContext is attached.</exception>
|
||||||
public void DestroyContext()
|
public void DestroyContext()
|
||||||
{
|
{
|
||||||
Context.Dispose();
|
Context.Dispose();
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace OpenTK
|
||||||
|
|
||||||
glWindow.Destroy += glWindow_Destroy;
|
glWindow.Destroy += glWindow_Destroy;
|
||||||
|
|
||||||
// TODO: GLContext is created inside this call.
|
// TODO: GraphicsContext is created inside this call.
|
||||||
glWindow.CreateWindow(width, height, format, out glContext);
|
glWindow.CreateWindow(width, height, format, out glContext);
|
||||||
this.Title = title;
|
this.Title = title;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace OpenTK.Graphics
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents and provides methods to manipulate an OpenGL render context.
|
/// Represents and provides methods to manipulate an OpenGL render context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class GLContext : IGraphicsContext, IGLContextInternal, IGLContextCreationHack
|
public sealed class GraphicsContext : IGraphicsContext, IGLContextInternal, IGLContextCreationHack
|
||||||
{
|
{
|
||||||
IGraphicsContext implementation; // The actual render context implementation for the underlying platform.
|
IGraphicsContext implementation; // The actual render context implementation for the underlying platform.
|
||||||
List<IDisposable> dispose_queue = new List<IDisposable>();
|
List<IDisposable> dispose_queue = new List<IDisposable>();
|
||||||
|
@ -26,14 +26,14 @@ namespace OpenTK.Graphics
|
||||||
static Dictionary<ContextHandle, WeakReference> available_contexts =
|
static Dictionary<ContextHandle, WeakReference> available_contexts =
|
||||||
new Dictionary<ContextHandle, WeakReference>(); // Contains all available OpenGL contexts.
|
new Dictionary<ContextHandle, WeakReference>(); // Contains all available OpenGL contexts.
|
||||||
|
|
||||||
#region public GLContext(DisplayMode mode, IWindowInfo window)
|
#region public GraphicsContext(DisplayMode mode, IWindowInfo window)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new GLContext with the specified DisplayMode, and bound to the specified IWindowInfo.
|
/// Constructs a new GraphicsContext with the specified DisplayMode, and bound to the specified IWindowInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mode"></param>
|
/// <param name="mode"></param>
|
||||||
/// <param name="window"></param>
|
/// <param name="window"></param>
|
||||||
public GLContext(DisplayMode mode, IWindowInfo window)
|
public GraphicsContext(DisplayMode mode, IWindowInfo window)
|
||||||
{
|
{
|
||||||
//if (available_contexts.Count == 0)
|
//if (available_contexts.Count == 0)
|
||||||
// available_contexts.Add(IntPtr.Zero, new WeakReference(null));
|
// available_contexts.Add(IntPtr.Zero, new WeakReference(null));
|
||||||
|
@ -58,14 +58,14 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
(this as IGLContextCreationHack).SetWindowHandle(window.Handle);
|
(this as IGLContextCreationHack).SetWindowHandle(window.Handle);
|
||||||
(this as IGLContextCreationHack).SelectDisplayMode(mode, window);
|
(this as IGLContextCreationHack).SelectDisplayMode(mode, window);
|
||||||
if (GLContext.ShareContexts)
|
if (GraphicsContext.ShareContexts)
|
||||||
{
|
{
|
||||||
lock (context_lock)
|
lock (context_lock)
|
||||||
{
|
{
|
||||||
// A small hack to create a shared context with the first available context.
|
// A small hack to create a shared context with the first available context.
|
||||||
foreach (WeakReference r in GLContext.available_contexts.Values)
|
foreach (WeakReference r in GraphicsContext.available_contexts.Values)
|
||||||
{
|
{
|
||||||
this.CreateContext(true, (GLContext)r.Target);
|
this.CreateContext(true, (GraphicsContext)r.Target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,15 +102,15 @@ namespace OpenTK.Graphics
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the current GraphicsContext in the calling thread.
|
/// Gets or sets the current GraphicsContext in the calling thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GLContext CurrentContext
|
public static GraphicsContext CurrentContext
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (available_contexts.Count > 0)
|
if (available_contexts.Count > 0)
|
||||||
return (GLContext)available_contexts[GetCurrentContext()].Target;
|
return (GraphicsContext)available_contexts[GetCurrentContext()].Target;
|
||||||
//return (GLContext)available_contexts[((IGLContextInternal)available_contexts[IntPtr.Zero].Target).GetCurrentContext()].Target;
|
//return (GraphicsContext)available_contexts[((IGLContextInternal)available_contexts[IntPtr.Zero].Target).GetCurrentContext()].Target;
|
||||||
return null;
|
return null;
|
||||||
//return (GLContext)available_contexts[StaticGetCurrentContext().ToInt64()].Target;
|
//return (GraphicsContext)available_contexts[StaticGetCurrentContext().ToInt64()].Target;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -334,7 +334,7 @@ namespace OpenTK.Graphics
|
||||||
#region --- IDisposable Members ---
|
#region --- IDisposable Members ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes of the GLContext.
|
/// Disposes of the GraphicsContext.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -355,7 +355,7 @@ namespace OpenTK.Graphics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~GLContext()
|
~GraphicsContext()
|
||||||
{
|
{
|
||||||
this.Dispose(false);
|
this.Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,8 +192,8 @@ namespace OpenTK.OpenGL
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static void LoadAll()
|
public static void LoadAll()
|
||||||
{
|
{
|
||||||
//TODO: Route GameWindow context creation through GLContext.
|
//TODO: Route GameWindow context creation through GraphicsContext.
|
||||||
//if (GLContext.CurrentContext == null)
|
//if (GraphicsContext.CurrentContext == null)
|
||||||
// throw new InvalidOperationException("You must create an OpenGL context before using the GL class.");
|
// throw new InvalidOperationException("You must create an OpenGL context before using the GL class.");
|
||||||
|
|
||||||
OpenTK.Platform.Utilities.LoadExtensions(glClass);
|
OpenTK.Platform.Utilities.LoadExtensions(glClass);
|
||||||
|
|
|
@ -46,12 +46,12 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
public void RegisterForDisposal(IDisposable resource)
|
public void RegisterForDisposal(IDisposable resource)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Use the general GLContext class instead.");
|
throw new NotImplementedException("Use the general GraphicsContext class instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeResources()
|
public void DisposeResources()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Use the general GLContext class instead.");
|
throw new NotImplementedException("Use the general GraphicsContext class instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetAddress(string function) { return IntPtr.Zero; }
|
public IntPtr GetAddress(string function) { return IntPtr.Zero; }
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace OpenTK.Platform.Windows
|
||||||
static WinGLContext()
|
static WinGLContext()
|
||||||
{
|
{
|
||||||
// Set the GetCurrentContext implementation.
|
// Set the GetCurrentContext implementation.
|
||||||
if (GLContext.GetCurrentContext == null)
|
if (GraphicsContext.GetCurrentContext == null)
|
||||||
GLContext.GetCurrentContext = WinGLContext.GetCurrentContext;
|
GraphicsContext.GetCurrentContext = WinGLContext.GetCurrentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WinGLContext()
|
public WinGLContext()
|
||||||
|
@ -218,7 +218,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
void IGLContextInternal.RegisterForDisposal(IDisposable resource)
|
void IGLContextInternal.RegisterForDisposal(IDisposable resource)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Use OpenTK.GLContext instead.");
|
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -227,7 +227,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
void IGLContextInternal.DisposeResources()
|
void IGLContextInternal.DisposeResources()
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Use OpenTK.GLContext instead.");
|
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -367,7 +367,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
Functions.SetWindowPos(this.Handle, WindowPlacementOptions.TOP, Left, Top, cp.Width, cp.Height, SetWindowPosFlags.SHOWWINDOW);
|
Functions.SetWindowPos(this.Handle, WindowPlacementOptions.TOP, Left, Top, cp.Width, cp.Height, SetWindowPosFlags.SHOWWINDOW);
|
||||||
|
|
||||||
//context = new GLContext(mode, window);
|
//context = new GraphicsContext(mode, window);
|
||||||
//context.CreateContext();
|
//context.CreateContext();
|
||||||
|
|
||||||
context = new WinGLContext();
|
context = new WinGLContext();
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace OpenTK.Platform.X11
|
||||||
static X11GLContext()
|
static X11GLContext()
|
||||||
{
|
{
|
||||||
// Set the GetCurrentContext implementation.
|
// Set the GetCurrentContext implementation.
|
||||||
if (GLContext.GetCurrentContext == null)
|
if (GraphicsContext.GetCurrentContext == null)
|
||||||
GLContext.GetCurrentContext = X11GLContext.GetCurrentContext;
|
GraphicsContext.GetCurrentContext = X11GLContext.GetCurrentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <private />
|
/// <private />
|
||||||
|
@ -302,12 +302,12 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
public void RegisterForDisposal(IDisposable resource)
|
public void RegisterForDisposal(IDisposable resource)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Use OpenTK.GLContext instead.");
|
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeResources()
|
public void DisposeResources()
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Use OpenTK.GLContext instead.");
|
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<DisplayMode> GetDisplayModes()
|
public IEnumerable<DisplayMode> GetDisplayModes()
|
||||||
|
|
|
@ -405,8 +405,8 @@ namespace OpenTK.Platform.X11
|
||||||
glContext = new X11GLContext();
|
glContext = new X11GLContext();
|
||||||
(glContext as IGLContextCreationHack).SelectDisplayMode(mode, window);
|
(glContext as IGLContextCreationHack).SelectDisplayMode(mode, window);
|
||||||
if (glContext == null)
|
if (glContext == null)
|
||||||
throw new ApplicationException("Could not create GLContext");
|
throw new ApplicationException("Could not create GraphicsContext");
|
||||||
Debug.Print("Created GLContext");
|
Debug.Print("Created GraphicsContext");
|
||||||
window.VisualInfo = ((X11.WindowInfo)((IGLContextInternal)glContext).Info).VisualInfo;
|
window.VisualInfo = ((X11.WindowInfo)((IGLContextInternal)glContext).Info).VisualInfo;
|
||||||
//window.VisualInfo = Marshal.PtrToStructure(Glx.ChooseVisual(window.Display, window.Screen,
|
//window.VisualInfo = Marshal.PtrToStructure(Glx.ChooseVisual(window.Display, window.Screen,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue