Removed the glControl.CreateControl() calls.

This commit is contained in:
the_fiddler 2007-10-05 07:46:56 +00:00
parent 65e2c7830c
commit 605225822a
5 changed files with 21 additions and 22 deletions

View file

@ -40,7 +40,6 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.glControl1.Fullscreen = false;
this.glControl1.Location = new System.Drawing.Point(1, 0); this.glControl1.Location = new System.Drawing.Point(1, 0);
this.glControl1.Name = "glControl1"; this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(629, 565); this.glControl1.Size = new System.Drawing.Size(629, 565);

View file

@ -41,8 +41,6 @@ namespace Examples.WinForms
{ {
base.OnLoad(e); base.OnLoad(e);
glControl1.CreateContext();
GL.ClearColor(Color.Crimson); GL.ClearColor(Color.Crimson);
} }

View file

@ -35,12 +35,12 @@
// //
this.glControl.BackColor = System.Drawing.Color.Black; this.glControl.BackColor = System.Drawing.Color.Black;
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill; this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Fullscreen = false;
this.glControl.Location = new System.Drawing.Point(0, 0); this.glControl.Location = new System.Drawing.Point(0, 0);
this.glControl.Name = "glControl"; this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(624, 444); this.glControl.Size = new System.Drawing.Size(624, 444);
this.glControl.TabIndex = 0; this.glControl.TabIndex = 0;
this.glControl.Visible = false; this.glControl.VSync = false;
this.glControl.Layout += new System.Windows.Forms.LayoutEventHandler(this.glControl_Layout);
// //
// W02_Immediate_Mode_Cube // W02_Immediate_Mode_Cube
// //

View file

@ -26,7 +26,7 @@ namespace Examples.WinForms
{ {
public partial class W02_Immediate_Mode_Cube : Form, IExample public partial class W02_Immediate_Mode_Cube : Form, IExample
{ {
static float angle; static float angle = 0.0f;
#region --- Constructor --- #region --- Constructor ---
@ -44,11 +44,9 @@ namespace Examples.WinForms
base.OnLoad(e); base.OnLoad(e);
glControl.KeyDown += new KeyEventHandler(glControl_KeyDown); glControl.KeyDown += new KeyEventHandler(glControl_KeyDown);
glControl.Resize += new EventHandler(glControl_Resize); //glControl.Resize += new EventHandler(glControl_Resize);
glControl.Paint += new PaintEventHandler(glControl_Paint); glControl.Paint += new PaintEventHandler(glControl_Paint);
glControl.CreateContext();
Text = Text =
GL.GetString(GL.Enums.StringName.VENDOR) + " " + GL.GetString(GL.Enums.StringName.VENDOR) + " " +
GL.GetString(GL.Enums.StringName.RENDERER) + " " + GL.GetString(GL.Enums.StringName.RENDERER) + " " +
@ -58,6 +56,8 @@ namespace Examples.WinForms
GL.Enable(GL.Enums.EnableCap.DEPTH_TEST); GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
Application.Idle += Application_Idle; Application.Idle += Application_Idle;
//glControl_Resize(glControl, EventArgs.Empty);
} }
#endregion #endregion
@ -103,8 +103,7 @@ namespace Examples.WinForms
DrawCube(); DrawCube();
glControl.Context.SwapBuffers(); glControl.SwapBuffers();
Thread.Sleep(0);
} }
#endregion #endregion
@ -134,12 +133,6 @@ namespace Examples.WinForms
void glControl_KeyDown(object sender, KeyEventArgs e) void glControl_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.Alt && e.Shift)
{
//this.SetResolution(this.Width, this.Height, this.ColorDepth, !this.IsFullscreen);
glControl.Fullscreen = !glControl.Fullscreen;
}
switch (e.KeyData) switch (e.KeyData)
{ {
case Keys.Escape: case Keys.Escape:
@ -215,5 +208,10 @@ namespace Examples.WinForms
} }
#endregion #endregion
private void glControl_Layout(object sender, LayoutEventArgs e)
{
glControl_Resize(sender, EventArgs.Empty);
}
} }
} }

View file

@ -38,14 +38,13 @@ namespace Examples.WinForms
delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic); delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic); importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic);
Application.Idle += StartAsync; glControl.Load += new EventHandler(glControl_Load);
glControl.CreateControl();
} }
void StartAsync(object sender, EventArgs e) void glControl_Load(object sender, EventArgs e)
{ {
Application.Idle -= StartAsync; Application.Idle += StartAsync;
glControl.CreateContext();
driver = driver =
GL.GetString(GL.Enums.StringName.VENDOR) + " " + GL.GetString(GL.Enums.StringName.VENDOR) + " " +
@ -54,6 +53,11 @@ namespace Examples.WinForms
all = delegatesClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic).Length; all = delegatesClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic).Length;
this.Text = String.Format("Loading {0} functions...", all); this.Text = String.Format("Loading {0} functions...", all);
}
void StartAsync(object sender, EventArgs e)
{
Application.Idle -= StartAsync;
this.backgroundWorker1.RunWorkerAsync(); this.backgroundWorker1.RunWorkerAsync();
} }