chart2/source/view/charttypes/GL3DBarChart.cxx | 6 ++- chart2/source/view/inc/GL3DRenderer.hxx | 17 ++++++--- chart2/source/view/main/3DChartObjects.cxx | 10 ++--- chart2/source/view/main/GL3DRenderer.cxx | 47 ++++++++++++++++++++++--- include/vcl/opengl/OpenGLHelper.hxx | 7 +++ vcl/source/opengl/OpenGLHelper.cxx | 36 +++++++++++++++++++ 6 files changed, 106 insertions(+), 17 deletions(-)
New commits: commit 61b2ae31c6642e09b3052599ae22077e8d41eabd Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Wed May 21 01:49:59 2014 +0200 use FBO for the picking Change-Id: Ibab6daa1f76300d159ccd4cfbca061c8d8c1951f diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index 1653668..d36a008 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -217,14 +217,16 @@ public: } -void GL3DBarChart::clickedAt(const Point& ) +void GL3DBarChart::clickedAt(const Point& rPos) { + sal_uInt32 nId = 1; { PickingModeSetter(mpRenderer.get()); render(); + nId = mpRenderer->GetPixelColorFromPoint(rPos.X(), rPos.Y()); } if (mpCamera) - mpCamera->zoom(1); + mpCamera->zoom(nId); } } diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx index 52d341a..b08e90e 100644 --- a/chart2/source/view/inc/GL3DRenderer.hxx +++ b/chart2/source/view/inc/GL3DRenderer.hxx @@ -179,6 +179,8 @@ public: void ProcessUnrenderedShape(); void SetPickingMode(bool bPickingMode); + + sal_uInt32 GetPixelColorFromPoint(long nX, long nY); private: void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale); @@ -362,6 +364,10 @@ private: bool mbPickingMode; SceneBox m_SenceBox; + + GLuint mnPickingFbo; + GLuint mnPickingRbo; + GLuint mnPickingTexture; }; } diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index 92cf61d..cea7e0f 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -249,6 +249,8 @@ void OpenGL3DRenderer::init() glBufferData(GL_ARRAY_BUFFER, sizeof(squareVertices), squareVertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); + OpenGLHelper::createFramebuffer(m_iWidth, m_iHeight, mnPickingFbo, mnPickingRbo, mnPickingTexture); + CHECK_GL_ERROR(); Init3DUniformBlock(); @@ -1580,6 +1582,22 @@ void OpenGL3DRenderer::MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scal void OpenGL3DRenderer::SetPickingMode(bool bPickingMode) { mbPickingMode = bPickingMode; + if(mbPickingMode) + { + glBindFramebuffer(GL_FRAMEBUFFER, mnPickingFbo); + } + else + { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } +} + +sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY) +{ + boost::scoped_array<sal_uInt8> buf(new sal_uInt8[4]); + glReadPixels(nX, nY, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, buf.get()); + Color aColor(buf[3], buf[2], buf[1], buf[0]); + return aColor.GetColor(); } } commit 8c39739a38237df6e8f39f312cf08fadae896ae4 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Wed May 21 00:41:37 2014 +0200 add method for creating framebuffer objects to OpenGLHelper Change-Id: I08bd2e58ee98a68accae256fcbcc288a8c56ae0b diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx index 3cb482b..70b1d2a 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -29,6 +29,13 @@ public: static void renderToFile(long nWidth, long nHeight, const OUString& rFileName); static const char* GLErrorString(GLenum errorCode); + + /** + * The caller is responsible for deleting the buffer objects identified by + * nFramebufferId, nRenderbufferId and nTexturebufferId + */ + static void createFramebuffer(long nWidth, long nHeight, + GLuint& nFramebufferId, GLuint& nRenderbufferId, GLuint& nTexturebufferId); }; VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix); diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 0e9d710..ad2506d 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -268,5 +268,41 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix) return rStrm; } +void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, + GLuint& nFramebufferId, GLuint& nRenderbufferId, GLuint& nTexturebufferId) +{ + // create a renderbuffer + glGenRenderbuffers(1, &nRenderbufferId); + glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferId); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, nWidth, nHeight); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + + // create a texture + glGenTextures(1, &nTexturebufferId); + glBindTexture(GL_TEXTURE_2D, nTexturebufferId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glBindTexture(GL_TEXTURE_2D, 0); + + // create a framebuffer object and attach renderbuffer and texture + glGenFramebuffers(1, &nFramebufferId); + glCheckFramebufferStatus(GL_FRAMEBUFFER); + glBindFramebuffer(GL_FRAMEBUFFER, nFramebufferId); + glBindTexture(GL_TEXTURE_2D, nTexturebufferId); + // attach a texture to FBO color attachement point + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, nTexturebufferId, 0); + glCheckFramebufferStatus(GL_FRAMEBUFFER); + glBindTexture(GL_TEXTURE_2D, 0); + // attach a renderbuffer to depth attachment point + glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferId); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, nRenderbufferId); + glCheckFramebufferStatus(GL_FRAMEBUFFER); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit e634b0dcdd6286cef92dac83847af8b6fb08ce70 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Wed May 21 00:18:13 2014 +0200 set the color for the picking Change-Id: If7b902b16626384440241d88937161cf327e14d5 diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx index f782140..52d341a 100644 --- a/chart2/source/view/inc/GL3DRenderer.hxx +++ b/chart2/source/view/inc/GL3DRenderer.hxx @@ -79,6 +79,7 @@ struct Polygon3DInfo bool twoSidesLighting; long fillStyle; glm::vec4 polygonColor; + glm::vec4 id; Vertices3D *vertices; UVs3D *uvs; Normals3D *normals; @@ -93,6 +94,7 @@ struct Extrude3DInfo bool rounded; bool twoSidesLighting; glm::vec4 extrudeColor; + glm::vec4 id; float xScale; float yScale; float zScale; @@ -136,6 +138,7 @@ struct PackedVertex{ struct TextInfo { + glm::vec4 id; GLuint texture; float vertex[12]; }; @@ -159,20 +162,20 @@ public: void Set3DSenceInfo(sal_uInt32 color = 255, bool twoSidesLighting = true); void SetLightInfo(bool lightOn, sal_uInt32 color, const glm::vec4& direction); void AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly, sal_uInt32 lineColor, - long fillStyle, sal_uInt32 specular); + long fillStyle, sal_uInt32 specular, sal_uInt32 nUniqueId); void EndAddShapePolygon3DObject(); void AddPolygon3DObjectNormalPoint(float x, float y, float z); void EndAddPolygon3DObjectNormalPoint(); void AddPolygon3DObjectPoint(float x, float y, float z); void EndAddPolygon3DObjectPoint(); - void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, glm::mat4 modelMatrix); + void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId); void EndAddShape3DExtrudeObject(); double GetTime(); void SetFPS(float fps); void RenderClickPos(Point aMPos); void SetSize(const Size& rSize); 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 CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId); void ProcessUnrenderedShape(); void SetPickingMode(bool bPickingMode); diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx index 4581d74..e67c25d 100644 --- a/chart2/source/view/main/3DChartObjects.cxx +++ b/chart2/source/view/main/3DChartObjects.cxx @@ -39,7 +39,7 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aCo void Bar::render() { - mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, maColor.GetColor(), 0xFFFFFF, maPos); + mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, maColor.GetColor(), 0xFFFFFF, maPos, mnUniqueId); mpRenderer->EndAddShape3DExtrudeObject(); } @@ -50,7 +50,7 @@ Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId): void Line::render() { - mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0); + mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0, mnUniqueId); mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z); mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z); mpRenderer->EndAddShapePolygon3DObject(); @@ -87,7 +87,7 @@ void Text::render() { glm::vec3 dir2 = maTopRight - maTopLeft; glm::vec3 bottomLeft = maBottomRight - dir2; - mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft); + mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft, mnUniqueId); } Size Text::getSize() const @@ -112,7 +112,7 @@ void Rectangle::render() glm::vec3 dir1 = maBottomRight - maTopLeft; glm::vec3 dir2 = maTopRight - maTopLeft; glm::vec3 normal = glm::normalize(glm::cross(dir1, dir2)); - mpRenderer->AddShapePolygon3DObject(maColor.GetColor(), false, 0, 1, 0xFFFFFF); + mpRenderer->AddShapePolygon3DObject(maColor.GetColor(), false, 0, 1, 0xFFFFFF, mnUniqueId); glm::vec3 bottomLeft = maBottomRight - dir2; //set polygon points and normals mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z); @@ -128,7 +128,7 @@ void Rectangle::render() //we should render the edge if the edge color is different from the fill color if (maColor.GetColor() != maLineColor.GetColor()) { - mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0xFFFFFF); + mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0xFFFFFF, mnUniqueId); mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z); mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z); mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z); diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index 07b652a..92cf61d 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -706,7 +706,10 @@ 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(maResources.m_2DColorID, 1, &polygon.polygonColor[0]); + if(mbPickingMode) + glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]); + else + glUniform4fv(maResources.m_2DColorID, 1, &polygon.polygonColor[0]); glUniformMatrix4fv(maResources.m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]); // 1rst attribute buffer : vertices @@ -786,6 +789,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon) { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]); } GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID; @@ -878,9 +882,10 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm:: } } -void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 nColor, bool lineOnly, sal_uInt32 nLineColor,long fillStyle, sal_uInt32 specular) +void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 nColor, bool lineOnly, sal_uInt32 nLineColor,long fillStyle, sal_uInt32 specular, sal_uInt32 nUniqueId) { m_Polygon3DInfo.polygonColor = getColorAsVector(nColor); + m_Polygon3DInfo.id = getColorAsVector(nUniqueId); m_Polygon3DInfo.material.materialColor = m_Polygon3DInfo.polygonColor;//material color seems to be the same for all parts, so we use the polygon color //line or Polygon m_Polygon3DInfo.lineOnly = lineOnly; @@ -960,8 +965,9 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint() m_Polygon3DInfo.vertices = NULL; } -void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, glm::mat4 modelMatrix) +void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId) { + m_Extrude3DInfo.id = getColorAsVector(nUniqueId); glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0); glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0); glm::vec4 DirY = modelMatrix * glm::vec4(0.0, 1.0, 0.0, 0.0); @@ -1091,6 +1097,7 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D, { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]); } glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex])); @@ -1134,6 +1141,7 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]); } glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE])); } @@ -1178,6 +1186,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]); } glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE])); } @@ -1223,6 +1232,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D) { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]); } glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE])); RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE); @@ -1253,6 +1263,7 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D) { glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model; glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]); + glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]); } glDrawArrays(GL_TRIANGLES, 0, 36); } @@ -1279,7 +1290,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject() glEnable(GL_CULL_FACE); glCullFace(GL_BACK); if(mbPickingMode) + { glUseProgram(maPickingResources.m_CommonProID); + } else { Update3DUniformBlock(); @@ -1294,6 +1307,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject() Extrude3DInfo extrude3DInfo = m_Extrude3DList[i]; GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox; GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal; + + if(mbPickingMode) + glUniform4fv(maResources.m_2DColorID, 1, &extrude3DInfo.id[0]); // 1st attribute buffer : vertices GLint aVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID; @@ -1348,13 +1364,14 @@ void OpenGL3DRenderer::RenderExtrude3DObject() glDisable(GL_CULL_FACE); } -void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft) +void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId) { long bmpWidth = rBitmapEx.GetSizePixel().Width(); long bmpHeight = rBitmapEx.GetSizePixel().Height(); boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx)); TextInfo aTextInfo; + aTextInfo.id = getColorAsVector(nUniqueId); aTextInfo.vertex[0] = vBottomRight.x; aTextInfo.vertex[1] = vBottomRight.y; aTextInfo.vertex[2] = vBottomRight.z * m_fHeightWeight; commit 1b8cfd5d1414da9127ff18e4701b40f5bceabb36 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue May 20 23:59:55 2014 +0200 remove unnecessary whitespaces Change-Id: I4d93c0149aaf90e2477c1382aa51f8f08c967626 diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx index 8628bb8..f782140 100644 --- a/chart2/source/view/inc/GL3DRenderer.hxx +++ b/chart2/source/view/inc/GL3DRenderer.hxx @@ -106,7 +106,6 @@ struct Extrude3DInfo int reverse; }; - struct CameraInfo { glm::vec3 cameraPos; @@ -150,7 +149,6 @@ typedef struct SceneBox{ float minZCoord; }SceneBox; - class OpenGL3DRenderer { public: commit 5500a4fedc406fad218a2529c905f33008e453f3 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue May 20 23:47:28 2014 +0200 avoid division by zero that happens to me in some cases Change-Id: Ifc80462e7826e7d717dc553f50dd00f2b771bf15 diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index c98ef30..07b652a 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -1030,7 +1030,7 @@ void OpenGL3DRenderer::Init3DUniformBlock() { return; } - int nUniformBufferAlignSize = 0; + int nUniformBufferAlignSize = 1; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &nUniformBufferAlignSize); GLint nBlockDataSizeLight = 0, nBlockDataSizeMertrial = 0; glGetActiveUniformBlockiv(maResources.m_3DProID, a3DLightBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &nBlockDataSizeLight); commit 08bed8aa8a8615f85cea404cb7a859f3bccf78cc Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue May 20 23:46:57 2014 +0200 we need to create the buffer Somehow this only crashes when I use gdb. Change-Id: Ic18ffa3af931b80a7241e8fe711753db03da166e diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx index f7867d5..c98ef30 100644 --- a/chart2/source/view/main/GL3DRenderer.cxx +++ b/chart2/source/view/main/GL3DRenderer.cxx @@ -109,6 +109,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer() glDeleteBuffers(1, &m_RenderTexCoordBuf); glDeleteBuffers(1, &m_RenderVertexBuf); glDeleteBuffers(1, &m_3DUBOBuffer); + glDeleteBuffers(1, &m_VertexBuffer); } void OpenGL3DRenderer::ShaderResources::LoadShaders() @@ -216,6 +217,7 @@ void OpenGL3DRenderer::init() glGenBuffers(1, &m_CubeVertexBuf); glGenBuffers(1, &m_CubeNormalBuf); glGenBuffers(1, &m_CubeElementBuf); + glGenBuffers(1, &m_VertexBuffer); glGenBuffers(1, &m_BoundBox); glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox); glBufferData(GL_ARRAY_BUFFER, sizeof(boundBox), boundBox, GL_STATIC_DRAW); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits