[Libreoffice-commits] core.git: 10 commits - chart2/opengl chart2/Package_opengl.mk chart2/source vcl/source

weigao weigao at multicorewareinc.com
Thu May 15 05:05:22 PDT 2014


 chart2/Package_opengl.mk                       |    2 
 chart2/opengl/pickingFragmentShader.glsl       |   17 
 chart2/opengl/pickingVertexShader.glsl         |   21 +
 chart2/source/view/charttypes/GL3DBarChart.cxx |   27 +
 chart2/source/view/inc/GL3DBarChart.hxx        |    1 
 chart2/source/view/inc/GL3DRenderer.hxx        |  122 ++++--
 chart2/source/view/main/GL3DRenderer.cxx       |  500 +++++++++++++++----------
 vcl/source/window/openglwin.cxx                |    1 
 8 files changed, 470 insertions(+), 221 deletions(-)

New commits:
commit 1528820450b9de1310140b4868a1526ff22fdafd
Author: weigao <weigao at multicorewareinc.com>
Date:   Thu May 15 04:18:20 2014 -0700

    modify the coordinate system to world coordinate system
    
    Change-Id: Ib496f33bcd94cac77aef02ddae2c91bb48150252

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index f2c5732..83008e6 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -141,6 +141,16 @@ struct TextInfo
     float vertex[12];
 };
 
+typedef struct SceneBox{
+    float maxXCoord;
+    float minXCoord;
+    float maxYCoord;
+    float minYCoord;
+    float maxZCoord;
+    float minZCoord;
+}SceneBox;
+
+
 class OpenGL3DRenderer
 {
 public:
@@ -204,7 +214,6 @@ private:
     int GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, std::vector<glm::vec3> &normals, float fRadius, int iSubDivY,
                                int iSubDivZ, float width, float height, float depth);
     void CreateSceneBoxView();
-    void CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize);
     void RenderTexture(GLuint TexID);
 private:
 
@@ -351,6 +360,7 @@ private:
     float m_fHeightWeight;
 
     bool mbPickingMode;
+    SceneBox m_SenceBox;
 };
 
 }
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 8278348..c661e33 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -20,7 +20,9 @@
 #include <StaticGeometry.h>
 #include "glm/gtc/matrix_inverse.hpp"
 
-#define DEBUG_FBO 0
+#define DEBUG_FBO 1
+
+#define GL_PI 3.14159f
 
 using namespace com::sun::star;
 
@@ -87,6 +89,12 @@ OpenGL3DRenderer::OpenGL3DRenderer():
 
     GetFreq();
     m_RoundBarMesh.iMeshSizes = 0;
+    m_SenceBox.maxXCoord = -1.0 * FLT_MAX;
+    m_SenceBox.minXCoord = FLT_MAX;
+    m_SenceBox.maxYCoord =  -1.0 * FLT_MAX;
+    m_SenceBox.minYCoord = FLT_MAX;
+    m_SenceBox.maxZCoord =  -1.0 * FLT_MAX;
+    m_SenceBox.minZCoord = FLT_MAX;
 }
 
 OpenGL3DRenderer::~OpenGL3DRenderer()
@@ -332,7 +340,7 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
     glm::vec3 actualNormals[3];
     std::vector<unsigned short> indeices[5];
     glm::vec3 externSurNormal;
-    glm::mat4 corrctCoord = glm::translate(glm::vec3(width / 2.0f, height / 2.0f  - fRadius, depth / 2.0f));
+    glm::mat4 corrctCoord = glm::translate(glm::vec3(width / 2.0f, height / 2.0f, depth / 2.0f - fRadius));
     m_RoundBarMesh.topThreshold = topThreshold;
     m_RoundBarMesh.bottomThreshold = bottomThreshold;
     m_RoundBarMesh.iMeshStartIndices = m_Vertices.size();
@@ -347,9 +355,9 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
             actualVerteices[k] = glm::vec3(corrctCoord * glm::vec4(vertices[i + k], 1.0));
             actualNormals[k] = normals[i + k];
         }
-        float maxY = std::max(std::max(actualVerteices[0].y, actualVerteices[1].y), actualVerteices[2].y);
-        float minY = std::min(std::min(actualVerteices[0].y, actualVerteices[1].y), actualVerteices[2].y);
-        int surfaceIndex = (minY >= topThreshold - 0.001) ? TOP_SURFACE : ((maxY <= bottomThreshold + 0.001) ? BOTTOM_SURFACE : MIDDLE_SURFACE);
+        float maxZ = std::max(std::max(actualVerteices[0].z, actualVerteices[1].z), actualVerteices[2].z);
+        float minZ = std::min(std::min(actualVerteices[0].z, actualVerteices[1].z), actualVerteices[2].z);
+        int surfaceIndex = (minZ >= topThreshold - 0.001) ? TOP_SURFACE : ((maxZ <= bottomThreshold + 0.001) ? BOTTOM_SURFACE : MIDDLE_SURFACE);
         for (int k = 0; k < 3; k++)
         {
             {
@@ -360,8 +368,8 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
             //add extern
             if ((surfaceIndex == TOP_SURFACE) || (surfaceIndex == BOTTOM_SURFACE))
             {
-                actualVerteices[k].y = 0.0f;
-                externSurNormal = (surfaceIndex == TOP_SURFACE) ? glm::vec3(0.0, 1.0, 0.0) : glm::vec3(0.0, -1.0, 0.0);
+                actualVerteices[k].z = 0.0f;
+                externSurNormal = (surfaceIndex == TOP_SURFACE) ? glm::vec3(0.0, 0.0, 1.0) : glm::vec3(0.0, 0.0, -1.0);
                 int tmpSurfaceIndex = (surfaceIndex == TOP_SURFACE) ? FLAT_TOP_SURFACE : FLAT_BOTTOM_SURFACE;
                 PackedVertex packed = {actualVerteices[k], externSurNormal};
                 SetVertex(packed, VertexToOutIndex, m_Vertices, m_Normals, indeices[tmpSurfaceIndex]);
@@ -381,6 +389,8 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
         }
         indeices[k].clear();
     }
+    vertices.clear();
+    normals.clear();
     VertexToOutIndex.clear();
 }
 
@@ -680,7 +690,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 
     PosVecf3 trans = {0.0f, 0, 0.0};
     PosVecf3 angle = {0.0f, 0.0f, 0.0f};
-    PosVecf3 scale = {1.0f, m_fHeightWeight, 1.0f};
+    PosVecf3 scale = {1.0f, 1.0f, m_fHeightWeight};
     MoveModelf(trans, angle, scale);
 
     m_3DMVP = m_3DProjection * m_3DView * m_Model;
@@ -752,7 +762,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
         Normals3D *normalList = polygon.normalsList.front();
         PosVecf3 trans = {0.0f, 0.0f, 0.0};
         PosVecf3 angle = {0.0f, 0.0f, 0.0f};
-        PosVecf3 scale = {1.0f, m_fHeightWeight, 1.0f};
+        PosVecf3 scale = {1.0f, 1.0f, m_fHeightWeight};
         MoveModelf(trans, angle, scale);
         glm::mat3 normalMatrix(m_Model);
         glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
@@ -933,6 +943,12 @@ void OpenGL3DRenderer::AddPolygon3DObjectPoint(float x, float y, float z)
     float actualY = y;
     float actualZ = z;
     m_Polygon3DInfo.vertices->push_back(glm::vec3(actualX, actualY, actualZ));
+    m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, actualX);
+    m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, actualX);
+    m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, actualY);
+    m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, actualY);
+    m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, actualZ);
+    m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, actualZ);
 }
 
 void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
@@ -948,10 +964,10 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
     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(DirZ);
-    m_Extrude3DInfo.zScale = glm::length(DirY);
+    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.zScale, m_Extrude3DInfo.yScale));
+    glm::mat4 scaleMatrixInverse = glm::inverse(glm::scale(m_Extrude3DInfo.xScale, m_Extrude3DInfo.yScale, m_Extrude3DInfo.zScale));
     m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
 
     //color
@@ -969,11 +985,10 @@ 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.zTransform = 0;
     m_Extrude3DInfo.rounded = roundedCorner;
     if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
     {
-        CreateActualRoundedCube(0.1f, 30, 30, 1.0f, 1.2f, m_Extrude3DInfo.zScale / m_Extrude3DInfo.xScale);
+        CreateActualRoundedCube(0.1f, 30, 30, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1.2f);
         AddVertexData(m_CubeVertexBuf);
         AddNormalData(m_CubeNormalBuf);
         AddIndexData(m_CubeElementBuf);
@@ -982,10 +997,16 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
             m_Extrude3DInfo.startIndex[j] = m_RoundBarMesh.iElementStartIndices[j];
             m_Extrude3DInfo.size[j] = m_RoundBarMesh.iElementSizes[j];
         }
+        m_Vertices.clear();
+        m_Normals.clear();
+        m_Indeices.clear();
     }
-    m_Vertices.clear();
-    m_Normals.clear();
-    m_Indeices.clear();
+    m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, m_Extrude3DInfo.xTransform + m_Extrude3DInfo.xScale);
+    m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, m_Extrude3DInfo.xTransform);
+    m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, m_Extrude3DInfo.yTransform + m_Extrude3DInfo.yScale);
+    m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, m_Extrude3DInfo.yTransform );
+    m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, m_Extrude3DInfo.zTransform + m_Extrude3DInfo.zScale);
+    m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, m_Extrude3DInfo.zTransform);
 }
 
 void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
@@ -1048,12 +1069,12 @@ void OpenGL3DRenderer::Update3DUniformBlock()
 
 void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D, int surIndex)
 {
-    float xzScale = extrude3D.xScale;
-    PosVecf3 trans = {extrude3D.xTransform,//m_Extrude3DInfo.xTransform + 140,
-                      -extrude3D.yTransform,
+    float xyScale = extrude3D.xScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
                       extrude3D.zTransform};
     glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
-    glm::mat4 flatScale = glm::scale(xzScale, xzScale, xzScale);
+    glm::mat4 flatScale = glm::scale(xyScale, xyScale, xyScale);
     m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
     if(!mbPickingMode)
     {
@@ -1072,27 +1093,27 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
 
 void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D)
 {
-    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,
+    float xyScale = extrude3D.xScale;
+    float zScale = extrude3D.zScale;
+    float actualZTrans = zScale - m_RoundBarMesh.bottomThreshold * xyScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
                       extrude3D.zTransform};
     //PosVecf3 angle = {0.0f, 0.0f, 0.0f};
-    if (actualYTrans < 0.0f)
+    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);
-        yScale /= (float)(m_RoundBarMesh.bottomThreshold);
-        PosVecf3 scale = {xzScale, yScale, xzScale};
+        zScale /= (float)(m_RoundBarMesh.bottomThreshold);
+        PosVecf3 scale = {xyScale, xyScale, zScale};
         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);
+        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;
     }
@@ -1113,13 +1134,13 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
 
 void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D)
 {
-    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,
+    float xyScale = extrude3D.xScale;
+    float zScale = extrude3D.zScale;
+    float actualZScale = zScale - m_RoundBarMesh.bottomThreshold * xyScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
                       extrude3D.zTransform};
-    if (actualYScale < 0.0f)
+    if (actualZScale < 0.0f)
     {
         // the height of rounded corner is higher than the cube than use the org scale matrix
  //       yScale /= (float)(1 + BOTTOM_THRESHOLD);
@@ -1129,14 +1150,14 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
     }
     else
     {
-        glm::mat4 scale = glm::scale(xzScale, actualYScale, xzScale);
+        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;
     }
 
     if (extrude3D.reverse)
     {
-        glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
+        glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, 0.0, -1.0));
         m_Model = m_Model * reverseMatrix;
     }
 
@@ -1156,20 +1177,20 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
 
 void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
 {
-    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,
+    float xyScale = extrude3D.xScale;
+    float zScale = extrude3D.zScale;
+    float actualZTrans = zScale - m_RoundBarMesh.bottomThreshold * xyScale;
+    PosVecf3 trans = {extrude3D.xTransform,
+                      extrude3D.yTransform,
                       extrude3D.zTransform};
 
-    if (actualYTrans < 0.0f)
+    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);
-        yScale /= (float)(m_RoundBarMesh.bottomThreshold);
-        glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, -1.0, 0.0));
-        glm::mat4 scale = glm::scale(xzScale, yScale, xzScale);
+        zScale /= (float)(m_RoundBarMesh.bottomThreshold);
+        glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, 0.0, -1.0));
+        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;
@@ -1177,9 +1198,9 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
     else
     {
         // use different matrices for different parts
-        glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, -1.0, 0.0));
-        glm::mat4 topTrans = glm::translate(glm::vec3(0.0, actualYTrans, 0.0));
-        glm::mat4 topScale = glm::scale(xzScale, xzScale, xzScale);
+        glm::mat4 orgTrans = glm::translate(glm::vec3(0.0, 0.0, -1.0));
+        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;
     }
@@ -1204,14 +1225,12 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
     float xScale = extrude3D.xScale;
     float yScale = extrude3D.yScale;
     float zScale = extrude3D.zScale;
-    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
-    glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform));
+    glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, extrude3D.yTransform, extrude3D.zTransform));
     glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale);
     m_Model = transformMatrix * extrude3D.rotation * scaleMatrix;
     if (extrude3D.reverse)
     {
-        glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0));
+        glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, 0.0, -1.0));
         m_Model = m_Model * reverseMatrix;
     }
 
@@ -1231,9 +1250,6 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
 
 void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
 {
-    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
-    CHECK_GL_ERROR();
     RenderExtrudeMiddleSurface(extrude3D);
     // check reverse flag to decide whether to render the top middle
     if (extrude3D.reverse)
@@ -1259,7 +1275,10 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     {
         Update3DUniformBlock();
         glUseProgram(maResources.m_3DProID);
+        glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+        glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     }
+    CHECK_GL_ERROR();
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
     {
@@ -1292,8 +1311,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
                     (void*)0            // array buffer offset
                     );
         }
-        extrude3DInfo.yTransform *= m_fHeightWeight;
-        extrude3DInfo.yScale *= m_fHeightWeight;
+        extrude3DInfo.zTransform *= m_fHeightWeight;
+        extrude3DInfo.zScale *= m_fHeightWeight;
         if(!mbPickingMode)
         {
             glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
@@ -1330,19 +1349,19 @@ void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vT
     TextInfo aTextInfo;
     aTextInfo.vertex[0] = vBottomRight.x;
     aTextInfo.vertex[1] = vBottomRight.y;
-    aTextInfo.vertex[2] = vBottomRight.z;
+    aTextInfo.vertex[2] = vBottomRight.z * m_fHeightWeight;
 
     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[5] = aTextInfo.vertex[2] + (vTopRight.z - vBottomRight.z);
 
     aTextInfo.vertex[9] = vBottomLeft.x;
     aTextInfo.vertex[10] = vBottomLeft.y;
-    aTextInfo.vertex[11] = vBottomLeft.z;
+    aTextInfo.vertex[11] = vBottomLeft.z * m_fHeightWeight;
+
+    aTextInfo.vertex[6] = vTopLeft.x;
+    aTextInfo.vertex[7] = vTopLeft.y;
+    aTextInfo.vertex[8] = aTextInfo.vertex[11] + (vTopLeft.z - vBottomLeft.z);
 
     CHECK_GL_ERROR();
     glGenTextures(1, &aTextInfo.texture);
@@ -1479,30 +1498,50 @@ void OpenGL3DRenderer::RenderClickPos(Point aMPos)
 
 void OpenGL3DRenderer::CreateSceneBoxView()
 {
+//original code start
     m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
                m_CameraInfo.cameraOrg,
                m_CameraInfo.cameraUp);
+//original code end
+    float senceBoxWidth = m_SenceBox.maxXCoord - m_SenceBox.minXCoord;
+    float senceBoxHeight = m_SenceBox.maxZCoord - m_SenceBox.minZCoord;
+    float senceBoxDepth = m_SenceBox.maxYCoord - m_SenceBox.minYCoord;
+    float distanceY = m_SenceBox.maxYCoord + senceBoxWidth / 2 / tan(m_fViewAngle / 2 * GL_PI / 180.0f);
+    float veriticalAngle = atan((float)m_iHeight / (float)m_iWidth);
+    float distance = distanceY / cos(veriticalAngle);
+    float horizontalAngle = 0;
+    m_fHeightWeight = senceBoxWidth * (float)m_iHeight / (float)m_iWidth / senceBoxHeight;
+    m_SenceBox.maxZCoord *= m_fHeightWeight;
+    m_SenceBox.minZCoord *= m_fHeightWeight;
+    m_CameraInfo.cameraOrg = glm::vec3(m_SenceBox.minXCoord + senceBoxWidth / 2,
+                                       m_SenceBox.minYCoord + senceBoxDepth * 2,
+                                       m_SenceBox.minZCoord + senceBoxHeight * m_fHeightWeight/ 2);    //update the camera position and org
+    m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x + distance * cos(veriticalAngle) * sin(horizontalAngle);
+    m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * cos(veriticalAngle) * cos(horizontalAngle);
+    m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * sin(veriticalAngle);
+    m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
+                            m_CameraInfo.cameraOrg,
+                            m_CameraInfo.cameraUp
+                            );
 }
 
 void OpenGL3DRenderer::ProcessUnrenderedShape()
 {
-    CreateSceneBoxView();
     glViewport(0, 0, m_iWidth, m_iHeight);
     glClearDepth(1.0f);
     glClearColor(1.0, 1.0, 1.0, 1.0);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    CreateSceneBoxView();
     //Polygon
     RenderPolygon3DObject();
     //Shape3DExtrudeObject
     RenderExtrude3DObject();
     //render text
     RenderTextShape();
-    glViewport(0, 0, m_iWidth, m_iHeight);
 #if DEBUG_FBO
     OUString aFileName = OUString("D://shaderout_") + OUString::number(m_iWidth) + "_" + OUString::number(m_iHeight) + ".png";
     OpenGLHelper::renderToFile(m_iWidth, m_iHeight, aFileName);
 #endif
-//    glBindFramebuffer(GL_FRAMEBUFFER, 0);
 }
 
 void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale)
commit ec4169a56e5120f452df2f6d232e5e4d90314d9e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 13:25:12 2014 +0200

    hopefully all places are now correct for the picking
    
    Only the handling of the color and the matrix is still missing
    
    Change-Id: I5603e966e6a62106f38d2cb7cfe196629714f793

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index fd6abf2..8278348 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -770,6 +770,10 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
             glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
             glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
         }
+        else
+        {
+            // TODO: moggi: model matrix
+        }
 
         GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
 
@@ -1051,10 +1055,18 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
     glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
     glm::mat4 flatScale = glm::scale(xzScale, xzScale, xzScale);
     m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
-    glm::mat3 normalMatrix(m_Model);
-    glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    if(!mbPickingMode)
+    {
+        glm::mat3 normalMatrix(m_Model);
+        glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    }
+    else
+    {
+        // TODO: moggi: model matrix
+    }
+
     glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
 }
 
@@ -1084,10 +1096,18 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
         glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
         m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale;
     }
-    glm::mat3 normalMatrix(m_Model);
-    glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+
+    if(!mbPickingMode)
+    {
+        glm::mat3 normalMatrix(m_Model);
+        glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    }
+    else
+    {
+        // TODO: moggi: model matrix
+    }
     glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
 }
 
@@ -1119,10 +1139,18 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
         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(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+
+    if(!mbPickingMode)
+    {
+        glm::mat3 normalMatrix(m_Model);
+        glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    }
+    else
+    {
+        // TODO: moggi: model matrix
+    }
     glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
 }
 
@@ -1155,10 +1183,18 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
         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);
-    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+
+    if(!mbPickingMode)
+    {
+        glm::mat3 normalMatrix(m_Model);
+        glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    }
+    else
+    {
+        // TODO: moggi: model matrix
+    }
     glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
     RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
 }
@@ -1178,10 +1214,18 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
         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(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+
+    if(!mbPickingMode)
+    {
+        glm::mat3 normalMatrix(m_Model);
+        glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    }
+    else
+    {
+        // TODO: moggi: model matrix
+    }
     glDrawArrays(GL_TRIANGLES, 0, 36);
 }
 
@@ -1209,8 +1253,13 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     glEnable(GL_DEPTH_TEST);
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
-    Update3DUniformBlock();
-    glUseProgram(maResources.m_3DProID);
+    if(mbPickingMode)
+        glUseProgram(maPickingResources.m_CommonProID);
+    else
+    {
+        Update3DUniformBlock();
+        glUseProgram(maResources.m_3DProID);
+    }
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
     {
@@ -1218,31 +1267,40 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
         GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
         // 1st attribute buffer : vertices
-        glEnableVertexAttribArray(maResources.m_3DVertexID);
+
+        GLint aVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
+        glEnableVertexAttribArray(aVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
-        glVertexAttribPointer(maResources.m_3DVertexID, // attribute
-                                3,                  // size
-                                GL_FLOAT,           // type
-                                GL_FALSE,           // normalized?
-                                0,                  // stride
-                                (void*)0            // array buffer offset
-                                );
-        // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(maResources.m_3DNormalID);
-        glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
-        glVertexAttribPointer(maResources.m_3DNormalID, // attribute
+        glVertexAttribPointer(aVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
                                 0,                  // stride
                                 (void*)0            // array buffer offset
                                 );
+
+        if(!mbPickingMode)
+        {
+            // 2nd attribute buffer : normals
+            glEnableVertexAttribArray(maResources.m_3DNormalID);
+            glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
+            glVertexAttribPointer(maResources.m_3DNormalID, // attribute
+                    3,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+        }
         extrude3DInfo.yTransform *= m_fHeightWeight;
         extrude3DInfo.yScale *= m_fHeightWeight;
-        glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
-        glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &extrude3DInfo.material);
-        CHECK_GL_ERROR();
-        glBindBuffer(GL_UNIFORM_BUFFER, 0);
+        if(!mbPickingMode)
+        {
+            glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
+            glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &extrude3DInfo.material);
+            CHECK_GL_ERROR();
+            glBindBuffer(GL_UNIFORM_BUFFER, 0);
+        }
         extrude3DInfo.reverse = 0;
         if (extrude3DInfo.rounded)
         {
@@ -1253,8 +1311,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         {
             RenderNonRoundedBar(extrude3DInfo);
         }
-        glDisableVertexAttribArray(maResources.m_3DVertexID);
-        glDisableVertexAttribArray(maResources.m_3DNormalID);
+        glDisableVertexAttribArray(aVertexID);
+        if(!mbPickingMode)
+            glDisableVertexAttribArray(maResources.m_3DNormalID);
     }
     m_Extrude3DList.clear();
     glUseProgram(0);
commit 859cbb9092536a44724a4c36a469e329bacb53ca
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 11:56:27 2014 +0200

    no reason that this is a member variable
    
    Change-Id: I125c85418bc19cc6bcf2d106ebd22f94d9ecd390

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 2154f7d9..f2c5732 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -283,8 +283,6 @@ private:
     glm::mat4 m_View;
     // Model matrix : an identity matrix (model will be at the origin
     glm::mat4 m_Model;
-    // Our ModelViewProjection : multiplication of our 3 matrices
-    glm::mat4 m_MVP;
 
     sal_Int32 m_iWidth;
 
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 029383f..fd6abf2 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1316,7 +1316,7 @@ void OpenGL3DRenderer::RenderTextShape()
         PosVecf3 angle = {0.0f, 0.0f, 0.0f};
         PosVecf3 scale = {1.0, 1.0, 1.0f};
         MoveModelf(trans, angle, scale);
-        m_MVP = m_3DProjection * m_3DView * m_Model;
+        glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         CHECK_GL_ERROR();
         glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
@@ -1324,7 +1324,7 @@ void OpenGL3DRenderer::RenderTextShape()
         glUseProgram(maResources.m_TextProID);
 
         CHECK_GL_ERROR();
-        glUniformMatrix4fv(maResources.m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+        glUniformMatrix4fv(maResources.m_TextMatrixID, 1, GL_FALSE, &aMVP[0][0]);
         // 1rst attribute buffer : vertices
         glEnableVertexAttribArray(maResources.m_TextVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
commit dfefcc2b89718971c0d63b42d796c5e20394be05
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 11:55:34 2014 +0200

    one more step to picking based rendering
    
    Change-Id: Ibf77c0b7b9cdc4f5b47deee3f9b50a61e8c0dc22

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 7411615..029383f 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -691,12 +691,12 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
         Vertices3D *pointList = polygon.verticesList.front();
         //if line only, using the common shader to render
 
-        //render to fbo
         //fill vertex buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
         glUniform4fv(maResources.m_2DColorID, 1, &polygon.polygonColor[0]);
         glUniformMatrix4fv(maResources.m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
+
         // 1rst attribute buffer : vertices
         glEnableVertexAttribArray(maResources.m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
@@ -733,9 +733,18 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
     glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
-    glUseProgram(maResources.m_3DProID);
-    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+
+    if(mbPickingMode)
+    {
+        glUseProgram(maPickingResources.m_CommonProID);
+    }
+    else
+    {
+        glUseProgram(maResources.m_3DProID);
+        glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+        glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    }
+
     for (size_t i = 0; i < verticesNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
@@ -752,26 +761,22 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
         //fill vertex buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
-        //fill normal buffer
-        glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
-        glBufferData(GL_ARRAY_BUFFER, normalList->size() * sizeof(glm::vec3), &normalList[0][0], GL_STATIC_DRAW);
-        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+
+        if(!mbPickingMode)
+        {
+            //fill normal buffer
+            glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
+            glBufferData(GL_ARRAY_BUFFER, normalList->size() * sizeof(glm::vec3), &normalList[0][0], GL_STATIC_DRAW);
+            glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+            glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+        }
+
+        GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
 
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(maResources.m_3DVertexID);
+        glEnableVertexAttribArray(maVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(maResources.m_3DVertexID, // attribute
-                                3,                  // size
-                                GL_FLOAT,           // type
-                                GL_FALSE,           // normalized?
-                                0,                  // stride
-                                (void*)0            // array buffer offset
-                                );
-        // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(maResources.m_3DNormalID);
-        glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
-        glVertexAttribPointer(maResources.m_3DNormalID, // attribute
+        glVertexAttribPointer(maVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -779,9 +784,26 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
                                 (void*)0            // array buffer offset
                                 );
 
+        if(!mbPickingMode)
+        {
+            // 2nd attribute buffer : normals
+            glEnableVertexAttribArray(maResources.m_3DNormalID);
+            glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
+            glVertexAttribPointer(maResources.m_3DNormalID, // attribute
+                    3,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+        }
+
         glDrawArrays(GL_POLYGON, 0, pointList->size());
-        glDisableVertexAttribArray(maResources.m_3DVertexID);
-        glDisableVertexAttribArray(maResources.m_3DNormalID);
+
+        glDisableVertexAttribArray(maVertexID);
+        if(!mbPickingMode)
+            glDisableVertexAttribArray(maResources.m_3DNormalID);
+
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         delete pointList;
         delete normalList;
@@ -969,6 +991,9 @@ void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
 
 void OpenGL3DRenderer::Init3DUniformBlock()
 {
+    if(mbPickingMode)
+        return;
+
     GLuint a3DLightBlockIndex = glGetUniformBlockIndex(maResources.m_3DProID, "GlobalLights");
     GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(maResources.m_3DProID, "GlobalMaterialParameters");
 
@@ -1002,6 +1027,9 @@ void OpenGL3DRenderer::Init3DUniformBlock()
 
 void OpenGL3DRenderer::Update3DUniformBlock()
 {
+    if(mbPickingMode)
+        return;
+
     glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
     glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(GLint), &m_LightsInfo.lightNum);
     CHECK_GL_ERROR();
commit 34e137f3a96682892dcbaa70c63deeb423f5fd8d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 11:26:09 2014 +0200

    don"t execute code in a loop
    
    Change-Id: I758d8ddb8b877638a5a36e56636e97fded790efc

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index cbfebed..7411615 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -677,16 +677,18 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 {
     size_t listNum = polygon.verticesList.size();
     glUseProgram(maResources.m_CommonProID);
+
+    PosVecf3 trans = {0.0f, 0, 0.0};
+    PosVecf3 angle = {0.0f, 0.0f, 0.0f};
+    PosVecf3 scale = {1.0f, m_fHeightWeight, 1.0f};
+    MoveModelf(trans, angle, scale);
+
+    m_3DMVP = m_3DProjection * m_3DView * m_Model;
+
     for (size_t i = 0; i < listNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
         Vertices3D *pointList = polygon.verticesList.front();
-        PosVecf3 trans = {0.0f, 0, 0.0};
-        PosVecf3 angle = {0.0f, 0.0f, 0.0f};
-        PosVecf3 scale = {1.0f, m_fHeightWeight, 1.0f};
-        MoveModelf(trans, angle, scale);
-
-        m_3DMVP = m_3DProjection * m_3DView * m_Model;
         //if line only, using the common shader to render
 
         //render to fbo
commit 42edee1ee1c993715a41b483eb4b67fb75a844e3
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 11:22:02 2014 +0200

    implement new struct and shaders for picking
    
    Change-Id: Ib3e08d69c031aa3130b10c0745119cf5935d86db

diff --git a/chart2/Package_opengl.mk b/chart2/Package_opengl.mk
index d96a1ce..cb8c456 100644
--- a/chart2/Package_opengl.mk
+++ b/chart2/Package_opengl.mk
@@ -16,6 +16,8 @@ $(eval $(call gb_Package_add_files,chart2_opengl_shader,$(LIBO_BIN_FOLDER)/openg
 	commonVertexShader.glsl \
 	debugFragmentShader.glsl \
 	debugVertexShader.glsl \
+	pickingVertexShader.glsl \
+	pickingFragmentShader.glsl \
 	symbolFragmentShader.glsl \
 	symbolVertexShader.glsl \
 	textFragmentShader.glsl \
diff --git a/chart2/opengl/pickingFragmentShader.glsl b/chart2/opengl/pickingFragmentShader.glsl
new file mode 100644
index 0000000..805789e
--- /dev/null
+++ b/chart2/opengl/pickingFragmentShader.glsl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+
+varying vec4 fragmentColor;
+
+void main()
+{
+    gl_FragColor = fragmentColor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/opengl/pickingVertexShader.glsl b/chart2/opengl/pickingVertexShader.glsl
new file mode 100644
index 0000000..f32e3fd
--- /dev/null
+++ b/chart2/opengl/pickingVertexShader.glsl
@@ -0,0 +1,21 @@
+/* -*- 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/.
+ */
+
+attribute vec3 vPosition;
+uniform mat4 MVP;
+uniform vec4 vColor;
+varying vec4 fragmentColor;
+
+void main()
+{
+    gl_Position =  MVP * vec4(vPosition, 1);
+    fragmentColor = vColor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 6bfc383..2154f7d9 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -255,7 +255,27 @@ private:
         void LoadShaders();
     };
 
+    struct PickingShaderResources
+    {
+        // CommonProID
+        GLint m_CommonProID;
+        GLint m_2DVertexID;
+        GLint m_2DColorID;
+        GLint m_MatrixID;
+
+        PickingShaderResources():
+            m_CommonProID(0) {}
+
+        ~PickingShaderResources()
+        {
+            glDeleteProgram(m_CommonProID);
+        }
+
+        void LoadShaders();
+    };
+
     ShaderResources maResources;
+    PickingShaderResources maPickingResources;
 
     // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
     glm::mat4 m_Projection;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6ef1fa7..cbfebed 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -131,6 +131,14 @@ void OpenGL3DRenderer::ShaderResources::LoadShaders()
     CHECK_GL_ERROR();
 }
 
+void OpenGL3DRenderer::PickingShaderResources::LoadShaders()
+{
+    m_CommonProID = OpenGLHelper::LoadShaders("pickingVertexShader", "pickingFragmentShader");
+    m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
+    m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
+    m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
+}
+
 void OpenGL3DRenderer::SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up)
 {
     m_CameraInfo.cameraPos = pos;
@@ -212,7 +220,10 @@ void OpenGL3DRenderer::init()
 
     m_fViewAngle = 60.0f;
     m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
+
     maResources.LoadShaders();
+    maPickingResources.LoadShaders();
+
     glGenBuffers(1, &m_TextTexCoordBuf);
     glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
     glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
commit 88b17ce132ff2ad6c4b90dfe1541fda15cfc83aa
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 11:07:36 2014 +0200

    try a better idea
    
    Change-Id: Ibf218c2e99013aeeeb1d8962b0eff1cbd602c6c3

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 04fc26c..6bfc383 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -255,9 +255,7 @@ private:
         void LoadShaders();
     };
 
-    ShaderResources maNormalResources;
-    ShaderResources maPickingResources;
-    ShaderResources* pResources;
+    ShaderResources maResources;
 
     // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
     glm::mat4 m_Projection;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index bc756a7..6ef1fa7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -71,8 +71,7 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
 }
 
 OpenGL3DRenderer::OpenGL3DRenderer():
-    pResources(&maPickingResources)
-    , m_uiSelectFrameCounter(0)
+    m_uiSelectFrameCounter(0)
     , m_fViewAngle(30.0f)
     , m_fHeightWeight(1.0f)
     , mbPickingMode(false)
@@ -143,22 +142,22 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    glUseProgram(pResources->m_RenderProID);
+    glUseProgram(maResources.m_RenderProID);
 
-    glEnableVertexAttribArray(pResources->m_RenderVertexID);
+    glEnableVertexAttribArray(maResources.m_RenderVertexID);
     glBindBuffer(GL_ARRAY_BUFFER, m_RenderVertexBuf);
     glVertexAttribPointer(
-        pResources->m_RenderVertexID, // attribute
+        maResources.m_RenderVertexID, // attribute
         3,                  // size
         GL_FLOAT,           // type
         GL_FALSE,           // normalized?
         0,                  // stride
         (void*)0            // array buffer offset
         );
-    glEnableVertexAttribArray(pResources->m_RenderTexCoordID);
+    glEnableVertexAttribArray(maResources.m_RenderTexCoordID);
     glBindBuffer(GL_ARRAY_BUFFER, m_RenderTexCoordBuf);
     glVertexAttribPointer(
-        pResources->m_RenderTexCoordID, // attribute.
+        maResources.m_RenderTexCoordID, // attribute.
         2,                  // size
         GL_FLOAT,           // type
         GL_FALSE,           // normalized?
@@ -166,10 +165,10 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
         (void*)0            // array buffer offset
         );
     glBindTexture(GL_TEXTURE_2D, TexID);
-    glUniform1i(pResources->m_RenderTexID, 0);
+    glUniform1i(maResources.m_RenderTexID, 0);
     glDrawArrays(GL_QUADS, 0, 4);
-    glDisableVertexAttribArray(pResources->m_RenderTexCoordID);
-    glDisableVertexAttribArray(pResources->m_RenderVertexID);
+    glDisableVertexAttribArray(maResources.m_RenderTexCoordID);
+    glDisableVertexAttribArray(maResources.m_RenderVertexID);
     glBindTexture(GL_TEXTURE_2D, 0);
     glUseProgram(0);
 }
@@ -213,8 +212,7 @@ void OpenGL3DRenderer::init()
 
     m_fViewAngle = 60.0f;
     m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
-    maNormalResources.LoadShaders();
-    maPickingResources.LoadShaders();
+    maResources.LoadShaders();
     glGenBuffers(1, &m_TextTexCoordBuf);
     glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
     glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
@@ -667,7 +665,7 @@ double OpenGL3DRenderer::GetTime()
 void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 {
     size_t listNum = polygon.verticesList.size();
-    glUseProgram(pResources->m_CommonProID);
+    glUseProgram(maResources.m_CommonProID);
     for (size_t i = 0; i < listNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
@@ -684,12 +682,12 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
         //fill vertex buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
-        glUniform4fv(pResources->m_2DColorID, 1, &polygon.polygonColor[0]);
-        glUniformMatrix4fv(pResources->m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
+        glUniform4fv(maResources.m_2DColorID, 1, &polygon.polygonColor[0]);
+        glUniformMatrix4fv(maResources.m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(pResources->m_2DVertexID);
+        glEnableVertexAttribArray(maResources.m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(pResources->m_2DVertexID, // attribute
+        glVertexAttribPointer(maResources.m_2DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -699,7 +697,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 
         glLineWidth(polygon.lineWidth);
         glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
-        glDisableVertexAttribArray(pResources->m_2DVertexID);
+        glDisableVertexAttribArray(maResources.m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         delete pointList;
         polygon.verticesList.pop_front();
@@ -722,9 +720,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
     glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
-    glUseProgram(pResources->m_3DProID);
-    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glUseProgram(maResources.m_3DProID);
+    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     for (size_t i = 0; i < verticesNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
@@ -744,13 +742,13 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
         //fill normal buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
         glBufferData(GL_ARRAY_BUFFER, normalList->size() * sizeof(glm::vec3), &normalList[0][0], GL_STATIC_DRAW);
-        glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-        glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+        glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
 
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(pResources->m_3DVertexID);
+        glEnableVertexAttribArray(maResources.m_3DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(pResources->m_3DVertexID, // attribute
+        glVertexAttribPointer(maResources.m_3DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -758,9 +756,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
                                 (void*)0            // array buffer offset
                                 );
         // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(pResources->m_3DNormalID);
+        glEnableVertexAttribArray(maResources.m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
-        glVertexAttribPointer(pResources->m_3DNormalID, // attribute
+        glVertexAttribPointer(maResources.m_3DNormalID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -769,8 +767,8 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
                                 );
 
         glDrawArrays(GL_POLYGON, 0, pointList->size());
-        glDisableVertexAttribArray(pResources->m_3DVertexID);
-        glDisableVertexAttribArray(pResources->m_3DNormalID);
+        glDisableVertexAttribArray(maResources.m_3DVertexID);
+        glDisableVertexAttribArray(maResources.m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         delete pointList;
         delete normalList;
@@ -958,8 +956,8 @@ void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
 
 void OpenGL3DRenderer::Init3DUniformBlock()
 {
-    GLuint a3DLightBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalLights");
-    GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalMaterialParameters");
+    GLuint a3DLightBlockIndex = glGetUniformBlockIndex(maResources.m_3DProID, "GlobalLights");
+    GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(maResources.m_3DProID, "GlobalMaterialParameters");
 
     if ((GL_INVALID_INDEX == a3DLightBlockIndex) || (GL_INVALID_INDEX == a3DMaterialBlockIndex))
     {
@@ -968,8 +966,8 @@ void OpenGL3DRenderer::Init3DUniformBlock()
     int nUniformBufferAlignSize = 0;
     glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &nUniformBufferAlignSize);
     GLint nBlockDataSizeLight = 0, nBlockDataSizeMertrial = 0;
-    glGetActiveUniformBlockiv(pResources->m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
-    glGetActiveUniformBlockiv(pResources->m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
+    glGetActiveUniformBlockiv(maResources.m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
+    glGetActiveUniformBlockiv(maResources.m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
     CHECK_GL_ERROR();
     glGenBuffers(1, &m_3DUBOBuffer);
     glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
@@ -980,10 +978,10 @@ void OpenGL3DRenderer::Init3DUniformBlock()
     glBufferData(GL_UNIFORM_BUFFER, dataSize, NULL, GL_DYNAMIC_DRAW);
     glBindBufferRange(GL_UNIFORM_BUFFER, 0, m_3DUBOBuffer, 0, nBlockDataSizeLight);
     CHECK_GL_ERROR();
-    glUniformBlockBinding(pResources->m_3DProID, a3DLightBlockIndex, 0);
+    glUniformBlockBinding(maResources.m_3DProID, a3DLightBlockIndex, 0);
 
     glBindBufferRange(GL_UNIFORM_BUFFER, 1, m_3DUBOBuffer, ((nBlockDataSizeLight / nUniformBufferAlignSize) + std::min(nBlockDataSizeLight % nUniformBufferAlignSize, 1)) * nUniformBufferAlignSize, nBlockDataSizeMertrial);
-    glUniformBlockBinding(pResources->m_3DProID, a3DMaterialBlockIndex, 1);
+    glUniformBlockBinding(maResources.m_3DProID, a3DMaterialBlockIndex, 1);
     //for the light source uniform, we must calc the offset of each element
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
@@ -1014,8 +1012,8 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
     m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
 }
 
@@ -1047,8 +1045,8 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
 }
 
@@ -1082,8 +1080,8 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
 }
 
@@ -1118,8 +1116,8 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
     RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
 }
@@ -1129,8 +1127,8 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
     float xScale = extrude3D.xScale;
     float yScale = extrude3D.yScale;
     float zScale = extrude3D.zScale;
-    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(maResources.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 * extrude3D.rotation * scaleMatrix;
@@ -1141,15 +1139,15 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
     }
     glm::mat3 normalMatrix(m_Model);
     glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix);
-    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+    glUniformMatrix4fv(maResources.m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(maResources.m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawArrays(GL_TRIANGLES, 0, 36);
 }
 
 void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
 {
-    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     CHECK_GL_ERROR();
     RenderExtrudeMiddleSurface(extrude3D);
     // check reverse flag to decide whether to render the top middle
@@ -1171,7 +1169,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
     Update3DUniformBlock();
-    glUseProgram(pResources->m_3DProID);
+    glUseProgram(maResources.m_3DProID);
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
     {
@@ -1179,9 +1177,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
         GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
         // 1st attribute buffer : vertices
-        glEnableVertexAttribArray(pResources->m_3DVertexID);
+        glEnableVertexAttribArray(maResources.m_3DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
-        glVertexAttribPointer(pResources->m_3DVertexID, // attribute
+        glVertexAttribPointer(maResources.m_3DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1189,9 +1187,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
                                 (void*)0            // array buffer offset
                                 );
         // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(pResources->m_3DNormalID);
+        glEnableVertexAttribArray(maResources.m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
-        glVertexAttribPointer(pResources->m_3DNormalID, // attribute
+        glVertexAttribPointer(maResources.m_3DNormalID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1214,8 +1212,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         {
             RenderNonRoundedBar(extrude3DInfo);
         }
-        glDisableVertexAttribArray(pResources->m_3DVertexID);
-        glDisableVertexAttribArray(pResources->m_3DNormalID);
+        glDisableVertexAttribArray(maResources.m_3DVertexID);
+        glDisableVertexAttribArray(maResources.m_3DNormalID);
     }
     m_Extrude3DList.clear();
     glUseProgram(0);
@@ -1282,15 +1280,15 @@ void OpenGL3DRenderer::RenderTextShape()
         CHECK_GL_ERROR();
         glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
         CHECK_GL_ERROR();
-        glUseProgram(pResources->m_TextProID);
+        glUseProgram(maResources.m_TextProID);
 
         CHECK_GL_ERROR();
-        glUniformMatrix4fv(pResources->m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+        glUniformMatrix4fv(maResources.m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(pResources->m_TextVertexID);
+        glEnableVertexAttribArray(maResources.m_TextVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glVertexAttribPointer(
-            pResources->m_TextVertexID,
+            maResources.m_TextVertexID,
             3,                  // size
             GL_FLOAT,           // type
             GL_FALSE,           // normalized?
@@ -1299,10 +1297,10 @@ void OpenGL3DRenderer::RenderTextShape()
             );
         //tex coord
         CHECK_GL_ERROR();
-        glEnableVertexAttribArray(pResources->m_TextTexCoordID);
+        glEnableVertexAttribArray(maResources.m_TextTexCoordID);
         glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
         glVertexAttribPointer(
-            pResources->m_TextTexCoordID,
+            maResources.m_TextTexCoordID,
             2,                  // size
             GL_FLOAT,           // type
             GL_FALSE,           // normalized?
@@ -1313,14 +1311,14 @@ void OpenGL3DRenderer::RenderTextShape()
         CHECK_GL_ERROR();
         glBindTexture(GL_TEXTURE_2D, textInfo.texture);
         CHECK_GL_ERROR();
-        glUniform1i(pResources->m_TextTexID, 0);
+        glUniform1i(maResources.m_TextTexID, 0);
         CHECK_GL_ERROR();
         //TODO: moggi: get rid fo GL_QUADS
         glDrawArrays(GL_QUADS, 0, 4);
         CHECK_GL_ERROR();
-        glDisableVertexAttribArray(pResources->m_TextTexCoordID);
+        glDisableVertexAttribArray(maResources.m_TextTexCoordID);
         CHECK_GL_ERROR();
-        glDisableVertexAttribArray(pResources->m_TextVertexID);
+        glDisableVertexAttribArray(maResources.m_TextVertexID);
         CHECK_GL_ERROR();
         glBindTexture(GL_TEXTURE_2D, 0);
         glUseProgram(0);
commit 7c2acb873d32a3e17ef9bd6ea89c7c8800f98f4a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 10:59:35 2014 +0200

    remove some misleading comments
    
    Change-Id: I939c676ffd71357dcf73f24c56c5fd70a3a67a28

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6645b92..bc756a7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -689,7 +689,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
         // 1rst attribute buffer : vertices
         glEnableVertexAttribArray(pResources->m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(pResources->m_2DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_2DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1171,7 +1171,6 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     glEnable(GL_CULL_FACE);
     glCullFace(GL_BACK);
     Update3DUniformBlock();
-    //render to fbo
     glUseProgram(pResources->m_3DProID);
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
@@ -1182,7 +1181,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         // 1st attribute buffer : vertices
         glEnableVertexAttribArray(pResources->m_3DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
-        glVertexAttribPointer(pResources->m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1192,7 +1191,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         // 2nd attribute buffer : normals
         glEnableVertexAttribArray(pResources->m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
-        glVertexAttribPointer(pResources->m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DNormalID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
commit 2941d38cb19465ae217602b687e6ddcae6712d76
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 10:55:36 2014 +0200

    these resources should be GLints
    
    Change-Id: Ib1075fb7dba8ea85e76c7cdf59635e0cec9aaf19

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c33735c..04fc26c 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -212,12 +212,12 @@ private:
     {
         // 3DProID
         GLint m_3DProID;
-        GLuint m_3DProjectionID;
-        GLuint m_3DViewID;
-        GLuint m_3DModelID;
-        GLuint m_3DNormalMatrixID;
-        GLuint m_3DVertexID;
-        GLuint m_3DNormalID;
+        GLint m_3DProjectionID;
+        GLint m_3DViewID;
+        GLint m_3DModelID;
+        GLint m_3DNormalMatrixID;
+        GLint m_3DVertexID;
+        GLint m_3DNormalID;
 
         // TextProID
         GLint m_TextProID;
commit 759573b37fad51bd4f5164acd645f186ed91809d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu May 15 10:55:02 2014 +0200

    introduce picking mode in 3D code
    
    Change-Id: Ifbe35a9b311bf79fa15bbad6b9fdfc5a472f516f

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index d570c72..98f015b 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -26,6 +26,7 @@ namespace chart {
 GL3DBarChart::GL3DBarChart(
     const css::uno::Reference<css::chart2::XChartType>& xChartType,
     OpenGLWindow& rWindow) :
+    mbPickingMode(false),
     mxChartType(xChartType),
     mpRenderer(new opengl3D::OpenGL3DRenderer()),
     mrWindow(rWindow),
@@ -186,8 +187,34 @@ void GL3DBarChart::update()
     render();
 }
 
+namespace {
+
+class PickingModeSetter
+{
+private:
+    opengl3D::OpenGL3DRenderer* mpRenderer;
+
+public:
+    PickingModeSetter(opengl3D::OpenGL3DRenderer* pRenderer):
+        mpRenderer(pRenderer)
+    {
+        mpRenderer->SetPickingMode(true);
+    }
+
+    ~PickingModeSetter()
+    {
+        mpRenderer->SetPickingMode(false);
+    }
+};
+
+}
+
 void GL3DBarChart::clickedAt(const Point& )
 {
+    {
+        PickingModeSetter(mpRenderer.get());
+        render();
+    }
     if (mpCamera)
         mpCamera->zoom(1);
 }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 92a3b6c..81e7639 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -49,6 +49,7 @@ public:
     virtual void clickedAt(const Point& rPos) SAL_OVERRIDE;
 
 private:
+    bool mbPickingMode;
     css::uno::Reference<css::chart2::XChartType> mxChartType;
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 9d5f441..c33735c 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -166,10 +166,11 @@ public:
     void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
     void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
     void ProcessUnrenderedShape();
+
+    void SetPickingMode(bool bPickingMode);
 private:
     void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
 
-    void LoadShaders();
     void GetFreq();
     void RenderPolygon3DObject();
     void RenderLine3D(Polygon3DInfo &polygon);
@@ -206,6 +207,58 @@ private:
     void CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize);
     void RenderTexture(GLuint TexID);
 private:
+
+    struct ShaderResources
+    {
+        // 3DProID
+        GLint m_3DProID;
+        GLuint m_3DProjectionID;
+        GLuint m_3DViewID;
+        GLuint m_3DModelID;
+        GLuint m_3DNormalMatrixID;
+        GLuint m_3DVertexID;
+        GLuint m_3DNormalID;
+
+        // TextProID
+        GLint m_TextProID;
+        GLint m_TextMatrixID;
+        GLint m_TextVertexID;
+        GLint m_TextTexCoordID;
+        GLint m_TextTexID;
+
+        // CommonProID
+        GLint m_CommonProID;
+        GLint m_2DVertexID;
+        GLint m_2DColorID;
+        GLint m_MatrixID;
+
+        // RenderProID
+        GLint m_RenderProID;
+        GLint m_RenderTexID;
+        GLint m_RenderVertexID;
+        GLint m_RenderTexCoordID;
+
+        ShaderResources():
+            m_3DProID(0),
+            m_TextProID(0),
+            m_CommonProID(0),
+            m_RenderProID(0) {}
+
+        ~ShaderResources()
+        {
+            glDeleteProgram(m_CommonProID);
+            glDeleteProgram(m_RenderProID);
+            glDeleteProgram(m_TextProID);
+            glDeleteProgram(m_3DProID);
+        }
+
+        void LoadShaders();
+    };
+
+    ShaderResources maNormalResources;
+    ShaderResources maPickingResources;
+    ShaderResources* pResources;
+
     // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
     glm::mat4 m_Projection;
     // Camera matrix
@@ -235,20 +288,6 @@ private:
 
     glm::mat4 m_3DMVP;
 
-    GLint m_3DProID;
-
-    GLuint m_3DProjectionID;
-
-    GLuint m_3DViewID;
-
-    GLuint m_3DModelID;
-
-    GLuint m_3DVertexID;
-
-    GLuint m_3DNormalID;
-
-    GLuint m_3DNormalMatrixID;
-
     GLuint m_3DUBOBuffer;
 #if 0
     GLint m_3DLightBlockIndex;
@@ -261,8 +300,6 @@ private:
 
     GLuint m_VertexBuffer;
 
-    GLint m_MatrixID;
-
     Extrude3DInfo m_Extrude3DInfo;
 
     std::vector <Extrude3DInfo> m_Extrude3DList;
@@ -277,12 +314,7 @@ private:
     GLuint m_BoundBoxNormal;
      // 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;
 
     int m_uiSelectFrameCounter;
 
@@ -294,25 +326,15 @@ private:
 
     RoundBarMesh m_RoundBarMesh;
 
-    GLint m_CommonProID;
-    GLint m_2DVertexID;
-    GLint m_2DColorID;
-
-    GLint m_RenderProID;
-
     GLuint m_RenderVertexBuf;
 
     GLuint m_RenderTexCoordBuf;
 
-    GLint m_RenderTexID;
-
-    GLint m_RenderVertexID;
-
-    GLint m_RenderTexCoordID;
-
     float m_fViewAngle;
 
     float m_fHeightWeight;
+
+    bool mbPickingMode;
 };
 
 }
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index abb41b0..6645b92 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -71,15 +71,11 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
 }
 
 OpenGL3DRenderer::OpenGL3DRenderer():
-    m_TextProID(0)
-    , m_TextMatrixID(0)
-    , m_TextVertexID(0)
-    , m_TextTexCoordID(0)
-    , m_TextTexCoordBuf(0)
-    , m_TextTexID(0)
+    pResources(&maPickingResources)
     , m_uiSelectFrameCounter(0)
     , m_fViewAngle(30.0f)
     , m_fHeightWeight(1.0f)
+    , mbPickingMode(false)
 {
     m_Polygon3DInfo.lineOnly = false;
     m_Polygon3DInfo.twoSidesLighting = false;
@@ -96,12 +92,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
 
 OpenGL3DRenderer::~OpenGL3DRenderer()
 {
-    // delete programs
-    glDeleteProgram(m_CommonProID);
-    glDeleteProgram(m_RenderProID);
-    glDeleteProgram(m_TextProID);
-    glDeleteProgram(m_3DProID);
-
     // delete buffers
     glDeleteBuffers(1, &m_CubeVertexBuf);
     glDeleteBuffers(1, &m_CubeNormalBuf);
@@ -114,7 +104,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
     glDeleteBuffers(1, &m_3DUBOBuffer);
 }
 
-void OpenGL3DRenderer::LoadShaders()
+void OpenGL3DRenderer::ShaderResources::LoadShaders()
 {
     m_3DProID = OpenGLHelper::LoadShaders("shape3DVertexShader", "shape3DFragmentShader");
     m_3DProjectionID = glGetUniformLocation(m_3DProID, "P");
@@ -153,22 +143,22 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    glUseProgram(m_RenderProID);
+    glUseProgram(pResources->m_RenderProID);
 
-    glEnableVertexAttribArray(m_RenderVertexID);
+    glEnableVertexAttribArray(pResources->m_RenderVertexID);
     glBindBuffer(GL_ARRAY_BUFFER, m_RenderVertexBuf);
     glVertexAttribPointer(
-        m_RenderVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        pResources->m_RenderVertexID, // attribute
         3,                  // size
         GL_FLOAT,           // type
         GL_FALSE,           // normalized?
         0,                  // stride
         (void*)0            // array buffer offset
         );
-    glEnableVertexAttribArray(m_RenderTexCoordID);
+    glEnableVertexAttribArray(pResources->m_RenderTexCoordID);
     glBindBuffer(GL_ARRAY_BUFFER, m_RenderTexCoordBuf);
     glVertexAttribPointer(
-        m_RenderTexCoordID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        pResources->m_RenderTexCoordID, // attribute.
         2,                  // size
         GL_FLOAT,           // type
         GL_FALSE,           // normalized?
@@ -176,10 +166,10 @@ void OpenGL3DRenderer::RenderTexture(GLuint TexID)
         (void*)0            // array buffer offset
         );
     glBindTexture(GL_TEXTURE_2D, TexID);
-    glUniform1i(m_RenderTexID, 0);
+    glUniform1i(pResources->m_RenderTexID, 0);
     glDrawArrays(GL_QUADS, 0, 4);
-    glDisableVertexAttribArray(m_RenderTexCoordID);
-    glDisableVertexAttribArray(m_RenderVertexID);
+    glDisableVertexAttribArray(pResources->m_RenderTexCoordID);
+    glDisableVertexAttribArray(pResources->m_RenderVertexID);
     glBindTexture(GL_TEXTURE_2D, 0);
     glUseProgram(0);
 }
@@ -223,7 +213,8 @@ void OpenGL3DRenderer::init()
 
     m_fViewAngle = 60.0f;
     m_3DProjection = glm::perspective(m_fViewAngle, (float)m_iWidth / (float)m_iHeight, 0.01f, 2000.0f);
-    LoadShaders();
+    maNormalResources.LoadShaders();
+    maPickingResources.LoadShaders();
     glGenBuffers(1, &m_TextTexCoordBuf);
     glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
     glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
@@ -676,7 +667,7 @@ double OpenGL3DRenderer::GetTime()
 void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 {
     size_t listNum = polygon.verticesList.size();
-    glUseProgram(m_CommonProID);
+    glUseProgram(pResources->m_CommonProID);
     for (size_t i = 0; i < listNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
@@ -693,12 +684,12 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
         //fill vertex buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
-        glUniform4fv(m_2DColorID, 1, &polygon.polygonColor[0]);
-        glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
+        glUniform4fv(pResources->m_2DColorID, 1, &polygon.polygonColor[0]);
+        glUniformMatrix4fv(pResources->m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(m_2DVertexID);
+        glEnableVertexAttribArray(pResources->m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(m_2DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_2DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -708,7 +699,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 
         glLineWidth(polygon.lineWidth);
         glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
-        glDisableVertexAttribArray(m_2DVertexID);
+        glDisableVertexAttribArray(pResources->m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         delete pointList;
         polygon.verticesList.pop_front();
@@ -731,9 +722,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
     glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
-    glUseProgram(m_3DProID);
-    glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
-    glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glUseProgram(pResources->m_3DProID);
+    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     for (size_t i = 0; i < verticesNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
@@ -753,13 +744,13 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
         //fill normal buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
         glBufferData(GL_ARRAY_BUFFER, normalList->size() * sizeof(glm::vec3), &normalList[0][0], GL_STATIC_DRAW);
-        glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
-        glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
+        glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+        glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
 
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(m_3DVertexID);
+        glEnableVertexAttribArray(pResources->m_3DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DVertexID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -767,9 +758,9 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
                                 (void*)0            // array buffer offset
                                 );
         // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(m_3DNormalID);
+        glEnableVertexAttribArray(pResources->m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, m_NormalBuffer);
-        glVertexAttribPointer(m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DNormalID, // attribute
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -778,8 +769,8 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
                                 );
 
         glDrawArrays(GL_POLYGON, 0, pointList->size());
-        glDisableVertexAttribArray(m_3DVertexID);
-        glDisableVertexAttribArray(m_3DNormalID);
+        glDisableVertexAttribArray(pResources->m_3DVertexID);
+        glDisableVertexAttribArray(pResources->m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         delete pointList;
         delete normalList;
@@ -967,8 +958,8 @@ void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
 
 void OpenGL3DRenderer::Init3DUniformBlock()
 {
-    GLuint a3DLightBlockIndex = glGetUniformBlockIndex(m_3DProID, "GlobalLights");
-    GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(m_3DProID, "GlobalMaterialParameters");
+    GLuint a3DLightBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalLights");
+    GLuint a3DMaterialBlockIndex = glGetUniformBlockIndex(pResources->m_3DProID, "GlobalMaterialParameters");
 
     if ((GL_INVALID_INDEX == a3DLightBlockIndex) || (GL_INVALID_INDEX == a3DMaterialBlockIndex))
     {
@@ -977,8 +968,8 @@ void OpenGL3DRenderer::Init3DUniformBlock()
     int nUniformBufferAlignSize = 0;
     glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &nUniformBufferAlignSize);
     GLint nBlockDataSizeLight = 0, nBlockDataSizeMertrial = 0;
-    glGetActiveUniformBlockiv(m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
-    glGetActiveUniformBlockiv(m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
+    glGetActiveUniformBlockiv(pResources->m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight);
+    glGetActiveUniformBlockiv(pResources->m_3DProID, a3DMaterialBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeMertrial);
     CHECK_GL_ERROR();
     glGenBuffers(1, &m_3DUBOBuffer);
     glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
@@ -989,10 +980,10 @@ void OpenGL3DRenderer::Init3DUniformBlock()
     glBufferData(GL_UNIFORM_BUFFER, dataSize, NULL, GL_DYNAMIC_DRAW);
     glBindBufferRange(GL_UNIFORM_BUFFER, 0, m_3DUBOBuffer, 0, nBlockDataSizeLight);
     CHECK_GL_ERROR();
-    glUniformBlockBinding(m_3DProID, a3DLightBlockIndex, 0);
+    glUniformBlockBinding(pResources->m_3DProID, a3DLightBlockIndex, 0);
 
     glBindBufferRange(GL_UNIFORM_BUFFER, 1, m_3DUBOBuffer, ((nBlockDataSizeLight / nUniformBufferAlignSize) + std::min(nBlockDataSizeLight % nUniformBufferAlignSize, 1)) * nUniformBufferAlignSize, nBlockDataSizeMertrial);
-    glUniformBlockBinding(m_3DProID, a3DMaterialBlockIndex, 1);
+    glUniformBlockBinding(pResources->m_3DProID, a3DMaterialBlockIndex, 1);
     //for the light source uniform, we must calc the offset of each element
     CHECK_GL_ERROR();
     glBindBuffer(GL_UNIFORM_BUFFER, 0);
@@ -1023,8 +1014,8 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
     m_Model = aTranslationMatrix * extrude3D.rotation * flatScale;
     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]);
+    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
 }
 
@@ -1056,8 +1047,8 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
     }
     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]);
+    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
 }
 
@@ -1091,8 +1082,8 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
     }
     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]);
+    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
 }
 
@@ -1127,8 +1118,8 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
     }
     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]);
+    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(pResources->m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]);
     glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
     RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
 }
@@ -1138,8 +1129,8 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
     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]);
+    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(pResources->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 * extrude3D.rotation * scaleMatrix;
@@ -1150,15 +1141,15 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
     }
     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]);
+    glUniformMatrix4fv(pResources->m_3DModelID, 1, GL_FALSE, &m_Model[0][0]);
+    glUniformMatrix3fv(pResources->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]);
-    glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
+    glUniformMatrix4fv(pResources->m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
+    glUniformMatrix4fv(pResources->m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
     CHECK_GL_ERROR();
     RenderExtrudeMiddleSurface(extrude3D);
     // check reverse flag to decide whether to render the top middle
@@ -1181,7 +1172,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
     glCullFace(GL_BACK);
     Update3DUniformBlock();
     //render to fbo
-    glUseProgram(m_3DProID);
+    glUseProgram(pResources->m_3DProID);
     size_t extrude3DNum = m_Extrude3DList.size();
     for (size_t i = 0; i < extrude3DNum; i++)
     {
@@ -1189,9 +1180,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
         GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
         // 1st attribute buffer : vertices
-        glEnableVertexAttribArray(m_3DVertexID);
+        glEnableVertexAttribArray(pResources->m_3DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, vertexBuf);
-        glVertexAttribPointer(m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1199,9 +1190,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
                                 (void*)0            // array buffer offset
                                 );
         // 2nd attribute buffer : normals
-        glEnableVertexAttribArray(m_3DNormalID);
+        glEnableVertexAttribArray(pResources->m_3DNormalID);
         glBindBuffer(GL_ARRAY_BUFFER, normalBuf);
-        glVertexAttribPointer(m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+        glVertexAttribPointer(pResources->m_3DNormalID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
                                 3,                  // size
                                 GL_FLOAT,           // type
                                 GL_FALSE,           // normalized?
@@ -1224,8 +1215,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         {
             RenderNonRoundedBar(extrude3DInfo);
         }
-        glDisableVertexAttribArray(m_3DVertexID);
-        glDisableVertexAttribArray(m_3DNormalID);
+        glDisableVertexAttribArray(pResources->m_3DVertexID);
+        glDisableVertexAttribArray(pResources->m_3DNormalID);
     }
     m_Extrude3DList.clear();
     glUseProgram(0);
@@ -1292,15 +1283,15 @@ void OpenGL3DRenderer::RenderTextShape()
         CHECK_GL_ERROR();
         glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
         CHECK_GL_ERROR();
-        glUseProgram(m_TextProID);
+        glUseProgram(pResources->m_TextProID);
 
         CHECK_GL_ERROR();
-        glUniformMatrix4fv(m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+        glUniformMatrix4fv(pResources->m_TextMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
         // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(m_TextVertexID);
+        glEnableVertexAttribArray(pResources->m_TextVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glVertexAttribPointer(
-            m_TextVertexID,
+            pResources->m_TextVertexID,
             3,                  // size
             GL_FLOAT,           // type
             GL_FALSE,           // normalized?
@@ -1309,10 +1300,10 @@ void OpenGL3DRenderer::RenderTextShape()
             );
         //tex coord
         CHECK_GL_ERROR();
-        glEnableVertexAttribArray(m_TextTexCoordID);
+        glEnableVertexAttribArray(pResources->m_TextTexCoordID);
         glBindBuffer(GL_ARRAY_BUFFER, m_TextTexCoordBuf);
         glVertexAttribPointer(
-            m_TextTexCoordID,
+            pResources->m_TextTexCoordID,
             2,                  // size
             GL_FLOAT,           // type
             GL_FALSE,           // normalized?
@@ -1323,14 +1314,14 @@ void OpenGL3DRenderer::RenderTextShape()
         CHECK_GL_ERROR();
         glBindTexture(GL_TEXTURE_2D, textInfo.texture);
         CHECK_GL_ERROR();
-        glUniform1i(m_TextTexID, 0);
+        glUniform1i(pResources->m_TextTexID, 0);
         CHECK_GL_ERROR();
         //TODO: moggi: get rid fo GL_QUADS
         glDrawArrays(GL_QUADS, 0, 4);
         CHECK_GL_ERROR();
-        glDisableVertexAttribArray(m_TextTexCoordID);
+        glDisableVertexAttribArray(pResources->m_TextTexCoordID);
         CHECK_GL_ERROR();
-        glDisableVertexAttribArray(m_TextVertexID);
+        glDisableVertexAttribArray(pResources->m_TextVertexID);
         CHECK_GL_ERROR();
         glBindTexture(GL_TEXTURE_2D, 0);
         glUseProgram(0);
@@ -1425,6 +1416,11 @@ void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scal
     m_Model = aTranslationMatrix * aRotationMatrix * aScaleMatrix;
 }
 
+void OpenGL3DRenderer::SetPickingMode(bool bPickingMode)
+{
+    mbPickingMode = bPickingMode;
+}
+
 }
 
 }
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 880376c..d6fb9c4 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -23,6 +23,7 @@ private:
 OpenGLWindowImpl::OpenGLWindowImpl(SystemChildWindow* pWindow)
 {
     maContext.init(pWindow);
+    pWindow->SetMouseTransparent(false);
 }
 
 OpenGLContext* OpenGLWindowImpl::getContext()


More information about the Libreoffice-commits mailing list