/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include "ogl_canvastools.hxx" using namespace ::com::sun::star; namespace oglcanvas { /// triangulates polygon before void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); const ::basegfx::B2DRange& rBounds(aPolyPoly.getB2DRange()); const double nWidth=rBounds.getWidth(); const double nHeight=rBounds.getHeight(); const ::basegfx::triangulator::B2DTriangleVector rTriangulatedPolygon( ::basegfx::triangulator::triangulate(aPolyPoly)); for( auto const& rTriangulatedPolygonItem : rTriangulatedPolygon ) { const::basegfx::triangulator::B2DTriangle& rCandidate(rTriangulatedPolygonItem); glTexCoord2f( rCandidate.getA().getX()/nWidth, rCandidate.getA().getY()/nHeight); glVertex2d( rCandidate.getA().getX(), rCandidate.getA().getY()); glTexCoord2f( rCandidate.getB().getX()/nWidth, rCandidate.getB().getY()/nHeight); glVertex2d( rCandidate.getB().getX(), rCandidate.getB().getY()); glTexCoord2f( rCandidate.getC().getX()/nWidth, rCandidate.getC().getY()/nHeight); glVertex2d( rCandidate.getC().getX(), rCandidate.getC().getY()); } } /** only use this for line polygons. better not leave triangulation to OpenGL. also, ignores texturing */ void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); for( sal_uInt32 i=0; i& rNumbers, double scale ) { double y=4.0; basegfx::B2DHomMatrix aTmp; basegfx::B2DHomMatrix aScaleShear; aScaleShear.shearX(-0.1); aScaleShear.scale(scale,scale); for(double rNumber : rNumbers) { aTmp.identity(); aTmp.translate(0,y); y += 1.2*scale; basegfx::B2DPolyPolygon aPoly= basegfx::utils::number2PolyPolygon(rNumber,10,3); aTmp=aTmp*aScaleShear; aPoly.transform(aTmp); glColor4f(0,1,0,1); renderPolyPolygon(aPoly); } } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */