VTK  9.3.0
vtkOpenGLBatchedPolyDataMapper.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 vtkOpenGLBatchedPolyDataMapper_h
16#define vtkOpenGLBatchedPolyDataMapper_h
17
18#include "vtkColor.h" // class uses vtkColor
19#include "vtkNew.h" // for ivar
20#include "vtkOpenGLCompositePolyDataMapperDelegator.h" // for struct BatchElement
21#include "vtkRenderingOpenGL2Module.h" // for export macro
22#include "vtkSmartPointer.h" // for arg
23#include "vtk_glew.h" // for OpenGL defs
24
25// clang-format off
26// Must be included after vtk_glew.h for GL_ES_VERSION_3_0
27#ifndef GL_ES_VERSION_3_0
29#define vtkOpenGLPolyDataMapperImplementation vtkOpenGLPolyDataMapper
30#else
32#define vtkOpenGLPolyDataMapperImplementation vtkOpenGLES30PolyDataMapper
33#endif
34// clang-format on
35
36#include <cstdint> // for std::uintptr_t
37#include <memory> // for shared_ptr
38
39VTK_ABI_NAMESPACE_BEGIN
41class vtkPolyData;
42
43class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLBatchedPolyDataMapper
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
57 void AddBatchElement(unsigned int flatIndex, BatchElement&& batchElement);
61
65 std::vector<vtkPolyData*> GetRenderedList() const;
67
71 void RenderPiece(vtkRenderer* renderer, vtkActor* actor) override;
74
80 vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
81
83 GLBatchElement* glBatchElement, std::vector<unsigned int>& mypixels);
84
85protected:
88
89 void RenderPieceDraw(vtkRenderer* renderer, vtkActor* actor) override;
90 void UpdateCameraShiftScale(vtkRenderer* renderer, vtkActor* actoror) override;
91
95 void DrawIBO(vtkRenderer* renderer, vtkActor* actoror, int primType, vtkOpenGLHelper& CellBO,
96 GLenum mode, int pointSize);
97
101 virtual void SetShaderValues(
102 vtkShaderProgram* prog, GLBatchElement* glBatchElement, size_t primOffset);
103
108 void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* renderer, vtkActor* actor) override;
109
115 std::map<vtkShader::Type, vtkShader*> shaders, vtkRenderer* renderer, vtkActor* actor) override;
116
120 bool GetNeedToRebuildBufferObjects(vtkRenderer* renderer, vtkActor* actor) override;
121
125 void BuildBufferObjects(vtkRenderer* renderer, vtkActor* actor) override;
126 virtual void AppendOneBufferObject(vtkRenderer* renderer, vtkActor* actor,
127 GLBatchElement* glBatchElement, vtkIdType& vertexOffset, std::vector<unsigned char>& colors,
128 std::vector<float>& norms);
129
134 vtkPolyData* poly, std::vector<unsigned int> (&indices)[4], vtkIdType offset) override;
135
142
143 // Reference to CPDM
144 vtkCompositePolyDataMapper* Parent = nullptr;
145 // Maps an address of a vtkPolyData to its rendering attributes.
146 std::map<std::uintptr_t, std::unique_ptr<GLBatchElement>> VTKPolyDataToGLBatchElement;
147 // Index arrays for vert, line, poly, strip, edge, stripedge
148 std::vector<unsigned int> IndexArray[PrimitiveEnd];
149 // Whether primitive IDs are used
151 // Whether override color is used for a vtkPolyData
153 // Reference to the current selector.
155 // used by the hardware selector
156 std::vector<std::vector<unsigned int>> PickPixels;
157 // cached array map
158 std::map<vtkAbstractArray*, vtkDataArray*> ColorArrayMap;
159
160private:
162 void operator=(const vtkOpenGLBatchedPolyDataMapper&) = delete;
163};
164
165VTK_ABI_NAMESPACE_END
166#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
a class that renders hierarchical polygonal data
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:29
An OpenGL mapper for batched rendering of vtkPolyData.
std::vector< vtkPolyData * > GetRenderedList() const
Accessor to the ordered list of PolyData that we last drew.
void ClearBatchElements()
API to add and query a GLBatchElement instance per vtkPolyData.
std::vector< std::vector< unsigned int > > PickPixels
void ReplaceShaderColor(std::map< vtkShader::Type, vtkShader * > shaders, vtkRenderer *renderer, vtkActor *actor) override
Perform string replacements on the shader templates, called from ReplaceShaderValues.
BatchElement * GetBatchElement(vtkPolyData *polydata)
API to add and query a GLBatchElement instance per vtkPolyData.
void RenderPiece(vtkRenderer *renderer, vtkActor *actor) override
Implemented by sub classes.
void UpdateShaders(vtkOpenGLHelper &cellBO, vtkRenderer *renderer, vtkActor *actor) override
Make sure appropriate shaders are defined, compiled and bound.
void BuildSelectionIBO(vtkPolyData *poly, std::vector< unsigned int >(&indices)[4], vtkIdType offset) override
Build the selection IBOs, called by UpdateBufferObjects.
virtual void AppendOneBufferObject(vtkRenderer *renderer, vtkActor *actor, GLBatchElement *glBatchElement, vtkIdType &vertexOffset, std::vector< unsigned char > &colors, std::vector< float > &norms)
void RenderPieceDraw(vtkRenderer *renderer, vtkActor *actor) override
void AddBatchElement(unsigned int flatIndex, BatchElement &&batchElement)
API to add and query a GLBatchElement instance per vtkPolyData.
void DrawIBO(vtkRenderer *renderer, vtkActor *actoror, int primType, vtkOpenGLHelper &CellBO, GLenum mode, int pointSize)
Draws primitives.
std::map< vtkAbstractArray *, vtkDataArray * > ColorArrayMap
int CanUseTextureMapForColoring(vtkDataObject *) override
Returns if we can use texture maps for scalar coloring.
void PrintSelf(ostream &os, vtkIndent indent) override
void BuildBufferObjects(vtkRenderer *renderer, vtkActor *actor) override
Build the VBO/IBO, called by UpdateBufferObjects.
void ProcessSelectorPixelBuffers(vtkHardwareSelector *sel, std::vector< unsigned int > &pixeloffsets, vtkProp *prop) override
allows a mapper to update a selections color buffers Called from a prop which in turn is called from ...
static vtkOpenGLBatchedPolyDataMapper * New()
virtual void SetShaderValues(vtkShaderProgram *prog, GLBatchElement *glBatchElement, size_t primOffset)
Applies rendering attributes for the corresponding polydata in the glBatchElement.
~vtkOpenGLBatchedPolyDataMapper() override
void UpdateCameraShiftScale(vtkRenderer *renderer, vtkActor *actoror) override
virtual void ProcessCompositePixelBuffers(vtkHardwareSelector *sel, vtkProp *prop, GLBatchElement *glBatchElement, std::vector< unsigned int > &mypixels)
std::map< std::uintptr_t, std::unique_ptr< GLBatchElement > > VTKPolyDataToGLBatchElement
bool GetNeedToRebuildBufferObjects(vtkRenderer *renderer, vtkActor *actor) override
Does the VBO/IBO need to be rebuilt.
void SetParent(vtkCompositePolyDataMapper *parent)
vtkCompositePolyDataMapperDelegator::BatchElement BatchElement
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
abstract specification for renderers
Definition vtkRenderer.h:59
The ShaderProgram uses one or more Shader objects.
#define vtkOpenGLPolyDataMapperImplementation
#define vtkOpenGLPolyDataMapperImplementation
int vtkIdType
Definition vtkType.h:315