
WindowsForm Appliction and GLControl questions.
Posted Monday, 25 May, 2009 - 21:32 by enablerbr in1: what should i be aware of when creating a New WindowsForm Appliction as a startup project and then dropping a GLControl onto the Form Designer?
2: Are there any modifictions i should do to the project, codewise, before i start my own coding?
3: Are there any limits or pitfalls regarding dropping a GLControl onto the Form Designer?
4: Does OpenTK support 64bit usage?
5: If i convert NeHe lessons over to OpenTK is there any tips that might come in handy?


Comments
Re: WindowsForm Appliction and GLControl questions.
1 and 2 - nothing comes to mind.
3 - yes. Some functionality is only available if you derive from GLControl. This includes support for OpenGL 3.0, custom pixel formats and the RecreateHandle() method (which can be useful in some uncommon scenarios).
4 - absolutely.
5 - there's no need to p/invoke platform-specific functions. OpenTK hides all platform-specific functionality behind cross-platform interfaces: DisplayResolution, GraphicsMode and GraphicsContext. These provide everything you need to emulate NeHe, like setting a display mode, selecting a pixel format and creating the OpenGL context (the latter is handled automatically by GLControl).
Hints:
Re: WindowsForm Appliction and GLControl questions.
so no way round 3 for accessing OpenGL 3.0, custom pixel formats? so as i want those i'll have to code the GLControl by hand. if i code the GLContorl by hand will that mean i can't drop other windows controls (like buttons, file menus) onto the windows Form Designer?
Re: WindowsForm Appliction and GLControl questions.
No, it's nothing like that. You simply create a new class:
Compile the project and this new class will appear in your toolbox - simply drag & drop it instead of a vanilla GLControl.
Edit: the reason for this is that the WinForms designer only uses parameterless constructors. The necessary functionality exists in GLControl, but you can only access it through code, not the designer.
Re: WindowsForm Appliction and GLControl questions.
hmm.. must be doing something wrong. did as you said. however there is no CustomGLControl in my toolbox.
Re: WindowsForm Appliction and GLControl questions.
Hm, maybe it needs to be public (rebuild the project afterwards). If it still doesn't appear, right click on the toolbox, select "choose items" and enable the new control there.
Re: WindowsForm Appliction and GLControl questions.
was public and it doesn't appear in the "choose items". only the normal GLControl is listed.
Problem solved.
i had to go into Tools> options> Windows Forms Designer> General. under Toolbox turn Auto ToolboxPopulate to true. then CustomGLControl appeared in Toolbox. now i feel like a newbie. :)
i even managed to convert the OpenTk Simple GLControl example as well. after i worked out i needed to change the anchor settings.