Drawing without flicker?
-
Hi all, :) Is it possible to draw several shapes directly on a window during a loop without having any flicker? I have tried to use the ValidateRect and InvalidateRect function, but I can’t seem to make them prevent flicker, maybe I am missing something. How do you prevent flicker when drawing directly on a window? :( Aidman » over and out
-
Hi all, :) Is it possible to draw several shapes directly on a window during a loop without having any flicker? I have tried to use the ValidateRect and InvalidateRect function, but I can’t seem to make them prevent flicker, maybe I am missing something. How do you prevent flicker when drawing directly on a window? :( Aidman » over and out
Use a memory device context: http://www.codeproject.com/gdi/flickerfree.asp[^] John
-
Hi all, :) Is it possible to draw several shapes directly on a window during a loop without having any flicker? I have tried to use the ValidateRect and InvalidateRect function, but I can’t seem to make them prevent flicker, maybe I am missing something. How do you prevent flicker when drawing directly on a window? :( Aidman » over and out
One way is to use a memory device context (search codeproject for CMemDC), which is essentially a bitmap in memory. Instead of drawing directly to the screen, you draw everything to the memory DC, and then as the last step in the drawing process, you BitBlt the memory DC onto the real DC. This means that if the same part of the DC is drawn multiple times during the drawing process, you won't see any flicker. Dave http://www.cloudsofheaven.org
-
One way is to use a memory device context (search codeproject for CMemDC), which is essentially a bitmap in memory. Instead of drawing directly to the screen, you draw everything to the memory DC, and then as the last step in the drawing process, you BitBlt the memory DC onto the real DC. This means that if the same part of the DC is drawn multiple times during the drawing process, you won't see any flicker. Dave http://www.cloudsofheaven.org
-
hehe... yes I know you can use doublebuffering, but I wanto know if it possible to have a flicker-free graphic without it. Thanks anyway ;) Aidman » over and out
Quick answer is no. John
-
Quick answer is no. John
But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? So that you can draw stuff on that area and update it when your done, sort of like when you use BeginPaint and EndPaint? Aidman » over and out
-
But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? So that you can draw stuff on that area and update it when your done, sort of like when you use BeginPaint and EndPaint? Aidman » over and out
-
But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? So that you can draw stuff on that area and update it when your done, sort of like when you use BeginPaint and EndPaint? Aidman » over and out
Aidman wrote: But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? Yes, but the part you don't validate will still flicker if you draw over the same part multiple times or if you don't handle WM_ERASEBKGND to prevent the background being erased. It's almost always better to use a memory DC, combined with selective invalidating like you suggested. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact" -
Aidman wrote: But shouldn't it be possible to use ValidateRect or some other function to prevent an graphic area from updating to the screen? Yes, but the part you don't validate will still flicker if you draw over the same part multiple times or if you don't handle WM_ERASEBKGND to prevent the background being erased. It's almost always better to use a memory DC, combined with selective invalidating like you suggested. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"Ryan Binns wrote: if you don't handle WM_ERASEBKGND to prevent the background being erased. YES! This is very important to avoid filcker even if you use a memory dc. John
-
Ryan Binns wrote: if you don't handle WM_ERASEBKGND to prevent the background being erased. YES! This is very important to avoid filcker even if you use a memory dc. John
John M. Drescher wrote: YES! This is very important to avoid filcker even if you use a memory dc. Absolutely! I probably didn't make that clear enough did I :) Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"