
After drawing quad or polygon and resizing entire viewport is the color of the quad/poly
Posted Wednesday, 27 July, 2011 - 20:33 by nlraley inTitle explains it.
I'm loading a bunch of texture into the background, then drawing a quad or polygon.
Everything draws just fine; however, whenever the form is resized, everything is tinted in the color of the quad/poly.
Here is my code:
// Draw Rectangle GL.MatrixMode(MatrixMode.Modelview); GL.Color4(0.0, 0.0, 1.0, 0.5); GL.BlendFunc(BlendingFactorSrc.OneMinusConstantAlpha, BlendingFactorDest.SrcAlpha); //GL.Color3(Color.Blue); GL.Begin(BeginMode.Polygon); foreach (Pixels point in tempPoints) { GL.Vertex3(point.X, point.Y, 0); } GL.End(); // Flush the buffer GL.Flush(); // Swap the buffers glControl1.SwapBuffers();
Am I forgetting to close/reset something that is causing everything to be blue once OpenGL has to redraw?


Comments
Re: After drawing quad or polygon and resizing entire ...
You're not actually clearing the previous contents of the buffer by the looks of it.
Something on the lines of:
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
(Also look at GL.ClearColor to set the color used to clear things)
Unless this is somewhere else in your drawing routine already?
Re: After drawing quad or polygon and resizing entire ...
Sorry, yes, I do that at the very beginning of the Paint routine for the control.
Full repaint from start to finish is:
Of course the first pass of this works just fine. However, when called again it loads the "Tiles" again and then redraws the rectangle, but everything is covered in a blue tint.
Any ideas? Do I have to Clear the buffer again after drawing the rectangles?
Re: After drawing quad or polygon and resizing entire ...
You're setting the draw color to blue with
GL.Color4(0.0, 0.0, 1.0, 0.5);, and I don't see anywhere where you reset it to white, so it shouldn't be surprising that everything is colored blue after the first pass. Try addingGL.Color4(1.0, 1.0, 1.0, 1.0) ;after drawing your rectangle.Re: After drawing quad or polygon and resizing entire ...
Odd, I'd figure the Color would be limited to the scope of the GL.Begin/End call.
If I enable the blend function and draw the quad, it fails to draw the background tiles. How do you clear/reset the blend function?