Jump to content
  • Advertisement
Sign in to follow this  
EnjoysMath

How do you get rid of "drag lag" in 2D graphics with Cairo.

This topic is 895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I am creating a quite-complex app using GtkD and the D programming language.

 

When you are moving a 2D graphics item with the mouse, there's a noticeable lag between the intermediately-rendered 2D graphics and the current mouse position.

 

I have an onMouseMove event handler that does something like:

onMouseMove {
     delta = currMousePos - lastMousePos;
     foreach (obj; freeObjs) {
         obj.translate(delta)
     }
     queueRedraw(boxList /*calculated above*/);
}

I queue the redraws (only effected boxes during a move) using:

queuRedraw(boxList) { 
   // calls gtk.DrawingArea.queueDrawArea
}

The draw callback looks like:

drawCallback() {
     // Draw effected geometry in AABBTree
     // Draw freeObjs
}

The problem is occuring because too many redraws are accumulating.    How do I limit the redraws or somehow only redraw the free objects at the current mouse pos?   I've tried many things and all have worse performance than the current set up or are buggy.

 

I've tried incrementing a redrawQCounter variable upon queuing and decrementing upon redraw, but it seems to grow and not converge back to zero.

 

I've tried playing with the time derivative of the mouse position as well, and failed.

 

Any ideas?  My next guess is my own queueing function that queues a redraw only when (WHAT? Idk...).

 

Thank you, Graphics Programming Gods!

 

If you have VisualD running and GtkD installed I can send you the source code.

 

-EM

Edited by EnjoysMath

Share this post


Link to post
Share on other sites
Advertisement

This little snippet seems to have reduced the number of draws when moving many objects:

 

I have my own queueDrawRect() function with a Rect[] drawQueue;   Whenever the queue gets full really quickly, I set its size back to zero and only draw the first and last.  Seems to work, though there's not an improvement when moving single objects.

 

Perhaps I should've used a list over my own AABBTree structure biggrin.png

 

(See attached photo)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!