safee's picture

Two GLControls on one Form

Hi,

I have two GLControls on a single Windows Form.

One is getting painted well, and the second is not getting painted properly.

Any ideas what may be going wrong?

Thanks


Comments

Comment viewing options

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

Define "not getting painted properly". Are some objects drawn? Are some objects shaded? Is the aspect ratio wrong? And about all, what objects do you use for drawing?

When using multiple GLControls, you are using multiple GL contexts. Therefore, you have to switch to the right context before drawing, so in each GLControl PaintEvent handler you start with the desired control's MakeCurrent() function. If the sizes of the two controls differ, you have to adjust the viewport accordingly, too, with GL.Viewport(x, y, width, height).

There are some OpenGL objects that are bound to a context, e.g. the vertex array object (VAO). You can't use VAOs to draw in multiple contexts, but need to create an individual one from mutually used VBOs for each context you use.

safee's picture

Thanks mOfl!

MakeCurrent was the missing call!