From 079c861f08d27aa8b6368aebc37f235979049286 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Wed, 17 Sep 2014 08:04:36 +0200 Subject: fdo#81237: 2D OpenGL charts was upside-down The problem is that LO drawinglayer uses a coordinate system with an origin at the top-left corner of the screen, while OpenGL uses a complete coordinate system (with all four quarters, e.g.: allows negative values). The points in LO are always positive values which means they are drawn in the first quarter of the OpenGL coordinate system which also means that the origin is at the bottom-left corner of the scene. This difference causes the flipped scene. * To solve that problem scale the projection matrix with -1.0f along the y axis. * glDisable(GL_CULL_FACE) is necessary to avoid dropping primitives after scaling with -1.0. * Since projection matrix mirrors also the textures we don't need to do that inside the ConvertBitmapExToRGBATextureBuffer() method. Change-Id: Ieba642f3e665778a12368fe50a20865ec8f73514 --- vcl/source/opengl/OpenGLHelper.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vcl') diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index e1fbb4eb0822..c94e290ac7f0 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -146,7 +146,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString return ProgramID; } -void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer) +void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer, const bool bFlip) { long nBmpWidth = rBitmapEx.GetSizePixel().Width(); long nBmpHeight = rBitmapEx.GetSizePixel().Height(); @@ -156,7 +156,7 @@ void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, Bitmap::ScopedReadAccess pReadAccces( aBitmap ); AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha ); size_t i = 0; - for (long ny = nBmpHeight - 1; ny >= 0; ny--) + for (long ny = (bFlip ? nBmpHeight - 1 : 0); (bFlip ? ny >= 0 : ny < nBmpHeight); (bFlip ? ny-- : ny++)) { Scanline pAScan = pAlphaReadAccess ? pAlphaReadAccess->GetScanline(ny) : 0; for(long nx = 0; nx < nBmpWidth; nx++) -- cgit