[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 10 commits - chart2/opengl chart2/Package_opengl.mk chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Wed May 28 10:28:40 PDT 2014


 chart2/Package_opengl.mk                       |    2 
 chart2/opengl/shape3DFragmentShaderBatch.glsl  |  108 ++++++++
 chart2/opengl/shape3DVertexShaderBatch.glsl    |   34 ++
 chart2/source/view/charttypes/GL3DBarChart.cxx |   22 +
 chart2/source/view/inc/GL3DBarChart.hxx        |    1 
 chart2/source/view/inc/GL3DRenderer.hxx        |   39 ++-
 chart2/source/view/inc/StaticGeometry.h        |    6 
 chart2/source/view/main/GL3DRenderer.cxx       |  315 +++++++++++++++++++++++--
 8 files changed, 503 insertions(+), 24 deletions(-)

New commits:
commit 9ee9a25b96a09a08ed58e1262ec217e2869f9119
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 28 19:11:47 2014 +0200

    prevent generating repeated information in rendering
    
    Change-Id: I1cc5453af6cabe7736cc43e13aad280aaf2c62f6

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 4cfd9b2..5dac458 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -296,8 +296,8 @@ void GL3DBarChart::render()
     {
         mpCamera->render();
     }
+    mpRenderer->ProcessUnrenderedShape(mbNeedsNewRender);
     mbNeedsNewRender = false;
-    mpRenderer->ProcessUnrenderedShape();
     mrWindow.getContext()->swapBuffers();
 }
 
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index efd131b..b24d45e 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -180,7 +180,7 @@ public:
 
                                  glm::vec2 vTopLeft, glm::vec2 vBottomRight,
                                  sal_uInt32 nUniqueId);
-    void ProcessUnrenderedShape();
+    void ProcessUnrenderedShape(bool bNewScene);
 
     void SetPickingMode(bool bPickingMode);
 
@@ -233,7 +233,7 @@ private:
     void GetBatchMiddleInfo(Extrude3DInfo &extrude3D);
     void InitBatch3DUniformBlock();
     void UpdateBatch3DUniformBlock();
-    void RenderBatchBars();
+    void RenderBatchBars(bool bNewScene);
 private:
 
     struct ShaderResources
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 55cd098..92f31ec 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1703,7 +1703,7 @@ void OpenGL3DRenderer::ClearBuffer()
     }
 }
 
-void OpenGL3DRenderer::ProcessUnrenderedShape()
+void OpenGL3DRenderer::ProcessUnrenderedShape(bool bNewScene)
 {
     glViewport(0, 0, m_iWidth, m_iHeight);
     ClearBuffer();
@@ -1714,7 +1714,7 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     if(mbPickingMode)
         RenderExtrude3DObject();
     else
-        RenderBatchBars();
+        RenderBatchBars(bNewScene);
     //render text
     RenderTextShape();
     // render screen text
@@ -1873,9 +1873,10 @@ void OpenGL3DRenderer::GetBatchBarsInfo()
     }
 }
 
-void OpenGL3DRenderer::RenderBatchBars()
+void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
 {
-    GetBatchBarsInfo();
+    if(bNewScene)
+        GetBatchBarsInfo();
     glEnable(GL_DEPTH_TEST);
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
commit 9e36b50141f0dc731b89895492b1319fa0e60054
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 28 18:51:38 2014 +0200

    avoid transferring the textures for each frame
    
    Change-Id: I79466e66dc18dbbf72f192fe44d05fb6d657fa34

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index c9ade73..4cfd9b2 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -35,7 +35,8 @@ GL3DBarChart::GL3DBarChart(
     mnStep(0),
     mnStepsTotal(0),
     mnCornerId(0),
-    mbBlockUserInput(false)
+    mbBlockUserInput(false),
+    mbNeedsNewRender(true)
 {
     Size aSize = mrWindow.GetSizePixel();
     mpRenderer->SetSize(aSize);
@@ -93,6 +94,7 @@ double findMaxValue(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer)
 void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
         ExplicitCategoriesProvider& rCatProvider)
 {
+    mpRenderer->ReleaseShapes();
     // Each series of data flows from left to right, and multiple series are
     // stacked vertically along y axis.
 
@@ -269,6 +271,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     mpCamera->setPosition(maCameraPosition);
     maCameraDirection = glm::vec3(mnMaxX/2, mnMaxY/2, 0);
     mpCamera->setDirection(maCameraDirection);
+
+    mbNeedsNewRender = true;
 }
 
 void GL3DBarChart::render()
@@ -280,11 +284,19 @@ void GL3DBarChart::render()
     Size aSize = mrWindow.GetSizePixel();
     mpRenderer->SetSize(aSize);
     mrWindow.getContext()->setWinSize(aSize);
-    for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
-            itrEnd = maShapes.end(); itr != itrEnd; ++itr)
+    if(mbNeedsNewRender)
+    {
+        for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
+                itrEnd = maShapes.end(); itr != itrEnd; ++itr)
+        {
+            itr->render();
+        }
+    }
+    else
     {
-        itr->render();
+        mpCamera->render();
     }
+    mbNeedsNewRender = false;
     mpRenderer->ProcessUnrenderedShape();
     mrWindow.getContext()->swapBuffers();
 }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index de92660..8c97ca8 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -105,6 +105,7 @@ private:
 
     std::map<sal_uInt32, const BarInformation> maBarMap;
     bool mbBlockUserInput;
+    bool mbNeedsNewRender;
 };
 
 }
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c6a9a55..efd131b 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -185,6 +185,9 @@ public:
     void SetPickingMode(bool bPickingMode);
 
     sal_uInt32 GetPixelColorFromPoint(long nX, long nY);
+
+    void ReleaseShapes();
+    void ReleaseScreenTextShapes();
 private:
     void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
 
@@ -221,11 +224,9 @@ private:
                                int iSubDivZ, float width, float height, float depth);
     void CreateSceneBoxView();
 
-    void ReleaseShapes();
     void ReleasePolygonShapes();
     void ReleaseExtrude3DShapes();
     void ReleaseTextShapes();
-    void ReleaseScreenTextShapes();
     void ReleaseBatchBarInfo();
     void GetBatchBarsInfo();
     void GetBatchTopAndFlatInfo(Extrude3DInfo &extrude3D);
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6792dab..55cd098 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1719,7 +1719,6 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     RenderTextShape();
     // render screen text
     RenderScreenTextShape();
-    ReleaseShapes();
 #if DEBUG_FBO
     OUString aFileName = OUString("D://shaderout_") + OUString::number(m_iWidth) + "_" + OUString::number(m_iHeight) + ".png";
     OpenGLHelper::renderToFile(m_iWidth, m_iHeight, aFileName);
@@ -1770,7 +1769,6 @@ void OpenGL3DRenderer::ReleaseBatchBarInfo()
     }
 }
 
-
 void OpenGL3DRenderer::ReleaseShapes()
 {
     ReleasePolygonShapes();
commit 61466d45912b446d0a12498cd34b27d25f3ccff0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 28 18:32:16 2014 +0200

    fix picking mode for the batch rendering
    
    Change-Id: I9bfe64d56f9217561bb059eacde1fa3ece5f2cc1

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index aac3a40..6792dab 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1711,8 +1711,10 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     //Polygon
     RenderPolygon3DObject();
     //Shape3DExtrudeObject
-    RenderBatchBars();
-//    RenderExtrude3DObject();
+    if(mbPickingMode)
+        RenderExtrude3DObject();
+    else
+        RenderBatchBars();
     //render text
     RenderTextShape();
     // render screen text
commit c7f08226bb3e6e0078f32b914286ad60ed7c7c9c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 28 18:28:59 2014 +0200

    remove unnecessary glFinish
    
    Change-Id: I368e045a7635410a94f2f3a794e1c75a39418520

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 0bfdff7..aac3a40 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1973,7 +1973,6 @@ void OpenGL3DRenderer::RenderBatchBars()
         glDisableVertexAttribArray(maResources.m_3DBatchNormalMatrixID + i);
         glVertexAttribDivisor(maResources.m_3DBatchNormalMatrixID + i, 0);
     }
-    glFinish();
     glUseProgram(0);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glDisable(GL_CULL_FACE);
commit 7183298d4d4a716704f203fe34739b52e8c19b6c
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 20:53:07 2014 +0800

    Modify the bar generate function
    
    Change-Id: Ia323c54b9113be15f01bff2a2f1e66da8ebfc39c

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 62b16e8..0bfdff7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -278,6 +278,7 @@ void OpenGL3DRenderer::init()
 
     OpenGLHelper::createFramebuffer(m_iWidth, m_iHeight, mnPickingFbo, mnPickingRboDepth, mnPickingRboColor);
 
+    m_Extrude3DInfo.rounded = false;
     CHECK_GL_ERROR();
     Init3DUniformBlock();
     InitBatch3DUniformBlock();
@@ -357,10 +358,6 @@ void OpenGL3DRenderer::SetVertex(PackedVertex &packed,
 
 void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int iSubDivZ, float width, float height, float depth)
 {
-    if ((fRadius > (width / 2)) || (fRadius > (height / 2)) || (fRadius > (depth / 2)))
-    {
-        return;
-    }
     float topThreshold = depth - 2 * fRadius;
     float bottomThreshold = fRadius;
 
@@ -1011,12 +1008,14 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
     m_Extrude3DInfo.xTransform = tranform.x;
     m_Extrude3DInfo.yTransform = tranform.y;
     m_Extrude3DInfo.zTransform = tranform.z;
-    m_Extrude3DInfo.rounded = roundedCorner;
-    if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
-    {
-        float radius = 0.2f;
-        CreateActualRoundedCube(radius, CORNER_DIVION_Y, CORNER_DIVION_Z,
-                1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
+    float width = 1.0f;
+    float height = m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale;
+    float radius = height > 0.2f ? 0.2f : height / 4.0f;
+    float depth = 1 + 2 * radius;
+    bool NORoundedCube = (radius > (width / 2)) || (radius > (height / 2)) || (radius > (depth / 2));
+    if (!NORoundedCube && roundedCorner && (m_RoundBarMesh.iMeshSizes == 0))
+    {
+        CreateActualRoundedCube(radius, CORNER_DIVION_Y, CORNER_DIVION_Z, width, height, depth);
         AddVertexData(m_CubeVertexBuf);
         AddNormalData(m_CubeNormalBuf);
         AddIndexData(m_CubeElementBuf);
@@ -1028,6 +1027,7 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
         m_Vertices.clear();
         m_Normals.clear();
         m_Indeices.clear();
+        m_Extrude3DInfo.rounded = true;
     }
     m_Batchmaterial = m_Extrude3DInfo.material;
 }
@@ -1879,7 +1879,6 @@ void OpenGL3DRenderer::RenderBatchBars()
     glEnable(GL_DEPTH_TEST);
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
-
     glUseProgram(maResources.m_3DBatchProID);
     UpdateBatch3DUniformBlock();
     glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
commit 0fa05cf3f830c0a0c9b16733dfb993e3d64e165b
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 13:35:40 2014 +0800

    add batch render function

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 288796f..c6a9a55 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -232,6 +232,7 @@ private:
     void GetBatchMiddleInfo(Extrude3DInfo &extrude3D);
     void InitBatch3DUniformBlock();
     void UpdateBatch3DUniformBlock();
+    void RenderBatchBars();
 private:
 
     struct ShaderResources
diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h
index 3ff412a..525b15b 100644
--- a/chart2/source/view/inc/StaticGeometry.h
+++ b/chart2/source/view/inc/StaticGeometry.h
@@ -12,9 +12,9 @@
 
 #define TOP_SURFACE 0
 #define MIDDLE_SURFACE 1
-#define BOTTOM_SURFACE 2
-#define FLAT_TOP_SURFACE 3
-#define FLAT_BOTTOM_SURFACE 4
+#define FLAT_BOTTOM_SURFACE 2
+#define BOTTOM_SURFACE 3
+#define FLAT_TOP_SURFACE 4
 
 static GLfloat boundBox[] = {
     0.0f, 0.0f, 0.0f,
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1a8cb79..62b16e8 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -101,6 +101,9 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
     glDeleteBuffers(1, &m_3DUBOBuffer);
     glDeleteBuffers(1, &m_VertexBuffer);
     glDeleteBuffers(1, &m_NormalBuffer);
+    glDeleteBuffers(1, &m_Batch3DUBOBuffer);
+    glDeleteBuffers(1, &m_3DUBOBuffer);
+    glDeleteBuffers(1, &m_3DUBOBuffer);
 
     glDeleteFramebuffers(1, &mnPickingFbo);
     glDeleteRenderbuffers(1, &mnPickingRboDepth);
@@ -128,6 +131,14 @@ OpenGL3DRenderer::ShaderResources::ShaderResources()
     , m_2DVertexID(0)
     , m_2DColorID(0)
     , m_MatrixID(0)
+    , m_3DBatchProID(0)
+    , m_3DBatchProjectionID(0)
+    , m_3DBatchViewID(0)
+    , m_3DBatchModelID(0)
+    , m_3DBatchNormalMatrixID(0)
+    , m_3DBatchVertexID(0)
+    , m_3DBatchNormalID(0)
+    , m_3DBatchColorID(0)
 {
 }
 
@@ -137,6 +148,7 @@ OpenGL3DRenderer::ShaderResources::~ShaderResources()
     glDeleteProgram(m_TextProID);
     glDeleteProgram(m_ScreenTextProID);
     glDeleteProgram(m_3DProID);
+    glDeleteProgram(m_3DBatchProID);
 }
 
 void OpenGL3DRenderer::ShaderResources::LoadShaders()
@@ -165,6 +177,14 @@ void OpenGL3DRenderer::ShaderResources::LoadShaders()
     m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
     m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
 
+    m_3DBatchProID = OpenGLHelper::LoadShaders("shape3DVertexShaderBatch", "shape3DFragmentShaderBatch");
+    m_3DBatchProjectionID = glGetUniformLocation(m_3DBatchProID, "P");
+    m_3DBatchViewID = glGetUniformLocation(m_3DBatchProID, "V");
+    m_3DBatchModelID = glGetAttribLocation(m_3DBatchProID, "M");
+    m_3DBatchNormalMatrixID = glGetAttribLocation(m_3DBatchProID, "normalMatrix");
+    m_3DBatchVertexID = glGetAttribLocation(m_3DBatchProID, "vertexPositionModelspace");
+    m_3DBatchNormalID = glGetAttribLocation(m_3DBatchProID, "vertexNormalModelspace");
+    m_3DBatchColorID = glGetAttribLocation(m_3DBatchProID, "barColor");
     CHECK_GL_ERROR();
 }
 
@@ -222,6 +242,9 @@ void OpenGL3DRenderer::init()
     glGenBuffers(1, &m_CubeElementBuf);
     glGenBuffers(1, &m_VertexBuffer);
     glGenBuffers(1, &m_NormalBuffer);
+    glGenBuffers(1, &m_BatchModelMatrixBuf);
+    glGenBuffers(1, &m_BatchNormalMatrixBuf);
+    glGenBuffers(1, &m_BatchColorBuf);
     glGenBuffers(1, &m_BoundBox);
     glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox);
     glBufferData(GL_ARRAY_BUFFER, sizeof(boundBox), boundBox, GL_STATIC_DRAW);
@@ -1006,6 +1029,7 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
         m_Normals.clear();
         m_Indeices.clear();
     }
+    m_Batchmaterial = m_Extrude3DInfo.material;
 }
 
 void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
@@ -1687,7 +1711,8 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     //Polygon
     RenderPolygon3DObject();
     //Shape3DExtrudeObject
-    RenderExtrude3DObject();
+    RenderBatchBars();
+//    RenderExtrude3DObject();
     //render text
     RenderTextShape();
     // render screen text
@@ -1847,6 +1872,113 @@ void OpenGL3DRenderer::GetBatchBarsInfo()
         }
     }
 }
+
+void OpenGL3DRenderer::RenderBatchBars()
+{
+    GetBatchBarsInfo();
+    glEnable(GL_DEPTH_TEST);
+    glEnable(GL_CULL_FACE);
+    glCullFace(GL_BACK);
+
+    glUseProgram(maResources.m_3DBatchProID);
+    UpdateBatch3DUniformBlock();
+    glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
+    glBufferSubData(GL_UNIFORM_BUFFER, m_Batch3DActualSizeLight, sizeof(MaterialParameters), &m_Batchmaterial);
+    CHECK_GL_ERROR();
+    glBindBuffer(GL_UNIFORM_BUFFER, 0);
+    glUniformMatrix4fv(maResources.m_3DBatchViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(maResources.m_3DBatchProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    CHECK_GL_ERROR();
+    GLuint vertexBuf = m_Extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
+    GLuint normalBuf = m_Extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
+    //vertex
+    glEnableVertexAttribArray(maResources.m_3DBatchVertexID);
+    glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
+    glVertexAttribPointer(maResources.m_3DBatchVertexID, // attribute
+                          3,                  // size
+                          GL_FLOAT,           // type
+                          GL_FALSE,           // normalized?
+                          0,                  // stride
+                          (void*)0            // array buffer offset
+                          );
+    //normal
+    glEnableVertexAttribArray(maResources.m_3DBatchNormalID);
+    glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
+    glVertexAttribPointer(maResources.m_3DBatchNormalID, // attribute
+                            3,                  // size
+                            GL_FLOAT,           // type
+                            GL_FALSE,           // normalized?
+                            0,                  // stride
+                            (void*)0            // array buffer offset
+                            );
+
+    for (unsigned int i = 0; i < 4 ; i++)
+    {
+        glEnableVertexAttribArray(maResources.m_3DBatchModelID + i);
+        glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf);
+        glVertexAttribPointer(maResources.m_3DBatchModelID + i, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), reinterpret_cast<GLvoid*>(sizeof(GLfloat) * i * 4));
+        glVertexAttribDivisor(maResources.m_3DBatchModelID + i, 1);
+    }
+
+    for (unsigned int i = 0; i < 3 ; i++)
+    {
+        glEnableVertexAttribArray(maResources.m_3DBatchNormalMatrixID + i);
+        glBindBuffer(GL_ARRAY_BUFFER, m_BatchNormalMatrixBuf);
+        glVertexAttribPointer(maResources.m_3DBatchNormalMatrixID + i, 3, GL_FLOAT, GL_FALSE, sizeof(glm::mat3), reinterpret_cast<GLvoid*>(sizeof(GLfloat) * i * 3));
+        glVertexAttribDivisor(maResources.m_3DBatchNormalMatrixID + i, 1);
+    }
+    glEnableVertexAttribArray(maResources.m_3DBatchColorID);
+    glBindBuffer(GL_ARRAY_BUFFER, m_BatchColorBuf);
+    glVertexAttribPointer(maResources.m_3DBatchColorID , 4, GL_FLOAT, GL_FALSE, sizeof(glm::vec4), 0);
+    glVertexAttribDivisor(maResources.m_3DBatchColorID, 1);
+    if (m_Extrude3DInfo.rounded)
+    {
+        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
+        for (int i = 0; i < 3; i++)
+        {
+            glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf);
+            glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat4) * m_BarSurface[i].modelMatrixList.size(), &m_BarSurface[i].modelMatrixList[0][0], GL_DYNAMIC_DRAW);
+            glBindBuffer(GL_ARRAY_BUFFER, m_BatchNormalMatrixBuf);
+            glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat3) * m_BarSurface[i].normalMatrixList.size(), &m_BarSurface[i].normalMatrixList[0][0], GL_DYNAMIC_DRAW);
+            glBindBuffer(GL_ARRAY_BUFFER, m_BatchColorBuf);
+            glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec4) * m_BarSurface[i].colorList.size(), &m_BarSurface[i].colorList[0], GL_DYNAMIC_DRAW);
+            glDrawElementsInstancedBaseVertex(GL_TRIANGLES,
+                                              m_Extrude3DInfo.size[i],
+                                              GL_UNSIGNED_SHORT,
+                                              reinterpret_cast<GLvoid*>(m_Extrude3DInfo.startIndex[i]),
+                                              m_BarSurface[i].modelMatrixList.size(),
+                                              0);
+        }
+    }
+    else
+    {
+        glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf);
+        glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat4) * m_BarSurface[0].modelMatrixList.size(), &m_BarSurface[0].modelMatrixList[0][0], GL_DYNAMIC_DRAW);
+        glBindBuffer(GL_ARRAY_BUFFER, m_BatchNormalMatrixBuf);
+        glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat3) * m_BarSurface[0].normalMatrixList.size(), &m_BarSurface[0].normalMatrixList[0][0], GL_DYNAMIC_DRAW);
+        glBindBuffer(GL_ARRAY_BUFFER, m_BatchColorBuf);
+        glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec4) * m_BarSurface[0].colorList.size(), &m_BarSurface[0].colorList[0], GL_DYNAMIC_DRAW);
+        glDrawArraysInstanced(GL_TRIANGLES, 0, 36, m_BarSurface[0].modelMatrixList.size());
+    }
+    glDisableVertexAttribArray(maResources.m_3DBatchVertexID);
+    glDisableVertexAttribArray(maResources.m_3DBatchNormalID);
+    glDisableVertexAttribArray(maResources.m_3DBatchColorID);
+    glVertexAttribDivisor(maResources.m_3DBatchColorID, 0);
+    for (unsigned int i = 0; i < 4 ; i++)
+    {
+        glDisableVertexAttribArray(maResources.m_3DBatchModelID + i);
+        glVertexAttribDivisor(maResources.m_3DBatchModelID + i, 0);
+    }
+    for (unsigned int i = 0; i < 3 ; i++)
+    {
+        glDisableVertexAttribArray(maResources.m_3DBatchNormalMatrixID + i);
+        glVertexAttribDivisor(maResources.m_3DBatchNormalMatrixID + i, 0);
+    }
+    glFinish();
+    glUseProgram(0);
+    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+    glDisable(GL_CULL_FACE);
+}
 }
 }
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 37a16738803b9e05642e1041a7e09ea43657083b
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 13:06:07 2014 +0800

    add get and release batch render info function

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 4f2bac9..288796f 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -227,6 +227,9 @@ private:
     void ReleaseTextShapes();
     void ReleaseScreenTextShapes();
     void ReleaseBatchBarInfo();
+    void GetBatchBarsInfo();
+    void GetBatchTopAndFlatInfo(Extrude3DInfo &extrude3D);
+    void GetBatchMiddleInfo(Extrude3DInfo &extrude3D);
     void InitBatch3DUniformBlock();
     void UpdateBatch3DUniformBlock();
 private:
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 4805d36..1a8cb79 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1733,16 +1733,120 @@ sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY)
     return aColor.GetColor();
 }
 
+void OpenGL3DRenderer::ReleaseBatchBarInfo()
+{
+    for (int i = 0; i < 3; i++)
+    {
+        m_BarSurface[i].modelMatrixList.clear();
+        m_BarSurface[i].normalMatrixList.clear();
+        m_BarSurface[i].colorList.clear();
+    }
+}
+
+
 void OpenGL3DRenderer::ReleaseShapes()
 {
     ReleasePolygonShapes();
     ReleaseExtrude3DShapes();
     ReleaseTextShapes();
     ReleaseScreenTextShapes();
+    ReleaseBatchBarInfo();
 }
 
+void OpenGL3DRenderer::GetBatchMiddleInfo(Extrude3DInfo &extrude3D)
+{
+    float xyScale = extrude3D.xScale;
+    float zScale = extrude3D.zScale;
+    float actualZScale = zScale - m_RoundBarMesh.bottomThreshold * xyScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
+                      extrude3D.zTransform};
+    if (actualZScale < 0.0f)
+    {
+          return ;
+    }
+    else
+    {
+        glm::mat4 scale = glm::scale(xyScale, xyScale,actualZScale);
+        glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+        m_Model = aTranslationMatrix * extrude3D.rotation * scale;
+    }
+    glm::mat3 normalMatrix(m_Model);
+    glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+    m_BarSurface[MIDDLE_SURFACE].modelMatrixList.push_back(m_Model);
+    m_BarSurface[MIDDLE_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
+    m_BarSurface[MIDDLE_SURFACE].colorList.push_back(extrude3D.material.materialColor);
 }
 
+void OpenGL3DRenderer::GetBatchTopAndFlatInfo(Extrude3DInfo &extrude3D)
+{
+    float xyScale = extrude3D.xScale;
+    float zScale = extrude3D.zScale;
+    float actualZTrans = zScale - m_RoundBarMesh.bottomThreshold * xyScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
+                      extrude3D.zTransform};
+    glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, 0.0, -1.0));
+    if (actualZTrans < 0.0f)
+    {
+        // the height of rounded corner is higher than the cube than use the org scale matrix
+        //yScale /= (float)(1 + BOTTOM_THRESHOLD);
+        zScale /= (float)(m_RoundBarMesh.bottomThreshold);
+        glm::mat4 scale = glm::scale(xyScale, xyScale, zScale);
+        //MoveModelf(trans, angle, scale);
+        glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+        m_Model = aTranslationMatrix * extrude3D.rotation * scale * orgTrans;
+    }
+    else
+    {
+        // use different matrices for different parts
+        glm::mat4 topTrans = glm::translate(glm::vec3(0.0, 0.0, actualZTrans));
+        glm::mat4 topScale = glm::scale(xyScale, xyScale, xyScale);
+        glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+        m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale * orgTrans;
+    }
+    glm::mat3 normalMatrix(m_Model);
+    glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+    m_BarSurface[TOP_SURFACE].modelMatrixList.push_back(m_Model);
+    m_BarSurface[TOP_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
+    m_BarSurface[TOP_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+
+    glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
+    glm::mat4 flatScale = glm::scale(xyScale, xyScale, xyScale);
+    m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
+    normalMatrix = glm::mat3(m_Model);
+    normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+
+    m_BarSurface[FLAT_BOTTOM_SURFACE].modelMatrixList.push_back(m_Model);
+    m_BarSurface[FLAT_BOTTOM_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
+    m_BarSurface[FLAT_BOTTOM_SURFACE].colorList.push_back(extrude3D.material.materialColor);
 }
 
+void OpenGL3DRenderer::GetBatchBarsInfo()
+{
+    for (size_t i = 0; i < m_Extrude3DList.size(); i++)
+    {
+        Extrude3DInfo &extrude3DInfo = m_Extrude3DList[i];
+        extrude3DInfo.zTransform *= m_fHeightWeight;
+        extrude3DInfo.zScale *= m_fHeightWeight;
+        if (m_Extrude3DInfo.rounded)
+        {
+            GetBatchTopAndFlatInfo(extrude3DInfo);
+            GetBatchMiddleInfo(extrude3DInfo);
+        }
+        else
+        {
+            glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3DInfo.xTransform, extrude3DInfo.yTransform, extrude3DInfo.zTransform));
+            glm::mat4 scaleMatrix = glm::scale(extrude3DInfo.xScale, extrude3DInfo.yScale, extrude3DInfo.zScale);
+            m_Model = transformMatrix * extrude3DInfo.rotation * scaleMatrix;
+            glm::mat3 normalMatrix(m_Model);
+            glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+            m_BarSurface[0].modelMatrixList.push_back(m_Model);
+            m_BarSurface[0].normalMatrixList.push_back(normalInverseTranspos);
+            m_BarSurface[0].colorList.push_back(extrude3DInfo.material.materialColor);
+        }
+    }
+}
+}
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5deb3699a221967e3f153b44cc25d0c70995816c
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 12:50:38 2014 +0800

    add use and update uno function
    
    Change-Id: I79d7d7ab77fff9a5e60a392e94fe2dd839803b64

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index f01297d..4f2bac9 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -226,6 +226,9 @@ private:
     void ReleaseExtrude3DShapes();
     void ReleaseTextShapes();
     void ReleaseScreenTextShapes();
+    void ReleaseBatchBarInfo();
+    void InitBatch3DUniformBlock();
+    void UpdateBatch3DUniformBlock();
 private:
 
     struct ShaderResources
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 07c3f4d..4805d36 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -257,6 +257,7 @@ void OpenGL3DRenderer::init()
 
     CHECK_GL_ERROR();
     Init3DUniformBlock();
+    InitBatch3DUniformBlock();
 
     glViewport(0, 0, m_iWidth, m_iHeight);
     Set3DSenceInfo(0xFFFFFF, true);
@@ -1048,6 +1049,59 @@ void OpenGL3DRenderer::Init3DUniformBlock()
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
 }
 
+void OpenGL3DRenderer::InitBatch3DUniformBlock()
+{
+    if(mbPickingMode)
+        return;
+
+    GLuint a3DLightBlockIndex = glGetUniformBlockIndex(maResources.m_3DBatchProID, "GlobalLights");
+    GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(maResources.m_3DBatchProID, "GlobalMaterialParameters");
+
+    if ((GL_INVALID_INDEX == a3DLightBlockIndex) || (GL_INVALID_INDEX == a3DMaterialBlockIndex))
+    {
+        return;
+    }
+    int nUniformBufferAlignSize = 1;
+    glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &nUniformBufferAlignSize);
+    GLint nBlockDataSizeLight = 0, nBlockDataSizeMertrial = 0;
+    glGetActiveUniformBlockiv(maResources.m_3DBatchProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
+    glGetActiveUniformBlockiv(maResources.m_3DBatchProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
+    CHECK_GL_ERROR();
+    glGenBuffers(1, &m_Batch3DUBOBuffer);
+    glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
+    CHECK_GL_ERROR();
+    m_Batch3DActualSizeLight = ((nBlockDataSizeLight / nUniformBufferAlignSize) + std::min(nBlockDataSizeLight % nUniformBufferAlignSize, 1)) * nUniformBufferAlignSize;
+//    cout << "nBlockDataSizeMertrial = " << nBlockDataSizeMertrial << ", nBlockDataSizeLight = " << nBlockDataSizeLight << ", m_3DActualSizeLight = " << m_3DActualSizeLight << endl;
+    int dataSize = m_Batch3DActualSizeLight + nBlockDataSizeMertrial;
+    glBufferData(GL_UNIFORM_BUFFER, dataSize, NULL, GL_DYNAMIC_DRAW);
+    glBindBufferRange(GL_UNIFORM_BUFFER, 2, m_Batch3DUBOBuffer, 0, nBlockDataSizeLight);
+    CHECK_GL_ERROR();
+    glUniformBlockBinding(maResources.m_3DBatchProID, a3DLightBlockIndex, 2);
+
+    glBindBufferRange(GL_UNIFORM_BUFFER, 3, m_Batch3DUBOBuffer, ((nBlockDataSizeLight / nUniformBufferAlignSize) + std::min(nBlockDataSizeLight % nUniformBufferAlignSize, 1)) * nUniformBufferAlignSize, nBlockDataSizeMertrial);
+    glUniformBlockBinding(maResources.m_3DBatchProID, a3DMaterialBlockIndex, 3);
+    //for the light source uniform, we must calc the offset of each element
+    CHECK_GL_ERROR();
+    glBindBuffer(GL_UNIFORM_BUFFER, 0);
+}
+
+void OpenGL3DRenderer::UpdateBatch3DUniformBlock()
+{
+    if(mbPickingMode)
+        return;
+
+    glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
+    glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(GLint), &m_LightsInfo.lightNum);
+    CHECK_GL_ERROR();
+    //current std140 alignment: 16
+    glBufferSubData(GL_UNIFORM_BUFFER, 16, sizeof(glm::vec4), &m_LightsInfo.ambient[0]);
+    CHECK_GL_ERROR();
+    //current std140 alignment: 16
+    glBufferSubData(GL_UNIFORM_BUFFER, 32, sizeof(LightSource) * MAX_LIGHT_NUM, &m_LightsInfo.light);
+    CHECK_GL_ERROR();
+    glBindBuffer(GL_UNIFORM_BUFFER, 0);
+}
+
 void OpenGL3DRenderer::Update3DUniformBlock()
 {
     if(mbPickingMode)
commit 41a3af6d501f7baea8c4d168fb904e409d7abf3d
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 12:43:43 2014 +0800

    add batch render variables
    
    Change-Id: Idfd6f5ce5f711631d6115fe9227724891ccd95ef

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index f110693..f01297d 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -143,6 +143,13 @@ struct TextInfo
     float vertex[12];
 };
 
+struct BatchBarInfo
+{
+    std::vector <glm::mat4> modelMatrixList;
+    std::vector <glm::mat3> normalMatrixList;
+    std::vector <glm::vec4> colorList;
+};
+
 class OpenGL3DRenderer
 {
 public:
@@ -251,6 +258,16 @@ private:
         GLint m_2DColorID;
         GLint m_MatrixID;
 
+        // Batch render
+        GLint m_3DBatchProID;
+        GLint m_3DBatchProjectionID;
+        GLint m_3DBatchViewID;
+        GLint m_3DBatchModelID;
+        GLint m_3DBatchNormalMatrixID;
+        GLint m_3DBatchVertexID;
+        GLint m_3DBatchNormalID;
+        GLint m_3DBatchColorID;
+
         ShaderResources();
         ~ShaderResources();
 
@@ -347,6 +364,14 @@ private:
     GLuint mnPickingFbo;
     GLuint mnPickingRboDepth;
     GLuint mnPickingRboColor;
+
+    BatchBarInfo m_BarSurface[3];
+    GLuint m_BatchModelMatrixBuf;
+    GLuint m_BatchNormalMatrixBuf;
+    GLuint m_BatchColorBuf;
+    MaterialParameters m_Batchmaterial;
+    GLuint m_Batch3DUBOBuffer;
+    GLint m_Batch3DActualSizeLight;
 };
 
 }
commit 2c3abf3595e6185e3bcf71184d7e2491859cb05b
Author: weigao <weigao at multicorewareinc.com>
Date:   Wed May 28 12:39:17 2014 +0800

    add batch render shader
    
    Change-Id: I44cd54b35f872365268db3b4455beeac01ba3197

diff --git a/chart2/Package_opengl.mk b/chart2/Package_opengl.mk
index 99cdde3..d8f9fa7 100644
--- a/chart2/Package_opengl.mk
+++ b/chart2/Package_opengl.mk
@@ -28,6 +28,8 @@ $(eval $(call gb_Package_add_files,chart2_opengl_shader,$(LIBO_BIN_FOLDER)/openg
 	shape3DVertexShader.glsl \
 	renderTextureVertexShader.glsl \
 	renderTextureFragmentShader.glsl \
+	shape3DFragmentShaderBatch.glsl \
+	shape3DVertexShaderBatch.glsl \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/chart2/opengl/shape3DFragmentShaderBatch.glsl b/chart2/opengl/shape3DFragmentShaderBatch.glsl
new file mode 100644
index 0000000..b7bdc7e
--- /dev/null
+++ b/chart2/opengl/shape3DFragmentShaderBatch.glsl
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#version 330 core
+#define MAX_LIGHT_NUM 8
+
+in vec3 positionWorldspace;
+in vec3 normalCameraspace;
+in vec4 fragBarColor;
+uniform mat4 V;
+out vec4 actualColor;
+struct MaterialParameters
+{
+    vec4 ambient;
+    vec4 diffuse;
+    vec4 specular;
+    vec4 materialColor;
+
+    int twoSidesLighting;
+    float shininess;
+    float pad;
+    float pad1;
+};
+
+layout(std140) uniform GlobalMaterialParameters
+{
+    MaterialParameters matralParameter;
+}Material;
+
+struct LightSource
+{
+    vec4   lightColor;
+    vec4   positionWorldspace;
+    float  lightPower;
+    float  pad1;
+    float  pad2;
+    float  pad3;
+};
+
+layout(std140) uniform GlobalLights
+{
+    int         lightNum;
+    vec4        ambient;
+    LightSource light[MAX_LIGHT_NUM];
+} Lights;
+
+void main()
+{
+    vec3 colorTotal = vec3(0.0f, 0.0f, 0.0f);
+
+    vec3 vertexPositionCameraspace = (V * vec4(positionWorldspace,1)).xyz;
+
+    vec3 MaterialDiffuseColor = fragBarColor.rgb;
+
+    vec3 normalDirectionCameraspace = normalCameraspace;
+    vec3 eyeDirectionCameraspace = normalize(vec3(0, 0, 0) - vertexPositionCameraspace);
+    float attenuation = 1.0;
+    int i = 0;
+    vec3 lightDirectionCameraspace;
+    vec3 vertexToLightSource;
+
+    vec3 lightAmbient = Lights.ambient.rgb *
+                        MaterialDiffuseColor *
+                        Material.matralParameter.ambient.rgb
+                        * 5.0;
+
+    for (i = 0; i < Lights.lightNum; i++)
+    {
+        float  LightPower = Lights.light[i].lightPower;
+        lightDirectionCameraspace = normalize((V * Lights.light[i].positionWorldspace).xyz);
+
+        float cosTheta = clamp(dot(normalDirectionCameraspace,lightDirectionCameraspace), 0,1);
+        vec3 lightDiffuse = LightPower *
+                            attenuation *
+                            Lights.light[i].lightColor.rgb *
+                            MaterialDiffuseColor *
+                            Material.matralParameter.diffuse.rgb *
+                            cosTheta;
+
+        vec3 specularReflection;
+        if (dot(normalDirectionCameraspace, lightDirectionCameraspace) < 0)
+        {
+            specularReflection = vec3(0.0, 0.0, 0.0);
+        }
+        else
+        {
+            vec3 R = reflect(-lightDirectionCameraspace,normalDirectionCameraspace);
+            float cosAlpha = clamp(dot(eyeDirectionCameraspace, R), 0,1);
+            specularReflection = attenuation *
+                                 LightPower *
+                                 Lights.light[i].lightColor.rgb *
+                                 Material.matralParameter.specular.rgb *
+                                 MaterialDiffuseColor *
+                                 pow(max(0.0, cosAlpha), Material.matralParameter.shininess);
+        }
+        colorTotal += lightDiffuse + specularReflection;
+
+    }
+    colorTotal += lightAmbient;
+    actualColor = vec4(colorTotal, 1.0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/opengl/shape3DVertexShaderBatch.glsl b/chart2/opengl/shape3DVertexShaderBatch.glsl
new file mode 100644
index 0000000..8c27c7a
--- /dev/null
+++ b/chart2/opengl/shape3DVertexShaderBatch.glsl
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#version 330 core
+in vec3 vertexPositionModelspace;
+in vec3 vertexNormalModelspace;
+in mat4 M;
+in mat3 normalMatrix;
+in vec4 barColor;
+
+out vec3 positionWorldspace;
+out vec3 normalCameraspace;
+out vec4 fragBarColor;
+
+uniform mat4 P;
+uniform mat4 V;
+
+void main()
+{
+    gl_Position =  P * V * M * vec4(vertexPositionModelspace,1);
+
+    positionWorldspace = (M * vec4(vertexPositionModelspace,1)).xyz;
+
+    normalCameraspace = normalize(mat3(V) * normalMatrix * vertexNormalModelspace);
+	
+	fragBarColor = barColor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list