VTK  9.1.0
vtkOpenGLInstanceCulling.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkOpenGLInstanceCulling.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
66#ifndef vtkOpenGLInstanceCulling_h
67#define vtkOpenGLInstanceCulling_h
68
69#include "vtkObject.h"
70#include "vtkOpenGLHelper.h" // For vtkOpenGLHelper
71#include "vtkRenderingOpenGL2Module.h" // For export macro
72#include "vtkSmartPointer.h" // For smart pointer
73
74#include <vector> // for std::vector
75
78class vtkPolyData;
80
81class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLInstanceCulling : public vtkObject
82{
83public:
86 void PrintSelf(ostream& os, vtkIndent indent) override;
87
89 {
90 float Distance;
91 unsigned int Query;
96
97 // used for sorting
98 bool operator<(const InstanceLOD& other) const { return this->Distance < other.Distance; }
99 };
100
105
113 void AddLOD(float distance, float targetReduction);
114
118 void BuildCullingShaders(vtkOpenGLShaderCache* cache, vtkIdType numInstances, bool withNormals);
119
124
129
134
139
143 void RunCullingShaders(vtkIdType numInstances, vtkOpenGLBufferObject* matrixBuffer,
144 vtkOpenGLBufferObject* colorBuffer, vtkOpenGLBufferObject* normalBuffer);
145
147
150 vtkSetMacro(ColorLOD, bool);
151 vtkGetMacro(ColorLOD, bool);
153
154protected:
157
160
161private:
163 void operator=(const vtkOpenGLInstanceCulling&) = delete;
164
165 vtkOpenGLHelper CullingHelper;
166 std::vector<InstanceLOD> LODList;
168 bool ColorLOD = false;
169};
170
171#endif // vtkOpenGLInstanceCulling_h
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
OpenGL buffer object.
OpenGL vertex buffer object.
Frustum culling and LOD management.
InstanceLOD & GetLOD(vtkIdType index)
Get LOD structure.
static vtkOpenGLInstanceCulling * New()
~vtkOpenGLInstanceCulling() override
void AddLOD(float distance, float targetReduction)
Add a level of detail.
void BuildCullingShaders(vtkOpenGLShaderCache *cache, vtkIdType numInstances, bool withNormals)
Build culling shader program (if not created yet) and binds it.
vtkOpenGLHelper & GetHelper()
Get helper structure.
void InitLOD(vtkPolyData *pd)
Initialize LOD with a polydata.
vtkIdType GetNumberOfLOD()
Get number of LOD currently declared.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RunCullingShaders(vtkIdType numInstances, vtkOpenGLBufferObject *matrixBuffer, vtkOpenGLBufferObject *colorBuffer, vtkOpenGLBufferObject *normalBuffer)
Run the culling program and generate LOD buffers.
vtkOpenGLBufferObject * GetLODBuffer(vtkIdType index)
Get the transform feedback buffer generated by the culling program.
void UploadCurrentState(InstanceLOD &lod, vtkPolyData *pd)
vtkOpenGLInstanceCulling()=default
manage Shader Programs within a context
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
Hold a reference to a vtkObjectBase instance.
bool operator<(const InstanceLOD &other) const
int vtkIdType
Definition: vtkType.h:332