Solved

Cursor flickering while Blitting

Posted on 2001-07-30
13
407 Views
Last Modified: 2013-11-20

    Hi,

    I'm Bliting from surface(IDirectDrawSurface) to surface, while DestRect is not equal to
SrcRect. (Yes, I'm aware of performance penalty) . I get cursor flickering. However, if blitting is done on rectangles of the same size there is no problem.

Is it possible to remove, or at least, to reduce that cursor flickering?
Thanks in advance,

Yakov.
0
Comment
Question by:yashik
  • 5
  • 2
  • 2
  • +4
13 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6335289
Hi!
Try use
ShowCursor(FALSE);
///blitting here;
ShowCursor(TRUE);
0
 
LVL 2

Author Comment

by:yashik
ID: 6335401
Hi Migel,

Thank you for your answer. Unfortunatelly, this makes the problem worse ( more flickering )  ;-(
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6335538
I would guess that the driver can transfer same-size blit within one screen refresh cycle, but when needing to resize the bitmap, it takes just enough extra time to cause the flicker.  

Solution:
You could try blitting to a memory DC first.  In this step, the destination-size rectangle of the memory DC is the desired final size.  Then blit from the memory DC to the screen (same-size).  This should at least minimize the flicker.  

-- Dan
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6335810
I agree with DAN on this also if you do all your bltting to the memory DC and then one last one to the screen DC then it should also be faster
0
 
LVL 2

Author Comment

by:yashik
ID: 6335870

My refresh rate is about 20-30 frames/sec, each frame is of size 800x600, or even more. The overhead of copying an extra 800x600x4 bytes is too high

I guess, what I will need to do is to draw the cursor by myself, as a part of the Blitting process, which is, of cause a major headache. ( Or convince the product manager to give up ;-)
0
 
LVL 2

Author Comment

by:yashik
ID: 6335880
BTW, this does not happens on small surfaces, like 300x200.

Dan and Shaun, thank you for your comments.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:GlennDean
ID: 6336403
I would recommend creating a secondary surface, do all drawing on the secondary surface, and then flip the primary surface with the secondary one.  IF you're writing to the primary surface, to me, that seems to be an incorrect/bad idea to begin with.

     Glenn
0
 
LVL 3

Assisted Solution

by:GlennDean
GlennDean earned 100 total points
ID: 6336419
When you create the primary surface, don't forget to set the dwFlags bit in the DDSURFACEDESC structure to have DDSD_BACKBUFFERCOUNT, and to set the dwBackBufferCount to 1.  The 1 creates the secondary surface that you need to do all your drawing on.  
   Then, to retrieve the secondary surface call the GetAttachedSurface method.  
  Then draw on this surface.  
   Then, to flip the two surfaces, call the Flip function (do this on the IDirectDrawSurface of the primary surface interface pointer!).  
0
 
LVL 9

Expert Comment

by:Pacman
ID: 6337204
Did you try it with other graphics adapters ?
Maybe the flickering blitting is done in the driver's part.
0
 
LVL 2

Author Comment

by:yashik
ID: 6337498
Glen,
I'm not working in fullscreen mode. Is it still correct? Besides, I'm not sure I can just "flip" surfaces, since I'm not drawing the whole frame each time, but only a part of it. So, I'll need some extra work to copy from the primary to back to the offscreen, draw on offscreen and then flip.
I think, customize cursor drawing is faster.

Pacman,
I've tried it on several adapters. On one of them there is almost no problem, while on others it only get worse. I agree with Dan, that this is clearly performance problem, but I was hoping DirectX has some ways to solve it.


Thank you all for your comments
0
 
LVL 9

Assisted Solution

by:Pacman
Pacman earned 100 total points
ID: 6339904
what about moving the cursor outside the screen while drawing ?

* save cursor position
* move cursor to the bottom right edge of the screen
* do blitting
* move cursor back to saved position
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490582
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : DanRollins, Pacman (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0
 
LVL 2

Author Comment

by:yashik
ID: 9494059
Although I gave this up, you guys gave good answers. Thank you all ( and sorry for the delay )
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now