2009-02-22 10:43:35 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Licensed under the MIT/X11 license.
|
|
|
|
|
* Copyright (c) 2006-2008 the OpenTK Team.
|
|
|
|
|
* This notice may not be removed from any source distribution.
|
|
|
|
|
* See license.txt for licensing detailed licensing details.
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.Windows
|
|
|
|
|
{
|
|
|
|
|
class WinGLControl : IGLControl
|
|
|
|
|
{
|
|
|
|
|
MSG msg = new MSG();
|
|
|
|
|
GraphicsMode mode;
|
|
|
|
|
Control control;
|
2009-05-19 09:48:47 +00:00
|
|
|
|
WinWindowInfo window_info;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
internal WinGLControl(GraphicsMode mode, Control control)
|
|
|
|
|
{
|
|
|
|
|
this.mode = mode;
|
|
|
|
|
this.control = control;
|
2009-05-19 09:48:47 +00:00
|
|
|
|
this.control.HandleCreated += delegate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (window_info != null)
|
|
|
|
|
window_info.Dispose();
|
|
|
|
|
window_info = new WinWindowInfo(this.control.Handle, null);
|
|
|
|
|
};
|
|
|
|
|
this.control.HandleDestroyed += delegate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (window_info != null)
|
|
|
|
|
{
|
|
|
|
|
window_info.Dispose();
|
|
|
|
|
window_info = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region --- IGLControl Members ---
|
|
|
|
|
|
2009-03-07 11:03:41 +00:00
|
|
|
|
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
2009-06-02 15:49:39 +00:00
|
|
|
|
// Make sure the Control exists before create the context.
|
2009-05-19 09:48:47 +00:00
|
|
|
|
if (window_info == null)
|
|
|
|
|
window_info = new WinWindowInfo(control.Handle, null);
|
|
|
|
|
|
|
|
|
|
return new GraphicsContext(mode, window_info, major, minor, flags);
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsIdle
|
|
|
|
|
{
|
|
|
|
|
get { return !OpenTK.Platform.Windows.Functions.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IWindowInfo WindowInfo
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// This method forces the creation of the control. Beware of this side-effect!
|
2009-05-19 09:48:47 +00:00
|
|
|
|
return window_info;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|