mandragora's picture

GLControl refresh ...

Hi All,

I'm having a strange behaviour refreshing using glControl.

I've one button that fires some calculations and create a texture witch is used within the paint method linked to the paint event of the control.

here is the code:

void glControl2_Paint(object sender, PaintEventArgs e)
            if (!glControl2.Context.IsCurrent)
            GL.BindTexture(TextureTarget.Texture2D, processedImage);
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f); //LowerLeft Corner
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f);  //LowerRight Corner
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f);   //UpperRight Corner
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f);  //UpperLeft Corner
        private void button1_Click(object sender, EventArgs e)
            processedImage = ProcessData(bmp);

It's working, is refreshing the control but ... only after the second click on the button.
Any idea on what could be?

Thanks in advance to everybody!

Have a nice day and weekend



Comment viewing options

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

Dear All,

I ported a Tao based project to OpenTK and now encounter a refresh problem:

Having a WinForms Application with a ToolStripContainer, a SplitContainer in the ContentPanel and a GLControl in one of the SplitContainer Panels.

By pressing a Button of the ToolStrip the Camera Position should be changed to a "View from Top" or with another button to "view from the side".
After changing the position and viewpoint of the camera I tried calling GLControl.Invalidate.
This didn't work, so followed an advice from this forum and directly called a drawing function "DrawOGL" instead of waiting for the Paint-Event to fire, which also didn't work.
As a next step I tried to check, whether my GLControl IsCurrent before I call my drawing method - no succes

The GLControl always refreshes OK as soon as the mouse pointer is over the GLControl.

Another way to make it work is to call the "DrawOGL" method twice.

Any idea?