mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-27 06:25:40 +00:00
59b503b3c3
WinRawInput now correctly subclasses WinGLNative or WinGLControl. WinRawKeyboard now correctly responds to events. Removed T10_GLSL_Cube.cs which was erroneously moved outside the Examples/Tutorial directory. Updated INativeWindow, IGameWindow and IGLControl interfaces. Updated examples to use the new GameWindow interface. Added documentation to GameWindow. Improved GameWindow error handling. More defensive programming.
123 lines
2.6 KiB
C#
123 lines
2.6 KiB
C#
#region --- License ---
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
* Contributions from Erik Ylvisaker
|
|
* See license.txt for license info
|
|
*/
|
|
#endregion
|
|
|
|
#region --- Using directives ---
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
#endregion
|
|
|
|
namespace OpenTK.Platform.Windows
|
|
{
|
|
sealed class WinGLControl : OpenTK.Platform.IGLControl
|
|
{
|
|
private WinGLContext glContext;
|
|
private bool fullscreen;
|
|
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
|
|
|
private bool disposed;
|
|
private Message msg; // Used only by the IsIdle event.
|
|
|
|
#region --- Constructors ---
|
|
|
|
public WinGLControl(Control c, int width, int height, bool fullscreen)
|
|
{
|
|
glContext = new WinGLContext(
|
|
c.Handle,
|
|
new DisplayMode(
|
|
width, height,
|
|
new ColorDepth(32),
|
|
16, 0, 0, 2,
|
|
fullscreen,
|
|
false,
|
|
false,
|
|
0.0f
|
|
)
|
|
);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IGLControl membmers ---
|
|
|
|
public event CreateEvent Create;
|
|
|
|
#region public bool IsIdle
|
|
|
|
public bool IsIdle
|
|
{
|
|
get
|
|
{
|
|
return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public bool Fullscreen
|
|
|
|
public bool Fullscreen
|
|
{
|
|
get
|
|
{
|
|
return fullscreen;
|
|
}
|
|
set
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public IGLContext Context
|
|
|
|
public IGLContext Context
|
|
{
|
|
get { return glContext; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region --- IDisposable Members ---
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
private void Dispose(bool calledManually)
|
|
{
|
|
if (!disposed)
|
|
{
|
|
// Clean unmanaged resources here:
|
|
|
|
if (calledManually)
|
|
{
|
|
// Safe to clean managed resources
|
|
glContext.Dispose();
|
|
}
|
|
disposed = true;
|
|
}
|
|
}
|
|
|
|
~WinGLControl()
|
|
{
|
|
Dispose(false);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|