Jump to content
  • Advertisement
Sign in to follow this  
GunBlade

OpenGL MFC OpenGL Animation

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

Hi all. I have an MFC OpenGL View class. How can I make it so the window refreshes regardless of any actions I take (For animation)? I have tried adding RedrawWindow() at the end of my rendering function, but it makes the entire program very very choppy. Is there a way to do this properly? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
If you're not already using double buffering, this might be the problem.

Here: http://www.codeproject.com/gdi/flickerfree.asp

Share this post


Link to post
Share on other sites
Hi.
I am using double-buffering. I also swap the buffers after every frame.
The question is when do I call the redraw in case the user is not doing anything? Right now the window redraws only if there is a click event for which I added a redraw, and whenever I move between windows. I want some sort of automatic refresh for animation.

Thank you

Share this post


Link to post
Share on other sites
For a MFC application, you need to write a function that does rendering in a infinite loop, like it is done in games. The Nehe tutorials do rendering in a inifinit loop.
It's something like this

while(1)
{

if(PostMessage()==0)
{
}
else
{
glClear();
RenderStuff();
SwapBuffers();
}
}

and then it will look smooth.
RedrawWindows, InvalidateRect and other such WinAPI functions just post a WM_PAINT to the queue, which gets low priority.

Share this post


Link to post
Share on other sites
Thanks for the answer.
Can you please explain a little? I checked out NeHe's tutorials and found nothing like that, I guess I should have looked harder. In any case, were I to use an infinite loop, where would I put it? There's no main function or anything like it. How would I respond to system messages such as mouse clicks?

Thanks again.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!