VTK
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 "vtkRenderingOpenGL2Module.h" // For export macro
31 #include "vtkObject.h"
32 
33 #include <string> // For string
34 #include <vector> // For vector
35 
36 class vtkShaderProgram;
37 class vtkWindow;
38 
39 class VTKRENDERINGOPENGL2_EXPORT vtkTransformFeedback : public vtkObject
40 {
41 public:
42  static vtkTransformFeedback *New();
44  virtual void PrintSelf(ostream &os, vtkIndent indent);
45 
50  {
51  Vertex_ClipCoordinate_F, // Projected XYZW
52  Color_RGBA_F
53  };
54 
56  {
58  : Role(role), Identifier(id) {}
61  };
62 
66  void ClearVaryings();
67 
71  void AddVarying(VaryingRole role, const std::string &var);
72 
76  const std::vector<VaryingMetaData>& GetVaryings() const
77  {
78  return this->Varyings;
79  }
80 
84  static size_t GetBytesPerVertex(VaryingRole role);
85 
89  size_t GetBytesPerVertex() const;
90 
92 
102  vtkSetMacro(NumberOfVertices, size_t)
103  void SetNumberOfVertices(int drawMode, size_t inputVerts);
104  vtkGetMacro(NumberOfVertices, size_t)
106 
111  size_t GetBufferSize() const;
112 
126  void BindVaryings(vtkShaderProgram *prog);
127 
129 
133  vtkGetMacro(BufferHandle, int)
135 
137 
142  vtkSetMacro(PrimitiveMode, int)
143  vtkGetMacro(PrimitiveMode, int)
145 
151  void BindBuffer();
152 
158  void ReadBuffer();
159 
161 
165  vtkGetMacro(BufferData, void*)
167 
171  void ReleaseGraphicsResources();
172 
178  void ReleaseBufferData(bool freeBuffer = true);
179 
180 protected:
182  ~vtkTransformFeedback();
183 
184 private:
185  vtkTransformFeedback(const vtkTransformFeedback &) VTK_DELETE_FUNCTION;
186  void operator=(const vtkTransformFeedback &) VTK_DELETE_FUNCTION;
187 
188  bool VaryingsBound;
189 
190  std::vector<VaryingMetaData> Varyings;
191  size_t NumberOfVertices;
192  int BufferMode;
193 
194  int BufferHandle;
195  int PrimitiveMode;
196 
197  unsigned char *BufferData;
198 };
199 
200 //------------------------------------------------------------------------------
201 inline size_t vtkTransformFeedback::GetBytesPerVertex(
202  vtkTransformFeedback::VaryingRole role)
203 {
204  switch (role)
205  {
206  case Vertex_ClipCoordinate_F:
207  return 4 * sizeof(float);
208  case Color_RGBA_F:
209  return 4 * sizeof(float);
210  }
211 
212  vtkGenericWarningMacro("Unknown role enum value: " << role);
213  return 0;
214 }
215 
216 #endif // vtkTransformFeedback_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
VaryingRole
The role a captured varying fills.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
const std::vector< VaryingMetaData > & GetVaryings() const
Get the list of captured varyings,.
a simple class to control print indentation
Definition: vtkIndent.h:39
Manages a TransformFeedback buffer.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
VaryingMetaData(VaryingRole role, const std::string &id)
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.