stupid WIN32 GDI crappy $#@#@$#@$&(@#(*$@(#*

Started by
5 comments, last by machiavelli 20 years, 1 month ago
how can i force a win32 app to re-paint itself. im making a stopwatch type app and the output is obviously text in a window that updates itself a gajillion times per second (as fast as computer can call gettickcount and calculate minutes and secs from it). so... i either need to force repaint because all of my textdraw is in that function or i need a way to draw outside of the paint function so that i can keep the stopwatch updated as often as computationly possible. i suck at life. please help. [edited by - machiavelli on February 21, 2004 1:01:41 AM]
Advertisement
You need to invalidate the window rectangle. A call to InvalidateRect() after your calculations should tell windows to update the display.

Something like InvalidateRect(hWnd, NULL, true); should work well enough.

-Arek the Absolute

[edited by - Arek the Absolute on February 21, 2004 1:07:50 AM]
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
thanks for your help that works but it produces a buttload of flickering... any other suggestions?
there should be a window message for that, look at msdn, i would, but msdn is your friend ill let you get to know it :-D (translation: im lazy)
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
There are a number of things you can do... Sorry if my memory''s a bit fuzzy on this though, it''s been a long time since I''ve done much in the way of graphics with GDI.

Basically, you see flicker because it takes time between when it erases what it draws, and when it prints the new text on the screen. You''d see less flicker if you passed the function false instead of true, because it wouldn''t erase the background, but instead your text would be illegible after one or two printouts. However, this will work fine if you draw every pixel within the rectangle though, for instance with BitBlt. If you need more suggestions, try looking into double buffering.

Sorry I''m not being more specific. The first time it was just not knowing a function, but this is something you should try to reason your way through. Hopefully I''ve given you hints enough to point you in the right direction. If you can''t get it after a while, feel free to ask again and I''ll be more specific, but it would really benefit you to be able to figure out the code yourself.

-Arek the Absolute
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
quote:Original post by machiavelli
thanks for your help that works but it produces a buttload of flickering... any other suggestions?


Double buffer whatever you''re drawing.

Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
Dubblebuffring in the gdi sample:

	// Initialize backbuffer	HDC hdc = GetDC( hwnd );	HDC hdcBackBuffer = CreateCompatibleDC( hdc );	HBITMAP hbBackBuffer = CreateCompatibleBitmap( hdcBackBuffer, 640, 480 );	SelectObject( hdcBackBuffer, (HANDLE)hbBackBuffer );		ReleaseDC( hwnd, hdc );// in the main loop do thiswhile(1){	// Get Dc & clear surface		HDC hdc = GetDC( hwnd );		BitBlt( hdcBackBuffer, 0, 0, 640, 480, 0, 0, 0, WHITENESS);// Paint your stuff here, target hdc is the backbuffer// for instance, draw text:TextOut(hdcBackBuffer, 150, 35, "hello", (int)strlen("hello"));// last thing you do is this:// Flip surfaces		BitBlt( hdc, 0, 0, 640, 480, hdcBackBuffer, 0, 0, SRCCOPY);		ReleaseDC( hwnd, hdc );}
Shields up! Rrrrred alert!

This topic is closed to new replies.

Advertisement