Added System.Drawing.Color overload to GL.ClearColor.
Updated W01 and W02 examples to use this overload. Removed 'Paint' message from W01 Paint event.
This commit is contained in:
parent
00463df2e8
commit
6ddd024fbf
4 changed files with 19 additions and 8 deletions
|
@ -41,29 +41,30 @@ namespace Examples.WinForms
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|
||||||
glControl1.CreateContext();
|
glControl1.CreateContext();
|
||||||
|
|
||||||
|
GL.ClearColor(Color.Crimson);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redButton_Click(object sender, EventArgs e)
|
private void redButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GL.ClearColor(0.7f, 0.0f, 0.0f, 0.0f);
|
GL.ClearColor(Color.Crimson);
|
||||||
glControl1.Invalidate();
|
glControl1.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void greenButton_Click(object sender, EventArgs e)
|
private void greenButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GL.ClearColor(0.0f, 0.5f, 0.0f, 0.0f);
|
GL.ClearColor(Color.ForestGreen);
|
||||||
glControl1.Invalidate();
|
glControl1.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void blueButton_Click(object sender, EventArgs e)
|
private void blueButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GL.ClearColor(0.0f, 0.0f, 0.7f, 0.0f);
|
GL.ClearColor(Color.RoyalBlue);
|
||||||
glControl1.Invalidate();
|
glControl1.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void glControl1_Paint(object sender, PaintEventArgs e)
|
private void glControl1_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Print("Paint");
|
|
||||||
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
|
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
|
||||||
glControl1.SwapBuffers();
|
glControl1.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,22 @@
|
||||||
//
|
//
|
||||||
// glControl
|
// glControl
|
||||||
//
|
//
|
||||||
this.glControl.BackColor = System.Drawing.Color.MidnightBlue;
|
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.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;
|
||||||
//
|
//
|
||||||
// Cube
|
// W02_Immediate_Mode_Cube
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(624, 444);
|
this.ClientSize = new System.Drawing.Size(624, 444);
|
||||||
this.Controls.Add(this.glControl);
|
this.Controls.Add(this.glControl);
|
||||||
this.Name = "Cube";
|
this.Name = "W02_Immediate_Mode_Cube";
|
||||||
this.Text = "Cube";
|
this.Text = "Cube";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Examples.WinForms
|
||||||
GL.GetString(GL.Enums.StringName.RENDERER) + " " +
|
GL.GetString(GL.Enums.StringName.RENDERER) + " " +
|
||||||
GL.GetString(GL.Enums.StringName.VERSION);
|
GL.GetString(GL.Enums.StringName.VERSION);
|
||||||
|
|
||||||
GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f);
|
GL.ClearColor(Color.MidnightBlue);
|
||||||
GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
|
GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
|
||||||
|
|
||||||
Application.Idle += Application_Idle;
|
Application.Idle += Application_Idle;
|
||||||
|
|
|
@ -298,5 +298,14 @@ namespace OpenTK.OpenGL
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public static void ClearColor() overloads
|
||||||
|
|
||||||
|
public static void ClearColor(System.Drawing.Color color)
|
||||||
|
{
|
||||||
|
ClearColor(color.R/255.0f, color.G/255.0f, color.B/255.0f, color.A/255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue