mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-05-11 19:22:14 +00:00
Add overload to OpenTK.Platform.Utilities.CreateGraphicsContext which takes version number and flag parameters. Deprecate old CreateGraphicsContext methods.
This commit is contained in:
parent
2f54b29ed8
commit
043421c7bc
|
@ -89,7 +89,7 @@ namespace OpenTK.Platform
|
||||||
throw new InvalidOperationException(type.ToString() + " does not contain a static LoadDelegate method.");
|
throw new InvalidOperationException(type.ToString() + " does not contain a static LoadDelegate method.");
|
||||||
LoadDelegateFunction LoadDelegate = (LoadDelegateFunction)Delegate.CreateDelegate(
|
LoadDelegateFunction LoadDelegate = (LoadDelegateFunction)Delegate.CreateDelegate(
|
||||||
typeof(LoadDelegateFunction), load_delegate_method_info);
|
typeof(LoadDelegateFunction), load_delegate_method_info);
|
||||||
|
|
||||||
Debug.Write("Load extensions for " + type.ToString() + "... ");
|
Debug.Write("Load extensions for " + type.ToString() + "... ");
|
||||||
|
|
||||||
System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
|
System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
|
||||||
|
@ -214,36 +214,65 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Creating an Graphics Context ---
|
#region --- Creating a Graphics Context ---
|
||||||
#region --- CreateWindowInfo ---
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// Creates a Graphics context and for a window or control.
|
||||||
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="mode"></param>
|
||||||
|
///
|
||||||
|
/// <param name="major">Major version number of OpenGL context to create.</param>
|
||||||
|
/// <param name="minor">Minor version number of OpenGL context to create.</param>
|
||||||
|
/// <param name="flags"></param>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
public static Graphics.GraphicsContext CreateGraphicsContext(
|
||||||
|
Graphics.GraphicsMode mode, IWindowInfo info,
|
||||||
|
int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags)
|
||||||
|
{
|
||||||
|
Graphics.GraphicsContext context = new Graphics.GraphicsContext(mode, info, major, minor, flags);
|
||||||
|
context.MakeCurrent(info);
|
||||||
|
|
||||||
|
(context as OpenTK.Graphics.IGraphicsContextInternal).LoadAll();
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
||||||
|
/// </summary>
|
||||||
/// <param name="cntrl"></param>
|
/// <param name="cntrl"></param>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
/// <param name="mode"></param>
|
/// <param name="mode"></param>
|
||||||
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, Control cntrl, out Graphics.GraphicsContext context, out IWindowInfo info)
|
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
||||||
{
|
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, Control cntrl,
|
||||||
CreateGraphicsContext(mode, cntrl.Handle, out context, out info);
|
out Graphics.GraphicsContext context, out IWindowInfo info)
|
||||||
}
|
{
|
||||||
/// <summary>
|
CreateGraphicsContext(mode, cntrl.Handle, out context, out info);
|
||||||
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
}
|
||||||
/// </summary>
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
||||||
|
/// </summary>
|
||||||
/// <param name="cntrlHandle"></param>
|
/// <param name="cntrlHandle"></param>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
/// <param name="mode"></param>
|
/// <param name="mode"></param>
|
||||||
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, IntPtr cntrlHandle, out Graphics.GraphicsContext context, out IWindowInfo info)
|
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
||||||
{
|
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, IntPtr cntrlHandle,
|
||||||
info = CreateWindowInfo(mode, cntrlHandle);
|
out Graphics.GraphicsContext context, out IWindowInfo info)
|
||||||
|
{
|
||||||
|
info = CreateWindowInfo(mode, cntrlHandle);
|
||||||
|
|
||||||
context = new Graphics.GraphicsContext(mode, info);
|
context = new Graphics.GraphicsContext(mode, info);
|
||||||
context.MakeCurrent(info);
|
context.MakeCurrent(info);
|
||||||
|
|
||||||
(context as OpenTK.Graphics.IGraphicsContextInternal).LoadAll();
|
(context as OpenTK.Graphics.IGraphicsContextInternal).LoadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region --- CreateWindowInfo ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an object which implements the IWindowInfo interface for the platform
|
/// Creates an object which implements the IWindowInfo interface for the platform
|
||||||
/// currently running on. This will create a handle for the control, so it is not
|
/// currently running on. This will create a handle for the control, so it is not
|
||||||
|
@ -296,12 +325,12 @@ namespace OpenTK.Platform
|
||||||
info.visualid = mode.Index;
|
info.visualid = mode.Index;
|
||||||
int dummy;
|
int dummy;
|
||||||
window.VisualInfo = (Platform.X11.XVisualInfo)Marshal.PtrToStructure(
|
window.VisualInfo = (Platform.X11.XVisualInfo)Marshal.PtrToStructure(
|
||||||
Platform.X11.Functions.XGetVisualInfo(window.Display, Platform.X11.XVisualInfoMask.ID,
|
Platform.X11.Functions.XGetVisualInfo(window.Display, Platform.X11.XVisualInfoMask.ID,
|
||||||
ref info, out dummy), typeof(Platform.X11.XVisualInfo));
|
ref info, out dummy), typeof(Platform.X11.XVisualInfo));
|
||||||
|
|
||||||
// set the X11 colormap.
|
// set the X11 colormap.
|
||||||
SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.visual);
|
SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.visual);
|
||||||
SetStaticFieldValue(xplatui, "CustomColormap",
|
SetStaticFieldValue(xplatui, "CustomColormap",
|
||||||
Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.visual, 0));
|
Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.visual, 0));
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
|
Loading…
Reference in a new issue