[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

Cursor flickering while Blitting


    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
yashik
Asked:
yashik
  • 5
  • 2
  • 2
  • +4
3 Solutions
 
migelCommented:
Hi!
Try use
ShowCursor(FALSE);
///blitting here;
ShowCursor(TRUE);
0
 
yashikAuthor Commented:
Hi Migel,

Thank you for your answer. Unfortunatelly, this makes the problem worse ( more flickering )  ;-(
0
 
DanRollinsCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ShaunWildeCommented:
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
 
yashikAuthor Commented:

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
 
yashikAuthor Commented:
BTW, this does not happens on small surfaces, like 300x200.

Dan and Shaun, thank you for your comments.
0
 
GlennDeanCommented:
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
 
GlennDeanCommented:
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
 
PacmanCommented:
Did you try it with other graphics adapters ?
Maybe the flickering blitting is done in the driver's part.
0
 
yashikAuthor Commented:
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
 
PacmanCommented:
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
 
Roshan DavisCommented:
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
 
yashikAuthor Commented:
Although I gave this up, you guys gave good answers. Thank you all ( and sorry for the delay )
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now