This sample demonstrates the GLControl, a powerful, easy-to-use WinForms Control that supports OpenGL rendering. It displays a Form that consists of a GLControl and three buttons that change the OpenGL clear color.\par
\par
The GLControl is suitable to rich, event-based GUIs. It is cross-platform and integrates well with WinForms applications but can also be used with WPF applications using a WindowsFormsHost control.\par
\par
While it is possible to implement continuous rendering with GLControl (see next sample), applications that require continuous rendering can achieve better performance with GameWindow.\par
\par
\b\fs28 Controls\par
\b0\fs22\par
Click on the buttons to change the background color for the GLControl.\par
Press Esc or click the close button to exit.\par
\par
\b\fs28 Implementation\par
\b0\fs22\par
This sample was created using the WinForms designer in Visual Studio. As such, the code follows the conventions of this designer.\par
\par
1. The constructor calls InitializeComponents(). This method is generated by the designer and initializes the Form, GLControl and Buttons.\par
\par
2. The glControl1_Paint event handler is called whenever GLControl needs to be repainted. A typical Paint handler will begin by calling GL.Clear() and end with a call to GLControl.SwapBuffers().\par
\par
3. The various *Button_Click event handlers change the OpenGL clear color and invalidate the GLControl. The Invalidate() method raises the GLControl Paint event and ensures the updated clear color becomes visible immediately.\par