• Advertisement
Sign in to follow this  

When do I update graphics?

This topic is 4044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello... I'm writing an app where I use direct3d to draw in the client area of the main form. I'm using the win32 api and I don't have a rendering loop becouse I have to render only on click messages. The problem is that i don't know on wich messages I have to redraw the screen, for example on the resizing of the form or when another window goes over client area. When that happens I get the black background color that I've set in the class of the main form. Can someone explain the methods to avoid that? Thx!

Share this post


Link to post
Share on other sites
Advertisement
Actually doing drawing inside WM_PAINT ought to be enough. You might want to override WM_ERASEBKGND by doing nothing and returning TRUE.

So in most cases (resizing) the update will happen automatically. On mouseclick you simply issue an InvalidateRect call and let WM_PAINT do the rest.

Share this post


Link to post
Share on other sites
Thanks for the answer...

I've added that in the message procedure of the main form:

case WM_PAINT:
cGraphic::Render();
break;

It works fine, but if i try to show a modal dialog from the main form the cpu starts to work at 100%, the dialog doesn't open and the main form don't process messages...am i doing something wrong?

for now cGraphics::Render() only clears the backbuffer and presents it

Share this post


Link to post
Share on other sites
Right now the client are stays "dirty" and Windows keeps sending WM_PAINT messages.

Since you override the WM_PAINT call you have to validate the dirty area. You can let Windows do the work for you:

Use BeginPaint, call your render function, call EndPaint and return 0 to stop further processing:


...
case WM_PAINT:
{
cGraphic::Render();

PAINTSTRUCT ps;
BeginPaint( hwnd, &ps )
EndPaint( hwnd, &ps );

return 0;
}


BTW: You do not have to call cGraphic::Render inside the BeginPaint/EndPaint block, just somewhere during WM_PAINT.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement