render function in MFC
hi.
where should i put the render() function in MFC created application?
i''ve tried to put it on WM_PAINT and do InvalidateRect() every th of second.
but this means i PREdetermined the FramePerSecs which is i not really like.
or should there any extra job to do this?
currently for testing purposes my render() only consist of
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(m_R,m_G,m_B), 1.0f, 0 );
m_pd3dDevice->Present( NULL, NULL, NULL, NULL );
Are you making a game in MFC or only an editor?
Anyway, put render into the OnDraw of your view(s). Put an InvalidateRect (or better, UpdateAllViews) in your CWinApp-derived classes OnIdle. This is probably as fast as it gets with proper MFC.
Anyway, put render into the OnDraw of your view(s). Put an InvalidateRect (or better, UpdateAllViews) in your CWinApp-derived classes OnIdle. This is probably as fast as it gets with proper MFC.
Methinks: UpdateWindow is faster than Invalidate because UpdateWindow sends WM_PAINT directly rather than simply marking area for repainting when next WM_PAINT arrives...
OnIdle is probly best in your case. I personaly use a timer (I use a flag to keep it from trying to go to fast on slow machines) because I am (trying) to use DirectX to make an drawing program, and I don''t want to use up all the CPU time (I want to share with other apps).
In C++ .NET you can use a while ( 1 == 1 ) loop and do a render than pump and event (System::Windows::Forms::Application::DoEvents();
This is best IMO if you are writting a real time game etc.
Thank you for your time,
Arrummzen
OnIdle is probly best in your case. I personaly use a timer (I use a flag to keep it from trying to go to fast on slow machines) because I am (trying) to use DirectX to make an drawing program, and I don''t want to use up all the CPU time (I want to share with other apps).
In C++ .NET you can use a while ( 1 == 1 ) loop and do a render than pump and event (System::Windows::Forms::Application::DoEvents();
This is best IMO if you are writting a real time game etc.
Thank you for your time,
Arrummzen
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement