Render Function Called Twice!?
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;
}
Your calling render in your UpdateVertices code.
[Edited by - RapidStunna on October 18, 2005 2:13:06 PM]
[Edited by - RapidStunna on October 18, 2005 2:13:06 PM]
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
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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement