diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-05-12 02:57:51 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-05-12 03:00:10 +0200 |
commit | 46351c13e9057bbb27bb490f166d8002f86a6025 (patch) | |
tree | 6db339c87810fc7f6149c8bb9a5ab869aa87a075 /chart2 | |
parent | 2124f55b5371c421c3c1793fc740921adda3dfac (diff) |
Revert "separate rounded corner bar and normal bar rendering"
This reverts commit 51d5062642189ff5a4330903253c012e83e5ef1f.
Conflicts:
chart2/source/view/main/GL3DRenderer.cxx
Change-Id: Id21e59d2cc605f0d7d637fb889725f0e91fa6cb3
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/inc/3DChartObjects.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/inc/GL3DRenderer.hxx | 6 | ||||
-rw-r--r-- | chart2/source/view/inc/StaticGeometry.h | 39 | ||||
-rw-r--r-- | chart2/source/view/main/3DChartObjects.cxx | 13 | ||||
-rw-r--r-- | chart2/source/view/main/GL3DRenderer.cxx | 80 |
5 files changed, 37 insertions, 103 deletions
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx index f8138aaa0f4a..8571fd804d6c 100644 --- a/chart2/source/view/inc/3DChartObjects.hxx +++ b/chart2/source/view/inc/3DChartObjects.hxx @@ -37,7 +37,7 @@ protected: class Bar : public Renderable3DObject { public: - Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nColor, sal_uInt32 nId); + Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 nColor, sal_uInt32 nId); virtual void render() SAL_OVERRIDE; private: diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx index 7840a022dcd9..5337384c787f 100644 --- a/chart2/source/view/inc/GL3DRenderer.hxx +++ b/chart2/source/view/inc/GL3DRenderer.hxx @@ -90,6 +90,7 @@ struct Polygon3DInfo struct Extrude3DInfo { + bool rounded; bool twoSidesLighting; glm::vec4 extrudeColor; float xScale; @@ -156,7 +157,7 @@ public: void EndAddPolygon3DObjectNormalPoint(); void AddPolygon3DObjectPoint(float x, float y, float z); void EndAddPolygon3DObjectPoint(); - void AddShape3DExtrudeObject(sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix); + void AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix); void EndAddShape3DExtrudeObject(); double GetTime(); void SetFPS(float fps); @@ -165,8 +166,6 @@ 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 RenderNonRoundedBar(const glm::mat4& rModelMatrix, sal_uInt32 nColor); - private: void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale); @@ -190,6 +189,7 @@ private: void AddVertexData(GLuint vertexBuf); void AddNormalData(GLuint normalBuf); void AddIndexData(GLuint indexBuf); + void RenderNonRoundedBar(const Extrude3DInfo& extrude3D); bool GetSimilarVertexIndex(PackedVertex & packed, std::map<PackedVertex,unsigned short> & VertexToOutIndex, unsigned short & result diff --git a/chart2/source/view/inc/StaticGeometry.h b/chart2/source/view/inc/StaticGeometry.h index d3d592667150..bdc8fe74a26a 100644 --- a/chart2/source/view/inc/StaticGeometry.h +++ b/chart2/source/view/inc/StaticGeometry.h @@ -130,45 +130,6 @@ static GLfloat squareVertices[] = { -1.0f, 1.0f, -1.0 }; -static const GLfloat cubeVertices[] = { - -1.0f,-1.0f,-1.0f, - -1.0f,-1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f,-1.0f, - -1.0f,-1.0f,-1.0f, - -1.0f, 1.0f,-1.0f, - 1.0f,-1.0f, 1.0f, - -1.0f,-1.0f,-1.0f, - 1.0f,-1.0f,-1.0f, - 1.0f, 1.0f,-1.0f, - 1.0f,-1.0f,-1.0f, - -1.0f,-1.0f,-1.0f, - -1.0f,-1.0f,-1.0f, - -1.0f, 1.0f, 1.0f, - -1.0f, 1.0f,-1.0f, - 1.0f,-1.0f, 1.0f, - -1.0f,-1.0f, 1.0f, - -1.0f,-1.0f,-1.0f, - -1.0f, 1.0f, 1.0f, - -1.0f,-1.0f, 1.0f, - 1.0f,-1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, - 1.0f,-1.0f,-1.0f, - 1.0f, 1.0f,-1.0f, - 1.0f,-1.0f,-1.0f, - 1.0f, 1.0f, 1.0f, - 1.0f,-1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f,-1.0f, - -1.0f, 1.0f,-1.0f, - 1.0f, 1.0f, 1.0f, - -1.0f, 1.0f,-1.0f, - -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, - 1.0f,-1.0f, 1.0f -}; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx index aa5d3bc26a7c..1c465091f241 100644 --- a/chart2/source/view/main/3DChartObjects.cxx +++ b/chart2/source/view/main/3DChartObjects.cxx @@ -28,7 +28,7 @@ void Renderable3DObject::render() (void) mnUniqueId; } -Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aColor, sal_uInt32 nId) +Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId) : Renderable3DObject(pRenderer, nId) , mbRoundedCorners(true) , maPos(rPosition) @@ -39,15 +39,8 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aCo void Bar::render() { - if(mbRoundedCorners) - { - mpRenderer->AddShape3DExtrudeObject((sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos); - mpRenderer->EndAddShape3DExtrudeObject(); - } - else - { - mpRenderer->RenderNonRoundedBar(maPos, maColor.GetColor()); - } + mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos); + mpRenderer->EndAddShape3DExtrudeObject(); } Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId): diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index e8a5f043da03..d60d64f5a5bd 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -919,7 +919,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint() m_Polygon3DInfo.vertices = NULL; } -void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix) +void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix) { glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0); glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0); @@ -954,7 +954,8 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(sal_Int32 color,sal_Int32 specula m_Extrude3DInfo.yTransform = tranform.y; m_Extrude3DInfo.zTransform = tranform.z; // m_Extrude3DInfo.zTransform = 0; - if (m_RoundBarMesh.iMeshSizes == 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); AddVertexData(m_CubeVertexBuf); @@ -1144,54 +1145,26 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D) RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE); } -namespace { - -glm::vec4 getColorAsVector(sal_uInt32 nColor) +void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D) { - sal_uInt8 nRed = sal_uInt8((nColor & 0xFF0000) >> 16); - sal_uInt8 nGreen = sal_uInt8((nColor & 0xFF00) >> 8); - sal_uInt8 nBlue = sal_uInt8((nColor & 0xFF)); - sal_uInt8 nAlpha = sal_uInt8((nColor & 0xFF000000) >> 24); - return glm::vec4(nRed/255.0, nGreen/255.0, nBlue/255.0, nAlpha/255.0); -} - -} - -void OpenGL3DRenderer::RenderNonRoundedBar(const glm::mat4& modelMatrix, sal_uInt32 nColor) -{ - glm::mat4 aMVP = m_3DProjection * m_3DView * modelMatrix; - SAL_INFO("chart2.3dopengl", "render new bar"); - SAL_INFO("chart2.3dopengl", aMVP); - - for(size_t i = 0; i < SAL_N_ELEMENTS(cubeVertices); i += 3) + float xScale = extrude3D.xScale; + float yScale = extrude3D.yScale; + float zScale = extrude3D.zScale; + glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]); + glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]); + glm::mat4 transformMatrix = glm::translate(glm::vec3(extrude3D.xTransform, -extrude3D.yTransform, extrude3D.zTransform)); + glm::mat4 scaleMatrix = glm::scale(xScale, yScale, zScale); + m_Model = transformMatrix * extrude3D.rotation * scaleMatrix; + if (extrude3D.reverse) { - glm::vec4 aPos(cubeVertices[i*3], cubeVertices[i*3+1], cubeVertices[i*3+2], 1.0); - glm::vec4 aNewPos = aMVP * aPos; - SAL_INFO("chart2.3dopengl", aNewPos); + glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, -1.0, 0.0)); + m_Model = m_Model * reverseMatrix; } - - glm::vec4 aColor = getColorAsVector(nColor); - glUseProgram(m_CommonProID); - //fill vertex buffer - glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices, GL_STATIC_DRAW); - glUniform4fv(m_2DColorID, 1, &aColor[0]); - glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); - // 1rst attribute buffer : vertices - glEnableVertexAttribArray(m_2DVertexID); - glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glVertexAttribPointer(m_2DVertexID, - 3, // size - GL_FLOAT, // type - GL_FALSE, // normalized? - 0, // stride - (void*)0 // array buffer offset - ); - + glm::mat3 normalMatrix(m_Model); + glm::mat3 normalInverseTranspos = glm::inverseTranspose(normalMatrix); + glUniformMatrix4fv(m_3DModelID, 1, GL_FALSE, &m_Model[0][0]); + glUniformMatrix3fv(m_3DNormalMatrixID, 1, GL_FALSE, &normalInverseTranspos[0][0]); glDrawArrays(GL_TRIANGLES, 0, 36); - glDisableVertexAttribArray(m_2DVertexID); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glUseProgram(0); } void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D) @@ -1225,8 +1198,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject() for (size_t i = 0; i < extrude3DNum; i++) { Extrude3DInfo extrude3DInfo = m_Extrude3DList[i]; - GLuint vertexBuf = m_CubeVertexBuf; - GLuint normalBuf = m_CubeNormalBuf; + GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox; + GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal; // 1st attribute buffer : vertices glEnableVertexAttribArray(m_3DVertexID); glBindBuffer(GL_ARRAY_BUFFER, vertexBuf); @@ -1254,8 +1227,15 @@ void OpenGL3DRenderer::RenderExtrude3DObject() CHECK_GL_ERROR(); glBindBuffer(GL_UNIFORM_BUFFER, 0); extrude3DInfo.reverse = 0; - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf); - RenderExtrudeSurface(extrude3DInfo); + if (extrude3DInfo.rounded) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf); + RenderExtrudeSurface(extrude3DInfo); + } + else + { + RenderNonRoundedBar(extrude3DInfo); + } glDisableVertexAttribArray(m_3DVertexID); glDisableVertexAttribArray(m_3DNormalID); } |