Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 2nd, 2007, 10:15 PM   #1
09jyoung
codemaniac
 
Join Date: Dec 2007
Posts: 9
Rep Power: 0 09jyoung is on a distinguished road
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.
09jyoung is offline   Reply With Quote
Old Dec 2nd, 2007, 10:18 PM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 742
Rep Power: 3 Jimbo is on a distinguished road
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>
Jimbo is offline   Reply With Quote
Old Dec 2nd, 2007, 10:24 PM   #3
09jyoung
codemaniac
 
Join Date: Dec 2007
Posts: 9
Rep Power: 0 09jyoung is on a distinguished road
Re: InvalidateRect???

double buffering??? ok... thanks... i'll look it up
09jyoung is offline   Reply With Quote
Old Dec 3rd, 2007, 1:12 AM   #4
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 887
Rep Power: 4 lectricpharaoh will become famous soon enough
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.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old Dec 3rd, 2007, 3:52 AM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,192
Rep Power: 5 grumpy is on a distinguished road
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.
grumpy is offline   Reply With Quote
Old Dec 3rd, 2007, 6:50 AM   #6
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 489
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: InvalidateRect???

Quote:
Originally Posted by grumpy View Post
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.
.
Where do you suggest we put it? (Please, don't say "Up Mine" )
Ancient Dragon is offline   Reply With Quote
Old Dec 3rd, 2007, 3:39 PM   #7
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,192
Rep Power: 5 grumpy is on a distinguished road
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, ....)
grumpy is offline   Reply With Quote
Old Dec 17th, 2007, 9:00 PM   #8
09jyoung
codemaniac
 
Join Date: Dec 2007
Posts: 9
Rep Power: 0 09jyoung is on a distinguished road
Re: InvalidateRect???

thanks and i soved the problem... heres the code if ya want it...
http://h1.ripway.com/jyoung0922/Temp.zip
09jyoung is offline   Reply With Quote
Old Dec 17th, 2007, 9:03 PM   #9
09jyoung
codemaniac
 
Join Date: Dec 2007
Posts: 9
Rep Power: 0 09jyoung is on a distinguished road
Re: InvalidateRect???

Quote:
Originally Posted by Jimbo View Post
Don't double post in the future please.

I'd suggest you look into double buffering if you haven't already.
sorry... no one answered me in the other one
09jyoung is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC