VTK  9.4.20241103
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
55 {
62 AbstractPatches
63 };
64
67 {
71 };
72
75
82 void BindArrayToTexture(vtkStringToken textureName, vtkDataArray* array, bool asScalars = false);
84 vtkStringToken textureName, vtkDataArray* array, bool asScalars = false);
86
88 vtkIdType GetNumberOfInstances() { return this->NumberOfInstances; }
89 virtual bool SetNumberOfInstances(vtkIdType numberOfInstances);
90
92 vtkIdType GetNumberOfElements() { return this->NumberOfElements; }
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
131
134
137
140
141protected:
145 void ReportUnsupportedLineWidth(float width, float maxWidth, vtkMapper* mapper);
146 void PreDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
148 void PostDraw(vtkRenderer* ren, vtkActor* a, vtkMapper* mapper);
149
150 using ShaderMap = std::map<vtkShader::Type, vtkShader*>;
151 struct Internal;
152
154 Internal* P{ nullptr };
155 vtkIdType FirstVertexId{ 0 };
156 vtkIdType NumberOfInstances{ 1 };
157 vtkIdType NumberOfElements{ 1 };
158 int ElementType{ ElementShape::TriangleStrip };
159 int PatchType{ PatchShape::PatchTriangle };
160 bool IncludeColormap{ true };
161 std::unordered_map<vtkStringToken, vtkOpenGLArrayTextureBufferAdapter> Arrays;
167
168private:
170 void operator=(const vtkDrawTexturedElements&) = delete;
171};
172
173VTK_ABI_NAMESPACE_END
174
175#endif // vtkDrawTexturedElements_h
176
177// Need to skip header testing since we do not inherit vtkObject:
178// 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
abstract superclass for arrays of numeric data
A base class for mappers or render responders that need to draw primitives via vertex-pulling.
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 ReadyShaderProgram(vtkRenderer *ren)
vtkIdType GetNumberOfInstances()
Set/get the number of element instances to draw.
vtkCollection * GetGLSLModCollection() const
Return the GLSL mods.
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.
@ 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
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
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:137
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
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:48
int vtkIdType
Definition vtkType.h:315