VTK  9.3.20240420
vtkOpenGLInstanceCulling.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
54#ifndef vtkOpenGLInstanceCulling_h
55#define vtkOpenGLInstanceCulling_h
56
57#include "vtkObject.h"
58#include "vtkOpenGLHelper.h" // For vtkOpenGLHelper
59#include "vtkRenderingOpenGL2Module.h" // For export macro
60#include "vtkSmartPointer.h" // For smart pointer
61
62#include <vector> // for std::vector
63
64VTK_ABI_NAMESPACE_BEGIN
67class vtkPolyData;
69
70class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLInstanceCulling : public vtkObject
71{
72public:
75 void PrintSelf(ostream& os, vtkIndent indent) override;
76
78 {
79 float Distance;
80 unsigned int Query;
85
86 // used for sorting
87 bool operator<(const InstanceLOD& other) const { return this->Distance < other.Distance; }
88 };
89
94
102 void AddLOD(float distance, float targetReduction);
103
107 void BuildCullingShaders(vtkOpenGLShaderCache* cache, vtkIdType numInstances, bool withNormals);
108
113
118
123
128
132 void RunCullingShaders(vtkIdType numInstances, vtkOpenGLBufferObject* matrixBuffer,
133 vtkOpenGLBufferObject* colorBuffer, vtkOpenGLBufferObject* normalBuffer);
134
136
139 vtkSetMacro(ColorLOD, bool);
140 vtkGetMacro(ColorLOD, bool);
142
143protected:
146
149
150private:
152 void operator=(const vtkOpenGLInstanceCulling&) = delete;
153
154 vtkOpenGLHelper CullingHelper;
155 std::vector<InstanceLOD> LODList;
157 bool ColorLOD = false;
158};
159
160VTK_ABI_NAMESPACE_END
161#endif // vtkOpenGLInstanceCulling_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.
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
Hold a reference to a vtkObjectBase instance.
bool operator<(const InstanceLOD &other) const
int vtkIdType
Definition vtkType.h:315