fix the OpenGL offscreen rendering a bit

Change-Id: I1f11cdff0de48e3281a58aec9ea37a78c637195e
This commit is contained in:
Markus Mohrhard
2014-05-06 06:35:32 +02:00
committed by Markus Mohrhard
parent 08a02bce23
commit 81074d6080
5 changed files with 14 additions and 8 deletions

View File

@@ -21,7 +21,8 @@ namespace chart {
GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries):
maDataSeries(rDataSeries),
mxContext(new opengl3D::temporary::TemporaryContext())
mpRenderer(new opengl3D::OpenGL3DRenderer()),
mxContext(new opengl3D::temporary::TemporaryContext(mpRenderer.get()))
{
}
@@ -35,10 +36,9 @@ 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(pRenderer));
maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
sal_Int32 nSeriesIndex = 0;
sal_uInt32 nId = 1;
for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
@@ -56,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(pRenderer, aBarPosition, nId++));
maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nId++));
}
++nSeriesIndex;

View File

@@ -99,7 +99,7 @@ namespace temporary {
class TemporaryContext: public opengl3D::Renderable3DObject
{
public:
TemporaryContext();
TemporaryContext(OpenGL3DRenderer* pRenderer);
void init();
virtual void render() SAL_OVERRIDE;

View File

@@ -21,6 +21,7 @@ namespace chart {
namespace opengl3D {
class Renderable3DObject;
class OpenGL3DRenderer;
namespace temporary {
@@ -43,6 +44,7 @@ private:
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
boost::scoped_ptr<opengl3D::temporary::TemporaryContext> mxContext;
};

View File

@@ -75,8 +75,8 @@ void Camera::render()
namespace temporary {
TemporaryContext::TemporaryContext():
Renderable3DObject(NULL, -1)
TemporaryContext::TemporaryContext(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, -1)
{
}
@@ -87,6 +87,10 @@ void TemporaryContext::render()
void TemporaryContext::init()
{
maContext.init();
Size winSize(800, 600);
maContext.setWinSize(winSize);
mpRenderer->SetSize(winSize);
}
}

View File

@@ -563,7 +563,7 @@ void OpenGLContext::renderToFile()
BitmapEx aBmp = OpenGLHelper::ConvertBGRABufferToBitmapEx(buf.get(), iWidth, iHeight);
static int nIdx = 0;
OUString aName = OUString( "file:///home/moggi/Documents/work/text" ) + OUString::number( nIdx++ ) + ".png";
OUString aName = OUString( "file:///home/moggi/Documents/work/output" ) + OUString::number( nIdx++ ) + ".png";
try {
vcl::PNGWriter aWriter( aBmp );
SvFileStream sOutput( aName, STREAM_WRITE );