VTK  9.3.1
vtkTransformFeedback.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
15 #ifndef vtkTransformFeedback_h
16 #define vtkTransformFeedback_h
17 
18 #include "vtkObject.h"
19 #include "vtkRenderingOpenGL2Module.h" // For export macro
20 
21 #include <string> // For string
22 #include <vector> // For vector
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkShaderProgram;
26 class vtkWindow;
28 
29 class VTKRENDERINGOPENGL2_EXPORT vtkTransformFeedback : public vtkObject
30 {
31 public:
32  static vtkTransformFeedback* New();
34  void PrintSelf(ostream& os, vtkIndent indent) override;
35 
40  {
41  Vertex_ClipCoordinate_F, // Projected XYZW
44  Next_Buffer // Switch to next vertex stream (varying name must be "gl_NextBuffer")
45  };
46 
48  {
50  : Role(role)
51  , Identifier(id)
52  {
53  }
56  };
57 
61  void ClearVaryings();
62 
66  void AddVarying(VaryingRole role, const std::string& var);
67 
71  const std::vector<VaryingMetaData>& GetVaryings() const { return this->Varyings; }
72 
76  static size_t GetBytesPerVertex(VaryingRole role);
77 
81  size_t GetBytesPerVertex() const;
82 
84 
94  vtkSetMacro(NumberOfVertices, size_t);
95  void SetNumberOfVertices(int drawMode, size_t inputVerts);
96  vtkGetMacro(NumberOfVertices, size_t);
98 
103  size_t GetBufferSize() const;
104 
118  void BindVaryings(vtkShaderProgram* prog);
119 
123  vtkOpenGLBufferObject* GetBuffer(int index);
124 
128  int GetBufferHandle(int index = 0);
129 
131 
136  vtkSetMacro(PrimitiveMode, int);
137  vtkGetMacro(PrimitiveMode, int);
139 
147  void Allocate(int nbBuffers, size_t size, unsigned int hint);
148 
155  void BindBuffer(bool allocateOneBuffer = true);
156 
163  void ReadBuffer(int index = 0);
164 
166 
170  vtkGetMacro(BufferData, void*);
172 
176  void ReleaseGraphicsResources();
177 
183  void ReleaseBufferData(bool freeBuffer = true);
184 
185 protected:
187  ~vtkTransformFeedback() override;
188 
189 private:
191  void operator=(const vtkTransformFeedback&) = delete;
192 
193  bool VaryingsBound;
194 
195  std::vector<VaryingMetaData> Varyings;
196  size_t NumberOfVertices;
197  int BufferMode;
198 
199  std::vector<vtkOpenGLBufferObject*> Buffers;
200  int PrimitiveMode;
201 
202  unsigned char* BufferData;
203 };
204 
205 //------------------------------------------------------------------------------
207 {
208  switch (role)
209  {
211  return 4 * sizeof(float);
212  case Color_RGBA_F:
213  return 4 * sizeof(float);
214  case Normal_F:
215  return 3 * sizeof(float);
216  case Next_Buffer:
217  return 0;
218  }
219 
220  vtkGenericWarningMacro("Unknown role enum value: " << role);
221  return 0;
222 }
223 
224 VTK_ABI_NAMESPACE_END
225 #endif // vtkTransformFeedback_h
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VaryingRole
The role a captured varying fills.
size_t GetBytesPerVertex() const
Returns the number of bytes per vertexs, accounting for all roles.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
const std::vector< VaryingMetaData > & GetVaryings() const
Get the list of captured varyings,.
a simple class to control print indentation
Definition: vtkIndent.h:28
Manages a TransformFeedback buffer.
VaryingMetaData(VaryingRole role, const std::string &id)
OpenGL buffer object.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
The ShaderProgram uses one or more Shader objects.