nythrix's picture

Controlling GLControl default constructor.

Project:The Open Toolkit library
Category:feature request

Is it possible to add a "pre-constructor" configuration for GLControl? Something like:

// "Form.cs"
GLControl.DefaultSettings = // mode, version, flags, etc.
// "Form.Designer.cs"
... new GLControl(); // creates a new GLControl with the "default" settings specified above.

This way it won't be necessary to update the constructor line each time Visual Studio rewrites the *.Designer.cs file.
I know it is possible to programmatically add a GLControl to a form, but AFAIK you loose the comfort of the Designer that way.

Such a mechanism would help a lot in case of complicated GUIs with two or more OpenGL 3+ GLControls. Currently, I'm using about six of them and maintenance is becoming a nightmare.


Comment viewing options

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


Right now, the best approach would be to create your own custom control and add that to your forms:

class MyGLControl : GLControl
    public MyGLControl()
        : base(/*mode, version, flags, etc*/)
    { }

A static 'pre-constructor' would be rather uninituitive, IMO, since it won't fit in the WinForms model (or, at least, I haven't seen any other WinForms Controls follow this pattern).

nythrix's picture


Status:open» closed

Duh, I could do that. I should do that.

Is that enough as far as WinForms are concerned? It probably is.
My knowledge in this area is quite lacking.


the Fiddler's picture


This works fine, plus it gives you a chance to tune the interface to your liking.

The downside is that it's not very discoverable. I'll add a note to the class documentation that you should do this for AA/custom GraphicsModes.