
Inheriting from GLControl
Posted Friday, 31 August, 2012 - 16:02 by rwols inHi everyone, first post here.
I'm having trouble figuring out how to tackle this problem.
Basically I have a custom view class that inherits from GLControl and overrides the OnPaint, OnResize, OnMouseClick, etc, methods that handle various events. Everything that is drawn is two-dimensional. This works excellent so far.
Now let's assume that my custom class has various child controls in it, located in this.Controls. I would like to draw all of these controls with OpenGL too. I'm thinking something along the lines of this:
// ... // the viewport is set so that the lower left corner has coordinates (0,0). GL.Begin(BeginMode.Quads); foreach (Control c in this.Controls) { // Draw each little quad using its Location property, its Size property and its BackColor property. GL.Color3(c.BackColor); GL.Vertex2(c.Location.X, this.Height - c.Location.Y); GL.Vertex2(c.Location.X + c.Width, this.Height - c.Location.Y); GL.Vertex2(c.Location.X + c.Width, this.Height - (c.Location.Y + c.Height)); GL.Vertex2(c.Location.X, this.Height - (c.Location.Y + c.Height)); } // ... GL.End();
*edit: corrected some code mistakes
However, I think GDI interferes and draws on top of my little quads. Basically I'd like to turn this off (the drawing of the many child controls is why I'm on the OpenTK endeavour). Is this really happening though? I don't quite understand the relationship between the OpenGL drawing and the GDI drawing.


Comments
Re: Inheriting from GLControl
After trying to override the OnPaint method on my custom control, GDI still draws "on top of" my custom GLControl view.
So this does not work. What gives? Should I not iterate over my controls collection?