Vitone's picture

Drawing the reversible frame without redrawing the all screen

Hi!
I need to draw the reversible frame without clearing and redrawing the all screen.
How can I to do this?


Comments

Comment viewing options

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

Are you referring to xor drawing? The link has details on how to implement this.

Since xor drawing is deprecated, I would suggest using CopyTexImage2D to copy your drawing to a texture. You can then use this texture to refresh damaged regions without redrawing the whole screen.

Vitone's picture

Thanks, Fiddler.
I will try to use this 2 ways.

Vitone's picture

I can't to find any example how to use CopyTexImage2D.
This is my wrong code (in Tao.Framework):

            bool startMouseMove=false;
            int RenderTex;
            private void glControl_MouseMove(object sender, MouseEventArgs e)
            {
                Gl.glDrawBuffer(Gl.GL_FRONT);
                if (startMouseMove)
                {
                    Gl.glBegin(Gl.GL_QUADS);                           // Black rectangle!!!
                    Gl.glTexCoord2dv(new double[] { 0.0, 0.0 });
                    Gl.glVertex2d(mousePositionPrev.X-35, mousePositionPrev.Y-60);
                    Gl.glTexCoord2dv(new double[] { 1.0, 0.0 });
                    Gl.glVertex2d(mousePositionPrev.X-35 + 70, mousePositionPrev.Y-60);
                    Gl.glTexCoord2dv(new double[] { 1.0, 1.0 });
                    Gl.glVertex2d(mousePositionPrev.X-35 + 70, mousePositionPrev.Y -60 + 120);
                    Gl.glTexCoord2dv(new double[] { 0.0, 1.0 });
                    Gl.glVertex2d(mousePositionPrev.X-35, mousePositionPrev.Y -60 + 120);
                    Gl.glEnd();
                }
                else
                {
                    startMouseMove = true;
                    mousePosition = glControl.PointToClient(Cursor.Position);
                }
                mousePositionPrev = mousePosition;
                mousePosition = glControl.PointToClient(Cursor.Position);
                 DrawFrames(mousePosition, 1);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, RenderTex);
                Gl.glCopyTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, 
                  mousePosition.X, mousePosition.Y, 70, 120, 0);
                Gl.glFlush();
                Gl.glDrawBuffer(Gl.GL_BACK);
 
 
            }

What is wrong?

the Fiddler's picture

You are not setting the read buffer anywhere in the code. Check the specs:

Quote:

glCopyTexImage2D defines a two-dimensional texture image with pixels from the current GL_READ_BUFFER.

In other words, you need to use glReadBuffer to indicate the source of the copy.

Vitone's picture

It does not help .
I correctly use CopyTexImage2D?

                Gl.glReadBuffer(Gl.GL_FRONT);
                Gl.glDrawBuffer(Gl.GL_FRONT);
 
                if (startMouseMove)
                {
                   ...

Thanks!

the Fiddler's picture

This looks just about right. Try calling glFinish() before glCopyTexImage2D().