febriano's picture

Windows form resize problem

i have a windows form application on VS2010 C# i added the GLcontrol to the form but when i am playing with the size of the form it doesnt seem to change its just stick to the size of the box i dropped in the form 256 ,229 i think it has something to do with the setupviewport() here it is

   private void SetupViewport()
            int w = glControl1.Width;
            int h = glControl1.Height;
            GL.Ortho(0, w, 0, h, -1, 1);
            GL.Viewport(0, 0, w, h);

this is the Resize event

  private void glControl1_Resize(object sender, EventArgs e)

should i be changing the w , h variables to have this.width and this.height of the form it self ? will that make gl.viewport draw on the entire form ? doesnt the invalidate fetch the size of the form ? thanks for your time much appreciated

Inline Images


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Use the Dock property with DockStyle.Fill: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx

febriano's picture

thanks for your time and reply , will give it a look
ok i used this glControl1.Dock = DockStyle.Fill; in the render function and it works now thank you alot

the Fiddler's picture

You don't need to set the Dock property every frame, you can do it once on startup, in the Load event.

febriano's picture

noted thanks for your time