By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,486 Members | 1,696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,486 IT Pros & Developers. It's quick & easy.

redraw shaking problem !

P: n/a
Hi all,

i'm trying to make my first windows tetris game but found a severe
problem. that is, everytime i update(redraw) the window it may be
filled with shaking lines. i checked some articles and also i have a
nice book "tricks of windows programming guru", but they both didnt
help.
here're parts of my code:

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Do something...

while (1)
{
if (PeekMessage(&msg, hwndRoot, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

updateGame();
}

return FALSE;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
drawGame();
break;
case WM_KEYDOWN:
keyPressedGame(wParam);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}

return 0;
}

void updateGame()
{
// Do something...

InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}

and also i use UpdateWindow and
is there anything wrong ? btw i use GDI to draw objects in my game,
does it matter anyway ?
btw, how to mail to this group directly ? i have to post my message
via browser.

Mar 21 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
black(flashing vampire) said:
Hi all,

i'm trying to make my first windows tetris game
comp.os.ms-windows.programmer.win32
but found a severe problem. that is, everytime i update(redraw) the
window it may be filled with shaking lines.
Double-buffering - blit from back buffer to main buffer. Works like a
charm.
btw, how to mail to this group directly ?
Use a newsreader, e.g. Thunderbird. Legal, free download from the Web.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 21 '07 #2

P: n/a
On Mar 21, 5:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
black(flashing vampire) said:
Hi all,
i'm trying to make my first windows tetris game

comp.os.ms-windows.programmer.win32
but found a severe problem. that is, everytime i update(redraw) the
window it may be filled with shaking lines.

Double-buffering - blit from back buffer to main buffer. Works like a
charm.
btw, how to mail to this group directly ?

Use a newsreader, e.g. Thunderbird. Legal, free download from the Web.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.

someone told me that double buffer is used only for applications which
have less memory, but my app is a very simple one, should i use double
buffer anyway ?
and because it is my first time to build a windows app, could you show
me a simple example of double buffer with GDI ? one million thanks !!!

Mar 21 '07 #3

P: n/a
black(flashing vampire) said:
On Mar 21, 5:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>>
Double-buffering - blit from back buffer to main buffer. Works like a
charm.
someone told me that double buffer is used only for applications which
have less memory, but my app is a very simple one, should i use double
buffer anyway ?
Since double-buffering requires *more* memory, that sounds like very
strange advice. The idea of double-buffering is that you update the
window in one fell swoop rather than in lots of itty-bitty little
draws, resulting in a vastly smoother transition between frames. It's
an astoundingly effective technique. But, as I suggested in my first
reply, you would be better off seeking advice on the precise details in
comp.os.ms-windows.programmer.win32, where Windows programming is
topical.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 21 '07 #4

P: n/a
...as I suggested in my first
reply, you would be better off seeking advice on the precise details in
comp.os.ms-windows.programmer.win32, where Windows programming is
topical.
oki i'll try my luck there, thanks man !

Mar 22 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.