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

Method DrawImage

Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1750–1798  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1748
1749//------------------------------------------------------------------------------
1750void vtkOpenGLContextDevice2D::DrawImage(float p[2], float scale, vtkImageData* image)
1751{
1752 vtkOpenGLGL2PSHelper* gl2ps = vtkOpenGLGL2PSHelper::GetInstance();
1753 if (gl2ps)
1754 {
1755 switch (gl2ps->GetActiveState())
1756 {
1757 case vtkOpenGLGL2PSHelper::Capture:
1758 this->DrawImageGL2PS(p, scale, image);
1759 return;
1760 case vtkOpenGLGL2PSHelper::Background:
1761 return; // Do nothing.
1762 case vtkOpenGLGL2PSHelper::Inactive:
1763 break; // Draw as normal.
1764 }
1765 }
1766
1767 vtkOpenGLClearErrorMacro();
1768
1769 this->SetTexture(image);
1770 this->Storage->Texture->Render(this->Renderer);
1771 int* extent = image->GetExtent();
1772 float points[] = { p[0], p[1], p[0] + scale * extent[1] + 1.0f, p[1],
1773 p[0] + scale * extent[1] + 1.0f, p[1] + scale * extent[3] + 1.0f, p[0], p[1],
1774 p[0] + scale * extent[1] + 1.0f, p[1] + scale * extent[3] + 1.0f, p[0],
1775 p[1] + scale * extent[3] + 1.0f };
1776
1777 float texCoord[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
1778
1779 vtkOpenGLClearErrorMacro();
1780
1781 this->ReadyVTBOProgram();
1782 vtkOpenGLHelper* cbo = this->VTBO;
1783 if (!cbo->Program)
1784 {
1785 return;
1786 }
1787 int tunit = vtkOpenGLTexture::SafeDownCast(this->Storage->Texture)->GetTextureUnit();
1788 cbo->Program->SetUniformi("texture1", tunit);
1789
1790 this->BuildVBO(cbo, points, 6, nullptr, 0, texCoord);
1791 this->SetMatrices(cbo->Program);
1792
1793 glDrawArrays(GL_TRIANGLES, 0, 6);
1794
1795 this->Storage->Texture->PostRender(this->Renderer);
1796
1797 vtkOpenGLCheckErrorMacro("failed after DrawImage");
1798}
1799
1800//------------------------------------------------------------------------------
1801void vtkOpenGLContextDevice2D::DrawPolyData(

Callers 1

DrawImageGL2PSMethod · 0.45

Calls 15

DrawImageGL2PSMethod · 0.95
SetTextureMethod · 0.95
ReadyVTBOProgramMethod · 0.95
BuildVBOMethod · 0.95
SetMatricesMethod · 0.95
vtkglActiveTextureMethod · 0.80
TextureFromImageMethod · 0.80
RenderMethod · 0.65
GetExtentMethod · 0.45
GetTextureUnitMethod · 0.45
SetUniformiMethod · 0.45
PostRenderMethod · 0.45

Tested by

no test coverage detected