[Libreoffice-commits] core.git: 12 commits - chart2/source sc/source vcl/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Mon May 5 22:30:53 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |    8 
 chart2/source/view/inc/3DChartObjects.hxx      |   24 -
 chart2/source/view/inc/GL3DBarChart.hxx        |    2 
 chart2/source/view/inc/GL3DRenderer.hxx        |   37 +-
 chart2/source/view/inc/StaticGeometry.h        |   50 +++
 chart2/source/view/main/3DChartObjects.cxx     |  109 ++++--
 chart2/source/view/main/GL3DRenderer.cxx       |  409 +++++++++++++++++--------
 sc/source/ui/view/tabvwshd.cxx                 |    8 
 vcl/source/opengl/OpenGLContext.cxx            |   10 
 9 files changed, 465 insertions(+), 192 deletions(-)

New commits:
commit c2941322d2d8bfe2a596b87f935be13b15268778
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 07:21:43 2014 +0200

    fix wrong shader names
    
    Change-Id: Icd2d219446cdf78c4be97f96e38c9e4b174f9ddd

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6617810..3197c56 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -106,7 +106,7 @@ GLfloat texCoords[] = {
 
 void OpenGL3DRenderer::LoadShaders()
 {
-    m_3DProID = OpenGLHelper::LoadShaders("Shape3DVertexShader", "Shape3DFragmentShader");
+    m_3DProID = OpenGLHelper::LoadShaders("shape3DVertexShader", "shape3DFragmentShader");
     m_3DProjectionID = glGetUniformLocation(m_3DProID, "P");
     m_3DViewID = glGetUniformLocation(m_3DProID, "V");
     m_3DModelID = glGetUniformLocation(m_3DProID, "M");
commit 8f46d30923f841322fa762580bac4ef0182e4ba8
Author: xukai <xukai at multicorewareinc.com>
Date:   Tue May 6 10:45:10 2014 +0800

    add code to call the bar api
    
    Change-Id: Icee44999c175b5d964ebd51c56e9a1585506e036

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 58bf689..8ae30b1 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -97,12 +97,13 @@ typedef struct Extrude3DInfo
     bool twoSidesLighting;
     glm::vec4 extrudeColor;
     long fillStyle;
-    float xRange[2];
-    float yRange[2];
-    float zRange[2];
+    float xScale;
+    float yScale;
+    float zScale;
     float xTransform;
     float yTransform;
     float zTransform;
+    glm::mat4 rotation;
     Material material;
     int startIndex[5];
     int size[5];
@@ -180,11 +181,8 @@ public:
     void EndAddPolygon3DObjectNormalPoint();
     void AddPolygon3DObjectPoint(float x, float y, float z);
     void EndAddPolygon3DObjectPoint();
-    void AddShape3DExtrudeObject(sal_Int32 color, sal_Int32 specular, float xTransform,
-            float yTransform, float zTransform);
+    void AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
     void EndAddShape3DExtrudeObject();
-    void AddExtrude3DObjectPoint(float x, float y, float z);
-    void EndAddExtrude3DObjectPoint();
     double GetTime();
     void SetFPS(float fps);
     void SetClickPos(Point aMPos);
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index ab1e12d..330747d 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -33,7 +33,8 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId
 
 void Bar::render()
 {
-    (void) mbRoundedCorners;
+    mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
+    mpRenderer->EndAddShape3DExtrudeObject();
 }
 
 Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 9fdf6f4..6617810 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -119,13 +119,6 @@ void OpenGL3DRenderer::LoadShaders()
     m_TextVertexID = glGetAttribLocation(m_TextProID, "vPosition");
     m_TextTexCoordID = glGetAttribLocation(m_TextProID, "texCoord");
     m_TextTexID = glGetUniformLocation(m_TextProID, "TextTex");
-
-    glGenBuffers(1, &m_TextTexCoordBuf);
-    glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
-    glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-    CHECK_GL_ERROR();
-    Init3DUniformBlock();
 }
 
 void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut)
@@ -191,6 +184,12 @@ void OpenGL3DRenderer::init()
 
     m_3DProjection = glm::perspective(30.0f, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
     LoadShaders();
+    glGenBuffers(1, &m_TextTexCoordBuf);
+    glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
+    glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    CHECK_GL_ERROR();
+    Init3DUniformBlock();
     m_IsOpenglInit = true;
 }
 
@@ -895,8 +894,18 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
     m_Polygon3DInfo.vertices = NULL;
 }
 
-void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specular,float xTransform,float yTransform,float zTransform)
+void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
 {
+    glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
+    glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
+    glm::vec4 DirY = modelMatrix * glm::vec4(0.0, 1.0, 0.0, 0.0);
+    glm::vec4 DirZ = modelMatrix * glm::vec4(0.0, 0.0, 1.0, 0.0);
+    m_Extrude3DInfo.xScale = glm::length(DirX);
+    m_Extrude3DInfo.yScale = glm::length(DirY);
+    m_Extrude3DInfo.zScale = glm::length(DirZ);
+    glm::mat4 transformMatrixInverse = glm::inverse(glm::translate(glm::vec3(tranform)));
+    glm::mat4 scaleMatrixInverse = glm::inverse(glm::scale(m_Extrude3DInfo.xScale, m_Extrude3DInfo.yScale, m_Extrude3DInfo.zScale));
+    m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
     //color
     m_Extrude3DInfo.extrudeColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
                                              (float)(((color) & 0x0000FF00) >> 8) / 255.0f,
@@ -915,10 +924,10 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specula
     m_Extrude3DInfo.material.ambient = glm::vec4(0.2, 0.2, 0.2, 1.0);
 
     m_Extrude3DInfo.material.shininess = 1.0f;
-
-    m_Extrude3DInfo.xTransform = xTransform - ((float)m_iWidth / 2);
-    m_Extrude3DInfo.yTransform = yTransform - ((float)m_iHeight / 2);
-    m_Extrude3DInfo.zTransform = zTransform;
+    m_Extrude3DInfo.xTransform = tranform.x - ((float)m_iWidth / 2);
+    m_Extrude3DInfo.yTransform = tranform.y - ((float)m_iHeight / 2);
+    m_Extrude3DInfo.zTransform = tranform.z;
+    m_Extrude3DInfo.rounded = roundedCorner;
 }
 
 void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
@@ -927,33 +936,6 @@ void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
     m_Extrude3DList.push_back(m_Extrude3DInfo);
 }
 
-void OpenGL3DRenderer::AddExtrude3DObjectPoint(float x, float y, float z)
-{
-    float maxCoord = std::max(x, std::max(y, z));
-    m_fZmax = std::max(maxCoord, m_fZmax);
-    if (m_iPointNum == 0)
-    {
-        m_Extrude3DInfo.xRange[0] = x;
-        m_Extrude3DInfo.xRange[1] = x;
-        m_Extrude3DInfo.yRange[0] = y;
-        m_Extrude3DInfo.yRange[1] = y;
-        m_Extrude3DInfo.zRange[0] = z;
-        m_Extrude3DInfo.zRange[1] = z;
-    }
-    m_Extrude3DInfo.xRange[0] = std::min(m_Extrude3DInfo.xRange[0], x);
-    m_Extrude3DInfo.xRange[1] = std::max(m_Extrude3DInfo.xRange[1], x);
-    m_Extrude3DInfo.yRange[0] = std::min(m_Extrude3DInfo.yRange[0], y);
-    m_Extrude3DInfo.yRange[1] = std::max(m_Extrude3DInfo.yRange[1], y);
-    m_Extrude3DInfo.zRange[0] = std::min(m_Extrude3DInfo.zRange[0], z);
-    m_Extrude3DInfo.zRange[1] = std::max(m_Extrude3DInfo.zRange[1], z);
-    m_iPointNum++;
-}
-
-void OpenGL3DRenderer::EndAddExtrude3DObjectPoint()
-{
-    m_iPointNum = 0;
-}
-
 void OpenGL3DRenderer::Init3DUniformBlock()
 {
     GLuint a3DLightBlockIndex = glGetUniformBlockIndex(m_3DProID, "GlobalLights");
@@ -1003,13 +985,13 @@ void OpenGL3DRenderer::Update3DUniformBlock()
 
 void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D, int surIndex)
 {
-    float xzScale = extrude3D.xRange[1] - extrude3D.xRange[0];
+    float xzScale = extrude3D.xScale;
     PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
                       -extrude3D.yTransform,
                       extrude3D.zTransform};
     m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
     glm::mat4 flatScale = glm::scale(xzScale, xzScale, xzScale);
-    m_Model = m_TranslationMatrix * flatScale;
+    m_Model = m_TranslationMatrix * extrude3D.rotation * flatScale;
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
     glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
@@ -1019,27 +1001,29 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
 
 void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D)
 {
-    float xzScale = extrude3D.xRange[1] - extrude3D.xRange[0];
-    float yScale = extrude3D.yRange[1] - extrude3D.yRange[0];
+    float xzScale = extrude3D.xScale;
+    float yScale = extrude3D.yScale;
     float actualYTrans = yScale - m_RoundBarMesh.bottomThreshold * xzScale;
     PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
                       -extrude3D.yTransform,
                       extrude3D.zTransform};
-    PosVecf3 angle = {0.0f, 0.0f, 0.0f};
+    //PosVecf3 angle = {0.0f, 0.0f, 0.0f};
     if (actualYTrans < 0.0f)
     {
         // the height of rounded corner is higher than the cube than use the org scale matrix
    //     yScale /= (float)(1 + BOTTOM_THRESHOLD);
         yScale /= (float)(m_RoundBarMesh.bottomThreshold);
         PosVecf3 scale = {xzScale, yScale, xzScale};
-        MoveModelf(trans, angle, scale);
+        glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+        glm::mat4 aScaleMatrix = glm::scale(glm::vec3(scale.x, scale.y, scale.z));
+        m_Model = aTranslationMatrix * extrude3D.rotation * aScaleMatrix;
     }
     else
     {
         glm::mat4 topTrans = glm::translate(glm::vec3(0.0, -actualYTrans, 0.0));
         glm::mat4 topScale = glm::scale(xzScale, xzScale, xzScale);
         m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
-        m_Model = m_TranslationMatrix * topTrans * topScale;
+        m_Model = m_TranslationMatrix * extrude3D.rotation * topTrans * topScale;
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
@@ -1050,8 +1034,8 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
 
 void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D)
 {
-    float xzScale = extrude3D.xRange[1] - extrude3D.xRange[0];
-    float yScale = extrude3D.yRange[1] - extrude3D.yRange[0];
+    float xzScale = extrude3D.xScale;
+    float yScale = extrude3D.yScale;
     float actualYScale = yScale - m_RoundBarMesh.bottomThreshold * xzScale;
     PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
                       -extrude3D.yTransform,
@@ -1068,7 +1052,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
     {
         glm::mat4 scale = glm::scale(xzScale, actualYScale, xzScale);
         m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
-        m_Model = m_TranslationMatrix * scale;
+        m_Model = m_TranslationMatrix * extrude3D.rotation * scale;
     }
 
     if (extrude3D.reverse)
@@ -1085,8 +1069,8 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
 
 void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
 {
-    float xzScale = extrude3D.xRange[1] - extrude3D.xRange[0];
-    float yScale = extrude3D.yRange[1] - extrude3D.yRange[0];
+    float xzScale = extrude3D.xScale;
+    float yScale = extrude3D.yScale;
     float actualYTrans = yScale - m_RoundBarMesh.bottomThreshold * xzScale;
     PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
                       -extrude3D.yTransform,
@@ -1101,7 +1085,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
         glm::mat4 scale = glm::scale(xzScale, yScale, xzScale);
         //MoveModelf(trans, angle, scale);
         m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
-        m_Model = m_TranslationMatrix * scale * orgTrans;
+        m_Model = m_TranslationMatrix * extrude3D.rotation * scale * orgTrans;
     }
     else
     {
@@ -1110,7 +1094,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
         glm::mat4 topTrans = glm::translate(glm::vec3(0.0, actualYTrans, 0.0));
         glm::mat4 topScale = glm::scale(xzScale, xzScale, xzScale);
         m_TranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
-        m_Model = m_TranslationMatrix * topTrans * topScale * orgTrans;
+        m_Model = m_TranslationMatrix * extrude3D.rotation * topTrans * topScale * orgTrans;
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
@@ -1122,14 +1106,14 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
 
 void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
 {
-    float xScale = extrude3D.xRange[1] - extrude3D.xRange[0];
-    float yScale = extrude3D.yRange[1] - extrude3D.yRange[0];
-    float zScale = extrude3D.zRange[1] - extrude3D.zRange[0];
+    float xScale = extrude3D.xScale;
+    float yScale = extrude3D.yScale;
+    float zScale = extrude3D.zScale;
     glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
     glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform));
     glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale);
-    m_Model = transformMatrix * scaleMatrix;
+    m_Model = transformMatrix * extrude3D.rotation * scaleMatrix;
     if (extrude3D.reverse)
     {
         glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
@@ -1174,16 +1158,14 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
         if (extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
         {
-            float xScale = extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0];
-            float zScale = extrude3DInfo.zRange[1] - extrude3DInfo.zRange[0];
-            CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, zScale / xScale);
+            CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, extrude3DInfo.zScale / extrude3DInfo.xScale);
             AddVertexData(m_CubeVertexBuf);
             AddNormalData(m_CubeNormalBuf);
             AddIndexData(m_CubeElementBuf);
-            for (int i = 0; i < 5; i++)
+            for (int j = 0; i < 5; i++)
             {
-                m_Extrude3DInfo.startIndex[i] = m_RoundBarMesh.iElementStartIndices[i];
-                m_Extrude3DInfo.size[i] = m_RoundBarMesh.iElementSizes[i];
+                m_Extrude3DInfo.startIndex[j] = m_RoundBarMesh.iElementStartIndices[i];
+                m_Extrude3DInfo.size[j] = m_RoundBarMesh.iElementSizes[i];
             }
         }
         GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
@@ -1209,13 +1191,12 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
                                 (void*)0            // array buffer offset
                                 );
         extrude3DInfo.yTransform *= m_fHeightWeight;
-        extrude3DInfo.yRange[0] *= m_fHeightWeight;
-        extrude3DInfo.yRange[1] *= m_fHeightWeight;
+        extrude3DInfo.yScale *= m_fHeightWeight;
         glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
         glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(Material), &extrude3DInfo.material);
         CHECK_GL_ERROR();
         glBindBuffer(GL_UNIFORM_BUFFER, 0);
-        extrude3DInfo.reverse = -extrude3DInfo.yRange[0] > extrude3DInfo.yRange[1] ? 0 : 1;
+        extrude3DInfo.reverse = 0;
         if (extrude3DInfo.rounded)
         {
             glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
@@ -1437,6 +1418,8 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     RenderPolygon3DObject();
     //Shape3DExtrudeObject
     RenderExtrude3DObject();
+    //render text
+    RenderTextShape();
     //render the axis
     RenderCoordinateAxis();
 }
@@ -1489,19 +1472,18 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
     {
         extrude3DInfo = m_Extrude3DList[i];
         extrude3DInfo.yTransform *= m_fHeightWeight;
-        extrude3DInfo.yRange[0] *= m_fHeightWeight;
-        extrude3DInfo.yRange[1] *= m_fHeightWeight;
+        extrude3DInfo.yScale *= m_fHeightWeight;
         PosVecf3 trans = {extrude3DInfo.xTransform,//m_Extrude3DInfo.xTransform + 140,
                           -extrude3DInfo.yTransform,
                           extrude3DInfo.zTransform};
         PosVecf3 angle = {0.0f, 0.0f, 0.0f};
-        PosVecf3 scale = {extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0],
-                          extrude3DInfo.yRange[1] - extrude3DInfo.yRange[0],
-                          extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]};
+        PosVecf3 scale = {extrude3DInfo.xScale,
+                          extrude3DInfo.yScale,
+                          extrude3DInfo.xScale};
         MoveModelf(trans, angle, scale);
         glm::mat4 boundMVP = m_3DProjection * m_3DView * m_Model;
         glm::vec4 boundColor = GetColorByIndex(i);
-        int reverse = extrude3DInfo.yRange[0] > extrude3DInfo.yRange[1] ? 1 : -1;
+        int reverse = 1;
         if (reverse < 0)
         {
             glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
@@ -1543,14 +1525,13 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
     float horizontalAngle = GL_PI / 6.0f;
     extrude3DInfo = m_Extrude3DList[selectID];
     extrude3DInfo.yTransform *= m_fHeightWeight;
-    extrude3DInfo.yRange[0] *= m_fHeightWeight;
-    extrude3DInfo.yRange[1] *= m_fHeightWeight;
-    int reverse = extrude3DInfo.yRange[0] > extrude3DInfo.yRange[1] ? 1 : -1;
+    extrude3DInfo.yScale *= m_fHeightWeight;
+    int reverse = 1;
     if (m_CameraInfo.useDefault)
     {
-        m_CameraInfo.cameraOrg = glm::vec3(extrude3DInfo.xTransform + (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]) / 2,
-                                           -extrude3DInfo.yTransform + (extrude3DInfo.yRange[1] - extrude3DInfo.yRange[0]) *reverse,
-                                           extrude3DInfo.zTransform + (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]) / 2);
+        m_CameraInfo.cameraOrg = glm::vec3(extrude3DInfo.xTransform + extrude3DInfo.xScale / 2,
+                                           -extrude3DInfo.yTransform + extrude3DInfo.yScale *reverse,
+                                           extrude3DInfo.zTransform + extrude3DInfo.xScale / 2);
 
         m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x - distance * cos(veriticalAngle) * sin(horizontalAngle);
         m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * cos(veriticalAngle) * cos(horizontalAngle);
@@ -1564,13 +1545,13 @@ int OpenGL3DRenderer::ProcessExtrude3DPickingBox()
 
     m_coordinateAxisinfo.pickingFlg = 1;
     m_coordinateAxisinfo.reverse = reverse;
-    m_coordinateAxisinfo.trans.x = extrude3DInfo.xTransform + (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]) / 2;
-    m_coordinateAxisinfo.trans.y = -extrude3DInfo.yTransform + (extrude3DInfo.yRange[1] - extrude3DInfo.yRange[0] + 1.5) * reverse;
-    m_coordinateAxisinfo.trans.z = extrude3DInfo.zTransform + (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]) / 2;
+    m_coordinateAxisinfo.trans.x = extrude3DInfo.xTransform + extrude3DInfo.xScale / 2;
+    m_coordinateAxisinfo.trans.y = -extrude3DInfo.yTransform + (extrude3DInfo.yScale + 1.5) * reverse;
+    m_coordinateAxisinfo.trans.z = extrude3DInfo.zTransform + extrude3DInfo.xScale / 2;
 
-    m_coordinateAxisinfo.scale.x = 4 * (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]);
-    m_coordinateAxisinfo.scale.y = 4 * (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]);
-    m_coordinateAxisinfo.scale.z = 4 * (extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0]);
+    m_coordinateAxisinfo.scale.x = 4 * extrude3DInfo.xScale;
+    m_coordinateAxisinfo.scale.y = 4 * extrude3DInfo.xScale;
+    m_coordinateAxisinfo.scale.z = 4 * extrude3DInfo.xScale;
     m_coordinateAxisinfo.color = glm::vec4(0.5, 1.0, 0.8, 1.0);
     glBindFramebuffer(GL_FRAMEBUFFER, 0);
     return 1;
commit 3176300bb3ee3b21efb60e667d94d4dc74120a3d
Author: xukai <xukai at multicorewareinc.com>
Date:   Tue May 6 09:43:08 2014 +0800

    add api for render non rouded bar
    
    Change-Id: I16bb4ec77cccf0ff9e73f02e13288562004eb5bc

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index bc2b323..58bf689 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -91,6 +91,7 @@ typedef struct Polygon3DInfo
 typedef struct Extrude3DInfo
 {
     int pickingFlg;
+    bool rounded;
     bool lineOnly;
     float lineWidth;
     bool twoSidesLighting;
@@ -98,6 +99,7 @@ typedef struct Extrude3DInfo
     long fillStyle;
     float xRange[2];
     float yRange[2];
+    float zRange[2];
     float xTransform;
     float yTransform;
     float zTransform;
@@ -218,6 +220,7 @@ private:
     void AddVertexData(GLuint vertexBuf);
     void AddNormalData(GLuint normalBuf);
     void AddIndexData(GLuint indexBuf);
+    void RenderNonRoundedBar(const Extrude3DInfo& extrude3D);
     bool GetSimilarVertexIndex(PackedVertex & packed,
         std::map<PackedVertex,unsigned short> & VertexToOutIndex,
         unsigned short & result
@@ -322,7 +325,7 @@ private:
     Point m_aMPos;
 
     GLuint m_BoundBox;
-
+    GLuint m_BoundBoxNormal;
      // add for text
     std::list <TextInfo> m_TextInfoList;
     GLint m_TextProID;
diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h
index 99a3f9d..2ee0446 100644
--- a/chart2/source/view/inc/StaticGeometry.h
+++ b/chart2/source/view/inc/StaticGeometry.h
@@ -54,6 +54,56 @@ static GLfloat boundBox[] = {
     1.0f,  0.0f, 1.0f//12
 };
 
+static const GLfloat boundBoxNormal[] = {
+    -1.0f, 0.0f, 0.0f,
+    -1.0f, 0.0f, 0.0f,
+    -1.0f, 0.0f, 0.0f,//1
+
+    -1.0f, 0.0f, 0.0f,
+    -1.0f, 0.0f, 0.0f,
+    -1.0f, 0.0f, 0.0f,//2
+
+    0.0f, 0.0f, -1.0f,
+    0.0f, 0.0f, -1.0f,
+    0.0f, 0.0f, -1.0f,//3
+
+    0.0f, 0.0f, -1.0f,
+    0.0f, 0.0f, -1.0f,
+    0.0f, 0.0f, -1.0f,//4
+
+    0.0f, -1.0f, 0.0f,
+    0.0f, -1.0f, 0.0f,
+    0.0f,- 1.0f, 0.0f,//5
+
+    0.0f, -1.0f, 0.0f,
+    0.0f, -1.0f, 0.0f,
+    0.0f, -1.0f, 0.0f,//6
+
+    0.0f, 1.0f, 0.0f,
+    0.0f, 1.0f, 0.0f,
+    0.0f, 1.0f, 0.0f,//7
+
+    0.0f, 1.0f, 0.0f,
+    0.0f, 1.0f, 0.0f,
+    0.0f, 1.0f, 0.0f,//8
+
+    0.0f, 0.0f, 1.0f,
+    0.0f, 0.0f, 1.0f,
+    0.0f, 0.0f, 1.0f,//9
+
+    0.0f, 0.0f, 1.0f,
+    0.0f, 0.0f, 1.0f,
+    0.0f, 0.0f, 1.0f,//10
+
+    1.0f, 0.0f, 0.0f,
+    1.0f, 0.0f, 0.0f,
+    1.0f, 0.0f, 0.0f,//11
+
+    1.0f, 0.0f, 0.0f,
+    1.0f, 0.0f, 0.0f,
+    1.0f, 0.0f, 0.0f//12
+};
+
 GLfloat coordinateAxis[] = {
       -1.0, 0.0, 0.0,
       1.0, 0.0, 0.0,//x
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 682e897..9fdf6f4 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -79,12 +79,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
 
     m_bCameraUpdated = false;
     GetFreq();
-
-    for (int i = 0; i < 5; i++)
-    {
-        m_Extrude3DInfo.startIndex[i] = m_RoundBarMesh.iElementStartIndices[i];
-        m_Extrude3DInfo.size[i] = m_RoundBarMesh.iElementSizes[i];
-    }
     m_fViewAngle = 30.0f;
     m_SenceBox.maxXCoord = -1.0 * FLT_MAX;
     m_SenceBox.minXCoord = FLT_MAX;
@@ -96,6 +90,7 @@ OpenGL3DRenderer::OpenGL3DRenderer():
     m_fHeightWeight = 1.0f;
     m_CameraInfo.useDefault = true;
     m_CameraInfo.cameraUp = glm::vec3(0, 1, 0);
+    m_RoundBarMesh.iMeshSizes = 0;
 }
 
 namespace {
@@ -176,25 +171,18 @@ void OpenGL3DRenderer::init()
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
     glGenBuffers(1, &m_CubeVertexBuf);
-    AddVertexData(m_CubeVertexBuf);
-
     glGenBuffers(1, &m_CubeNormalBuf);
-    AddNormalData(m_CubeNormalBuf);
-
     glGenBuffers(1, &m_CubeElementBuf);
-    AddIndexData(m_CubeElementBuf);
-
-    for (int i = 0; i < 5; i++)
-    {
-        m_Extrude3DInfo.startIndex[i] = m_RoundBarMesh.iElementStartIndices[i];
-        m_Extrude3DInfo.size[i] = m_RoundBarMesh.iElementSizes[i];
-    }
-
     glGenBuffers(1, &m_BoundBox);
     glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox);
     glBufferData(GL_ARRAY_BUFFER, sizeof(boundBox), boundBox, GL_STATIC_DRAW);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
 
+    glGenBuffers(1, &m_BoundBoxNormal);
+    glBindBuffer(GL_ARRAY_BUFFER, m_BoundBoxNormal);
+    glBufferData(GL_ARRAY_BUFFER, sizeof(boundBoxNormal), boundBoxNormal, GL_STATIC_DRAW);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+
     glGenBuffers(1, &m_CoordinateBuf);
     glBindBuffer(GL_ARRAY_BUFFER, m_CoordinateBuf);
     glBufferData(GL_ARRAY_BUFFER, sizeof(coordinateAxis), coordinateAxis, GL_STATIC_DRAW);
@@ -949,11 +937,15 @@ void OpenGL3DRenderer::AddExtrude3DObjectPoint(float x, float y, float z)
         m_Extrude3DInfo.xRange[1] = x;
         m_Extrude3DInfo.yRange[0] = y;
         m_Extrude3DInfo.yRange[1] = y;
+        m_Extrude3DInfo.zRange[0] = z;
+        m_Extrude3DInfo.zRange[1] = z;
     }
     m_Extrude3DInfo.xRange[0] = std::min(m_Extrude3DInfo.xRange[0], x);
     m_Extrude3DInfo.xRange[1] = std::max(m_Extrude3DInfo.xRange[1], x);
     m_Extrude3DInfo.yRange[0] = std::min(m_Extrude3DInfo.yRange[0], y);
     m_Extrude3DInfo.yRange[1] = std::max(m_Extrude3DInfo.yRange[1], y);
+    m_Extrude3DInfo.zRange[0] = std::min(m_Extrude3DInfo.zRange[0], z);
+    m_Extrude3DInfo.zRange[1] = std::max(m_Extrude3DInfo.zRange[1], z);
     m_iPointNum++;
 }
 
@@ -1128,6 +1120,28 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
     RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
 }
 
+void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
+{
+    float xScale = extrude3D.xRange[1] - extrude3D.xRange[0];
+    float yScale = extrude3D.yRange[1] - extrude3D.yRange[0];
+    float zScale = extrude3D.zRange[1] - extrude3D.zRange[0];
+    glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform));
+    glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale);
+    m_Model = transformMatrix * scaleMatrix;
+    if (extrude3D.reverse)
+    {
+        glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
+        m_Model = m_Model * reverseMatrix;
+    }
+    glm::mat3 normalMatrix(m_Model);
+    glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+    glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glDrawArrays(GL_TRIANGLES, 0, 36);
+}
+
 void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
 {
     glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
@@ -1154,32 +1168,46 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     Update3DUniformBlock();
     //render to fbo
     glUseProgram(m_3DProID);
-
-    // 1rst attribute buffer : vertices
-    glEnableVertexAttribArray(m_3DVertexID);
-    glBindBuffer(GL_ARRAY_BUFFER, m_CubeVertexBuf);
-    glVertexAttribPointer(m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
-                            3,                  // size
-                            GL_FLOAT,           // type
-                            GL_FALSE,           // normalized?
-                            0,                  // stride
-                            (void*)0            // array buffer offset
-                            );
-    // 2nd attribute buffer : normals
-    glEnableVertexAttribArray(m_3DNormalID);
-    glBindBuffer(GL_ARRAY_BUFFER, m_CubeNormalBuf);
-    glVertexAttribPointer(m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
-                            3,                  // size
-                            GL_FLOAT,           // type
-                            GL_FALSE,           // normalized?
-                            0,                  // stride
-                            (void*)0            // array buffer offset
-                            );
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
     {
         Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
+        if (extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
+        {
+            float xScale = extrude3DInfo.xRange[1] - extrude3DInfo.xRange[0];
+            float zScale = extrude3DInfo.zRange[1] - extrude3DInfo.zRange[0];
+            CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, zScale / xScale);
+            AddVertexData(m_CubeVertexBuf);
+            AddNormalData(m_CubeNormalBuf);
+            AddIndexData(m_CubeElementBuf);
+            for (int i = 0; i < 5; i++)
+            {
+                m_Extrude3DInfo.startIndex[i] = m_RoundBarMesh.iElementStartIndices[i];
+                m_Extrude3DInfo.size[i] = m_RoundBarMesh.iElementSizes[i];
+            }
+        }
+        GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
+        GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
+        // 1st attribute buffer : vertices
+        glEnableVertexAttribArray(m_3DVertexID);
+        glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
+        glVertexAttribPointer(m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                                3,                  // size
+                                GL_FLOAT,           // type
+                                GL_FALSE,           // normalized?
+                                0,                  // stride
+                                (void*)0            // array buffer offset
+                                );
+        // 2nd attribute buffer : normals
+        glEnableVertexAttribArray(m_3DNormalID);
+        glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
+        glVertexAttribPointer(m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                                3,                  // size
+                                GL_FLOAT,           // type
+                                GL_FALSE,           // normalized?
+                                0,                  // stride
+                                (void*)0            // array buffer offset
+                                );
         extrude3DInfo.yTransform *= m_fHeightWeight;
         extrude3DInfo.yRange[0] *= m_fHeightWeight;
         extrude3DInfo.yRange[1] *= m_fHeightWeight;
@@ -1188,11 +1216,19 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         CHECK_GL_ERROR();
         glBindBuffer(GL_UNIFORM_BUFFER, 0);
         extrude3DInfo.reverse = -extrude3DInfo.yRange[0] > extrude3DInfo.yRange[1] ? 0 : 1;
-        RenderExtrudeSurface(extrude3DInfo);
+        if (extrude3DInfo.rounded)
+        {
+            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
+            RenderExtrudeSurface(extrude3DInfo);
+        }
+        else
+        {
+            RenderNonRoundedBar(extrude3DInfo);
+        }
+        glDisableVertexAttribArray(m_3DVertexID);
+        glDisableVertexAttribArray(m_3DNormalID);
     }
     m_Extrude3DList.clear();
-    glDisableVertexAttribArray(m_3DVertexID);
-    glDisableVertexAttribArray(m_3DNormalID);
     glUseProgram(0);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
     glDisable(GL_CULL_FACE);
commit f518ed3f04342ef18b15c982fec31c8a898b9048
Author: xukai <xukai at multicorewareinc.com>
Date:   Tue May 6 09:24:04 2014 +0800

    add codes to Text::render()
    
    Change-Id: I894cbb42b795f1adee41694011fa2477f87850f0

diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 14391af..db2e5fd 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -63,6 +63,7 @@ class Text : public Renderable3DObject
 {
 public:
     Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
+    virtual void render() SAL_OVERRIDE;
 private:
     BitmapEx maText;
     glm::vec3 maTopLeft;
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 2ed77db..bc2b323 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -189,6 +189,7 @@ public:
     void RenderClickPos(Point aMPos);
     void SetSize(const Size& rSize);
     void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up, bool useDefalut);
+    void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
 private:
     void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
 
@@ -201,7 +202,6 @@ private:
     void RenderExtrude3DObject();
     void RenderFPS(float fps);
     //add for text
-    void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
     void RenderTextShape();
     void RenderText(const ::rtl::OUString& string, com::sun::star::awt::Point aPos);
     void RenderExtrudeSurface(const Extrude3DInfo& extrude3D);
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 2d69c4f..ab1e12d 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -54,6 +54,13 @@ Text::Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
 {
 }
 
+void Text::render()
+{
+    glm::vec3 dir2 = maTopRight - maTopLeft;
+    glm::vec3 bottomLeft = maBottomRight - dir2;
+    mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft);
+}
+
 Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
     Renderable3DObject(pRenderer, nId)
 {
commit ba268b9033765ba14e4a502e3c8d5d98a4cd4b20
Author: xukai <xukai at multicorewareinc.com>
Date:   Mon May 5 18:12:03 2014 +0800

    add the codes for rendering text in class:GL3dRenderer
    
    Change-Id: Ia36e042d30afcc13be5fa3452123ae0778217877

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 59b9b00..2ed77db 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/awt/Point.hpp>
 #include <tools/gen.hxx>
 
+#include <vcl/bitmapex.hxx>
 #include <vcl/opengl/IOpenGLRenderer.hxx>
 
 #include <vector>
@@ -142,6 +143,13 @@ struct PackedVertex{
     };
 };
 
+typedef struct TextInfo
+{
+    GLuint texture;
+    float vertex[12];
+}TextInfo;
+
+
 typedef struct SceneBox
 {
     float maxXCoord;
@@ -158,7 +166,6 @@ class OpenGL3DRenderer : public IOpenGLInfoProvider
 public:
     OpenGL3DRenderer();
 
-    void CreateFrameBufferObj();
     void LoadShaders();
     void init();
     virtual bool isOpenGLInitialized() SAL_OVERRIDE;
@@ -193,6 +200,9 @@ private:
     void Update3DUniformBlock();
     void RenderExtrude3DObject();
     void RenderFPS(float fps);
+    //add for text
+    void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
+    void RenderTextShape();
     void RenderText(const ::rtl::OUString& string, com::sun::star::awt::Point aPos);
     void RenderExtrudeSurface(const Extrude3DInfo& extrude3D);
     void RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D);
@@ -313,6 +323,15 @@ private:
 
     GLuint m_BoundBox;
 
+     // add for text
+    std::list <TextInfo> m_TextInfoList;
+    GLint m_TextProID;
+    GLint m_TextMatrixID;
+    GLint m_TextVertexID;
+    GLint m_TextTexCoordID;
+    GLuint m_TextTexCoordBuf;
+    GLint m_TextTexID;
+
     GLuint m_CoordinateBuf;
 
     int m_uiSelectFrameCounter;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b28e42e..682e897 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -31,15 +31,6 @@ namespace opengl3D {
 
 namespace {
 
-struct TextInfo
-{
-    GLuint texture;
-    double rotation;
-    float vertex[12];
-    float nDx;
-    float nDy;
-};
-
 int static checkGLError(const char *file, int line)
 {
     GLenum glErr;
@@ -65,7 +56,14 @@ int static checkGLError(const char *file, int line)
 }
 
 OpenGL3DRenderer::OpenGL3DRenderer():
-    m_TranslationMatrix(glm::translate(m_Model, glm::vec3(0.0f, 0.0f, 0.0f)))
+    m_IsOpenglInit(false)
+    , m_TranslationMatrix(glm::translate(m_Model, glm::vec3(0.0f, 0.0f, 0.0f)))
+    , m_TextProID(0)
+    , m_TextMatrixID(0)
+    , m_TextVertexID(0)
+    , m_TextTexCoordID(0)
+    , m_TextTexCoordBuf(0)
+    , m_TextTexID(0)
 {
     m_Polygon3DInfo.lineOnly = false;
     m_Polygon3DInfo.twoSidesLighting = false;
@@ -100,26 +98,15 @@ OpenGL3DRenderer::OpenGL3DRenderer():
     m_CameraInfo.cameraUp = glm::vec3(0, 1, 0);
 }
 
-void OpenGL3DRenderer::CreateFrameBufferObj()
-{
-    // create a framebuffer object, you need to delete them when program exits.
-    glGenFramebuffers(2, m_FboID);
-    glCheckFramebufferStatus(GL_FRAMEBUFFER);
-    for (int i = 0; i < 2; i++)
-    {
-        glBindFramebuffer(GL_FRAMEBUFFER, m_FboID[i]);
-        glBindTexture(GL_TEXTURE_2D, m_TextureObj[i]);
-        // attach a texture to FBO color attachement point
-        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TextureObj[i], 0);
-        glCheckFramebufferStatus(GL_FRAMEBUFFER);
-        glBindTexture(GL_TEXTURE_2D, 0);
-        // attach a renderbuffer to depth attachment point
-        glBindRenderbuffer(GL_RENDERBUFFER, m_RboID[i]);
-        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_RboID[i]);
-        glCheckFramebufferStatus(GL_FRAMEBUFFER);
-        glBindRenderbuffer(GL_RENDERBUFFER, 0);
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
-    }
+namespace {
+
+GLfloat texCoords[] = {
+    0.0f, 0.0f,
+    1.0f, 0.0f,
+    1.0f, 1.0f,
+    0.0f, 1.0f
+};
+
 }
 
 void OpenGL3DRenderer::LoadShaders()
@@ -132,12 +119,17 @@ void OpenGL3DRenderer::LoadShaders()
     m_3DVertexID = glGetAttribLocation(m_3DProID, "vertexPositionModelspace");
     m_3DNormalID = glGetAttribLocation(m_3DProID, "vertexNormalModelspace");
 
-    m_CommonProID = OpenGLHelper::LoadShaders("commonVertexShader", "commonFragmentShader");
-    m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
-    m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
-    m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
-    CHECK_GL_ERROR();
+    m_TextProID = OpenGLHelper::LoadShaders("textVertexShader", "textFragmentShader");
+    m_TextMatrixID = glGetUniformLocation(m_TextProID, "MVP");
+    m_TextVertexID = glGetAttribLocation(m_TextProID, "vPosition");
+    m_TextTexCoordID = glGetAttribLocation(m_TextProID, "texCoord");
+    m_TextTexID = glGetUniformLocation(m_TextProID, "TextTex");
 
+    glGenBuffers(1, &m_TextTexCoordBuf);
+    glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
+    glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    CHECK_GL_ERROR();
     Init3DUniformBlock();
 }
 
@@ -153,6 +145,8 @@ void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::ve
     m_CameraInfo.cameraUp = up;
 }
 
+
+
 void OpenGL3DRenderer::init()
 {
     if (glewIsSupported("framebuffer_object") != GLEW_OK)
@@ -209,7 +203,6 @@ void OpenGL3DRenderer::init()
 
     m_3DProjection = glm::perspective(30.0f, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
     LoadShaders();
-    CreateFrameBufferObj();
     m_IsOpenglInit = true;
 }
 
@@ -1215,6 +1208,114 @@ void OpenGL3DRenderer::SetClickPos(Point aMPos)
     m_aMPos = aMPos;
 }
 
+void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft)
+{
+    long bmpWidth = rBitmapEx.GetSizePixel().Width();
+    long bmpHeight = rBitmapEx.GetSizePixel().Height();
+    boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx));
+
+    TextInfo aTextInfo;
+    aTextInfo.vertex[0] = vBottomRight.x;
+    aTextInfo.vertex[1] = vBottomRight.y;
+    aTextInfo.vertex[2] = vBottomRight.z;
+
+    aTextInfo.vertex[3] = vTopRight.x;
+    aTextInfo.vertex[4] = vTopRight.y;
+    aTextInfo.vertex[5] = vTopRight.z;
+
+    aTextInfo.vertex[6] = vTopLeft.x;
+    aTextInfo.vertex[7] = vTopLeft.y;
+    aTextInfo.vertex[8] = vTopLeft.z;
+
+    aTextInfo.vertex[9] = vBottomLeft.x;
+    aTextInfo.vertex[10] = vBottomLeft.y;
+    aTextInfo.vertex[11] = vBottomLeft.z;
+
+    CHECK_GL_ERROR();
+    glGenTextures(1, &aTextInfo.texture);
+    CHECK_GL_ERROR();
+    glBindTexture(GL_TEXTURE_2D, aTextInfo.texture);
+    CHECK_GL_ERROR();
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    CHECK_GL_ERROR();
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+    CHECK_GL_ERROR();
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    CHECK_GL_ERROR();
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    CHECK_GL_ERROR();
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmapBuf.get());
+    CHECK_GL_ERROR();
+    glBindTexture(GL_TEXTURE_2D, 0);
+    CHECK_GL_ERROR();
+    m_TextInfoList.push_back(aTextInfo);
+}
+
+void OpenGL3DRenderer::RenderTextShape()
+{
+    CHECK_GL_ERROR();
+    size_t listNum = m_TextInfoList.size();
+    for (size_t i = 0; i < listNum; i++)
+    {
+        TextInfo &textInfo = m_TextInfoList.front();
+        PosVecf3 trans = {0, 0, 0};
+        PosVecf3 angle = {0.0f, 0.0f, 0.0f};
+        PosVecf3 scale = {1.0, 1.0, 1.0f};
+        MoveModelf(trans, angle, scale);
+        m_MVP = m_Projection * m_View * m_Model;
+        glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+        CHECK_GL_ERROR();
+        glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
+        CHECK_GL_ERROR();
+        glUseProgram(m_TextProID);
+
+        CHECK_GL_ERROR();
+        glUniformMatrix4fv(m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+        // 1rst attribute buffer : vertices
+        glEnableVertexAttribArray(m_TextVertexID);
+        glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+        glVertexAttribPointer(
+            m_TextVertexID,
+            3,                  // size
+            GL_FLOAT,           // type
+            GL_FALSE,           // normalized?
+            0,                  // stride
+            (void*)0            // array buffer offset
+            );
+        //tex coord
+        CHECK_GL_ERROR();
+        glEnableVertexAttribArray(m_TextTexCoordID);
+        glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
+        glVertexAttribPointer(
+            m_TextTexCoordID,
+            2,                  // size
+            GL_FLOAT,           // type
+            GL_FALSE,           // normalized?
+            0,                  // stride
+            (void*)0            // array buffer offset
+            );
+        //texture
+        CHECK_GL_ERROR();
+        glBindTexture(GL_TEXTURE_2D, textInfo.texture);
+        CHECK_GL_ERROR();
+        glUniform1i(m_TextTexID, 0);
+        CHECK_GL_ERROR();
+        //TODO: moggi: get rid fo GL_QUADS
+        glDrawArrays(GL_QUADS, 0, 4);
+        CHECK_GL_ERROR();
+        glDisableVertexAttribArray(m_TextTexCoordID);
+        CHECK_GL_ERROR();
+        glDisableVertexAttribArray(m_TextVertexID);
+        CHECK_GL_ERROR();
+        glBindTexture(GL_TEXTURE_2D, 0);
+        glUseProgram(0);
+        glDeleteTextures(1, &textInfo.texture);
+        CHECK_GL_ERROR();
+        m_TextInfoList.pop_front();
+    }
+    CHECK_GL_ERROR();
+}
+
 void OpenGL3DRenderer::RenderText(const ::rtl::OUString& , awt::Point )
 {
     //TODO: moggi: disabled for now
commit 6f73d3a845067e1aa3bb5862643bf5282fc8c35f
Author: xukai <xukai at multicorewareinc.com>
Date:   Mon May 5 16:24:44 2014 +0800

    add codes to Rectangle::render()
    
    Change-Id: I4a86de032970bfd9cba6270e8e6c6a00e550d74e

diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 739384b..14391af 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -8,7 +8,6 @@
  */
 
 #include <glm/glm.hpp>
-
 #include <tools/color.hxx>
 #include <vcl/bitmapex.hxx>
 
@@ -75,6 +74,7 @@ class Rectangle : public Renderable3DObject
 {
 public:
     Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
+    virtual void render() SAL_OVERRIDE;
 private:
     glm::vec3 maTopLeft;
     glm::vec3 maTopRight;
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index d45dc9f..2d69c4f 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -59,6 +59,37 @@ Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
 {
 }
 
+void Rectangle::render()
+{
+    glm::vec3 dir1 = maBottomRight - maTopLeft;
+    glm::vec3 dir2 = maTopRight - maTopLeft;
+    glm::vec3 normal = glm::normalize(glm::cross(dir1, dir2));
+    mpRenderer->AddShapePolygon3DObject((sal_Int32)maColor.GetColor(), false, 0, 1, 0xFFFFFF);
+    glm::vec3 bottomLeft = maBottomRight - dir2;
+    //set polygon points and normals
+    mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
+    mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
+    mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z);
+    mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
+    mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
+    mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
+    mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
+    mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
+    mpRenderer->EndAddPolygon3DObjectPoint();
+    mpRenderer->EndAddPolygon3DObjectNormalPoint();
+    //we should render the edge if the edge color is different from the fill color
+    if ((sal_Int32)maColor.GetColor() != (sal_Int32)maLineColor.GetColor())
+    {
+        mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0xFFFFFF);
+        mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
+        mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z);
+        mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
+        mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
+        mpRenderer->EndAddPolygon3DObjectPoint();
+    }
+    mpRenderer->EndAddShapePolygon3DObject();
+}
+
 Camera::Camera(OpenGL3DRenderer* pRenderer):
     Renderable3DObject(pRenderer, 0),
     maPos(10,10,-10),
commit 37ec4aefdf054c28bf6f2d3d283dad0f3a799884
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 07:00:28 2014 +0200

    more 3D rendering fixes
    
    Change-Id: I8943355de1b9440104e0281131fb0df3fc599bb4

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 4782f50..59b9b00 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -158,6 +158,7 @@ class OpenGL3DRenderer : public IOpenGLInfoProvider
 public:
     OpenGL3DRenderer();
 
+    void CreateFrameBufferObj();
     void LoadShaders();
     void init();
     virtual bool isOpenGLInitialized() SAL_OVERRIDE;
@@ -288,8 +289,12 @@ private:
 
     GLint m_MatrixID;
 
+    GLuint m_TextureObj[2];
+
     GLuint m_FboID[2];
 
+    GLuint m_RboID[2];
+
     Extrude3DInfo m_Extrude3DInfo;
 
     std::vector <Extrude3DInfo> m_Extrude3DList;
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 4f9da33..d45dc9f 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -91,6 +91,7 @@ void TemporaryContext::init()
     Size winSize(800, 600);
     maContext.setWinSize(winSize);
     mpRenderer->SetSize(winSize);
+    mpRenderer->init();
 }
 
 }
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 651fca4..b28e42e 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -100,6 +100,28 @@ OpenGL3DRenderer::OpenGL3DRenderer():
     m_CameraInfo.cameraUp = glm::vec3(0, 1, 0);
 }
 
+void OpenGL3DRenderer::CreateFrameBufferObj()
+{
+    // create a framebuffer object, you need to delete them when program exits.
+    glGenFramebuffers(2, m_FboID);
+    glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    for (int i = 0; i < 2; i++)
+    {
+        glBindFramebuffer(GL_FRAMEBUFFER, m_FboID[i]);
+        glBindTexture(GL_TEXTURE_2D, m_TextureObj[i]);
+        // attach a texture to FBO color attachement point
+        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TextureObj[i], 0);
+        glCheckFramebufferStatus(GL_FRAMEBUFFER);
+        glBindTexture(GL_TEXTURE_2D, 0);
+        // attach a renderbuffer to depth attachment point
+        glBindRenderbuffer(GL_RENDERBUFFER, m_RboID[i]);
+        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_RboID[i]);
+        glCheckFramebufferStatus(GL_FRAMEBUFFER);
+        glBindRenderbuffer(GL_RENDERBUFFER, 0);
+        glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    }
+}
+
 void OpenGL3DRenderer::LoadShaders()
 {
     m_3DProID = OpenGLHelper::LoadShaders("Shape3DVertexShader", "Shape3DFragmentShader");
@@ -110,6 +132,12 @@ void OpenGL3DRenderer::LoadShaders()
     m_3DVertexID = glGetAttribLocation(m_3DProID, "vertexPositionModelspace");
     m_3DNormalID = glGetAttribLocation(m_3DProID, "vertexNormalModelspace");
 
+    m_CommonProID = OpenGLHelper::LoadShaders("commonVertexShader", "commonFragmentShader");
+    m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
+    m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
+    m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
+    CHECK_GL_ERROR();
+
     Init3DUniformBlock();
 }
 
@@ -127,6 +155,32 @@ void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::ve
 
 void OpenGL3DRenderer::init()
 {
+    if (glewIsSupported("framebuffer_object") != GLEW_OK)
+    {
+        SAL_WARN("chart2.opengl", "GL stack has no framebuffer support");
+        return;
+    }
+
+    glEnable(GL_TEXTURE_2D);
+    glEnable(GL_CULL_FACE);
+    glCullFace(GL_BACK);
+    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+    // Enable depth test
+    glEnable(GL_DEPTH_TEST);
+    // Accept fragment if it closer to the camera than the former one
+    glDepthFunc(GL_LESS);
+    glEnable(GL_POINT_SMOOTH);
+    glEnable(GL_LINE_SMOOTH);
+    glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
+    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+    glClearColor (1.0, 1.0, 1.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glClearDepth(1.0f);
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
     glGenBuffers(1, &m_CubeVertexBuf);
     AddVertexData(m_CubeVertexBuf);
 
@@ -155,6 +209,7 @@ void OpenGL3DRenderer::init()
 
     m_3DProjection = glm::perspective(30.0f, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
     LoadShaders();
+    CreateFrameBufferObj();
     m_IsOpenglInit = true;
 }
 
commit 81074d60801b5ca1c29f7f8127de5c62d652dce1
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 06:35:32 2014 +0200

    fix the OpenGL offscreen rendering a bit
    
    Change-Id: I1f11cdff0de48e3281a58aec9ea37a78c637195e

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 9bb94f5..caf13a7 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -21,7 +21,8 @@ namespace chart {
 
 GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries):
     maDataSeries(rDataSeries),
-    mxContext(new opengl3D::temporary::TemporaryContext())
+    mpRenderer(new opengl3D::OpenGL3DRenderer()),
+    mxContext(new opengl3D::temporary::TemporaryContext(mpRenderer.get()))
 {
 }
 
@@ -35,10 +36,9 @@ void GL3DBarChart::create3DShapes()
     const float nBarSizeY = 10;
     const float nBarDistanceX = nBarSizeX / 2;
     const float nBarDistanceY = nBarSizeY / 2;
-    opengl3D::OpenGL3DRenderer* pRenderer = NULL;
 
     maShapes.clear();
-    maShapes.push_back(new opengl3D::Camera(pRenderer));
+    maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
     sal_Int32 nSeriesIndex = 0;
     sal_uInt32 nId = 1;
     for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
@@ -56,7 +56,7 @@ void GL3DBarChart::create3DShapes()
             glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
             glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
 
-            maShapes.push_back(new opengl3D::Bar(pRenderer, aBarPosition, nId++));
+            maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nId++));
         }
 
         ++nSeriesIndex;
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 9e964ff..739384b 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -99,7 +99,7 @@ namespace temporary {
 class TemporaryContext: public opengl3D::Renderable3DObject
 {
 public:
-    TemporaryContext();
+    TemporaryContext(OpenGL3DRenderer* pRenderer);
 
     void init();
     virtual void render() SAL_OVERRIDE;
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 4eefdaa..da3d1e1 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -21,6 +21,7 @@ namespace chart {
 namespace opengl3D {
 
 class Renderable3DObject;
+class OpenGL3DRenderer;
 
 namespace temporary {
 
@@ -43,6 +44,7 @@ private:
     std::vector<VDataSeries*> maDataSeries;
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
+    boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
     boost::scoped_ptr<opengl3D::temporary::TemporaryContext> mxContext;
 };
 
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 6e3df0c..4f9da33 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -75,8 +75,8 @@ void Camera::render()
 
 namespace temporary {
 
-TemporaryContext::TemporaryContext():
-    Renderable3DObject(NULL, -1)
+TemporaryContext::TemporaryContext(OpenGL3DRenderer* pRenderer):
+    Renderable3DObject(pRenderer, -1)
 {
 }
 
@@ -87,6 +87,10 @@ void TemporaryContext::render()
 
 void TemporaryContext::init()
 {
+    maContext.init();
+    Size winSize(800, 600);
+    maContext.setWinSize(winSize);
+    mpRenderer->SetSize(winSize);
 }
 
 }
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 08f6b32..33e2ffb 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -563,7 +563,7 @@ void OpenGLContext::renderToFile()
 
     BitmapEx aBmp = OpenGLHelper::ConvertBGRABufferToBitmapEx(buf.get(), iWidth, iHeight);
     static int nIdx = 0;
-    OUString aName = OUString( "file:///home/moggi/Documents/work/text" ) + OUString::number( nIdx++ ) + ".png";
+    OUString aName = OUString( "file:///home/moggi/Documents/work/output" ) + OUString::number( nIdx++ ) + ".png";
     try {
         vcl::PNGWriter aWriter( aBmp );
         SvFileStream sOutput( aName, STREAM_WRITE );
commit 08a02bce23fd2b9a4b5602bbe03c70beb4ba01c9
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 03:41:01 2014 +0200

    sal_Bool to bool
    
    Change-Id: I2febe40b1128eefa8838f3dc0836863ed96c0048

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 8faa4d9..08f6b32 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -581,18 +581,18 @@ bool OpenGLContext::initWindow()
     if( !m_pChildWindow )
     {
         SystemWindowData winData = generateWinData(mpWindow);
-        m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, sal_False);
+        m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
         m_pChildWindowGC.reset(m_pChildWindow);
     }
 
     if( m_pChildWindow )
     {
-        m_pChildWindow->SetMouseTransparent( sal_True );
+        m_pChildWindow->SetMouseTransparent( true );
         m_pChildWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
-        m_pChildWindow->EnableEraseBackground( sal_False );
+        m_pChildWindow->EnableEraseBackground( false );
         m_pChildWindow->SetControlForeground();
         m_pChildWindow->SetControlBackground();
-        m_pChildWindow->EnablePaint(sal_False);
+        m_pChildWindow->EnablePaint(false);
 
         const SystemEnvData* sysData(m_pChildWindow->GetSystemData());
         m_aGLWin.hWnd = sysData->hWnd;
commit f63a24a4c2f5687a259b17f2bdaceeecdf16c43c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 02:49:56 2014 +0200

    fix typo
    
    Change-Id: Ic54d87505ac628abfec6942403a066cdb3e02a01

diff --git a/sc/source/ui/view/tabvwshd.cxx b/sc/source/ui/view/tabvwshd.cxx
index e3a5a78..eac3ea4 100644
--- a/sc/source/ui/view/tabvwshd.cxx
+++ b/sc/source/ui/view/tabvwshd.cxx
@@ -57,11 +57,11 @@ Window* ScTabViewShell::GetDialogParent()
     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     if ( pDocSh->IsOle() )
     {
-        //TODO/LATER: how to GetEditWindow in embedded document?!
-        //It should be OK to return the VieShell Window!
+        // TODO/LATER: how to GetEditWindow in embedded document?!
+        // It should be OK to return the ViewShell Window!
         return GetWindow();
-        //SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv();
-        //if (pEnv)
+        // SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv();
+        // if (pEnv)
         //    return pEnv->GetEditWin();
     }
 
commit 9ccd357d2a45c36f2eb1b5d7a1ac8148124683ba
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 02:05:29 2014 +0200

    remove global variable
    
    Change-Id: Ie5f55feb39798dff27e0c6b41d5b88b6e9bf19bc

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 160f40e..9bb94f5 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -15,6 +15,7 @@
 #include <glm/gtx/transform.hpp>
 
 #include "3DChartObjects.hxx"
+#include "GL3DRenderer.hxx"
 
 namespace chart {
 
@@ -34,9 +35,10 @@ void GL3DBarChart::create3DShapes()
     const float nBarSizeY = 10;
     const float nBarDistanceX = nBarSizeX / 2;
     const float nBarDistanceY = nBarSizeY / 2;
+    opengl3D::OpenGL3DRenderer* pRenderer = NULL;
 
     maShapes.clear();
-    maShapes.push_back(new opengl3D::Camera());
+    maShapes.push_back(new opengl3D::Camera(pRenderer));
     sal_Int32 nSeriesIndex = 0;
     sal_uInt32 nId = 1;
     for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
@@ -54,7 +56,7 @@ void GL3DBarChart::create3DShapes()
             glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
             glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
 
-            maShapes.push_back(new opengl3D::Bar(aBarPosition, nId++));
+            maShapes.push_back(new opengl3D::Bar(pRenderer, aBarPosition, nId++));
         }
 
         ++nSeriesIndex;
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index a437871..9e964ff 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -22,7 +22,7 @@ namespace opengl3D {
 class Renderable3DObject
 {
 public:
-    Renderable3DObject(sal_uInt32 nId);
+    Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
 
     virtual ~Renderable3DObject() {};
 
@@ -31,14 +31,14 @@ public:
     OpenGL3DRenderer* getRender();
 
 protected:
+    OpenGL3DRenderer* mpRenderer;
     sal_uInt32 mnUniqueId;
-    static OpenGL3DRenderer* mPrender;
 };
 
 class Bar : public Renderable3DObject
 {
 public:
-    Bar( const glm::mat4& rPosition, sal_uInt32 nId );
+    Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId);
 
     virtual void render() SAL_OVERRIDE;
 private:
@@ -50,7 +50,7 @@ private:
 class Line : public Renderable3DObject
 {
 public:
-    Line( sal_uInt32 nId );
+    Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
 
     virtual void render() SAL_OVERRIDE;
 
@@ -63,7 +63,7 @@ private:
 class Text : public Renderable3DObject
 {
 public:
-    Text( sal_uInt32 nId );
+    Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
 private:
     BitmapEx maText;
     glm::vec3 maTopLeft;
@@ -74,7 +74,7 @@ private:
 class Rectangle : public Renderable3DObject
 {
 public:
-    Rectangle( sal_uInt32 nId );
+    Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
 private:
     glm::vec3 maTopLeft;
     glm::vec3 maTopRight;
@@ -86,7 +86,7 @@ private:
 class Camera : public Renderable3DObject
 {
 public:
-    Camera();
+    Camera(OpenGL3DRenderer* pRenderer);
     virtual void render() SAL_OVERRIDE;
 private:
     glm::vec3 maPos;
@@ -106,9 +106,6 @@ public:
 
 private:
     OpenGLContext maContext;
-
-    int miWidth;
-    int miHeight;
 };
 
 }
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 045107b..6e3df0c 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -13,9 +13,8 @@ namespace chart {
 
 namespace opengl3D {
 
-OpenGL3DRenderer* Renderable3DObject::mPrender = NULL;
-
-Renderable3DObject::Renderable3DObject(sal_uInt32 nId):
+Renderable3DObject::Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+    mpRenderer(pRenderer),
     mnUniqueId(nId)
 {
 }
@@ -25,20 +24,8 @@ void Renderable3DObject::render()
     (void) mnUniqueId;
 }
 
-OpenGL3DRenderer* Renderable3DObject::getRender()
-{
-    if(mPrender==NULL)
-    {
-        mPrender = new OpenGL3DRenderer();
-        mPrender->init();
-        mPrender->Set3DSenceInfo();
-    }
-    return mPrender;
-}
-
-
-Bar::Bar(const glm::mat4& rPosition, sal_uInt32 nId)
-    : Renderable3DObject(nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId)
+    : Renderable3DObject(pRenderer, nId)
     , mbRoundedCorners(false)
     , maPos(rPosition)
 {
@@ -49,31 +36,31 @@ void Bar::render()
     (void) mbRoundedCorners;
 }
 
-Line::Line(sal_uInt32 nId):
-    Renderable3DObject(nId)
+Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+    Renderable3DObject(pRenderer, nId)
 {
 }
 
 void Line::render()
 {
-    getRender()->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
-    getRender()->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
-    getRender()->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
-    getRender()->EndAddShapePolygon3DObject();
+    mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
+    mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
+    mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
+    mpRenderer->EndAddShapePolygon3DObject();
 }
 
-Text::Text(sal_uInt32 nId):
-    Renderable3DObject(nId)
+Text::Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+    Renderable3DObject(pRenderer, nId)
 {
 }
 
-Rectangle::Rectangle(sal_uInt32 nId):
-    Renderable3DObject(nId)
+Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+    Renderable3DObject(pRenderer, nId)
 {
 }
 
-Camera::Camera():
-    Renderable3DObject(0),
+Camera::Camera(OpenGL3DRenderer* pRenderer):
+    Renderable3DObject(pRenderer, 0),
     maPos(10,10,-10),
     maUp(0, 1, 0),
     maDirection(glm::vec3(0,0,0)-maPos)
@@ -82,30 +69,24 @@ Camera::Camera():
 
 void Camera::render()
 {
-    getRender()->SetCameraInfo(maPos, maDirection, maUp, true);
+    mpRenderer->SetCameraInfo(maPos, maDirection, maUp, true);
 }
 
 
 namespace temporary {
 
 TemporaryContext::TemporaryContext():
-    Renderable3DObject(-1),
-    miWidth(200),
-    miHeight(200)
+    Renderable3DObject(NULL, -1)
 {
 }
 
-void TemporaryContext::init()
+void TemporaryContext::render()
 {
-    maContext.init();
-    Size winSize(miWidth, miHeight);
-    maContext.setWinSize(winSize);
-    getRender()->SetSize(winSize);
+    maContext.renderToFile();
 }
 
-void TemporaryContext::render()
+void TemporaryContext::init()
 {
-    maContext.renderToFile();
 }
 
 }
commit 39fc73fe0a29fa6d34987fd57e0fd2e6c3751f89
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue May 6 01:39:19 2014 +0200

    remove whitespace
    
    Change-Id: I4c2d0447526bda4ccbe2fa7edaf8be1886d214f0

diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index a6bf266..a437871 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -15,8 +15,6 @@
 #include <vcl/opengl/OpenGLContext.hxx>
 #include "GL3DRenderer.hxx"
 
-
-
 namespace chart {
 
 namespace opengl3D {


More information about the Libreoffice-commits mailing list