summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/view/charttypes/GL3DBarChart.cxx6
-rw-r--r--chart2/source/view/inc/3DChartObjects.hxx17
-rw-r--r--chart2/source/view/main/3DChartObjects.cxx61
3 files changed, 32 insertions, 52 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 160f40eaa143..9bb94f54e4e3 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -15,6 +15,7 @@
#include <glm/gtx/transform.hpp>
#include "3DChartObjects.hxx"
+#include "GL3DRenderer.hxx"
namespace chart {
@@ -34,9 +35,10 @@ void GL3DBarChart::create3DShapes()
const float nBarSizeY = 10;
const float nBarDistanceX = nBarSizeX / 2;
const float nBarDistanceY = nBarSizeY / 2;
+ opengl3D::OpenGL3DRenderer* pRenderer = NULL;
maShapes.clear();
- maShapes.push_back(new opengl3D::Camera());
+ maShapes.push_back(new opengl3D::Camera(pRenderer));
sal_Int32 nSeriesIndex = 0;
sal_uInt32 nId = 1;
for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
@@ -54,7 +56,7 @@ void GL3DBarChart::create3DShapes()
glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
- maShapes.push_back(new opengl3D::Bar(aBarPosition, nId++));
+ maShapes.push_back(new opengl3D::Bar(pRenderer, aBarPosition, nId++));
}
++nSeriesIndex;
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index a4378711e08f..9e964ff8f1c6 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -22,7 +22,7 @@ namespace opengl3D {
class Renderable3DObject
{
public:
- Renderable3DObject(sal_uInt32 nId);
+ Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
virtual ~Renderable3DObject() {};
@@ -31,14 +31,14 @@ public:
OpenGL3DRenderer* getRender();
protected:
+ OpenGL3DRenderer* mpRenderer;
sal_uInt32 mnUniqueId;
- static OpenGL3DRenderer* mPrender;
};
class Bar : public Renderable3DObject
{
public:
- Bar( const glm::mat4& rPosition, sal_uInt32 nId );
+ Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
private:
@@ -50,7 +50,7 @@ private:
class Line : public Renderable3DObject
{
public:
- Line( sal_uInt32 nId );
+ Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
@@ -63,7 +63,7 @@ private:
class Text : public Renderable3DObject
{
public:
- Text( sal_uInt32 nId );
+ Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
private:
BitmapEx maText;
glm::vec3 maTopLeft;
@@ -74,7 +74,7 @@ private:
class Rectangle : public Renderable3DObject
{
public:
- Rectangle( sal_uInt32 nId );
+ Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
private:
glm::vec3 maTopLeft;
glm::vec3 maTopRight;
@@ -86,7 +86,7 @@ private:
class Camera : public Renderable3DObject
{
public:
- Camera();
+ Camera(OpenGL3DRenderer* pRenderer);
virtual void render() SAL_OVERRIDE;
private:
glm::vec3 maPos;
@@ -106,9 +106,6 @@ public:
private:
OpenGLContext maContext;
-
- int miWidth;
- int miHeight;
};
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 045107be730b..6e3df0c4f5ee 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -13,9 +13,8 @@ namespace chart {
namespace opengl3D {
-OpenGL3DRenderer* Renderable3DObject::mPrender = NULL;
-
-Renderable3DObject::Renderable3DObject(sal_uInt32 nId):
+Renderable3DObject::Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+ mpRenderer(pRenderer),
mnUniqueId(nId)
{
}
@@ -25,20 +24,8 @@ void Renderable3DObject::render()
(void) mnUniqueId;
}
-OpenGL3DRenderer* Renderable3DObject::getRender()
-{
- if(mPrender==NULL)
- {
- mPrender = new OpenGL3DRenderer();
- mPrender->init();
- mPrender->Set3DSenceInfo();
- }
- return mPrender;
-}
-
-
-Bar::Bar(const glm::mat4& rPosition, sal_uInt32 nId)
- : Renderable3DObject(nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nId)
+ : Renderable3DObject(pRenderer, nId)
, mbRoundedCorners(false)
, maPos(rPosition)
{
@@ -49,31 +36,31 @@ void Bar::render()
(void) mbRoundedCorners;
}
-Line::Line(sal_uInt32 nId):
- Renderable3DObject(nId)
+Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+ Renderable3DObject(pRenderer, nId)
{
}
void Line::render()
{
- getRender()->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
- getRender()->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
- getRender()->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
- getRender()->EndAddShapePolygon3DObject();
+ mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
+ mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
+ mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
+ mpRenderer->EndAddShapePolygon3DObject();
}
-Text::Text(sal_uInt32 nId):
- Renderable3DObject(nId)
+Text::Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+ Renderable3DObject(pRenderer, nId)
{
}
-Rectangle::Rectangle(sal_uInt32 nId):
- Renderable3DObject(nId)
+Rectangle::Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+ Renderable3DObject(pRenderer, nId)
{
}
-Camera::Camera():
- Renderable3DObject(0),
+Camera::Camera(OpenGL3DRenderer* pRenderer):
+ Renderable3DObject(pRenderer, 0),
maPos(10,10,-10),
maUp(0, 1, 0),
maDirection(glm::vec3(0,0,0)-maPos)
@@ -82,30 +69,24 @@ Camera::Camera():
void Camera::render()
{
- getRender()->SetCameraInfo(maPos, maDirection, maUp, true);
+ mpRenderer->SetCameraInfo(maPos, maDirection, maUp, true);
}
namespace temporary {
TemporaryContext::TemporaryContext():
- Renderable3DObject(-1),
- miWidth(200),
- miHeight(200)
+ Renderable3DObject(NULL, -1)
{
}
-void TemporaryContext::init()
+void TemporaryContext::render()
{
- maContext.init();
- Size winSize(miWidth, miHeight);
- maContext.setWinSize(winSize);
- getRender()->SetSize(winSize);
+ maContext.renderToFile();
}
-void TemporaryContext::render()
+void TemporaryContext::init()
{
- maContext.renderToFile();
}
}