public void Run()
{
using (Form form = CreateForm())
{
var mGLControl = new GLControl
{
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
BackColor = Color.LightGreen,
Location = new Point(1, 0),
Name = "GL Control",
Size = new Size(WIDTH, HEIGHT),
TabIndex = 0,
VSync = false
};
form.Controls.Add(mGLControl);
//have to set this to get a -1 to 1 system view
GL.Viewport(0, 0, WIDTH, HEIGHT);
if (false)//!GL.SupportsExtension("VERSION_1_5"))
{
Assert.Fail("You need at least OpenGL 1.5 to run this example. Aborting.", "VBOs not supported");
}
var positions = new[]
{
new Vector3(-1, -1, 0),
new Vector3(1, -1, 0),
new Vector3(1, 1, 0),
new Vector3(-1, 1, 0),
};
var colors = new[]
{
new Vector3(1, 0, 0), new Vector3(0, 1, 0),
new Vector3(0, 0, 1), new Vector3(1, 1, 0)
};
var indices = new uint[] { 0, 1, 2, 0, 2, 3 };
LoadBuffers(positions, indices, colors);
Application.Idle +=
delegate
{
mGLControl.MakeCurrent();
GL.ClearColor(mGLControl.BackColor);
GL.Clear(ClearBufferMask.ColorBufferBit);
RenderFrame();
mGLControl.SwapBuffers();
};
form.BringToFront();
Application.Run(form);
}
}