2007-07-23 00:15:18 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
|
* See license.txt for license info
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- Using directives ---
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.OpenGL;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace Examples.WinForms
|
|
|
|
|
{
|
|
|
|
|
public partial class W01_First_Window : Form, IExample
|
|
|
|
|
{
|
2007-08-04 13:28:16 +00:00
|
|
|
|
OpenTK.InputDriver input;
|
2007-07-23 00:15:18 +00:00
|
|
|
|
public W01_First_Window()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-04 12:17:30 +00:00
|
|
|
|
protected override void OnHandleCreated(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHandleCreated(e);
|
|
|
|
|
|
2007-08-05 13:42:31 +00:00
|
|
|
|
input = new OpenTK.InputDriver(OpenTK.Platform.Utilities.GetWindowInfo(this));
|
2007-08-04 12:17:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-23 00:15:18 +00:00
|
|
|
|
private void redButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GL.ClearColor(0.7f, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
glControl1.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void greenButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GL.ClearColor(0.0f, 0.5f, 0.0f, 0.0f);
|
|
|
|
|
glControl1.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void blueButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GL.ClearColor(0.0f, 0.0f, 0.7f, 0.0f);
|
|
|
|
|
glControl1.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void glControl1_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
2007-08-01 09:32:49 +00:00
|
|
|
|
GL.Clear(GL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
|
2007-07-23 00:15:18 +00:00
|
|
|
|
glControl1.Context.SwapBuffers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void glControl1_Resize(object sender, OpenTK.Platform.ResizeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (glControl1.ClientSize.Height == 0)
|
|
|
|
|
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
|
|
|
|
|
|
|
|
|
|
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void glControl1_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Escape:
|
|
|
|
|
this.Close();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-04 12:09:58 +00:00
|
|
|
|
|
|
|
|
|
#region IExample Members
|
|
|
|
|
|
|
|
|
|
public void Launch()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2007-07-23 00:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|