1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkFramebufferPass.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /**
16  * @class   vtkFramebufferPass
17  * @brief   Render into a FO
18  *
19  * @sa
20  * vtkRenderPass
21  */
22 
23 #ifndef vtkFramebufferPass_h
24 #define vtkFramebufferPass_h
25 
26 #include "vtkDepthImageProcessingPass.h"
27 #include "vtkRenderingOpenGL2Module.h" // For export macro
28 
29 class vtkOpenGLFramebufferObject;
30 class vtkOpenGLHelper;
31 class vtkOpenGLRenderWindow;
32 class vtkTextureObject;
33 
34 class VTKRENDERINGOPENGL2_EXPORT vtkFramebufferPass : public vtkDepthImageProcessingPass
35 {
36 public:
37   static vtkFramebufferPass* New();
38   vtkTypeMacro(vtkFramebufferPass, vtkDepthImageProcessingPass);
39   void PrintSelf(ostream& os, vtkIndent indent) override;
40 
41   /**
42    * Perform rendering according to a render state \p s.
43    * \pre s_exists: s!=0
44    */
45   void Render(const vtkRenderState* s) override;
46 
47   /**
48    * Release graphics resources and ask components to release their own
49    * resources.
50    * \pre w_exists: w!=0
51    */
52   void ReleaseGraphicsResources(vtkWindow* w) override;
53 
54   /**
55    *  Set the format to use for the depth texture
56    * e.g. vtkTextureObject::Float32
57    */
58   vtkSetMacro(DepthFormat, int);
59 
60   /**
61    *  Set the format to use for the color texture
62    *  vtkTextureObject::Float16 vtkTextureObject::Float32
63    *  and vtkTextureObject::Fixed8 are supported. Fixed8
64    *  is the default.
65    */
66   vtkSetMacro(ColorFormat, int);
67 
68   // Get the depth texture object
69   vtkGetObjectMacro(DepthTexture, vtkTextureObject);
70 
71   // Get the Color texture object
72   vtkGetObjectMacro(ColorTexture, vtkTextureObject);
73 
74 protected:
75   /**
76    * Default constructor. DelegatePass is set to NULL.
77    */
78   vtkFramebufferPass();
79 
80   /**
81    * Destructor.
82    */
83   ~vtkFramebufferPass() override;
84 
85   /**
86    * Graphics resources.
87    */
88   vtkOpenGLFramebufferObject* FrameBufferObject;
89   vtkTextureObject* ColorTexture; // render target for the scene
90   vtkTextureObject* DepthTexture; // render target for the depth
91 
92   ///@{
93   /**
94    * Cache viewport values for depth peeling.
95    */
96   int ViewportX;
97   int ViewportY;
98   int ViewportWidth;
99   int ViewportHeight;
100   ///@}
101 
102   int DepthFormat;
103   int ColorFormat;
104 
105 private:
106   vtkFramebufferPass(const vtkFramebufferPass&) = delete;
107   void operator=(const vtkFramebufferPass&) = delete;
108 };
109 
110 #endif
111