summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-03-07 11:37:30 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-03-07 11:39:41 +0100
commitd102ae2ce8873b01d9408e37a843e16062c50531 (patch)
tree7bd15233898a85bb4f0e4e45fd941ec67613ca84 /chart2
parent82ff9ec5935fd5647cb39ae5a85565f4260b0212 (diff)
fix the rotation matrix for text shapes
Change-Id: I78bf93da4b06f694621e92832773a1abd01256d7
Diffstat (limited to 'chart2')
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx27
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx4
2 files changed, 13 insertions, 18 deletions
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 7c8932d51951..3b81db2845be 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1299,24 +1299,23 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&
TextInfo aTextInfo;
aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
- aTextInfo.vertex[0] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
- aTextInfo.vertex[1] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[0] = -aSize.Width / 2 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[1] = -aSize.Height / 2 / OPENGL_SCALE_VALUE;
aTextInfo.vertex[2] = m_fZStep;
- aTextInfo.vertex[3] = (rTrans.Line1.Column3 + aSize.Width ) / OPENGL_SCALE_VALUE ;
- aTextInfo.vertex[4] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[3] = aSize.Width / 2 / OPENGL_SCALE_VALUE ;
+ aTextInfo.vertex[4] = -aSize.Height / 2 / OPENGL_SCALE_VALUE;
aTextInfo.vertex[5] = m_fZStep;
- aTextInfo.vertex[6] = (rTrans.Line1.Column3 + aSize.Width) / OPENGL_SCALE_VALUE;
- aTextInfo.vertex[7] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[6] = aSize.Width / 2 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[7] = aSize.Height / 2 / OPENGL_SCALE_VALUE;
aTextInfo.vertex[8] = m_fZStep;
- aTextInfo.vertex[9] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
- aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[9] = -aSize.Width / 2 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[10] = aSize.Height / 2 / OPENGL_SCALE_VALUE;
aTextInfo.vertex[11] = m_fZStep;
-
- aTextInfo.bmpWidth = bmpWidth;
- aTextInfo.bmpHeight = bmpHeight;
+ aTextInfo.nDx = (rTrans.Line1.Column3 + aSize.Width / 2 ) / OPENGL_SCALE_VALUE - bmpWidth/2;
+ aTextInfo.nDy = (rTrans.Line2.Column3 + aSize.Height / 2 ) / OPENGL_SCALE_VALUE - bmpHeight/2;
CHECK_GL_ERROR();
glGenTextures(1, &aTextInfo.texture);
@@ -1346,11 +1345,7 @@ int OpenGLRender::RenderTextShape()
for (size_t i = 0; i < listNum; i++)
{
TextInfo &textInfo = m_TextInfoList.front();
- PosVecf3 trans = { (float)-textInfo.bmpWidth/2.0f, (float)-textInfo.bmpHeight/2.0f, 0};
- if(0.0 != textInfo.rotation)
- {
- SAL_WARN("chart2.opengl", "rotation: " << textInfo.rotation);
- }
+ PosVecf3 trans = { textInfo.nDx, textInfo.nDy, 0};
PosVecf3 angle = {0.0f, 0.0f, float(textInfo.rotation)};
PosVecf3 scale = {1.0, 1.0, 1.0f};
MoveModelf(trans, angle, scale);
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index ca999e2864f6..8e5314da1e41 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -81,8 +81,8 @@ struct TextInfo
GLuint texture;
double rotation;
float vertex[12];
- long bmpWidth;
- long bmpHeight;
+ float nDx;
+ float nDy;
};
typedef std::vector<GLfloat> Area2DPointList;