Game Development Reference
In-Depth Information
Figure 6.2
Problems with full-screen mode.
when in full-screen mode. The second size is the OpenGL viewport; this hasn't
changed at all, and that's why it's still rendering the triangle the same small size.
To fix this we must know when the form changes size and informOpenGL about
the change. The form's size can be accessed in a number of ways. Figure 6.3
shows the difference between the form Size and ClientSize values. Size in-
cludes things like the frame and title bar. We're only interested in the size of the
form where the OpenGL graphics are drawn. This can be obtained by querying
the ClientSize value of the form.
In the form you'll see an overridable method call, OnClientSizeChanged ;
this is the perfect place to update the OpenGL viewport size. In Form.cs, add this
method.
protected override void OnClientSizeChanged(EventArgs e)
{
base.OnClientSizeChanged(e);
Gl.glViewport(0, 0, this.ClientSize.Width, this.ClientSize.Height);
}
Now any time the client size is changed, such as going to full-screen, the OpenGL
viewport will be changed to match it. This also allows the form to be resized at
 
Search WWH ::




Custom Search