PostProcessSample.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef POSTPROCESSSAMPLE_H_
  2. #define POSTPROCESSSAMPLE_H_
  3. #include "gameplay.h"
  4. #include "Sample.h"
  5. using namespace gameplay;
  6. /**
  7. * Sample post processing.
  8. */
  9. class PostProcessSample: public Sample
  10. {
  11. public:
  12. /**
  13. * Constructor.
  14. */
  15. PostProcessSample();
  16. /**
  17. * @see Sample::touchEvent
  18. */
  19. void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
  20. /**
  21. * Compositing blitter with a specified material/technique applied from a source buffer into the destination buffer.
  22. *
  23. * If destination buffer is NULL then it composites to the default frame buffer.
  24. *
  25. * Requried uniforms:
  26. * sampler2d u_texture - The input texture sampler
  27. */
  28. class Compositor
  29. {
  30. public:
  31. static Compositor* create(FrameBuffer* srcBuffer, FrameBuffer* dstBuffer, const char* materialPath, const char* techniqueId);
  32. ~Compositor();
  33. FrameBuffer* getSrcFrameBuffer() const;
  34. FrameBuffer* getDstFrameBuffer() const;
  35. const char* getTechniqueId() const;
  36. Material* getMaterial() const;
  37. void blit(const Rectangle& dst);
  38. private:
  39. Compositor();
  40. Compositor(FrameBuffer* srcBuffer, FrameBuffer* dstBuffer, Material* material, const char* techniqueId);
  41. FrameBuffer* _srcBuffer;
  42. FrameBuffer* _dstBuffer;
  43. Material* _material;
  44. const char* _techniqueId;
  45. };
  46. protected:
  47. void initialize();
  48. void finalize();
  49. void update(float elapsedTime);
  50. void render(float elapsedTime);
  51. private:
  52. bool drawScene(Node* node);
  53. void drawTechniqueId(const char* techniqueId);
  54. private:
  55. Font* _font;
  56. Scene* _scene;
  57. Node* _modelNode;
  58. FrameBuffer* _frameBuffer;
  59. unsigned int _compositorIndex;
  60. std::vector<Compositor*> _compositors;
  61. static Model* _quadModel;
  62. static Material* _compositorMaterial;
  63. };
  64. #endif