diff options
-rw-r--r-- | avmedia/source/opengl/oglplayer.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/OpenGLRender.cxx | 8 | ||||
-rw-r--r-- | include/vcl/opengl/OpenGLHelper.hxx | 4 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLHelper.cxx | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index a21d5db403d1..c7f0c05f0703 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -103,7 +103,7 @@ bool OGLPlayer::create( const OUString& rURL ) } BitmapEx aBitmapEx = aGraphic.GetBitmapEx(); rFile.buffer = new char[4 * aBitmapEx.GetSizePixel().Width() * aBitmapEx.GetSizePixel().Height()]; - OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer)); + OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer), true); rFile.imagewidth = aBitmapEx.GetSizePixel().Width(); rFile.imageheight = aBitmapEx.GetSizePixel().Height(); } diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 7c328b91303c..428b300c1d0e 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -87,7 +87,7 @@ GLfloat texCoords[] = { int OpenGLRender::InitOpenGL() { glEnable(GL_TEXTURE_2D); - glEnable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); glCullFace(GL_BACK); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Enable depth test @@ -107,7 +107,8 @@ int OpenGLRender::InitOpenGL() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Init the Projection matrix - m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -1.f, 1.f); + m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -1.f, 1.f); + m_Projection = m_Projection * glm::scale(1.0f, -1.0f, 1.0f); m_View = glm::lookAt(glm::vec3(0,0,1), // Camera is at (4,3,-3), in World Space glm::vec3(0,0,0), // and looks at the origin glm::vec3(0,1,0) // Head is up (set to 0,-1,0 to look upside-down) @@ -356,7 +357,8 @@ void OpenGLRender::SetSize(int width, int height) { m_iWidth = width; m_iHeight = height; - m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -4.f, 3.f); + m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -4.f, 3.f); + m_Projection = m_Projection * glm::scale(1.0f, -1.0f, 1.0f); } void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha) diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx index f4ed8ea288d3..8c04e320d4be 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -25,9 +25,9 @@ public: * The caller is responsible for allocate the memory for the RGBA buffer, before call * this method. RGBA buffer size is assumed to be 4*width*height. * Since OpenGL uses textures flipped relative to BitmapEx storage this method - * also mirrors the bitmap vertically. + * also adds the possibility to mirror the bitmap vertically at the same time. **/ - static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer); + static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer, const bool bFlip = false); static BitmapEx ConvertBGRABufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight); static void renderToFile(long nWidth, long nHeight, const OUString& rFileName); 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++) |