mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-23 19:51:17 +00:00
Added new GLControl constructors that allow you specify the desired GraphicsContext (OpenGL) version and flags.
This commit is contained in:
parent
d43123f219
commit
4e5d758fa1
|
@ -30,8 +30,10 @@ namespace OpenTK
|
||||||
IGLControl implementation;
|
IGLControl implementation;
|
||||||
GraphicsMode format;
|
GraphicsMode format;
|
||||||
IWindowInfo window_info;
|
IWindowInfo window_info;
|
||||||
|
int major, minor;
|
||||||
|
GraphicsContextFlags flags;
|
||||||
|
|
||||||
#region --- Constructor ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new GLControl.
|
/// Constructs a new GLControl.
|
||||||
|
@ -40,18 +42,22 @@ namespace OpenTK
|
||||||
: this(GraphicsMode.Default)
|
: this(GraphicsMode.Default)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>This method is obsolete and will be removed in future versions.</summary>
|
/// <summary>
|
||||||
/// <param name="mode">Obsolete.</param>
|
/// Constructs a new GLControl with the specified GraphicsMode.
|
||||||
[Obsolete]
|
/// </summary>
|
||||||
public GLControl(DisplayMode mode)
|
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the control.</param>
|
||||||
: this(mode.ToGraphicsMode())
|
public GLControl(GraphicsMode mode)
|
||||||
|
: this(mode, 1, 0, GraphicsContextFlags.Default)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new GLControl with the specified GraphicsMode.
|
/// Constructs a new GLControl with the specified GraphicsMode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the control.</param>
|
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the control.</param>
|
||||||
public GLControl(GraphicsMode mode)
|
/// <param name="major">The major version for the OpenGL GraphicsContext.</param>
|
||||||
|
/// <param name="major">The minor version for the OpenGL GraphicsContext.</param>
|
||||||
|
/// <param name="major">The GraphicsContextFlags for the OpenGL GraphicsContext.</param>
|
||||||
|
public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
SetStyle(ControlStyles.Opaque, true);
|
SetStyle(ControlStyles.Opaque, true);
|
||||||
SetStyle(ControlStyles.UserPaint, true);
|
SetStyle(ControlStyles.UserPaint, true);
|
||||||
|
@ -61,6 +67,9 @@ namespace OpenTK
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.format = mode;
|
this.format = mode;
|
||||||
|
this.major = major;
|
||||||
|
this.minor = minor;
|
||||||
|
this.flags = flags;
|
||||||
|
|
||||||
// On Windows, you first need to create the window, then set the pixel format.
|
// On Windows, you first need to create the window, then set the pixel format.
|
||||||
// On X11, you first need to select the visual, then create the window.
|
// On X11, you first need to select the visual, then create the window.
|
||||||
|
@ -77,22 +86,18 @@ namespace OpenTK
|
||||||
this.CreateControl();
|
this.CreateControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Obsolete
|
||||||
|
|
||||||
|
/// <summary>This method is obsolete and will be removed in future versions.</summary>
|
||||||
|
/// <param name="mode">Obsolete.</param>v
|
||||||
|
[Obsolete]
|
||||||
|
public GLControl(DisplayMode mode)
|
||||||
|
: this(mode.ToGraphicsMode())
|
||||||
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected override void OnResize(EventArgs e)
|
#endregion
|
||||||
{
|
|
||||||
if (context != null)
|
|
||||||
context.Update(window_info);
|
|
||||||
|
|
||||||
base.OnResize(e);
|
|
||||||
}
|
|
||||||
protected override void OnParentChanged(EventArgs e)
|
|
||||||
{
|
|
||||||
if (context != null)
|
|
||||||
context.Update(window_info);
|
|
||||||
|
|
||||||
base.OnParentChanged(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region --- Protected Methods ---
|
#region --- Protected Methods ---
|
||||||
|
|
||||||
|
@ -102,7 +107,7 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
base.OnHandleCreated(e);
|
base.OnHandleCreated(e);
|
||||||
|
|
||||||
this.Context = implementation.CreateContext();
|
this.Context = implementation.CreateContext(major, minor, flags);
|
||||||
|
|
||||||
this.window_info = implementation.WindowInfo;
|
this.window_info = implementation.WindowInfo;
|
||||||
this.MakeCurrent();
|
this.MakeCurrent();
|
||||||
|
@ -133,6 +138,30 @@ namespace OpenTK
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the Resize event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A System.EventArgs that contains the event data.</param>
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
if (context != null)
|
||||||
|
context.Update(window_info);
|
||||||
|
|
||||||
|
base.OnResize(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the ParentChanged event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A System.EventArgs that contains the event data.</param>
|
||||||
|
protected override void OnParentChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
if (context != null)
|
||||||
|
context.Update(window_info);
|
||||||
|
|
||||||
|
base.OnParentChanged(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Public Methods ---
|
#region --- Public Methods ---
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace OpenTK.Platform.Dummy
|
||||||
{
|
{
|
||||||
#region IGLControl Members
|
#region IGLControl Members
|
||||||
|
|
||||||
public OpenTK.Graphics.GraphicsContext CreateContext()
|
public OpenTK.Graphics.GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
return new GraphicsContext(null, null);
|
return new GraphicsContext(null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
internal interface IGLControl
|
internal interface IGLControl
|
||||||
{
|
{
|
||||||
GraphicsContext CreateContext();
|
GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags);
|
||||||
bool IsIdle { get; }
|
bool IsIdle { get; }
|
||||||
IWindowInfo WindowInfo { get; }
|
IWindowInfo WindowInfo { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
#region IGLControl Members
|
#region IGLControl Members
|
||||||
|
|
||||||
public OpenTK.Graphics.GraphicsContext CreateContext()
|
public OpenTK.Graphics.GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
return new GraphicsContext(mode, WindowInfo);
|
return new GraphicsContext(mode, WindowInfo, major, minor, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this
|
// TODO: Fix this
|
||||||
|
|
|
@ -29,10 +29,10 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region --- IGLControl Members ---
|
#region --- IGLControl Members ---
|
||||||
|
|
||||||
public GraphicsContext CreateContext()
|
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
WinWindowInfo window = new WinWindowInfo(control.Handle, null);
|
WinWindowInfo window = new WinWindowInfo(control.Handle, null);
|
||||||
return new GraphicsContext(mode, window);
|
return new GraphicsContext(mode, window, major, minor, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIdle
|
public bool IsIdle
|
||||||
|
|
|
@ -44,9 +44,9 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#region --- IGLControl Members ---
|
#region --- IGLControl Members ---
|
||||||
|
|
||||||
public GraphicsContext CreateContext()
|
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
return new GraphicsContext(mode, this.WindowInfo);
|
return new GraphicsContext(mode, this.WindowInfo, major, minor, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIdle
|
public bool IsIdle
|
||||||
|
|
Loading…
Reference in a new issue