Jump to content
  • Advertisement

Archived

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

DavidClarke

Render Function Called Twice!?

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

I''ve noticed that my render function is called twice (from MyApp.cpp) whenever my vertices have changed once. There is one call to the render function (in a file called d3dapp.cpp)? (Here''s a snippet of my code from d3dapp.cpp) HRESULT CD3DApplication::Render3DEnvironment() { HRESULT hr; // Render the scene as normal if( FAILED( hr = Render() ) ) return hr; // Show the frame on the primary surface. hr = g_pDirect3DDevice->Present( NULL, NULL, NULL, NULL ); if( D3DERR_DEVICELOST == hr ) m_bDeviceLost = true; return S_OK; } (Here''s a snippet of my code from MyApp.cpp) HRESULT CAppForm::Render() { // Clear the viewport g_pDirect3DDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x00000000, 1.0f, 0L ); UpdateVertices(); // Begin the scene if(SUCCEEDED(g_pDirect3DDevice->BeginScene())) // g_pDirect3DDevice->EndScene();// } return S_OK; }

Share this post


Link to post
Share on other sites
Advertisement
Looks like someone is playing with the VC++ MFC/DirectX app wizard

What you are looking at is one render loop. It''s the sequence that''s confusing you..

Look at "CApp::OnIdle()" It uses a global instance of a "CAppForm" to check for lost surfaces and render the scene.

CAppForm::RenderScene() simply calls Render3DEnvironment(). As CAppForm is derived partly from CD3DApplication, look at CD3DApplication::Render3DEnvironment().

This is where rendering begins and ends. Because CAppForm is also derived from CFormView, when (in this case) Render3DEnvironment() calls Render() it''s actually calling CAppForm::Render() - Your apparent second render function is in fact where your app should do all it''s drawing.

Sometime after calling Render(), Render3DEnvironment() finishes the rendering process with "m_pd3dDevice->Present()".

Messing in the murky waters of the MFC framework isn''t recommended without a life-vest

Share this post


Link to post
Share on other sites
quote:
Original post by DavidClarke
I''ve noticed that my render function is called twice (from MyApp.cpp) whenever my vertices have changed once. There is one call to the render function (in a file called d3dapp.cpp)?




Then change it.

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!