2007-07-23 00:15:18 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Copyright (c) 2007 Stefanos Apostolopoulos
|
|
|
|
|
* See license.txt for license info
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- Using directives ---
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows.Forms;
|
2007-08-04 12:09:58 +00:00
|
|
|
|
using System.Diagnostics;
|
2007-09-02 22:52:00 +00:00
|
|
|
|
using OpenTK.OpenGL;
|
2007-09-26 11:55:55 +00:00
|
|
|
|
using OpenTK.Input;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.Windows
|
|
|
|
|
{
|
2007-08-05 13:42:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drives GameWindow on Windows.
|
|
|
|
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
|
|
|
|
/// </summary>
|
2007-09-02 00:16:22 +00:00
|
|
|
|
sealed class WinGLNative : NativeWindow, INativeGLWindow
|
2007-07-23 00:15:18 +00:00
|
|
|
|
{
|
2007-08-04 12:09:58 +00:00
|
|
|
|
#region --- Fields ---
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
private WinGLContext glContext;
|
|
|
|
|
private DisplayMode mode = new DisplayMode();
|
2007-10-19 20:00:45 +00:00
|
|
|
|
//private WinRawInput driver;
|
2007-08-05 13:42:31 +00:00
|
|
|
|
|
2007-08-31 16:10:38 +00:00
|
|
|
|
private bool fullscreen;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
private bool disposed;
|
2007-08-10 16:55:24 +00:00
|
|
|
|
private bool isExiting;
|
2007-08-06 09:22:04 +00:00
|
|
|
|
private bool exists;
|
2007-08-06 11:22:18 +00:00
|
|
|
|
private WindowInfo window;
|
2007-08-21 12:04:01 +00:00
|
|
|
|
private int top, bottom, left, right;
|
2007-08-06 11:22:18 +00:00
|
|
|
|
|
2007-09-26 11:55:55 +00:00
|
|
|
|
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
/// <summary>
|
2007-09-26 11:55:55 +00:00
|
|
|
|
/// For use in PeekMessage.
|
2007-09-02 00:16:22 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
private MSG myGoodMsg = new MSG();
|
|
|
|
|
|
2007-08-06 11:22:18 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// For use in WndProc only.
|
|
|
|
|
/// </summary>
|
2007-08-21 12:04:01 +00:00
|
|
|
|
private int width = 0, height = 0;
|
|
|
|
|
|
|
|
|
|
private int left_border, right_border, top_border, bottom_border;
|
2007-08-04 12:09:58 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
|
|
|
|
#region --- Contructors ---
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2007-08-05 10:33:23 +00:00
|
|
|
|
/// Constructs a new WinGLNative class. Call CreateWindow to create the
|
|
|
|
|
/// actual render window.
|
2007-07-23 00:15:18 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public WinGLNative()
|
|
|
|
|
{
|
2007-08-05 13:42:31 +00:00
|
|
|
|
Debug.Print("Native window driver: {0}", this.ToString());
|
2007-08-04 12:09:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region protected override void WndProc(ref Message m)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Processes incoming WM_* messages.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="m">Reference to the incoming Windows Message.</param>
|
|
|
|
|
protected override void WndProc(ref Message m)
|
|
|
|
|
{
|
2007-09-02 00:16:22 +00:00
|
|
|
|
switch ((WindowMessage)m.Msg)
|
2007-08-04 12:09:58 +00:00
|
|
|
|
{
|
2007-09-02 00:16:22 +00:00
|
|
|
|
case WindowMessage.WINDOWPOSCHANGED:
|
2007-08-04 12:09:58 +00:00
|
|
|
|
// Get window size
|
2007-09-02 00:16:22 +00:00
|
|
|
|
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cx"));
|
|
|
|
|
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cy"));
|
2007-08-21 12:04:01 +00:00
|
|
|
|
width -= (left_border + right_border);
|
|
|
|
|
height -= (top_border + bottom_border);
|
2007-08-04 12:09:58 +00:00
|
|
|
|
//if (resizeEventArgs.Width != width || resizeEventArgs.Height != height)
|
2007-08-21 12:04:01 +00:00
|
|
|
|
if (this.mode.Width != width || this.mode.Height != height)
|
2007-08-04 12:09:58 +00:00
|
|
|
|
{
|
2007-09-26 11:55:55 +00:00
|
|
|
|
mode.Width = width;
|
|
|
|
|
mode.Height = height;
|
2007-08-04 12:09:58 +00:00
|
|
|
|
// If the size has changed, raise the ResizeEvent.
|
2007-09-26 11:55:55 +00:00
|
|
|
|
//resizeEventArgs.Width = width;
|
|
|
|
|
//resizeEventArgs.Height = height;
|
|
|
|
|
//this.OnResize(resizeEventArgs);
|
2007-08-04 12:09:58 +00:00
|
|
|
|
// The message was processed.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// If the message was not a resize notification, send it to the default WndProc.
|
|
|
|
|
break;
|
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
case WindowMessage.CREATE:
|
2007-08-04 12:09:58 +00:00
|
|
|
|
// Set the window width and height:
|
2007-09-02 00:16:22 +00:00
|
|
|
|
this.mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cx"));
|
|
|
|
|
this.mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cy"));
|
2007-08-21 12:04:01 +00:00
|
|
|
|
this.mode.Width -= (left_border + right_border);
|
|
|
|
|
this.mode.Height -= (top_border + bottom_border);
|
2007-08-05 13:42:31 +00:00
|
|
|
|
|
2007-08-04 12:09:58 +00:00
|
|
|
|
// Raise the Create event
|
|
|
|
|
this.OnCreate(EventArgs.Empty);
|
|
|
|
|
return;
|
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
case WindowMessage.CLOSE:
|
2007-08-10 16:55:24 +00:00
|
|
|
|
this.DestroyWindow();
|
2007-08-06 09:22:04 +00:00
|
|
|
|
return;
|
2007-08-05 13:42:31 +00:00
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
case WindowMessage.DESTROY:
|
2007-08-06 11:22:18 +00:00
|
|
|
|
this.OnDestroy(EventArgs.Empty);
|
|
|
|
|
break;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
case WindowMessage.QUIT:
|
2007-08-10 16:55:24 +00:00
|
|
|
|
isExiting = true;
|
2007-09-02 00:16:22 +00:00
|
|
|
|
//this.Dispose();
|
2007-08-10 16:55:24 +00:00
|
|
|
|
//Debug.WriteLine("Application quit.");
|
2007-08-04 12:09:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
//DefWndProc(ref m);
|
|
|
|
|
base.WndProc(ref m);
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-08-05 13:42:31 +00:00
|
|
|
|
#region --- INativeGLWindow Members ---
|
2007-07-23 00:15:18 +00:00
|
|
|
|
|
|
|
|
|
#region public void ProcessEvents()
|
|
|
|
|
|
2007-08-04 12:09:58 +00:00
|
|
|
|
private int ret;
|
2007-09-02 00:16:22 +00:00
|
|
|
|
MSG msg;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
public void ProcessEvents()
|
|
|
|
|
{
|
2007-08-04 12:09:58 +00:00
|
|
|
|
while (!IsIdle)
|
2007-07-23 00:15:18 +00:00
|
|
|
|
{
|
2007-09-26 11:55:55 +00:00
|
|
|
|
ret = Functions.GetMessage(ref msg, Handle, 0, 0);
|
2007-08-04 12:09:58 +00:00
|
|
|
|
if (ret == -1)
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException(String.Format(
|
|
|
|
|
"An error happened while processing the message queue. Windows error: {0}",
|
|
|
|
|
Marshal.GetLastWin32Error()));
|
|
|
|
|
}
|
2007-09-26 11:55:55 +00:00
|
|
|
|
Functions.DispatchMessage(ref msg);
|
2007-08-06 11:22:18 +00:00
|
|
|
|
//WndProc(ref msg);
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-08-06 09:22:04 +00:00
|
|
|
|
#region public bool Exists
|
2007-08-04 12:09:58 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if a render window/context exists.
|
|
|
|
|
/// </summary>
|
2007-08-06 09:22:04 +00:00
|
|
|
|
public bool Exists
|
2007-08-04 12:09:58 +00:00
|
|
|
|
{
|
2007-08-06 09:22:04 +00:00
|
|
|
|
get { return exists; }
|
2007-08-04 12:09:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
#region public bool Quit
|
|
|
|
|
|
2007-08-10 16:55:24 +00:00
|
|
|
|
public bool IsExiting
|
2007-07-23 00:15:18 +00:00
|
|
|
|
{
|
2007-08-10 16:55:24 +00:00
|
|
|
|
get { return isExiting; }
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public IGLContext Context
|
|
|
|
|
|
|
|
|
|
public IGLContext Context
|
|
|
|
|
{
|
|
|
|
|
get { return glContext; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool Fullscreen
|
|
|
|
|
|
|
|
|
|
public bool Fullscreen
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2007-08-05 13:51:07 +00:00
|
|
|
|
return false;
|
|
|
|
|
//throw new NotImplementedException();
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2007-08-05 13:51:07 +00:00
|
|
|
|
fullscreen = false;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool IsIdle
|
|
|
|
|
|
|
|
|
|
public bool IsIdle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2007-08-04 12:09:58 +00:00
|
|
|
|
//return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
2007-09-26 11:55:55 +00:00
|
|
|
|
return !Functions.PeekMessage(ref myGoodMsg, this.Handle, 0, 0, 0);
|
2007-08-04 12:09:58 +00:00
|
|
|
|
//return API.GetQueueStatus(API.QueueStatusFlags.ALLEVENTS) == 0;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-09-26 11:55:55 +00:00
|
|
|
|
#region public string Text
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
StringBuilder title = new StringBuilder(256);
|
|
|
|
|
Functions.GetWindowText(window.Handle, title, title.Capacity);
|
|
|
|
|
return title.ToString();
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
#if DEBUG
|
|
|
|
|
bool ret = Functions.SetWindowText(window.Handle, value);
|
|
|
|
|
if (ret)
|
|
|
|
|
Debug.Print("Window {0} title changed to {1}.", window.Handle, value);
|
|
|
|
|
else
|
|
|
|
|
Debug.Print("Window {0} title failed to change to {1}.", window.Handle, value);
|
|
|
|
|
#else
|
|
|
|
|
Functions.SetWindowText(window.Handle, value);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool Visible
|
|
|
|
|
|
2007-09-26 15:44:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// TODO
|
|
|
|
|
/// </summary>
|
2007-09-26 11:55:55 +00:00
|
|
|
|
public bool Visible
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
//Functions.GetW
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-08-05 13:42:31 +00:00
|
|
|
|
#region public IWindowInfo WindowInfo
|
|
|
|
|
|
|
|
|
|
public IWindowInfo WindowInfo
|
|
|
|
|
{
|
2007-08-06 11:22:18 +00:00
|
|
|
|
get { return window; }
|
2007-09-25 16:45:12 +00:00
|
|
|
|
//private set { window = value as WindowInfo; }
|
2007-08-06 11:22:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region private void CreateWindow(DisplayMode mode)
|
|
|
|
|
|
2007-08-21 12:04:01 +00:00
|
|
|
|
public void CreateWindow(DisplayMode windowMode)
|
2007-08-06 11:22:18 +00:00
|
|
|
|
{
|
2007-09-26 11:55:55 +00:00
|
|
|
|
Debug.Print("Creating native window with mode: {0}", windowMode.ToString());
|
2007-08-06 11:22:18 +00:00
|
|
|
|
Debug.Indent();
|
|
|
|
|
|
|
|
|
|
CreateParams cp = new CreateParams();
|
|
|
|
|
cp.ClassStyle =
|
2007-09-02 00:16:22 +00:00
|
|
|
|
(int)WindowClassStyle.OwnDC |
|
|
|
|
|
(int)WindowClassStyle.VRedraw |
|
|
|
|
|
(int)WindowClassStyle.HRedraw |
|
|
|
|
|
(int)WindowClassStyle.Ime;
|
2007-08-06 11:22:18 +00:00
|
|
|
|
cp.Style =
|
2007-09-02 00:16:22 +00:00
|
|
|
|
(int)WindowStyle.Visible |
|
|
|
|
|
(int)WindowStyle.ClipChildren |
|
|
|
|
|
(int)WindowStyle.ClipSiblings |
|
|
|
|
|
(int)WindowStyle.OverlappedWindow;
|
2007-08-21 12:04:01 +00:00
|
|
|
|
|
2007-09-02 00:16:22 +00:00
|
|
|
|
Rectangle rect = new Rectangle();
|
2007-08-21 12:04:01 +00:00
|
|
|
|
rect.top = rect.left = 0;
|
|
|
|
|
rect.bottom = windowMode.Height;
|
|
|
|
|
rect.right = windowMode.Width;
|
2007-09-26 11:55:55 +00:00
|
|
|
|
Functions.AdjustWindowRect(ref rect, WindowStyle.OverlappedWindow, false);
|
2007-08-21 12:04:01 +00:00
|
|
|
|
|
|
|
|
|
// Not used
|
|
|
|
|
Top = 0;
|
|
|
|
|
Left = 0;
|
|
|
|
|
Right = windowMode.Width;
|
|
|
|
|
Bottom = windowMode.Height;
|
|
|
|
|
// --------
|
|
|
|
|
|
|
|
|
|
top_border = -rect.top;
|
|
|
|
|
left_border = -rect.left;
|
|
|
|
|
bottom_border = rect.bottom - windowMode.Height;
|
|
|
|
|
right_border = rect.right - windowMode.Width;
|
|
|
|
|
|
|
|
|
|
cp.Width = rect.right - rect.left;
|
|
|
|
|
cp.Height = rect.bottom - rect.top;
|
2007-08-06 11:22:18 +00:00
|
|
|
|
cp.Caption = "OpenTK Game Window";
|
|
|
|
|
|
|
|
|
|
// Keep in mind that some construction code runs in WM_CREATE,
|
|
|
|
|
// which is raised CreateHandle()
|
|
|
|
|
CreateHandle(cp);
|
|
|
|
|
|
|
|
|
|
if (this.Handle != IntPtr.Zero && glContext != null)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("Window creation was succesful.");
|
|
|
|
|
exists = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException(String.Format(
|
|
|
|
|
"Could not create native window and/or context. Handle: {0}, Context {1}",
|
|
|
|
|
this.Handle, this.Context.ToString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug.Unindent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region OnCreate
|
|
|
|
|
|
|
|
|
|
public event CreateEvent Create;
|
|
|
|
|
|
|
|
|
|
public void OnCreate(EventArgs e)
|
|
|
|
|
{
|
2007-09-25 16:45:12 +00:00
|
|
|
|
this.window = new WindowInfo(this);
|
2007-10-19 20:00:45 +00:00
|
|
|
|
//driver = new WinRawInput(this.window);
|
2007-08-06 11:22:18 +00:00
|
|
|
|
|
|
|
|
|
Debug.Print("Window created: {0}", window);
|
|
|
|
|
|
2007-08-20 12:25:48 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2007-09-09 11:52:09 +00:00
|
|
|
|
glContext = new WinGLContext(this.mode, this.WindowInfo);
|
2007-08-20 12:25:48 +00:00
|
|
|
|
glContext.CreateContext();
|
|
|
|
|
}
|
|
|
|
|
catch (ApplicationException expt)
|
|
|
|
|
{
|
|
|
|
|
Debug.Print("Could not create opengl context, error: {0}", expt.ToString());
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2007-08-06 11:22:18 +00:00
|
|
|
|
|
|
|
|
|
if (this.Create != null)
|
|
|
|
|
{
|
|
|
|
|
this.Create(this, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region private void DestroyWindow()
|
|
|
|
|
|
2007-08-10 16:55:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts the teardown sequence for the current window.
|
|
|
|
|
/// </summary>
|
2007-08-06 11:22:18 +00:00
|
|
|
|
public void DestroyWindow()
|
|
|
|
|
{
|
|
|
|
|
Debug.Print("Destroying window: {0}", window.ToString());
|
2007-09-26 11:55:55 +00:00
|
|
|
|
Functions.PostMessage(this.Handle, WindowMessage.DESTROY, IntPtr.Zero, IntPtr.Zero);
|
2007-08-06 11:22:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region OnDestroy
|
|
|
|
|
|
|
|
|
|
public void OnDestroy(EventArgs e)
|
|
|
|
|
{
|
2007-08-10 16:55:24 +00:00
|
|
|
|
if (this.Destroy != null)
|
|
|
|
|
{
|
|
|
|
|
this.Destroy(this, e);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 11:22:18 +00:00
|
|
|
|
if (this.Handle != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
Debug.Print("Window handle {0} destroyed.", this.Handle);
|
|
|
|
|
//this.DestroyHandle(); // Destroyed automatically by DefWndProc
|
2007-08-22 00:30:16 +00:00
|
|
|
|
//this.Dispose();
|
2007-08-06 11:22:18 +00:00
|
|
|
|
exists = false;
|
|
|
|
|
}
|
2007-08-22 00:30:16 +00:00
|
|
|
|
//API.PostQuitMessage(0);
|
2007-08-05 13:42:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 11:22:18 +00:00
|
|
|
|
public event DestroyEvent Destroy;
|
|
|
|
|
|
2007-08-05 13:42:31 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- IResizable Members ---
|
|
|
|
|
|
|
|
|
|
#region public int Width
|
|
|
|
|
|
|
|
|
|
public int Width
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return mode.Width;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public int Height
|
|
|
|
|
|
|
|
|
|
public int Height
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return mode.Height;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
//WinApi.PostMessage(
|
|
|
|
|
// this.Handle,
|
|
|
|
|
// WinApi.Constants.WM_WINDOWPOSCHANGING,
|
|
|
|
|
|
|
|
|
|
//mode.Height = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-09-26 11:55:55 +00:00
|
|
|
|
#region public void OnResize
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
public event ResizeEvent Resize;
|
2007-09-26 11:55:55 +00:00
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
public void OnResize(ResizeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mode.Width = e.Width;
|
|
|
|
|
mode.Height = e.Height;
|
|
|
|
|
if (this.Resize != null)
|
|
|
|
|
this.Resize(this, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2007-08-21 12:04:01 +00:00
|
|
|
|
public int Top
|
|
|
|
|
{
|
|
|
|
|
get { return top; }
|
|
|
|
|
private set { top = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Bottom
|
|
|
|
|
{
|
|
|
|
|
get { return bottom; }
|
|
|
|
|
private set { bottom = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Left
|
|
|
|
|
{
|
|
|
|
|
get { return left; }
|
|
|
|
|
private set { left = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Right
|
|
|
|
|
{
|
|
|
|
|
get { return right; }
|
|
|
|
|
private set { right = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
#endregion
|
2007-08-22 00:30:16 +00:00
|
|
|
|
|
|
|
|
|
#region --- IDisposable Members ---
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
this.Dispose(true);
|
2007-09-02 00:16:22 +00:00
|
|
|
|
//GC.SuppressFinalize(this);
|
2007-08-22 00:30:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Dispose(bool calledManually)
|
|
|
|
|
{
|
|
|
|
|
if (!disposed)
|
|
|
|
|
{
|
|
|
|
|
// Clean unmanaged resources here:
|
|
|
|
|
|
|
|
|
|
if (calledManually)
|
|
|
|
|
{
|
|
|
|
|
// Safe to clean managed resources
|
|
|
|
|
glContext.Dispose();
|
2007-09-02 00:16:22 +00:00
|
|
|
|
//base.DestroyHandle();
|
2007-08-22 00:30:16 +00:00
|
|
|
|
}
|
|
|
|
|
disposed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-09-02 00:16:22 +00:00
|
|
|
|
/*
|
2007-08-22 00:30:16 +00:00
|
|
|
|
~WinGLNative()
|
|
|
|
|
{
|
|
|
|
|
Dispose(false);
|
|
|
|
|
}
|
2007-09-02 00:16:22 +00:00
|
|
|
|
*/
|
2007-08-22 00:30:16 +00:00
|
|
|
|
#endregion
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region class WindowHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
class WindowHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
|
|
|
|
|
{
|
|
|
|
|
protected override bool ReleaseHandle()
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("The method or operation is not implemented.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsInvalid
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return base.IsInvalid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|