Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow offscreen image size configuration
  • Loading branch information
wonder-sk committed Jul 19, 2018
1 parent 6884053 commit 89d3fda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/3d/qgsoffscreen3dengine.cpp
Expand Up @@ -33,8 +33,6 @@
#include <Qt3DRender/QTexture>
#include <Qt3DRender/QViewport>

// TODO: set size
// TODO: destructor

QgsOffscreen3DEngine::QgsOffscreen3DEngine()
{
Expand All @@ -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 ) );
Expand Down Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/3d/qgsoffscreen3dengine.h
Expand Up @@ -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;
Expand Down

0 comments on commit 89d3fda

Please sign in to comment.