-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenGLControl.Designer.cs
76 lines (71 loc) · 2.07 KB
/
OpenGLControl.Designer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Security.Permissions;
using System.Windows.Forms;
using HDC=System.IntPtr;
using HGLRC=System.IntPtr;
namespace Win32.WGL
{
partial class OpenGLControl
{
/// <summary>
/// Overrides the window procedure to handle <see cref="WM.DESTROY"/>, <see cref="WM.PAINT"/> and <see cref="WM.ERASEBKGND"/> messages.
/// </summary>
/// <param name="m">The message.</param>
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM.DESTROY:
{
EventHandler<OpenGLDestroyEventArgs> destroy=Destroy;
if(destroy!=null)
{
bool err=false;
if(RC!=HGLRC.Zero) err=wgl.MakeCurrent(DC, RC);
destroy(this, new OpenGLDestroyEventArgs(!err));
if(RC!=HGLRC.Zero) wgl.MakeCurrent(HDC.Zero, HGLRC.Zero);
}
if(RC!=HGLRC.Zero)
{
wgl.DeleteContext(RC);
RC=HGLRC.Zero;
}
if(DC!=HDC.Zero)
{
Window.ReleaseDC(Handle, DC);
DC=HDC.Zero;
}
}
break;
case WM.PAINT:
Invalidate();
break;
case WM.ERASEBKGND: return; // Speed up the handling. This is not needed for OpenGL.
case WM.INPUT: OnWmInput(new OpenGLMessageEventArgs(m)); break;
case WM.INPUT_DEVICE_CHANGE: OnWmInputDeviceChange(new OpenGLMessageEventArgs(m)); break;
}
base.WndProc(ref m);
}
/// <summary>Clean up any resources being used.</summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleDimensions=new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
this.Name="Win32.OpenGLControl";
this.ResumeLayout(false);
}
#endregion
}
}