------------------------------------------------------------------------------
| 1748 | |
| 1749 | //------------------------------------------------------------------------------ |
| 1750 | void 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 | //------------------------------------------------------------------------------ |
| 1801 | void vtkOpenGLContextDevice2D::DrawPolyData( |
no test coverage detected