COGLES2ParallaxMapRenderer.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (C) 2013 Patryk Nadrowski
  2. // Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt
  3. // OpenGL ES driver implemented by Christian Stehno and first OpenGL ES 2.0
  4. // driver implemented by Amundis.
  5. // This file is part of the "Irrlicht Engine".
  6. // For conditions of distribution and use, see copyright notice in Irrlicht.h
  7. #include "IrrCompileConfig.h"
  8. #ifdef _IRR_COMPILE_WITH_OGLES2_
  9. #include "COGLES2ParallaxMapRenderer.h"
  10. #include "IGPUProgrammingServices.h"
  11. #include "os.h"
  12. #include "COGLES2Driver.h"
  13. namespace irr
  14. {
  15. namespace video
  16. {
  17. //! Constructor
  18. COGLES2ParallaxMapRenderer::COGLES2ParallaxMapRenderer(const c8* vertexShaderProgram,
  19. const c8* pixelShaderProgram, E_MATERIAL_TYPE baseMaterial,
  20. COGLES2Driver* driver)
  21. : COGLES2MaterialRenderer(driver, 0, baseMaterial)
  22. {
  23. #ifdef _DEBUG
  24. setDebugName("COGLES2ParallaxMapRenderer");
  25. #endif
  26. int Temp = 0;
  27. SharedRenderer = reinterpret_cast<COGLES2MaterialRenderer*>(driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID));
  28. if (SharedRenderer)
  29. SharedRenderer->grab();
  30. else
  31. init(Temp, vertexShaderProgram, pixelShaderProgram, false);
  32. }
  33. //! Destructor
  34. COGLES2ParallaxMapRenderer::~COGLES2ParallaxMapRenderer()
  35. {
  36. if(SharedRenderer)
  37. SharedRenderer->drop();
  38. }
  39. void COGLES2ParallaxMapRenderer::OnSetMaterial(const video::SMaterial& material,
  40. const video::SMaterial& lastMaterial,
  41. bool resetAllRenderstates,
  42. video::IMaterialRendererServices* services)
  43. {
  44. if (SharedRenderer)
  45. SharedRenderer->OnSetMaterial(material, lastMaterial, resetAllRenderstates, services);
  46. else
  47. COGLES2MaterialRenderer::OnSetMaterial(material, lastMaterial, resetAllRenderstates, services);
  48. }
  49. bool COGLES2ParallaxMapRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
  50. {
  51. if (SharedRenderer)
  52. return SharedRenderer->OnRender(service, vtxtype);
  53. else
  54. {
  55. /* Vertex Shader part */
  56. return true;
  57. }
  58. }
  59. } // end namespace video
  60. } // end namespace irr
  61. #endif