[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 8 commits - chart2/source include/vcl sc/inc sc/source vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Tue May 20 17:16:16 PDT 2014
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 | 51 ++++++++++++++++++++++---
include/vcl/opengl/OpenGLHelper.hxx | 7 +++
sc/inc/chartarr.hxx | 24 +++++------
sc/source/core/tool/chartarr.cxx | 36 ++++++-----------
sc/source/ui/unoobj/cellsuno.cxx | 6 +-
vcl/source/opengl/OpenGLHelper.cxx | 36 +++++++++++++++++
9 files changed, 139 insertions(+), 54 deletions(-)
New commits:
commit ae1426a2667ba2a426753283eb6f501341d7a517
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 21 02:09:11 2014 +0200
forgot to release the OpenGL resources
Change-Id: I2baefbe611f9ed28defc46ca3af332d13b32c561
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index cea7e0f..cf75ea6 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -110,6 +110,10 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_RenderVertexBuf);
glDeleteBuffers(1, &m_3DUBOBuffer);
glDeleteBuffers(1, &m_VertexBuffer);
+
+ glDeleteFramebuffers(1, &mnPickingFbo);
+ glDeleteRenderbuffers(1, &mnPickingRbo);
+ glDeleteTextures(1, &mnPickingTexture);
}
void OpenGL3DRenderer::ShaderResources::LoadShaders()
commit 9d9b631c60dc4b88d5cff0a4a8c9e5c94b019a47
Author: Markus Mohrhard <markus.mohrhard at 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 8f6411c08f8382ff486af1f10fff5cf9c6525265
Author: Markus Mohrhard <markus.mohrhard at 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 801898ae0d9c61e37235d9d90affdca694aa2a69
Author: Markus Mohrhard <markus.mohrhard at 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 b4aeb3a6532b327d7bf4e8d60516c8b1e10ea873
Author: Markus Mohrhard <markus.mohrhard at 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 b789e4c239c24238f0729b4d425aeafe4a688809
Author: Markus Mohrhard <markus.mohrhard at 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 9eaaceebc6a1cc9904b9afc55d0c5de16b0e2e1b
Author: Markus Mohrhard <markus.mohrhard at 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);
commit 7df69681ebdd884f9808d71798128e436f5fb6f2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon May 19 13:42:54 2014 +0200
kill some old 16 bit column indices
Change-Id: Ie1c3f3b11ed216b53f3fd385614f6fcb2c38220c
diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx
index 4e48d27..0dfcede 100644
--- a/sc/inc/chartarr.hxx
+++ b/sc/inc/chartarr.hxx
@@ -33,26 +33,26 @@ class ScDocument;
class ScMemChart
{
- short nRowCnt;
- short nColCnt;
- double* pData;
+ SCROW nRowCnt;
+ SCCOL nColCnt;
+ double* pData;
OUString* pColText;
OUString* pRowText;
ScMemChart(const ScMemChart& rMemChart); // not implemented
public:
- ScMemChart(short nCols, short nRows);
+ ScMemChart(SCCOL nCols, SCROW nRows);
~ScMemChart();
- short GetColCount() const { return nColCnt; }
- short GetRowCount() const { return nRowCnt; }
- const OUString& GetColText(short nCol) const { return pColText[nCol]; }
- const OUString& GetRowText(short nRow) const { return pRowText[nRow]; }
- double GetData(short nCol, short nRow) const { return pData[nCol * nRowCnt + nRow]; }
- void SetData(short nCol, short nRow, const double& rVal) { pData[nCol * nRowCnt + nRow] = rVal; }
- void SetColText(short nCol, const OUString& rText) { pColText[nCol] = rText; }
- void SetRowText(short nRow, const OUString& rText) { pRowText[nRow] = rText; }
+ SCCOL GetColCount() const { return nColCnt; }
+ SCROW GetRowCount() const { return nRowCnt; }
+ const OUString& GetColText(SCCOL nCol) const { return pColText[nCol]; }
+ const OUString& GetRowText(SCROW nRow) const { return pRowText[nRow]; }
+ double GetData(SCCOL nCol, SCROW nRow) const { return pData[nCol * nRowCnt + nRow]; }
+ void SetData(SCCOL nCol, SCROW nRow, const double& rVal) { pData[nCol * nRowCnt + nRow] = rVal; }
+ void SetColText(SCCOL nCol, const OUString& rText) { pColText[nCol] = rText; }
+ void SetRowText(SCROW nRow, const OUString& rText) { pRowText[nRow] = rText; }
};
class SC_DLLPUBLIC ScChartArray // only parameter-struct
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index cc6311c..e3d3a19 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -33,7 +33,7 @@
using ::std::vector;
-ScMemChart::ScMemChart(short nCols, short nRows)
+ScMemChart::ScMemChart(SCCOL nCols, SCROW nRows)
{
nRowCnt = nRows;
nColCnt = nCols;
@@ -43,8 +43,8 @@ ScMemChart::ScMemChart(short nCols, short nRows)
{
double *pFill = pData;
- for (short i = 0; i < nColCnt; i++)
- for (short j = 0; j < nRowCnt; j++)
+ for (SCCOL i = 0; i < nColCnt; i++)
+ for (SCROW j = 0; j < nRowCnt; j++)
*(pFill ++) = 0.0;
}
@@ -238,12 +238,8 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
aRows.push_back(nStrRow);
}
-
- // Data
-
-
- ScMemChart* pMemChart = new ScMemChart(
- static_cast<short>(nColCount), static_cast<short>(nRowCount) );
+ // Data
+ ScMemChart* pMemChart = new ScMemChart( nColCount, nRowCount );
if (pMemChart)
{
if ( bValidData )
@@ -256,7 +252,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
// DBL_MIN is a Hack for Chart to recognize empty cells.
ScAddress aPos(aCols[nCol], aRows[nRow], nTab1);
double nVal = getCellValue(*pDocument, aPos, DBL_MIN, bCalcAsShown);
- pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
+ pMemChart->SetData(nCol, nRow, nVal);
}
}
}
@@ -265,7 +261,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
// Flag marking data as invalid?
for (nCol=0; nCol<nColCount; nCol++)
for (nRow=0; nRow<nRowCount; nRow++)
- pMemChart->SetData( static_cast<short>(nCol), static_cast<short>(nRow), DBL_MIN );
+ pMemChart->SetData( nCol, nRow, DBL_MIN );
}
@@ -287,7 +283,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
aString = aBuf.makeStringAndClear();
}
- pMemChart->SetColText( static_cast<short>(nCol), aString);
+ pMemChart->SetColText( nCol, aString);
}
@@ -309,7 +305,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
aBuf.append(static_cast<sal_Int32>(aRows[nRow]+1));
aString = aBuf.makeStringAndClear();
}
- pMemChart->SetRowText( static_cast<short>(nRow), aString);
+ pMemChart->SetRowText( nRow, aString);
}
}
@@ -340,12 +336,8 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
nRowCount = 1;
}
-
// Data
-
-
- ScMemChart* pMemChart = new ScMemChart(
- static_cast<short>(nColCount), static_cast<short>(nRowCount) );
+ ScMemChart* pMemChart = new ScMemChart( nColCount, nRowCount );
if (pMemChart)
{
SCSIZE nCol = 0;
@@ -364,7 +356,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
// otherwise: Gap
nVal = getCellValue(*pDocument, *pPos, DBL_MIN, bCalcAsShown);
- pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
+ pMemChart->SetData(nCol, nRow, nVal);
}
}
}
@@ -378,7 +370,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
// otherwise: Gap
nVal = getCellValue(*pDocument, *pPos, DBL_MIN, bCalcAsShown);
- pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
+ pMemChart->SetData(nCol, nRow, nVal);
}
}
@@ -408,7 +400,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
aBuf.append(aPos.Format(SCA_VALID_COL, NULL));
aString = aBuf.makeStringAndClear();
}
- pMemChart->SetColText( static_cast<short>(nCol), aString);
+ pMemChart->SetColText( nCol, aString);
}
@@ -434,7 +426,7 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
aBuf.append(static_cast<sal_Int32>(nPosRow));
aString = aBuf.makeStringAndClear();
}
- pMemChart->SetRowText( static_cast<short>(nRow), aString);
+ pMemChart->SetRowText( nRow, aString);
}
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index f07ffd2..dd3a0e2 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3047,7 +3047,7 @@ uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
uno::Sequence<double> aColSeq( nColCount );
double* pColAry = aColSeq.getArray();
for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
- pColAry[nCol] = pMemChart->GetData( static_cast<short>(nCol), static_cast<short>(nRow) );
+ pColAry[nCol] = pMemChart->GetData( nCol, nRow );
pRowAry[nRow] = aColSeq;
}
@@ -3155,7 +3155,7 @@ uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
uno::Sequence<OUString> aSeq( nRowCount );
OUString* pAry = aSeq.getArray();
for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
- pAry[nRow] = pMemChart->GetRowText(static_cast<short>(nRow));
+ pAry[nRow] = pMemChart->GetRowText(nRow);
return aSeq;
}
@@ -3226,7 +3226,7 @@ uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
uno::Sequence<OUString> aSeq( nColCount );
OUString* pAry = aSeq.getArray();
for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
- pAry[nCol] = pMemChart->GetColText(static_cast<short>(nCol));
+ pAry[nCol] = pMemChart->GetColText(nCol);
return aSeq;
}
More information about the Libreoffice-commits
mailing list