Skip to content
Permalink
Browse files

Allow offscreen image size configuration

  • Loading branch information
wonder-sk committed Jul 18, 2018
1 parent 6884053 commit 89d3fda4d6ec06b247fa39d26ce28a8f5c217b48
Showing with 20 additions and 3 deletions.
  1. +17 −3 src/3d/qgsoffscreen3dengine.cpp
  2. +3 −0 src/3d/qgsoffscreen3dengine.h
@@ -33,8 +33,6 @@
#include <Qt3DRender/QTexture>
#include <Qt3DRender/QViewport>

// TODO: set size
// TODO: destructor

QgsOffscreen3DEngine::QgsOffscreen3DEngine()
{
@@ -48,7 +46,7 @@ QgsOffscreen3DEngine::QgsOffscreen3DEngine()

// Set up a camera to point at the shapes.
mCamera = new Qt3DRender::QCamera;
mCamera->lens()->setPerspectiveProjection( 45.0f, 1200.0f / 800.0f, 0.1f, 1000.0f );
mCamera->lens()->setPerspectiveProjection( 45.0f, float( mSize.width() ) / float( mSize.height() ), 0.1f, 1000.0f );
mCamera->setPosition( QVector3D( 0, 0, 20.0f ) );
mCamera->setUpVector( QVector3D( 0, 1, 0 ) );
mCamera->setViewCenter( QVector3D( 0, 0, 0 ) );
@@ -84,6 +82,22 @@ QgsOffscreen3DEngine::QgsOffscreen3DEngine()

}

QgsOffscreen3DEngine::~QgsOffscreen3DEngine()
{
delete mAspectEngine;
}

void QgsOffscreen3DEngine::setSize( const QSize &s )
{
mSize = s;

mTexture->setSize( mSize.width(), mSize.height() );
mDepthTexture->setSize( mSize.width(), mSize.height() );
mSurfaceSelector->setExternalRenderTargetSize( mSize );

mCamera->setAspectRatio( float( mSize.width() ) / float( mSize.height() ) );
}

void QgsOffscreen3DEngine::setClearColor( const QColor &color )
{
mClearBuffers->setClearColor( color );
@@ -39,6 +39,9 @@ class _3D_EXPORT QgsOffscreen3DEngine : public QgsAbstract3DEngine
Q_OBJECT
public:
QgsOffscreen3DEngine();
~QgsOffscreen3DEngine();

void setSize( const QSize &s );

void setClearColor( const QColor &color ) override;
void setFrustumCullingEnabled( bool enabled ) override;

0 comments on commit 89d3fda

Please sign in to comment.
You can’t perform that action at this time.