BsBansheeLitTexRenderableHandler.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsBansheeRendererPrerequisites.h"
  6. #include "BsRenderableHandler.h"
  7. #include "BsMaterialProxy.h"
  8. #include "BsGpuParamDesc.h"
  9. #include "BsGpuParam.h"
  10. namespace BansheeEngine
  11. {
  12. /**
  13. * @brief Renderer handler that manages initializing, updating
  14. * and rendering of renderable objects with a single texture
  15. * and a single light.
  16. *
  17. * @note This class is DEBUG ONLY. Until a better renderer is complete.
  18. */
  19. class BS_BSRND_EXPORT LitTexRenderableHandler : public RenderableHandler
  20. {
  21. public:
  22. /**
  23. * @brief Contains lit tex renderable data unique for each object.
  24. */
  25. struct PerObjectData
  26. {
  27. GpuParamBlockBufferPtr perObjectParamBuffer;
  28. bool hasWVPParam = false;
  29. GpuParamMat4 wvpParam;
  30. Vector<MaterialProxy::BufferBindInfo> perObjectBuffers;
  31. };
  32. LitTexRenderableHandler();
  33. /**
  34. * @copydoc RenderableHandler::initializeRenderElem
  35. */
  36. void initializeRenderElem(RenderableElement* element);
  37. /**
  38. * @copydoc RenderableHandler::bindPerObjectBuffers
  39. */
  40. void bindPerObjectBuffers(const RenderableElement* element);
  41. /**
  42. * @brief Updates global parameter buffers with new values.
  43. * To be called whenever global values change.
  44. */
  45. void updateGlobalBuffers(float time);
  46. /**
  47. * @brief Updates object specific parameter buffers with new values.
  48. * To be called whenever object specific values change.
  49. */
  50. void updatePerObjectBuffers(RenderableElement* element, const Matrix4& wvpMatrix);
  51. protected:
  52. /**
  53. * @brief Creates a new default shader used for lit textured renderables.
  54. * It is used for matching custom shaders and determining if they
  55. * comply with lit textured renderable requirements.
  56. */
  57. ShaderPtr createDefaultShader();
  58. ShaderPtr defaultShader;
  59. GpuParamBlockDesc staticParamBlockDesc;
  60. GpuParamBlockDesc perFrameParamBlockDesc;
  61. GpuParamBlockDesc perObjectParamBlockDesc;
  62. GpuParamDataDesc timeParamDesc;
  63. GpuParamDataDesc lightDirParamDesc;
  64. GpuParamDataDesc wvpParamDesc;
  65. GpuParamBlockBufferPtr staticParamBuffer;
  66. GpuParamBlockBufferPtr perFrameParamBuffer;
  67. GpuParamsPtr staticParams;
  68. GpuParamsPtr perFrameParams;
  69. GpuParamVec4 lightDirParam;
  70. GpuParamFloat timeParam;
  71. };
  72. }