From f71bb87fe182c05a12aef50dbf178569ca5132d4 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 5 Oct 2007 07:46:56 +0000 Subject: [PATCH] Removed the glControl.CreateControl() calls. --- .../WinForms/W01_First_Window.Designer.cs | 1 - Source/Examples/WinForms/W01_First_Window.cs | 2 -- .../W02_Immediate_Mode_Cube.Designer.cs | 4 ++-- .../WinForms/W02_Immediate_Mode_Cube.cs | 22 +++++++++---------- Source/Examples/WinForms/W03_Extensions.cs | 14 +++++++----- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Source/Examples/WinForms/W01_First_Window.Designer.cs b/Source/Examples/WinForms/W01_First_Window.Designer.cs index 9cca2746..656c7aa3 100644 --- a/Source/Examples/WinForms/W01_First_Window.Designer.cs +++ b/Source/Examples/WinForms/W01_First_Window.Designer.cs @@ -40,7 +40,6 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark; - this.glControl1.Fullscreen = false; this.glControl1.Location = new System.Drawing.Point(1, 0); this.glControl1.Name = "glControl1"; this.glControl1.Size = new System.Drawing.Size(629, 565); diff --git a/Source/Examples/WinForms/W01_First_Window.cs b/Source/Examples/WinForms/W01_First_Window.cs index 0b89e410..0162a18a 100644 --- a/Source/Examples/WinForms/W01_First_Window.cs +++ b/Source/Examples/WinForms/W01_First_Window.cs @@ -41,8 +41,6 @@ namespace Examples.WinForms { base.OnLoad(e); - glControl1.CreateContext(); - GL.ClearColor(Color.Crimson); } diff --git a/Source/Examples/WinForms/W02_Immediate_Mode_Cube.Designer.cs b/Source/Examples/WinForms/W02_Immediate_Mode_Cube.Designer.cs index 40706d56..5dda0eaf 100644 --- a/Source/Examples/WinForms/W02_Immediate_Mode_Cube.Designer.cs +++ b/Source/Examples/WinForms/W02_Immediate_Mode_Cube.Designer.cs @@ -35,12 +35,12 @@ // this.glControl.BackColor = System.Drawing.Color.Black; this.glControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.glControl.Fullscreen = false; this.glControl.Location = new System.Drawing.Point(0, 0); this.glControl.Name = "glControl"; this.glControl.Size = new System.Drawing.Size(624, 444); 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 // diff --git a/Source/Examples/WinForms/W02_Immediate_Mode_Cube.cs b/Source/Examples/WinForms/W02_Immediate_Mode_Cube.cs index 63ee6d49..91a579c8 100644 --- a/Source/Examples/WinForms/W02_Immediate_Mode_Cube.cs +++ b/Source/Examples/WinForms/W02_Immediate_Mode_Cube.cs @@ -26,7 +26,7 @@ namespace Examples.WinForms { public partial class W02_Immediate_Mode_Cube : Form, IExample { - static float angle; + static float angle = 0.0f; #region --- Constructor --- @@ -44,11 +44,9 @@ namespace Examples.WinForms base.OnLoad(e); 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.CreateContext(); - Text = GL.GetString(GL.Enums.StringName.VENDOR) + " " + GL.GetString(GL.Enums.StringName.RENDERER) + " " + @@ -58,6 +56,8 @@ namespace Examples.WinForms GL.Enable(GL.Enums.EnableCap.DEPTH_TEST); Application.Idle += Application_Idle; + + //glControl_Resize(glControl, EventArgs.Empty); } #endregion @@ -103,8 +103,7 @@ namespace Examples.WinForms DrawCube(); - glControl.Context.SwapBuffers(); - Thread.Sleep(0); + glControl.SwapBuffers(); } #endregion @@ -134,12 +133,6 @@ namespace Examples.WinForms 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) { case Keys.Escape: @@ -215,5 +208,10 @@ namespace Examples.WinForms } #endregion + + private void glControl_Layout(object sender, LayoutEventArgs e) + { + glControl_Resize(sender, EventArgs.Empty); + } } } diff --git a/Source/Examples/WinForms/W03_Extensions.cs b/Source/Examples/WinForms/W03_Extensions.cs index a51ee587..040841a4 100644 --- a/Source/Examples/WinForms/W03_Extensions.cs +++ b/Source/Examples/WinForms/W03_Extensions.cs @@ -38,14 +38,13 @@ namespace Examples.WinForms delegatesClass = glClass.GetNestedType("Delegates", 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; - - glControl.CreateContext(); + Application.Idle += StartAsync; driver = GL.GetString(GL.Enums.StringName.VENDOR) + " " + @@ -54,6 +53,11 @@ namespace Examples.WinForms all = delegatesClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic).Length; this.Text = String.Format("Loading {0} functions...", all); + } + + void StartAsync(object sender, EventArgs e) + { + Application.Idle -= StartAsync; this.backgroundWorker1.RunWorkerAsync(); }