Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

in the end render loop is there a way to get rid of this line?

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



for( UINT p = 0; p < techDesc.Passes; ++p )
{
entityTech->GetPassByIndex( p )->Apply( 0 );
g_pd3dDevice->DrawIndexed( meshPointer->m_NumIndices, 0, 0 );

}



ist this line entityTech->GetPassByIndex( p )->Apply( 0 );

even though it uses the same shader techneque, still have to pass it over , evev if there is only one pass
this feels odd, try to only use it once per shader change , but not work , or is it a case of just have to live with it ?

Share this post


Link to post
Share on other sites
Advertisement
If you know for sure that you only have one pass in the effect file, you could cache the effect pass pointer after the compilation and just call its Apply method when rendering your things. However, this would deliberately make your code less flexible - you may not know if you have multiple passes in the future. The loop approach works with any number of passes.

In addition, this code should be written in as few different places as possible, anyway - usually, only in a "renderable" base class.

The GetPassByIndex method is very lightweight, especially when compared to the calls that the Apply method has to do internally.

Share this post


Link to post
Share on other sites
Yeah I agree, It will definitely make your code less flexible, even if you did decide to take the loop out, it wouldn't make much of a different in your frame time.

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!