iliak's picture

Custom GlControl creation with Visual Studio editor

Project:The Open Toolkit library
Version:all versions
Category:support request

For my project, I need to enable Stencil buffer. By default, it's not activated. So I need the following code (not yet sure about argument values) :

// Commented the following code from "InitializeComponent();" :
// "this.RenderControl = new OpenTK.GLControl();"
// Added the following to the constructor of my form :
GraphicsMode mode = new GraphicsMode(new ColorFormat(32), 24, 8);
RenderControl = new OpenTK.GLControl(mode);

This way I can create a custom GlControl.

But now, when I want to edit my form in the Form Designer, I have a nice error :

'RenderControl is not declared or not assigned'

Is there a better way ?


Comment viewing options

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


I'd suggest creating a new custom Control that inherits from GLControl. This way you can set the mode in your constructor and everything will work as expected:

class RenderControl : GLControl
    public RenderControl()
        : base(new GraphicsMode(new ColorFormat(32), 24, 8))
    { }
iliak's picture


Works great.

Thanks !

the Fiddler's picture


Status:open» closed