CmDeferredRenderContext.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCommon.h"
  4. #include "CmSamplerState.h"
  5. #include "CmGpuProgram.h"
  6. #include "CmColor.h"
  7. namespace CamelotEngine
  8. {
  9. /**
  10. * @brief Deferred render context allows you to execute RenderSystem commands outside of the render thread.
  11. * DeferredRenderContext cannot be shared between threads. It must be created and used on the threat that created it.
  12. *
  13. * @note All commands are queued and only executed after the call to submitToGpu, in the order they were called.
  14. */
  15. class CM_EXPORT DeferredRenderContext
  16. {
  17. public:
  18. DeferredRenderContext(RenderSystem* rs, CM_THREAD_ID_TYPE threadId);
  19. ~DeferredRenderContext();
  20. /** @copydoc RenderSystem::setWaitForVerticalBlank() */
  21. void setWaitForVerticalBlank(bool enabled);
  22. /** @copydoc RenderSystem::getWaitForVerticalBlank() */
  23. bool getWaitForVerticalBlank(void) const;
  24. /** @copydoc RenderSystem::disableTextureUnit() */
  25. void disableTextureUnit(UINT16 texUnit);
  26. /** @copydoc RenderSystem::disableTextureUnitsFrom() */
  27. void disableTextureUnitsFrom(UINT16 texUnit);
  28. /** @copydoc RenderSystem::setPointParameters() */
  29. void setPointParameters(float size, bool attenuationEnabled, float constant, float linear, float quadratic, float minSize, float maxSize);
  30. /** @copydoc RenderSystem::setTexture() */
  31. void setTexture(UINT16 unit, bool enabled, const TexturePtr &texPtr);
  32. /** @copydoc RenderSystem::setSamplerState() */
  33. void setSamplerState(UINT16 texUnit, const SamplerState& samplerState);
  34. /** @copydoc RenderSystem::setBlendState() */
  35. void setBlendState(const BlendState& blendState);
  36. /** @copydoc RenderSystem::setRasterizerState() */
  37. void setRasterizerState(const RasterizerState& rasterizerState);
  38. /** @copydoc RenderSystem::setRasterizerState() */
  39. void setDepthStencilState(const DepthStencilState& depthStencilState);
  40. /** @copydoc RenderSystem::setStencilRefValue() */
  41. void setStencilRefValue(UINT32 refValue);
  42. /** @copydoc RenderSystem::setViewport() */
  43. void setViewport(const Viewport& vp);
  44. /** @copydoc RenderSystem::setClipPlanes() */
  45. void setClipPlanes(const PlaneList& clipPlanes);
  46. /** @copydoc RenderSystem::addClipPlane(const Plane&) */
  47. void addClipPlane(const Plane& p);
  48. /** @copydoc RenderSystem::addClipPlane(float, float, float, float) */
  49. void addClipPlane(float A, float B, float C, float D);
  50. /** @copydoc RenderSystem::resetClipPlanes() */
  51. void resetClipPlanes();
  52. /** @copydoc RenderSystem::setScissorTest() */
  53. void setScissorTest(UINT32 left = 0, UINT32 top = 0, UINT32 right = 800, UINT32 bottom = 600);
  54. /** @copydoc RenderSystem::setRenderTarget() */
  55. void setRenderTarget(RenderTarget *target);
  56. /** @copydoc RenderSystem::bindGpuProgram() */
  57. void bindGpuProgram(GpuProgramHandle prg);
  58. /** @copydoc RenderSystem::bindGpuProgramParameters() */
  59. void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params, UINT16 variabilityMask);
  60. /** @copydoc RenderSystem::unbindGpuProgram() */
  61. void unbindGpuProgram(GpuProgramType gptype);
  62. /** @copydoc RenderSystem::beginFrame() */
  63. void beginFrame(void);
  64. /** @copydoc RenderSystem::endFrame() */
  65. void endFrame(void);
  66. /** @copydoc RenderSystem::render() */
  67. void render(const RenderOperation& op);
  68. /** @copydoc RenderSystem::swapAllRenderTargetBuffers() */
  69. void swapAllRenderTargetBuffers(bool waitForVsync = true);
  70. /** @copydoc RenderSystem::clearFrameBuffer() */
  71. void clearFrameBuffer(unsigned int buffers, const Color& color = Color::Black, float depth = 1.0f, unsigned short stencil = 0);
  72. /**
  73. * @brief Makes all the currently queued commands available to the GPU. They will be executed
  74. * as soon as the render thread is ready.
  75. */
  76. void submitToGpu();
  77. private:
  78. CommandQueue* mCommandQueue;
  79. RenderSystem* mRenderSystem;
  80. bool mWaitForVerticalBlank;
  81. };
  82. }