VTK  9.3.20240420
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
24VTK_ABI_NAMESPACE_BEGIN
26class vtkWindow;
28
29class VTKRENDERINGOPENGL2_EXPORT vtkTransformFeedback : public vtkObject
30{
31public:
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 {
49 VaryingMetaData(VaryingRole role, const std::string& id)
50 : Role(role)
51 , Identifier(id)
52 {
53 }
55 std::string Identifier;
56 };
57
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
119
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
177
183 void ReleaseBufferData(bool freeBuffer = true);
184
185protected:
188
189private:
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
224VTK_ABI_NAMESPACE_END
225#endif // vtkTransformFeedback_h
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
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:48
VaryingMetaData(VaryingRole role, const std::string &id)