mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 07:15:38 +00:00
Added new GameWindow constructors that specify the desired GraphicsContext (OpenGL) version and flags.
This commit is contained in:
parent
9981b92e5a
commit
0759beaebf
|
@ -149,6 +149,25 @@ namespace OpenTK
|
||||||
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
|
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
|
||||||
/// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
|
/// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
|
||||||
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device)
|
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device)
|
||||||
|
: this(width, height, mode, title, options, device, 1, 0, GraphicsContextFlags.Default)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags)
|
||||||
|
|
||||||
|
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
|
||||||
|
/// <param name="width">The width of the GameWindow in pixels.</param>
|
||||||
|
/// <param name="height">The height of the GameWindow in pixels.</param>
|
||||||
|
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
|
||||||
|
/// <param name="title">The title of the GameWindow.</param>
|
||||||
|
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
|
||||||
|
/// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
|
||||||
|
/// <param name="major">The major version for the OpenGL GraphicsContext.</param>
|
||||||
|
/// <param name="major">The minor version for the OpenGL GraphicsContext.</param>
|
||||||
|
/// <param name="flags">The GraphicsContextFlags version for the OpenGL GraphicsContext.</param>
|
||||||
|
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device,
|
||||||
|
int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
||||||
if (height <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
if (height <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
||||||
|
@ -162,7 +181,7 @@ namespace OpenTK
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
glWindow.CreateWindow(width, height, mode, out glContext);
|
glWindow.CreateWindow(width, height, mode, major, minor, flags, out glContext);
|
||||||
glContext.MakeCurrent(this.WindowInfo);
|
glContext.MakeCurrent(this.WindowInfo);
|
||||||
(glContext as IGraphicsContextInternal).LoadAll();
|
(glContext as IGraphicsContextInternal).LoadAll();
|
||||||
}
|
}
|
||||||
|
@ -184,20 +203,13 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
|
|
||||||
this.VSync = VSyncMode.On; //VSyncMode.Adaptive;
|
this.VSync = VSyncMode.On; //VSyncMode.Adaptive;
|
||||||
glWindow.Resize += new ResizeEvent(glWindow_Resize);
|
glWindow.Resize += delegate(object sender, ResizeEventArgs e) { OnResizeInternal(e); };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void glWindow_Resize(object sender, ResizeEventArgs e)
|
|
||||||
{
|
|
||||||
Debug.Print("glWindow_Resize event fired.");
|
|
||||||
|
|
||||||
OnResizeInternal(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Obsolete
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -218,6 +230,8 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region --- Private Methods ---
|
#region --- Private Methods ---
|
||||||
|
|
||||||
#region void glWindow_Destroy(object sender, EventArgs e)
|
#region void glWindow_Destroy(object sender, EventArgs e)
|
||||||
|
|
|
@ -15,12 +15,9 @@ using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace OpenTK.Platform
|
namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// This interface supports OpenTK, and is not intended for use by OpenTK programs.
|
|
||||||
/// </summary>
|
|
||||||
internal interface INativeGLWindow : IResizable, IDisposable
|
internal interface INativeGLWindow : IResizable, IDisposable
|
||||||
{
|
{
|
||||||
void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context);
|
void CreateWindow(int width, int height, GraphicsMode mode, int major, int minor, GraphicsContextFlags flags, out IGraphicsContext context);
|
||||||
void DestroyWindow();
|
void DestroyWindow();
|
||||||
void ProcessEvents();
|
void ProcessEvents();
|
||||||
void PointToClient(ref System.Drawing.Point p);
|
void PointToClient(ref System.Drawing.Point p);
|
||||||
|
@ -32,9 +29,7 @@ namespace OpenTK.Platform
|
||||||
string Title { get; set; }
|
string Title { get; set; }
|
||||||
bool Visible { get; set; }
|
bool Visible { get; set; }
|
||||||
bool IsIdle { get; }
|
bool IsIdle { get; }
|
||||||
//IGraphicsContext Context { get; }
|
|
||||||
IInputDriver InputDriver { get; }
|
IInputDriver InputDriver { get; }
|
||||||
//bool Fullscreen { get; set; }
|
|
||||||
WindowState WindowState { get; set; }
|
WindowState WindowState { get; set; }
|
||||||
WindowBorder WindowBorder { get; set; }
|
WindowBorder WindowBorder { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -574,14 +574,14 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
#region INativeGLWindow Members
|
#region INativeGLWindow Members
|
||||||
|
|
||||||
public void CreateWindow(int width, int height, OpenTK.Graphics.GraphicsMode mode, out OpenTK.Graphics.IGraphicsContext context)
|
public void CreateWindow(int width, int height, OpenTK.Graphics.GraphicsMode mode, int major, int minor, GraphicsContextFlags flags, out OpenTK.Graphics.IGraphicsContext context)
|
||||||
{
|
{
|
||||||
Rect r = new Rect(0, 0, (short)width, (short)height);
|
Rect r = new Rect(0, 0, (short)width, (short)height);
|
||||||
CreateNativeWindow(mWindowClass, mWindowAttrib, r);
|
CreateNativeWindow(mWindowClass, mWindowAttrib, r);
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
this.context = new Graphics.GraphicsContext(mode, window);
|
this.context = new Graphics.GraphicsContext(mode, window, major, minor, flags);
|
||||||
this.context.MakeCurrent(window);
|
this.context.MakeCurrent(window);
|
||||||
|
|
||||||
context = this.context;
|
context = this.context;
|
||||||
|
|
|
@ -311,7 +311,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region public void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context)
|
#region public void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context)
|
||||||
|
|
||||||
public void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context)
|
public void CreateWindow(int width, int height, GraphicsMode mode, int major, int minor, GraphicsContextFlags flags, out IGraphicsContext context)
|
||||||
{
|
{
|
||||||
Debug.Print("Creating native window.");
|
Debug.Print("Creating native window.");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
@ -370,7 +370,7 @@ namespace OpenTK.Platform.Windows
|
||||||
Functions.SetWindowPos(this.Handle, IntPtr.Zero, Left, Top, rect.right - rect.left,
|
Functions.SetWindowPos(this.Handle, IntPtr.Zero, Left, Top, rect.right - rect.left,
|
||||||
rect.bottom - rect.top, SetWindowPosFlags.SHOWWINDOW);
|
rect.bottom - rect.top, SetWindowPosFlags.SHOWWINDOW);
|
||||||
|
|
||||||
context = new GraphicsContext(mode, window);
|
context = new GraphicsContext(mode, window, major, minor, flags);
|
||||||
|
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
|
|
||||||
|
|
|
@ -199,9 +199,9 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#region --- INativeGLWindow Members ---
|
#region --- INativeGLWindow Members ---
|
||||||
|
|
||||||
#region public void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context)
|
#region CreateWindow
|
||||||
|
|
||||||
public void CreateWindow(int width, int height, GraphicsMode mode, out IGraphicsContext context)
|
public void CreateWindow(int width, int height, GraphicsMode mode, int major, int minor, GraphicsContextFlags flags, out IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
|
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
|
||||||
if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");
|
if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");
|
||||||
|
@ -244,7 +244,7 @@ namespace OpenTK.Platform.X11
|
||||||
//XVisualInfo vis = window.VisualInfo;
|
//XVisualInfo vis = window.VisualInfo;
|
||||||
//Glx.CreateContext(window.Display, ref vis, IntPtr.Zero, true);
|
//Glx.CreateContext(window.Display, ref vis, IntPtr.Zero, true);
|
||||||
}
|
}
|
||||||
context = new GraphicsContext(mode, window);
|
context = new GraphicsContext(mode, window, major, minor, flags);
|
||||||
|
|
||||||
// Set the window hints
|
// Set the window hints
|
||||||
SetWindowMinMax(_min_width, _min_height, -1, -1);
|
SetWindowMinMax(_min_width, _min_height, -1, -1);
|
||||||
|
|
Loading…
Reference in a new issue