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;
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), Identifier(id) {}
64  };
65 
69  void ClearVaryings();
70 
74  void AddVarying(VaryingRole role, const std::string &var);
75 
79  const std::vector<VaryingMetaData>& GetVaryings() const
80  {
81  return this->Varyings;
82  }
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:
201  vtkTransformFeedback(const vtkTransformFeedback &) = delete;
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 //------------------------------------------------------------------------------
219 {
220  switch (role)
221  {
222  case Vertex_ClipCoordinate_F:
223  return 4 * sizeof(float);
224  case Color_RGBA_F:
225  return 4 * sizeof(float);
226  case Normal_F:
227  return 3 * sizeof(float);
228  case Next_Buffer:
229  return 0;
230  }
231 
232  vtkGenericWarningMacro("Unknown role enum value: " << role);
233  return 0;
234 }
235 
236 #endif // vtkTransformFeedback_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
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: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.
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.