[Libreoffice-commits] core.git: 11 commits - chart2/source include/vcl vcl/source
weigao
weigao at multicorewareinc.com
Sat May 24 01:53:57 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 37 ++++++++++++++-----------
chart2/source/view/main/3DChartObjects.cxx | 7 +++-
chart2/source/view/main/GL3DRenderer.cxx | 31 ++++++++------------
include/vcl/opengl/OpenGLHelper.hxx | 1
vcl/source/opengl/OpenGLHelper.cxx | 6 ++++
5 files changed, 47 insertions(+), 35 deletions(-)
New commits:
commit fed8631d31c4598466ef0d09f509bfabd5ce9dd7
Author: weigao <weigao at multicorewareinc.com>
Date: Sat May 24 11:45:02 2014 +0800
modify the camera position to show the whole scene
Change-Id: I0d197295046a478d59f4260f2931fbaec9a17a33
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index f7af953..ffd89ad 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1547,7 +1547,7 @@ void OpenGL3DRenderer::CreateSceneBoxView()
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.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);
commit 08c1c406055f689ef70725a13770037d7d420d5b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:41:00 2014 +0200
the destructor alreadz clears the vector
Change-Id: I085e3463251a7d73be9724ae56bd6aa3fcf50a34
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 8112ed1e..f7af953 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -734,7 +734,6 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
glDisableVertexAttribArray(maResources.m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
delete pointList;
polygon.verticesList.pop_front();
}
@@ -828,8 +827,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glDisableVertexAttribArray(maResources.m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
- normalList->clear();
delete pointList;
delete normalList;
polygon.verticesList.pop_front();
commit 2d3d63a3da88373e15c0218a9a417ad20db8b85a
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 05:07:38 2014 -0700
fix the calling of polygon API
Change-Id: I14d7e8594dae86830ca05aeb28633feac0a258cc
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index aa77743..bf8c10b 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -53,6 +53,7 @@ void Line::render()
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->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddShapePolygon3DObject();
}
@@ -131,6 +132,7 @@ void Rectangle::render()
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddPolygon3DObjectNormalPoint();
+ mpRenderer->EndAddShapePolygon3DObject();
//we should render the edge if the edge color is different from the fill color
if (maColor.GetColor() != maLineColor.GetColor())
{
@@ -140,8 +142,8 @@ void Rectangle::render()
mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
mpRenderer->EndAddPolygon3DObjectPoint();
+ mpRenderer->EndAddShapePolygon3DObject();
}
- mpRenderer->EndAddShapePolygon3DObject();
}
void Rectangle::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight)
commit 7c603d4a2313de4c870e0db792e2d7fd3dc02efa
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 05:03:37 2014 -0700
fix the polygon normal
Change-Id: I89f27b409cf04f98f90bdc61396a8c58ec91d7f7
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6f4636b..8112ed1e 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -939,7 +939,7 @@ void OpenGL3DRenderer::AddPolygon3DObjectNormalPoint(float x, float y, float z)
{
m_Polygon3DInfo.normals = new Normals3D;
}
- m_Polygon3DInfo.normals->push_back(glm::vec3(x, -y, z));
+ m_Polygon3DInfo.normals->push_back(glm::vec3(x, y, z));
}
}
commit f09e3210014a7b61f1b4bb995984e8076f519281
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 09:12:46 2014 -0700
fix polygon render
Change-Id: Id808ce630f6b3a15a31fdcfac99b332ed5f7f29f
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b75ec07..6f4636b 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -41,12 +41,10 @@ int static checkGLError(const char *file, int line)
while (glErr != GL_NO_ERROR)
{
const char* sError = OpenGLHelper::GLErrorString(glErr);
-
if (sError)
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") " << " in File " << file << " at line: " << line);
else
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available)" << " in File " << file << " at line: " << line);
-
retCode = -1;
return retCode;
}
@@ -111,6 +109,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_RenderVertexBuf);
glDeleteBuffers(1, &m_3DUBOBuffer);
glDeleteBuffers(1, &m_VertexBuffer);
+ glDeleteBuffers(1, &m_NormalBuffer);
glDeleteFramebuffers(1, &mnPickingFbo);
glDeleteRenderbuffers(1, &mnPickingRboDepth);
@@ -223,6 +222,7 @@ void OpenGL3DRenderer::init()
glGenBuffers(1, &m_CubeNormalBuf);
glGenBuffers(1, &m_CubeElementBuf);
glGenBuffers(1, &m_VertexBuffer);
+ glGenBuffers(1, &m_NormalBuffer);
glGenBuffers(1, &m_BoundBox);
glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox);
glBufferData(GL_ARRAY_BUFFER, sizeof(boundBox), boundBox, GL_STATIC_DRAW);
@@ -734,6 +734,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
glDisableVertexAttribArray(maResources.m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ pointList->clear();
delete pointList;
polygon.verticesList.pop_front();
}
@@ -755,7 +756,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
-
if(mbPickingMode)
{
glUseProgram(maPickingResources.m_CommonProID);
@@ -766,7 +766,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
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
@@ -783,6 +782,7 @@ 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);
+ CHECK_GL_ERROR();
if(!mbPickingMode)
{
@@ -798,9 +798,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
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;
-
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(maVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
@@ -811,7 +809,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
0, // stride
(void*)0 // array buffer offset
);
-
if(!mbPickingMode)
{
// 2nd attribute buffer : normals
@@ -825,14 +822,14 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
(void*)0 // array buffer offset
);
}
-
glDrawArrays(GL_POLYGON, 0, pointList->size());
-
glDisableVertexAttribArray(maVertexID);
if(!mbPickingMode)
glDisableVertexAttribArray(maResources.m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ pointList->clear();
+ normalList->clear();
delete pointList;
delete normalList;
polygon.verticesList.pop_front();
@@ -1362,6 +1359,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
RenderExtrudeSurface(extrude3DInfo);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
else
{
commit f3c47df81680fc220cc9c0b9c8aa447a9cb65ad4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:35:07 2014 +0200
adapt code to the text mapping fix
Change-Id: I8fd22529a0749f9bf1bff75534dca61f2f65312b
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 02161bc..efd27af 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -104,8 +104,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
glm::vec3 aTopLeft, aTopRight, aBottomRight;
- aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
+ aTopLeft.x = 0.0f;
aTopLeft.y = nYPos;
+ aTopRight.x = calculateTextWidth(aSeriesName) * -1.0;
aTopRight.y = nYPos;
aBottomRight = aTopRight;
aBottomRight.y += TEXT_HEIGHT;
@@ -182,12 +183,12 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
- aTopLeft.x = nXPos;
- aTopLeft.y = nYPos;
+ aTopLeft.x = nXPos + TEXT_HEIGHT;
+ aTopLeft.y = nYPos + calculateTextWidth(aCats[i]);
aTopRight = aTopLeft;
- aTopRight.x += calculateTextWidth(aCats[i]);
- aBottomRight = aTopRight;
- aBottomRight.y += TEXT_HEIGHT;
+ aTopRight.y = nYPos;
+ aBottomRight.x = nXPos;
+ aBottomRight.y = nYPos;
p->setPosition(aTopLeft, aTopRight, aBottomRight);
}
}
commit 2c75e669689107687183e0ba34b00c22056867a0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:34:34 2014 +0200
map strings correctly to 3d objects
Change-Id: I21b62a869b89c23ddba75eb8c33c30a73160098b
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b2db1e7..b75ec07 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1385,21 +1385,21 @@ void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vT
TextInfo aTextInfo;
aTextInfo.id = getColorAsVector(nUniqueId);
- aTextInfo.vertex[0] = vBottomRight.x;
- aTextInfo.vertex[1] = vBottomRight.y;
- aTextInfo.vertex[2] = vBottomRight.z * m_fHeightWeight;
+ aTextInfo.vertex[0] = vTopLeft.x;
+ aTextInfo.vertex[1] = vTopLeft.y;
+ aTextInfo.vertex[2] = vTopLeft.z * m_fHeightWeight;
aTextInfo.vertex[3] = vTopRight.x;
aTextInfo.vertex[4] = vTopRight.y;
- aTextInfo.vertex[5] = aTextInfo.vertex[2] + (vTopRight.z - vBottomRight.z);
+ aTextInfo.vertex[5] = vTopRight.z * m_fHeightWeight;
aTextInfo.vertex[9] = vBottomLeft.x;
aTextInfo.vertex[10] = vBottomLeft.y;
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);
+ aTextInfo.vertex[6] = vBottomRight.x;
+ aTextInfo.vertex[7] = vBottomRight.y;
+ aTextInfo.vertex[8] = vBottomRight.z * m_fHeightWeight;
CHECK_GL_ERROR();
glGenTextures(1, &aTextInfo.texture);
commit 609d16263ff303c1c2dd1691e90b6731ea03e7c4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:31:25 2014 +0200
GetTexBoundRect does not really return teh bounding rectangle
Change-Id: I66c996dadab51debc39a50c5e93e8c6a76842ceb
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index d9c0724..aa77743 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -80,7 +80,8 @@ Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
aDevice.Erase();
aDevice.GetTextBoundRect(aRect, rStr);
Size aSize = aRect.GetSize();
- aSize.Height() *= 2;
+ aSize.Width() += 5;
+ aSize.Height() *= 1.6;
aDevice.SetOutputSizePixel(aSize);
aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
aDevice.DrawText(Point(0,0), rStr);
commit 66120256587c88d8746095485ab0d12aea9232a6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:30:24 2014 +0200
add ostream operator<< for glm::vec3
Change-Id: Ic3ce4a647936f3f1c62c2dc3cf37f687d8fbccc1
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 475bd72..9cc485b 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -40,6 +40,7 @@ public:
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix);
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos);
+VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::vec3& rPos);
#endif
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index bace47b..a2d9b83 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -253,6 +253,12 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
return rStrm;
}
+std::ostream& operator<<(std::ostream& rStrm, const glm::vec3& rPos)
+{
+ rStrm << "( " << rPos[0] << ", " << rPos[1] << ", " << rPos[2] << ")";
+ return rStrm;
+}
+
std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
{
for(int i = 0; i < 4; ++i)
commit 53fb2cd4539aedd4b647d01eb0421c14d3da4f23
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:29:50 2014 +0200
improve text rendering
Change-Id: Idf2b0129f9d72739e934c65ccf40acf0b3000a5a
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index cbec5c3..02161bc 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -50,7 +50,7 @@ const float TEXT_HEIGHT = 15.0f;
float calculateTextWidth(const OUString& rText)
{
- return rText.getLength() * 7.5;
+ return rText.getLength() * 10;
}
}
commit d9b9f50242ece39f9ecbbb24128ae3eff4c3319e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 20:51:30 2014 +0200
avoid the creation of empty text
Change-Id: If1be3f50ed4ceac40b513b341f411fc2d2533f7f
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5b0c764..cbec5c3 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -99,15 +99,18 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
DataSeriesHelper::getDataSeriesLabel(
rDataSeries.getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
- maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
- opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
- glm::vec3 aTopLeft, aTopRight, aBottomRight;
- aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
- aTopLeft.y = nYPos;
- aTopRight.y = nYPos;
- aBottomRight = aTopRight;
- aBottomRight.y += TEXT_HEIGHT;
- p->setPosition(aTopLeft, aTopRight, aBottomRight);
+ if(!aSeriesName.isEmpty())
+ {
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
+ opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
+ glm::vec3 aTopLeft, aTopRight, aBottomRight;
+ aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
+ aTopLeft.y = nYPos;
+ aTopRight.y = nYPos;
+ aBottomRight = aTopRight;
+ aBottomRight.y += TEXT_HEIGHT;
+ p->setPosition(aTopLeft, aTopRight, aBottomRight);
+ }
sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor();
for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
@@ -172,6 +175,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
uno::Sequence<OUString> aCats = rCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
{
+ if(aCats[i].isEmpty())
+ continue;
+
float nXPos = i * (nBarSizeX + nBarDistanceX);
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
More information about the Libreoffice-commits
mailing list