MCPcopy Create free account
hub / github.com/Kitware/VTK / DrawInstancedElementsImpl

Method DrawInstancedElementsImpl

Rendering/OpenGL2/vtkDrawTexturedElements.cxx:438–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438void vtkDrawTexturedElements::DrawInstancedElementsImpl(
439 vtkRenderer* ren, vtkActor*, vtkMapper* mapper)
440{
441 if (this->ShaderProgram == nullptr)
442 {
443 // can be nullptr if glsl failed to compile or link
444 return;
445 }
446
447 // Determine number of invocations of the vertex shader.
448 this->P->Count = static_cast<GLsizei>(this->NumberOfElements);
449 switch (this->ElementType)
450 {
451 case vtkDrawTexturedElements::ElementShape::Point:
452 break;
453 case vtkDrawTexturedElements::ElementShape::Line:
454 this->P->Count *= 2;
455 break;
456 case vtkDrawTexturedElements::ElementShape::LineStrip:
457 ++this->P->Count;
458 break;
459 case vtkDrawTexturedElements::ElementShape::Triangle:
460 this->P->Count *= 3;
461 break;
462 case vtkDrawTexturedElements::ElementShape::TriangleStrip:
463 this->P->Count += 2;
464 break;
465 case vtkDrawTexturedElements::ElementShape::TriangleFan:
466 this->P->Count += 2;
467 break;
468 case vtkDrawTexturedElements::ElementShape::AbstractPatches:
469#ifdef GL_ARB_tessellation_shader
470 {
471 (void)mapper;
472 const int patchVertexCount = this->PatchVertexCountFromPrimitive(this->PatchType);
473 this->P->Count *= patchVertexCount;
474 glPatchParameteri(GL_PATCH_VERTICES, patchVertexCount);
475 break;
476 }
477#else
478 vtkErrorWithObjectMacro(mapper, << "ElementType cannot be \'AbstractPatches\' because "
479 "GL_PATCHES is not supported in this build of VTK.");
480 break;
481#endif
482 default:
483 {
484 vtkGenericWarningMacro("Invalid element type " << this->ElementType << ".");
485 break;
486 }
487 }
488 auto instances = static_cast<GLsizei>(this->NumberOfInstances);
489 vtkOpenGLStaticCheckErrorMacro("Just before draw instanced");
490 // Render the element instances:
491#ifdef GL_ES_VERSION_3_0
492 (void)ren;
493 glDrawArraysInstanced(this->P->Primitive, this->FirstVertexId, this->P->Count, instances);
494#else
495 if (GLAD_GL_VERSION_3_1)

Callers 1

DrawInstancedElementsMethod · 0.95

Calls 1

Tested by

no test coverage detected