summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-09-17 08:04:36 +0200
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-09-17 09:59:50 +0200
commit079c861f08d27aa8b6368aebc37f235979049286 (patch)
tree835917e048fe884135f8fbea373579c20e7ac81d /chart2
parentb3d50feaa87b670baf68288974005ac26ad31736 (diff)
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
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/main/OpenGLRender.cxx8
1 files changed, 5 insertions, 3 deletions
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)