![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
codemaniac
Join Date: Dec 2007
Posts: 9
Rep Power: 0
![]() |
InvalidateRect???
hello... i'm writing a C++/Win32 connect four program... its still in development... but the source can be found here[link]... i'm doing alright... except with updating the board... I used InvalidateRect(hWnd,NULL,true) to update it... the problem is that this updates the entire screen and causes it to flicker... does anyone know any better methods to keep it form flickering??? Any help would be greatly appreciated.
|
|
|
|
|
|
#2 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
Re: InvalidateRect???
Don't double post in the future please.
I'd suggest you look into double buffering if you haven't already.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#3 |
|
codemaniac
Join Date: Dec 2007
Posts: 9
Rep Power: 0
![]() |
Re: InvalidateRect???
double buffering??? ok... thanks... i'll look it up
|
|
|
|
|
|
#4 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5
![]() |
Re: InvalidateRect???
Another thing besides double buffering is proper use of
InvalidateRect(). The purpose of this function is to invalidate (ie mark as not up-to-date) a rectangle within your window. As such, if you pass the entire window (or more precisely, the entire client area), you will get more flicker than if you invalidate the smallest region possible.With something like your game, it should only be updating a small region (about 1/16th of the client area) with each move, and this will probably lead to less flicker. Even if you get the flicker issue solved with double buffering, you should do this; it doesn't make sense to blit sixteen times the pixels you need to.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: InvalidateRect???
This is more a windows programming (or, a graphics programming) question, which is independent of programming language, and has no place in a C++ forum.
win32 specific answer follows..... When using InvalidateRect(), it is also necessary for the WM_PAINT handler for the window to determine (using means specific to the application) whether it has been invoked in response to one or more invalidated regions or in response to a requirement to redraw the whole window. Failure to do this means that, by default, the WM_PAINT must update the whole window .... which sort of counteracts the benefits of using InvalidateRect() in the first place [one of the symptoms will be window flicker, as the entire window may be refreshed every time a region within the window is invalidated]. Look up the documentation on the WM_PAINT message (eg here) for more information. |
|
|
|
|
|
#6 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 547
Rep Power: 4
![]() |
Re: InvalidateRect???
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Re: InvalidateRect???
Up yours.
![]() Generically, I'd normally suggest it go into a win32 programming area or into a graphics programming area. Catch is, neither of those exist in PFO. The problem with putting it into a C++ area is that it is really not C++. And the problem is independent of programming language: it is a win32 problem that exists, and has the same solution, if it comes up in any win32 context (eg Delphi, VB, Digital Fortran, ....) |
|
|
|
|
|
#8 |
|
codemaniac
Join Date: Dec 2007
Posts: 9
Rep Power: 0
![]() |
Re: InvalidateRect???
thanks and i soved the problem... heres the code if ya want it...
http://h1.ripway.com/jyoung0922/Temp.zip |
|
|
|
|
|
#9 |
|
codemaniac
Join Date: Dec 2007
Posts: 9
Rep Power: 0
![]() |
Re: InvalidateRect???
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|