private void RenderControl_ContextCreated(object sender, GlControlEventArgs e)
{
// Here you can allocate resources or initialize state
Gl.MatrixMode(MatrixMode.Projection);
Gl.LoadIdentity();
Gl.Ortho(0.0, 1.0f, 0.0, 1.0, 0.0, 1.0);
Gl.MatrixMode(MatrixMode.Modelview);
Gl.LoadIdentity();
}
private void RenderControl_Render(object sender, GlControlEventArgs e)
{
Control senderControl = (Control)sender;
Gl.Viewport(0, 0, senderControl.ClientSize.Width, senderControl.ClientSize.Height);
Gl.Clear(ClearBufferMask.ColorBufferBit);
Gl.Begin(PrimitiveType.Triangles);
Gl.Color3(1.0f, 0.0f, 0.0f); Gl.Vertex2(0.0f, 0.0f);
Gl.Color3(0.0f, 1.0f, 0.0f); Gl.Vertex2(0.5f, 1.0f);
Gl.Color3(0.0f, 0.0f, 1.0f); Gl.Vertex2(1.0f, 0.0f);
Gl.End();
}
private void RenderControl_ContextDestroying(object sender, GlControlEventArgs e)
{
// Here you can dispose resources allocated in RenderControl_ContextCreated
}
From what I see, these are event functions raised by GLControlEventArgs. But what if I want to make a button when I click it, OpenGL will draw a triangle on winform.
Hi, I am looking at your code provided here: https://github.com/luca-piccioni/OpenGL.Net/wiki/GL-%5C-OpenGL.GlControl-(System.Windows.Forms)
From what I see, these are event functions raised by GLControlEventArgs. But what if I want to make a button when I click it, OpenGL will draw a triangle on winform.
The method should look like this: