VTK  9.6.20260613
vtkDrawTexturedElements.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
15#ifndef vtkDrawTexturedElements_h
16#define vtkDrawTexturedElements_h
17
18#include "vtkRenderingOpenGL2Module.h" // For export macro
19
20#include "vtkNew.h" // for ivar
21#include "vtkOpenGLArrayTextureBufferAdapter.h" // for ivar
22#include "vtkOpenGLTexture.h" // for ivar
23#include "vtkOpenGLVertexArrayObject.h" // for ivar
24#include "vtkShader.h" // for ivar
25#include "vtkSmartPointer.h" // for ivar
26#include "vtkStringToken.h" // for passing shader and array names
27
28#include <unordered_map>
29
30VTK_ABI_NAMESPACE_BEGIN
31
32class vtkActor;
33class vtkDataArray;
34class vtkGLSLRuntimeModBase;
35class vtkMapper;
36class vtkMatrix3x3;
37class vtkMatrix4x4;
41class vtkRenderer;
45class vtkWindow;
46
47class VTKRENDERINGOPENGL2_EXPORT vtkDrawTexturedElements
48{
49public:
52
64
72
75
82 void BindArrayToTexture(vtkStringToken textureName, vtkDataArray* array, bool asScalars = false);
84 vtkStringToken textureName, vtkDataArray* array, bool asScalars = false);
86
89 virtual bool SetNumberOfInstances(vtkIdType numberOfInstances);
90
93 virtual bool SetNumberOfElements(vtkIdType numberOfElements);
94
101 int GetElementType() { return this->ElementType; }
102 virtual bool SetElementType(int elementType);
104
111 int GetPatchType() { return this->PatchType; }
112 virtual bool SetPatchType(int patchType);
114
120 bool GetIncludeColormap() { return this->IncludeColormap; }
121 virtual bool SetIncludeColormap(bool includeColormap);
123
128
149
156
158 bool GetUsesIndexBuffer() const;
159
167 void SetIndexedDrawEnabled(bool enabled);
169
172
175
178
181
182protected:
186 void ReportUnsupportedLineWidth(float width, float maxWidth, vtkMapper* mapper);
187 void PreDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
189 void PostDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
190
191 using ShaderMap = std::map<vtkShader::Type, vtkShader*>;
192 struct Internal;
193
195 Internal* P{ nullptr };
201 bool IncludeColormap{ true };
202 std::unordered_map<vtkStringToken, vtkOpenGLArrayTextureBufferAdapter> Arrays;
208
209private:
211 void operator=(const vtkDrawTexturedElements&) = delete;
212};
213
214VTK_ABI_NAMESPACE_END
215
216#endif // vtkDrawTexturedElements_h
217
218// Need to skip header testing since we do not inherit vtkObject:
219// VTK-HeaderTest-Exclude: vtkDrawTexturedElements.h
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
create and manipulate ordered lists of objects
virtual ~vtkDrawTexturedElements()
vtkNew< vtkOpenGLTexture > ColorTextureGL
virtual bool SetPatchType(int patchType)
void PostDraw(vtkRenderer *ren, vtkActor *a, vtkMapper *mapper)
vtkNew< vtkOpenGLVertexArrayObject > VAO
void DrawInstancedElementsImpl(vtkRenderer *ren, vtkActor *a, vtkMapper *mapper)
PatchShape
The type of primitive that abstract patches are tessellated into.
@ PatchQuadrilateral
Input to the essellation control shader is a quadrilateral.
@ PatchLine
Input to the essellation control shader is a line segment.
@ PatchTriangle
Input to the essellation control shader is a triangle.
void AppendElementIndexBuffer(vtkDataArray *indices)
Append connectivity to the element (index) buffer, concatenating in memory order.
void ReadyShaderProgram(vtkRenderer *ren)
void SetElementIndexBuffer(vtkDataArray *indices)
vtkIdType GetNumberOfInstances()
Set/get the number of element instances to draw.
vtkCollection * GetGLSLModCollection() const
Return the GLSL mods.
void SetIndexedDrawEnabled(bool enabled)
Per-draw selector for the hybrid surface/expansion dispatch.
ElementShape
The type of primitive to output.
@ Triangle
Send triangles to the shader.
@ TriangleStrip
Send triangles to the shader (moving window of 3 vertices).
@ TriangleFan
Send triangle fans to the shader (first vertex is constant).
@ Line
Send line segments to the shader.
@ LineStrip
Send line segments to the shader.
@ AbstractPatches
Send abstract patches to the shader.
@ Point
Send points to the shader.
vtkSmartPointer< vtkShaderProgram > ShaderProgram
void BindArrayToTexture(vtkStringToken textureName, vtkDataArray *array, bool asScalars=false)
Bind a data array to the given textureName (used in shader program texelFetch calls).
vtkIdType GetNumberOfElements()
Set/get the number of elements (primitives) to draw per instance.
virtual bool SetNumberOfInstances(vtkIdType numberOfInstances)
void DrawInstancedElements(vtkRenderer *ren, vtkActor *a, vtkMapper *mapper)
Render geometry.
virtual bool SetElementType(int elementType)
bool UnbindArray(vtkStringToken)
vtkShader * GetShader(vtkShader::Type shaderType)
Return a shader of the given type (creating as needed).
void AppendArrayToTexture(vtkStringToken textureName, vtkDataArray *array, bool asScalars=false)
std::unordered_map< vtkStringToken, vtkOpenGLArrayTextureBufferAdapter > Arrays
Internal * P
Private data for this class.
void ReleaseResources(vtkWindow *window)
Release any graphics resources associated with the window.
vtkShaderProgram * GetShaderProgram()
Return the internal shader program so subclasses can create/replace shaders.
void ReportUnsupportedLineWidth(float width, float maxWidth, vtkMapper *mapper)
void PreDraw(vtkRenderer *ren, vtkActor *a, vtkMapper *mapper)
vtkNew< vtkCollection > GLSLMods
bool GetUsesIndexBuffer() const
void SetCustomUniforms(vtkRenderer *ren, vtkActor *a)
Set any custom uniforms provided by the actor.
std::map< vtkShader::Type, vtkShader * > ShaderMap
virtual bool SetNumberOfElements(vtkIdType numberOfElements)
static vtkIdType PatchVertexCountFromPrimitive(int element)
Return the number of vertices in the patch primitive.
virtual bool SetIncludeColormap(bool includeColormap)
abstract class specifies interface to map data to graphics primitives
Definition vtkMapper.h:97
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:168
OpenGL rendering window.
OpenGL texture map.
The VertexArrayObject class uses, or emulates, vertex array objects.
abstract specification for renderers
Superclass for mapping scalar values to colors.
The ShaderProgram uses one or more Shader objects.
Vertex or Fragment shader, combined into a ShaderProgram.
Definition vtkShader.h:120
Type
Available shader types.
Definition vtkShader.h:128
Hold a reference to a vtkObjectBase instance.
Represent a string by its integer hash.
abstracts an OpenGL texture object.
window superclass for vtkRenderWindow
Definition vtkWindow.h:61
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363