|
VTK
9.6.20260613
|
A base class for mappers or render responders that need to draw primitives via vertex-pulling. More...
#include <vtkDrawTexturedElements.h>
Public Types | |
| enum | ElementShape { Point , Line , LineStrip , Triangle , TriangleStrip , TriangleFan , AbstractPatches } |
| The type of primitive to output. More... | |
| enum | PatchShape { PatchLine , PatchTriangle , PatchQuadrilateral } |
| The type of primitive that abstract patches are tessellated into. More... | |
Public Member Functions | |
| vtkDrawTexturedElements () | |
| virtual | ~vtkDrawTexturedElements () |
| vtkShader * | GetShader (vtkShader::Type shaderType) |
| Return a shader of the given type (creating as needed). | |
| void | BindArrayToTexture (vtkStringToken textureName, vtkDataArray *array, bool asScalars=false) |
| Bind a data array to the given textureName (used in shader program texelFetch calls). | |
| void | AppendArrayToTexture (vtkStringToken textureName, vtkDataArray *array, bool asScalars=false) |
| bool | UnbindArray (vtkStringToken) |
| vtkIdType | GetNumberOfInstances () |
| Set/get the number of element instances to draw. | |
| virtual bool | SetNumberOfInstances (vtkIdType numberOfInstances) |
| vtkIdType | GetNumberOfElements () |
| Set/get the number of elements (primitives) to draw per instance. | |
| virtual bool | SetNumberOfElements (vtkIdType numberOfElements) |
| void | DrawInstancedElements (vtkRenderer *ren, vtkActor *a, vtkMapper *mapper) |
| Render geometry. | |
| 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. | |
| vtkCollection * | GetGLSLModCollection () const |
| Return the GLSL mods. | |
| int | GetElementType () |
| virtual bool | SetElementType (int elementType) |
| int | GetPatchType () |
| virtual bool | SetPatchType (int patchType) |
| bool | GetIncludeColormap () |
| virtual bool | SetIncludeColormap (bool includeColormap) |
| void | SetElementIndexBuffer (vtkDataArray *indices) |
| void | AppendElementIndexBuffer (vtkDataArray *indices) |
| Append connectivity to the element (index) buffer, concatenating in memory order. | |
| void | ClearElementIndexBuffer () |
| bool | GetUsesIndexBuffer () const |
| void | SetIndexedDrawEnabled (bool enabled) |
| Per-draw selector for the hybrid surface/expansion dispatch. | |
Static Public Member Functions | |
| static vtkIdType | PatchVertexCountFromPrimitive (int element) |
| Return the number of vertices in the patch primitive. | |
Protected Types | |
| using | ShaderMap = std::map<vtkShader::Type, vtkShader*> |
Protected Member Functions | |
| void | SetCustomUniforms (vtkRenderer *ren, vtkActor *a) |
| Set any custom uniforms provided by the actor. | |
| void | ReadyShaderProgram (vtkRenderer *ren) |
| void | ReportUnsupportedLineWidth (float width, float maxWidth, vtkMapper *mapper) |
| void | PreDraw (vtkRenderer *ren, vtkActor *a, vtkMapper *mapper) |
| void | DrawInstancedElementsImpl (vtkRenderer *ren, vtkActor *a, vtkMapper *mapper) |
| void | PostDraw (vtkRenderer *ren, vtkActor *a, vtkMapper *mapper) |
Protected Attributes | |
| Internal * | P { nullptr } |
| Private data for this class. | |
| vtkIdType | FirstVertexId { 0 } |
| vtkIdType | NumberOfInstances { 1 } |
| vtkIdType | NumberOfElements { 1 } |
| int | ElementType { ElementShape::TriangleStrip } |
| int | PatchType { PatchShape::PatchTriangle } |
| bool | IncludeColormap { true } |
| std::unordered_map< vtkStringToken, vtkOpenGLArrayTextureBufferAdapter > | Arrays |
| ShaderMap | Shaders |
| vtkSmartPointer< vtkShaderProgram > | ShaderProgram |
| vtkNew< vtkOpenGLVertexArrayObject > | VAO |
| vtkNew< vtkOpenGLTexture > | ColorTextureGL |
| vtkNew< vtkCollection > | GLSLMods |
A base class for mappers or render responders that need to draw primitives via vertex-pulling.
Since this class is intended to be inherited by other classes that must also inherit a VTK mapper or responder class, it is not a subclass of vtkObject; instead, it provides methods your subclass can invoke during rendering.
This currently handles hexahedra and tetrahedra.
Definition at line 47 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 191 of file vtkDrawTexturedElements.h.
The type of primitive to output.
Definition at line 54 of file vtkDrawTexturedElements.h.
The type of primitive that abstract patches are tessellated into.
Definition at line 66 of file vtkDrawTexturedElements.h.
| vtkDrawTexturedElements::vtkDrawTexturedElements | ( | ) |
|
virtual |
| vtkShader * vtkDrawTexturedElements::GetShader | ( | vtkShader::Type | shaderType | ) |
Return a shader of the given type (creating as needed).
| void vtkDrawTexturedElements::BindArrayToTexture | ( | vtkStringToken | textureName, |
| vtkDataArray * | array, | ||
| bool | asScalars = false ) |
Bind a data array to the given textureName (used in shader program texelFetch calls).
If asScalars is false (the default), then the array's components are treated as components of single texture values. If asScalars is true, then a 2-d texture image is uploaded where each value is a scalar (row indices are tuple IDs, column indices are component IDs).
| void vtkDrawTexturedElements::AppendArrayToTexture | ( | vtkStringToken | textureName, |
| vtkDataArray * | array, | ||
| bool | asScalars = false ) |
| bool vtkDrawTexturedElements::UnbindArray | ( | vtkStringToken | ) |
|
inline |
Set/get the number of element instances to draw.
Definition at line 88 of file vtkDrawTexturedElements.h.
|
virtual |
Reimplemented in vtkArrayRenderer.
|
inline |
Set/get the number of elements (primitives) to draw per instance.
Definition at line 92 of file vtkDrawTexturedElements.h.
|
virtual |
Reimplemented in vtkArrayRenderer.
|
inline |
Set/get the type of elements to draw.
This determines the number of vertices rendered per element. Values must come from the ElementShape enum; the default is ElementShape::TriangleStrip.
Definition at line 101 of file vtkDrawTexturedElements.h.
|
virtual |
Set/get the type of elements to draw.
This determines the number of vertices rendered per element. Values must come from the ElementShape enum; the default is ElementShape::TriangleStrip.
Reimplemented in vtkArrayRenderer.
|
inline |
Set/get the type of primitive an abstract patch gets tessellated into.
This determines the number of input patch vertices to the tessellation shaders. Values must come from the PatchShape enum; the default is PatchShape::Triangle.
Definition at line 111 of file vtkDrawTexturedElements.h.
|
virtual |
Set/get the type of primitive an abstract patch gets tessellated into.
This determines the number of input patch vertices to the tessellation shaders. Values must come from the PatchShape enum; the default is PatchShape::Triangle.
|
inline |
Set/get whether to upload a colormap texture.
If enabled (the default), then create (if needed) and upload a colormap texture image bound to a "color_map" uniform sampler.
Definition at line 120 of file vtkDrawTexturedElements.h.
|
virtual |
Set/get whether to upload a colormap texture.
If enabled (the default), then create (if needed) and upload a colormap texture image bound to a "color_map" uniform sampler.
| void vtkDrawTexturedElements::DrawInstancedElements | ( | vtkRenderer * | ren, |
| vtkActor * | a, | ||
| vtkMapper * | mapper ) |
Render geometry.
This just calls glDrawElementInstanced().
| void vtkDrawTexturedElements::SetElementIndexBuffer | ( | vtkDataArray * | indices | ) |
Enable indexed vertex-pulling by supplying an index (element) buffer.
When an index buffer is set, DrawInstancedElements issues glDrawElementsInstanced rather than glDrawArraysInstanced. With glDrawElements, the shader's gl_VertexID is the fetched index value, so the post-transform vertex cache can reuse vertices shared between primitives (a triangle-mesh vertex shared by ~6 triangles runs the vertex shader roughly once instead of ~6 times). The shader should therefore use gl_VertexID directly as the point id instead of fetching it from a connectivity texture buffer.
indices must hold 32-bit (or smaller) integer connectivity; values are copied and uploaded as GL_UNSIGNED_INT. Passing nullptr (or calling ClearElementIndexBuffer) reverts to non-indexed pulling.
The draw also honors FirstVertexId as the offset (in elements) of the slice to draw within the supplied connectivity, so a single concatenated buffer can back several draws.
| void vtkDrawTexturedElements::AppendElementIndexBuffer | ( | vtkDataArray * | indices | ) |
Append connectivity to the element (index) buffer, concatenating in memory order.
Use this (instead of SetElementIndexBuffer, which replaces) to build a single element buffer from several meshes, e.g. composite/batched input. The accumulated values must stay aligned with the matching connectivity texture so a draw's FirstVertexId indexes both the same way.
| void vtkDrawTexturedElements::ClearElementIndexBuffer | ( | ) |
Enable indexed vertex-pulling by supplying an index (element) buffer.
When an index buffer is set, DrawInstancedElements issues glDrawElementsInstanced rather than glDrawArraysInstanced. With glDrawElements, the shader's gl_VertexID is the fetched index value, so the post-transform vertex cache can reuse vertices shared between primitives (a triangle-mesh vertex shared by ~6 triangles runs the vertex shader roughly once instead of ~6 times). The shader should therefore use gl_VertexID directly as the point id instead of fetching it from a connectivity texture buffer.
indices must hold 32-bit (or smaller) integer connectivity; values are copied and uploaded as GL_UNSIGNED_INT. Passing nullptr (or calling ClearElementIndexBuffer) reverts to non-indexed pulling.
The draw also honors FirstVertexId as the offset (in elements) of the slice to draw within the supplied connectivity, so a single concatenated buffer can back several draws.
| bool vtkDrawTexturedElements::GetUsesIndexBuffer | ( | ) | const |
Enable indexed vertex-pulling by supplying an index (element) buffer.
When an index buffer is set, DrawInstancedElements issues glDrawElementsInstanced rather than glDrawArraysInstanced. With glDrawElements, the shader's gl_VertexID is the fetched index value, so the post-transform vertex cache can reuse vertices shared between primitives (a triangle-mesh vertex shared by ~6 triangles runs the vertex shader roughly once instead of ~6 times). The shader should therefore use gl_VertexID directly as the point id instead of fetching it from a connectivity texture buffer.
indices must hold 32-bit (or smaller) integer connectivity; values are copied and uploaded as GL_UNSIGNED_INT. Passing nullptr (or calling ClearElementIndexBuffer) reverts to non-indexed pulling.
The draw also honors FirstVertexId as the offset (in elements) of the slice to draw within the supplied connectivity, so a single concatenated buffer can back several draws.
| void vtkDrawTexturedElements::SetIndexedDrawEnabled | ( | bool | enabled | ) |
Per-draw selector for the hybrid surface/expansion dispatch.
SetElementIndexBuffer leaves indexed drawing enabled by default. A caller that shares one uploaded buffer across draws with mixed eligibility (e.g. plain triangles indexed, surface-with-edges expanded) toggles this before each DrawInstancedElements call. It has no effect unless an index buffer is present.
| void vtkDrawTexturedElements::ReleaseResources | ( | vtkWindow * | window | ) |
Release any graphics resources associated with the window.
| vtkShaderProgram * vtkDrawTexturedElements::GetShaderProgram | ( | ) |
Return the internal shader program so subclasses can create/replace shaders.
| vtkCollection * vtkDrawTexturedElements::GetGLSLModCollection | ( | ) | const |
Return the GLSL mods.
|
static |
Return the number of vertices in the patch primitive.
|
protected |
Set any custom uniforms provided by the actor.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Private data for this class.
Definition at line 195 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 196 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 197 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 198 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 199 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 200 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 201 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 202 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 203 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 204 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 205 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 206 of file vtkDrawTexturedElements.h.
|
protected |
Definition at line 207 of file vtkDrawTexturedElements.h.