mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-03 09:41:07 +00:00
GameWindow constructor now creates a window. Made CreateWindow private. Added InputDriver.
This commit is contained in:
parent
91b52b5143
commit
6559df8533
|
@ -51,6 +51,8 @@ namespace OpenTK
|
||||||
int width, height;
|
int width, height;
|
||||||
VSyncMode vsync;
|
VSyncMode vsync;
|
||||||
|
|
||||||
|
InputDriver input_driver;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Internal Properties ---
|
#region --- Internal Properties ---
|
||||||
|
@ -65,9 +67,22 @@ namespace OpenTK
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new GameWindow. Call CreateWindow() to open a render window.
|
/// Constructs a new GameWindow using a safe DisplayMode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GameWindow()
|
public GameWindow() : this(new DisplayMode(640, 480, 0, 16, false), "OpenTK game window") { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||||
|
public GameWindow(DisplayMode mode) : this(mode, "OpenTK game window") { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new GameWindow with the specified title, and opens a render window with the specified DisplayMode.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||||
|
/// <param name="title">The Title of the GameWindow.</param>
|
||||||
|
public GameWindow(DisplayMode mode, string title)
|
||||||
{
|
{
|
||||||
switch (Environment.OSVersion.Platform)
|
switch (Environment.OSVersion.Platform)
|
||||||
{
|
{
|
||||||
|
@ -87,43 +102,18 @@ namespace OpenTK
|
||||||
throw new PlatformNotSupportedException("Your platform is not supported currently. Please, refer to http://opentk.sourceforge.net for more information.");
|
throw new PlatformNotSupportedException("Your platform is not supported currently. Please, refer to http://opentk.sourceforge.net for more information.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//glWindow.Resize += new ResizeEvent(glWindow_Resize);
|
|
||||||
glWindow.Destroy += new DestroyEvent(glWindow_Destroy);
|
glWindow.Destroy += new DestroyEvent(glWindow_Destroy);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
|
||||||
public GameWindow(DisplayMode mode)
|
|
||||||
: this()
|
|
||||||
{
|
|
||||||
CreateWindow(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs a new GameWindow with the specified title, and opens a render window with the specified DisplayMode.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
|
||||||
/// <param name="title">The Title of the GameWindow.</param>
|
|
||||||
public GameWindow(DisplayMode mode, string title)
|
|
||||||
: this()
|
|
||||||
{
|
|
||||||
CreateWindow(mode, title);
|
CreateWindow(mode, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glWindow_Destroy(object sender, EventArgs e)
|
void glWindow_Destroy(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
glWindow.Destroy -= glWindow_Destroy;
|
||||||
|
|
||||||
Debug.Print("GameWindow destruction imminent.");
|
Debug.Print("GameWindow destruction imminent.");
|
||||||
this.isExiting = true;
|
this.isExiting = true;
|
||||||
this.OnDestroy(EventArgs.Empty);
|
//this.OnDestroy(EventArgs.Empty);
|
||||||
glWindow.Destroy -= glWindow_Destroy;
|
|
||||||
//this.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void glWindow_Resize(object sender, ResizeEventArgs e)
|
|
||||||
{
|
|
||||||
this.OnResizeInternal(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -142,7 +132,7 @@ namespace OpenTK
|
||||||
/// <para>Call DestroyWindow to close the render window.</para>
|
/// <para>Call DestroyWindow to close the render window.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="ApplicationException">Occurs when a render window already exists.</exception>
|
/// <exception cref="ApplicationException">Occurs when a render window already exists.</exception>
|
||||||
public void CreateWindow(DisplayMode mode, string title)
|
private void CreateWindow(DisplayMode mode, string title)
|
||||||
{
|
{
|
||||||
if (!Exists)
|
if (!Exists)
|
||||||
{
|
{
|
||||||
|
@ -150,6 +140,7 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
glWindow.CreateWindow(mode);
|
glWindow.CreateWindow(mode);
|
||||||
this.Title = title;
|
this.Title = title;
|
||||||
|
input_driver = new InputDriver(this);
|
||||||
}
|
}
|
||||||
catch (ApplicationException expt)
|
catch (ApplicationException expt)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +150,7 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ApplicationException("A render window already exists for this GameWindow.");
|
throw new InvalidOperationException("A render window already exists for this GameWindow.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +288,8 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#if false
|
||||||
|
|
||||||
#region public IInputDriver InputDriver
|
#region public IInputDriver InputDriver
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -306,12 +299,14 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return glWindow.InputDriver;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#region public void CreateWindow(DisplayMode mode)
|
#region public void CreateWindow(DisplayMode mode)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -330,6 +325,7 @@ namespace OpenTK
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
glWindow.CreateWindow(mode);
|
glWindow.CreateWindow(mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (ApplicationException expt)
|
catch (ApplicationException expt)
|
||||||
{
|
{
|
||||||
|
@ -757,8 +753,8 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (InputDriver.Keyboard.Count > 0)
|
if (input_driver.Keyboard.Count > 0)
|
||||||
return InputDriver.Keyboard[0];
|
return input_driver.Keyboard[0];
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -775,8 +771,8 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (InputDriver.Mouse.Count > 0)
|
if (input_driver.Mouse.Count > 0)
|
||||||
return InputDriver.Mouse[0];
|
return input_driver.Mouse[0];
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue