Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

deamicis

Where must i put the Render() funtion?

This topic is 5526 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

In the main program... where i must put the Render() function? in the WM_PAINT section? in the Message loop? where?

Share this post


Link to post
Share on other sites
Advertisement
LOL...

you could put the render function in the wm_paint section and call it from there, or set up a timer and call it in the wm_timer, or call it up in the peek message/translate message thing, again using a custom timer/function call.

kind of paracoded below, the if peek might need to be while peek..

while(1) {
qtimer = diffTime; (current_time - last time called)
if (peekmessage(..)) {
"" ""
"" ""
else
if qtimer>==n_intervals (interval you want render to be called at)
Render();
}
}
return 0;
}

hope that helps..

I fseek, therefore I fam.

Share this post


Link to post
Share on other sites
i had trouble with WM_PAINT, but WM_ERASEBCKGND worked perfectly, like WM_PAINT is supposed to i think.

Share this post


Link to post
Share on other sites
i did This... is it correct???


while(msg.message != WM_QUIT)
{
bGotMessage = PeekMessage(&msg,NULL,0U,0U,PM_REMOVE);
if(bGotMessage)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
Render();
}
else
{
Render();
}
}

Share this post


Link to post
Share on other sites
you are calling Render() twice..


/* Run the message loop. It will run until GetMessage() returns 0 */
while (bRun) {
if (PeekMessage (&messages, NULL, 0, 0, PM_REMOVE))
{
if (messages.message == WM_QUIT) break;
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
else { while (!list.event());
Render();
}
}
COMMAND.CleanUp();
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}


list.event() loops until timer interval is met

Share this post


Link to post
Share on other sites
it renders also when i have an input... is that bad?

Whend i tried to use the WM_PAIN it works only when i resize the window or i move it, when the window is stopped it doesn''t go to the WM_PAIN section

Share this post


Link to post
Share on other sites
You could also try

InvalidateRect(hwnd, NULL, NULL)

which will tell your window to invalidate itself, and will have windows schedule a WM_PAINT message in your queue, then you can render within the WM_PAINT handler. You call InvalidateRect whenever something will change on your screen. (For instance in your WM_CHAR handler, or maybe when some timer fires).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!