Bs.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "anki/renderer/Bs.h"
  2. #include "anki/renderer/Renderer.h"
  3. #include "anki/resource/ShaderProgramResource.h"
  4. namespace anki {
  5. //==============================================================================
  6. Bs::~Bs()
  7. {}
  8. //==============================================================================
  9. void Bs::createFbo()
  10. {
  11. try
  12. {
  13. fbo.create();
  14. fbo.bind();
  15. fbo.setColorAttachments({&r->getPps().getPrePassFai()});
  16. fbo.setOtherAttachment(GL_DEPTH_STENCIL_ATTACHMENT,
  17. r->getMs().getDepthFai());
  18. fbo.checkIfGood();
  19. fbo.unbind();
  20. }
  21. catch(std::exception& e)
  22. {
  23. throw ANKI_EXCEPTION("Failed to create blending stage FBO") << e;
  24. }
  25. }
  26. //==============================================================================
  27. void Bs::createRefractFbo()
  28. {
  29. try
  30. {
  31. refractFbo.create();
  32. refractFbo.bind();
  33. refractFbo.setColorAttachments({&refractFai});
  34. refractFbo.setOtherAttachment(GL_DEPTH_STENCIL_ATTACHMENT,
  35. r->getMs().getDepthFai());
  36. refractFbo.checkIfGood();
  37. refractFbo.unbind();
  38. }
  39. catch(std::exception& e)
  40. {
  41. throw ANKI_EXCEPTION("Failed to create blending stage refract FBO")
  42. << e;
  43. }
  44. }
  45. //==============================================================================
  46. void Bs::init(const RendererInitializer& /*initializer*/)
  47. {
  48. createFbo();
  49. Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGBA8, GL_RGBA,
  50. GL_FLOAT, refractFai);
  51. createRefractFbo();
  52. refractSProg.load("shaders/BsRefract.glsl");
  53. }
  54. //==============================================================================
  55. void Bs::run()
  56. {
  57. /// @todo
  58. }
  59. } // end namespace