redraw shaking problem !

  • Thread starter black(flashing vampire)
  • Start date
B

black(flashing vampire)

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.
 
R

Richard Heathfield

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.
 
B

black(flashing vampire)

black(flashing vampire) said:



Double-buffering - blit from back buffer to main buffer. Works like a
charm.


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


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 !!!
 
R

Richard Heathfield

black(flashing vampire) said:
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.
 
B

black(flashing vampire)

...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 !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top