VTK  9.0.20201026
vtkTransformFeedback.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTransformFeedback.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 
27 #ifndef vtkTransformFeedback_h
28 #define vtkTransformFeedback_h
29 
30 #include "vtkObject.h"
31 #include "vtkRenderingOpenGL2Module.h" // For export macro
32 
33 #include <string> // For string
34 #include <vector> // For vector
35 
36 class vtkShaderProgram;
37 class vtkWindow;
39 
40 class VTKRENDERINGOPENGL2_EXPORT vtkTransformFeedback : public vtkObject
41 {
42 public:
43  static vtkTransformFeedback* New();
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
51  {
52  Vertex_ClipCoordinate_F, // Projected XYZW
55  Next_Buffer // Switch to next vertex stream (varying name must be "gl_NextBuffer")
56  };
57 
59  {
61  : Role(role)
62  , Identifier(id)
63  {
64  }
67  };
68 
72  void ClearVaryings();
73 
77  void AddVarying(VaryingRole role, const std::string& var);
78 
82  const std::vector<VaryingMetaData>& GetVaryings() const { return this->Varyings; }
83 
87  static size_t GetBytesPerVertex(VaryingRole role);
88 
92  size_t GetBytesPerVertex() const;
93 
95 
105  vtkSetMacro(NumberOfVertices, size_t);
106  void SetNumberOfVertices(int drawMode, size_t inputVerts);
107  vtkGetMacro(NumberOfVertices, size_t);
109 
114  size_t GetBufferSize() const;
115 
129  void BindVaryings(vtkShaderProgram* prog);
130 
134  vtkOpenGLBufferObject* GetBuffer(int index);
135 
139  int GetBufferHandle(int index = 0);
140 
142 
147  vtkSetMacro(PrimitiveMode, int);
148  vtkGetMacro(PrimitiveMode, int);
150 
158  void Allocate(int nbBuffers, size_t size, unsigned int hint);
159 
166  void BindBuffer(bool allocateOneBuffer = true);
167 
174  void ReadBuffer(int index = 0);
175 
177 
181  vtkGetMacro(BufferData, void*);
183 
187  void ReleaseGraphicsResources();
188 
194  void ReleaseBufferData(bool freeBuffer = true);
195 
196 protected:
198  ~vtkTransformFeedback() override;
199 
200 private:
202  void operator=(const vtkTransformFeedback&) = delete;
203 
204  bool VaryingsBound;
205 
206  std::vector<VaryingMetaData> Varyings;
207  size_t NumberOfVertices;
208  int BufferMode;
209 
210  std::vector<vtkOpenGLBufferObject*> Buffers;
211  int PrimitiveMode;
212 
213  unsigned char* BufferData;
214 };
215 
216 //------------------------------------------------------------------------------
218 {
219  switch (role)
220  {
222  return 4 * sizeof(float);
223  case Color_RGBA_F:
224  return 4 * sizeof(float);
225  case Normal_F:
226  return 3 * sizeof(float);
227  case Next_Buffer:
228  return 0;
229  }
230 
231  vtkGenericWarningMacro("Unknown role enum value: " << role);
232  return 0;
233 }
234 
235 #endif // vtkTransformFeedback_h
vtkOpenGLBufferObject
OpenGL buffer object.
Definition: vtkOpenGLBufferObject.h:33
vtkTransformFeedback::Color_RGBA_F
Definition: vtkTransformFeedback.h:53
vtkTransformFeedback::GetVaryings
const std::vector< VaryingMetaData > & GetVaryings() const
Get the list of captured varyings,.
Definition: vtkTransformFeedback.h:82
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkTransformFeedback::Next_Buffer
Definition: vtkTransformFeedback.h:55
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkTransformFeedback::Vertex_ClipCoordinate_F
Definition: vtkTransformFeedback.h:52
vtkTransformFeedback::GetBytesPerVertex
size_t GetBytesPerVertex() const
Returns the number of bytes per vertexs, accounting for all roles.
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkTransformFeedback::VaryingMetaData::Identifier
std::string Identifier
Definition: vtkTransformFeedback.h:66
vtkTransformFeedback::VaryingRole
VaryingRole
The role a captured varying fills.
Definition: vtkTransformFeedback.h:50
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTransformFeedback::VaryingMetaData
Definition: vtkTransformFeedback.h:58
vtkTransformFeedback::Normal_F
Definition: vtkTransformFeedback.h:54
vtkX3D::size
Definition: vtkX3D.h:259
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkObject.h
vtkX3D::string
Definition: vtkX3D.h:496
vtkTransformFeedback::VaryingMetaData::VaryingMetaData
VaryingMetaData(VaryingRole role, const std::string &id)
Definition: vtkTransformFeedback.h:60
vtkTransformFeedback::VaryingMetaData::Role
VaryingRole Role
Definition: vtkTransformFeedback.h:65
vtkX3D::index
Definition: vtkX3D.h:252
vtkTransformFeedback
Manages a TransformFeedback buffer.
Definition: vtkTransformFeedback.h:40