VTK  9.6.20260704
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
97
100 virtual bool SetNumberOfInstances(vtkIdType numberOfInstances);
101
104 virtual bool SetNumberOfElements(vtkIdType numberOfElements);
105
112 int GetElementType() { return this->ElementType; }
113 virtual bool SetElementType(int elementType);
115
122 int GetPatchType() { return this->PatchType; }
123 virtual bool SetPatchType(int patchType);
125
131 bool GetIncludeColormap() { return this->IncludeColormap; }
132 virtual bool SetIncludeColormap(bool includeColormap);
134
139
160
167
169 bool GetUsesIndexBuffer() const;
170
178 void SetIndexedDrawEnabled(bool enabled);
180
183
186
189
192
193protected:
197 void ReportUnsupportedLineWidth(float width, float maxWidth, vtkMapper* mapper);
198 void PreDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
200 void PostDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
201
202 using ShaderMap = std::map<vtkShader::Type, vtkShader*>;
203 struct Internal;
204
206 Internal* P{ nullptr };
212 bool IncludeColormap{ true };
213 std::unordered_map<vtkStringToken, vtkOpenGLArrayTextureBufferAdapter> Arrays;
221 bool ShaderProgramBuilt{ false };
225
226private:
228 void operator=(const vtkDrawTexturedElements&) = delete;
229};
230
231VTK_ABI_NAMESPACE_END
232
233#endif // vtkDrawTexturedElements_h
234
235// Need to skip header testing since we do not inherit vtkObject:
236// 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)
void BeginArrayRebuild()
Begin re-listing the bound arrays without discarding their uploaded textures.
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)
bool ShaderProgramBuilt
True once ShaderProgram has been resolved from the current Shaders sources.
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