EarlyZ.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "Renderer.h"
  2. #include "App.h"
  3. #include "MeshNode.h"
  4. #include "Scene.h"
  5. //=====================================================================================================================================
  6. // init =
  7. //=====================================================================================================================================
  8. void Renderer::Ms::EarlyZ::init()
  9. {
  10. //
  11. // init FBO
  12. //
  13. fbo.create();
  14. fbo.bind();
  15. fbo.setNumOfColorAttachements( 0 );
  16. glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r.ms.depthFai.getGlId(), 0 );
  17. if( !fbo.isGood() )
  18. FATAL( "Cannot create shadowmapping FBO" );
  19. fbo.unbind();
  20. }
  21. //=====================================================================================================================================
  22. // run =
  23. //=====================================================================================================================================
  24. void Renderer::Ms::EarlyZ::run()
  25. {
  26. fbo.bind();
  27. Renderer::setViewport( 0, 0, r.width, r.height );
  28. glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
  29. glEnable( GL_DEPTH_TEST );
  30. glDisable( GL_BLEND );
  31. for( Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++ )
  32. {
  33. MeshNode* meshNode = (*it);
  34. if( meshNode->material->blends || meshNode->material->refracts ) continue;
  35. DEBUG_ERR( meshNode->material->dpMtl == NULL );
  36. r.setupMaterial( *meshNode->material->dpMtl, *meshNode, *r.cam );
  37. meshNode->render();
  38. }
  39. glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
  40. }