VTK  9.1.0
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
37class vtkWindow;
39
40class VTKRENDERINGOPENGL2_EXPORT vtkTransformFeedback : public vtkObject
41{
42public:
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
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
130
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
188
194 void ReleaseBufferData(bool freeBuffer = true);
195
196protected:
199
200private:
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
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
OpenGL buffer object.
The ShaderProgram uses one or more Shader objects.
Manages a TransformFeedback buffer.
void AddVarying(VaryingRole role, const std::string &var)
Capture the varying 'var' with the indicated role.
int GetBufferHandle(int index=0)
Get the transform buffer object handle.
void BindVaryings(vtkShaderProgram *prog)
GL_SEPARATE_ATTRIBS is not supported yet.
void ReleaseBufferData(bool freeBuffer=true)
Release the memory used by the buffer data.
void SetNumberOfVertices(int drawMode, size_t inputVerts)
The number of vertices expected to be captured.
void Allocate(int nbBuffers, size_t size, unsigned int hint)
Generates and allocates the transform feedback buffers.
VaryingRole
The role a captured varying fills.
void ReleaseGraphicsResources()
Release any graphics resources used by this object.
~vtkTransformFeedback() override
const std::vector< VaryingMetaData > & GetVaryings() const
Get the list of captured varyings,.
vtkOpenGLBufferObject * GetBuffer(int index)
Get the transform buffer object.
size_t GetBytesPerVertex() const
Returns the number of bytes per vertexs, accounting for all roles.
void ReadBuffer(int index=0)
Calls glEndTransformFeedback(), flushes the OpenGL command stream, and reads the transform feedback b...
size_t GetBufferSize() const
The size (in bytes) of the capture buffer.
void ClearVaryings()
Clear the list of varying attributes to capture.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void BindBuffer(bool allocateOneBuffer=true)
Binds the feedback buffer, then call glBeginTransformFeedback with the specified PrimitiveMode.
static vtkTransformFeedback * New()
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ size
Definition: vtkX3D.h:259
@ index
Definition: vtkX3D.h:252
@ string
Definition: vtkX3D.h:496
VaryingMetaData(VaryingRole role, const std::string &id)