CmDeferredRenderContext.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCommonEnums.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::disableTextureUnit() */
  21. void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
  22. /** @copydoc RenderSystem::setPointParameters() */
  23. void setPointParameters(float size, bool attenuationEnabled, float constant, float linear, float quadratic, float minSize, float maxSize);
  24. /** @copydoc RenderSystem::setTexture() */
  25. void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr &texPtr);
  26. /** @copydoc RenderSystem::setSamplerState() */
  27. void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState);
  28. /** @copydoc RenderSystem::setBlendState() */
  29. void setBlendState(const BlendStatePtr& blendState);
  30. /** @copydoc RenderSystem::setRasterizerState() */
  31. void setRasterizerState(const RasterizerStatePtr& rasterizerState);
  32. /** @copydoc RenderSystem::setRasterizerState() */
  33. void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue);
  34. /** @copydoc RenderSystem::setViewport() */
  35. void setViewport(ViewportPtr& vp);
  36. /** @copydoc RenderSystem::setVertexBuffer() */
  37. void setVertexBuffer(UINT32 index, const VertexBufferPtr& buffer);
  38. /** @copydoc RenderSystem::setIndexBuffer() */
  39. void setIndexBuffer(const IndexBufferPtr& buffer);
  40. /** @copydoc RenderSystem::setVertexDeclaration() */
  41. void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
  42. /** @copydoc RenderSystem::setDrawOperation() */
  43. void setDrawOperation(DrawOperationType op);
  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(RenderTargetPtr target);
  56. /** @copydoc RenderSystem::bindGpuProgram() */
  57. void bindGpuProgram(GpuProgramHandle prg);
  58. /** @copydoc RenderSystem::unbindGpuProgram() */
  59. void unbindGpuProgram(GpuProgramType gptype);
  60. /** @copydoc RenderSystem::bindGpuParams() */
  61. void bindGpuParams(GpuProgramType gptype, GpuParamsPtr params);
  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::draw() */
  69. void draw(UINT32 vertexCount);
  70. /** @copydoc RenderSystem::drawIndexed() */
  71. void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexCount);
  72. /** @copydoc RenderSystem::clear() */
  73. void clear(RenderTargetPtr target, unsigned int buffers, const Color& color = Color::Black, float depth = 1.0f, unsigned short stencil = 0);
  74. /**
  75. * @brief Makes all the currently queued commands available to the GPU. They will be executed
  76. * as soon as the render thread is ready.
  77. */
  78. void submitToGpu();
  79. /**
  80. * @brief Cancels all commands in the queue.
  81. */
  82. void cancelAll();
  83. private:
  84. CommandQueue* mCommandQueue;
  85. RenderSystem* mRenderSystem;
  86. };
  87. }