00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Windows.Forms;
00032
00033 using OpenTK.Graphics;
00034 using OpenTK.Platform;
00035
00036 namespace OpenTK
00037 {
00038 class WinGLControl : IGLControl
00039 {
00040 #region P/Invoke declarations
00041
00042 #region Message
00043
00044 struct MSG
00045 {
00046 public IntPtr HWnd;
00047 public uint Message;
00048 public IntPtr WParam;
00049 public IntPtr LParam;
00050 public uint Time;
00051 public POINT Point;
00052
00053
00054 public override string ToString()
00055 {
00056 return String.Format("msg=0x{0:x} ({1}) hwnd=0x{2:x} wparam=0x{3:x} lparam=0x{4:x} pt=0x{5:x}", (int)Message, Message.ToString(), HWnd.ToInt32(), WParam.ToInt32(), LParam.ToInt32(), Point);
00057 }
00058 }
00059
00060 #endregion
00061
00062 #region Point
00063
00064 struct POINT
00065 {
00066 public int X;
00067 public int Y;
00068
00069 public POINT(int x, int y)
00070 {
00071 this.X = x;
00072 this.Y = y;
00073 }
00074
00075 public System.Drawing.Point ToPoint()
00076 {
00077 return new System.Drawing.Point(X, Y);
00078 }
00079
00080 public override string ToString()
00081 {
00082 return "Point {" + X.ToString() + ", " + Y.ToString() + ")";
00083 }
00084 }
00085
00086 #endregion
00087
00088 #region PeekMessage
00089
00090 [System.Security.SuppressUnmanagedCodeSecurity]
00091 [System.Runtime.InteropServices.DllImport("User32.dll")]
00092 static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
00093
00094 #endregion
00095
00096 #region
00097
00098 #endregion
00099
00100 #endregion
00101
00102 #region Fields
00103
00104 MSG msg = new MSG();
00105 IWindowInfo window_info;
00106 GraphicsMode mode;
00107
00108 #endregion
00109
00110 #region Constructors
00111
00112 public WinGLControl(GraphicsMode mode, Control control)
00113 {
00114 this.mode = mode;
00115
00116 window_info = Utilities.CreateWindowsWindowInfo(control.Handle);
00117 }
00118
00119 #endregion
00120
00121 #region IGLControl Members
00122
00123 public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
00124 {
00125 return new GraphicsContext(mode, window_info, major, minor, flags);
00126 }
00127
00128 public bool IsIdle
00129 {
00130 get { return !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
00131 }
00132
00133 public IWindowInfo WindowInfo
00134 {
00135 get
00136 {
00137
00138 return window_info;
00139 }
00140 }
00141
00142 #endregion
00143 }
00144 }