42 mCamera =
new Qt3DRender::QCamera;
43 mCamera->lens()->setPerspectiveProjection( 45.0f,
float( mSize.width() ) /
float( mSize.height() ), 0.1f, 1000.0f );
44 mCamera->setPosition( QVector3D( 0, 0, 20.0f ) );
45 mCamera->setUpVector( QVector3D( 0, 1, 0 ) );
46 mCamera->setViewCenter( QVector3D( 0, 0, 0 ) );
49 mAspectEngine =
new Qt3DCore::QAspectEngine();
51#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
52 mRenderAspect =
new Qt3DRender::QRenderAspect( Qt3DRender::QRenderAspect::Threaded );
54 mRenderAspect =
new Qt3DRender::QRenderAspect();
57 mLogicAspect =
new Qt3DLogic::QLogicAspect();
59 mAspectEngine->registerAspect( mRenderAspect );
60 mAspectEngine->registerAspect( mLogicAspect );
67 mRoot =
new Qt3DCore::QEntity;
68 mRenderSettings =
new Qt3DRender::QRenderSettings( mRoot );
69 mRoot->addComponent( mRenderSettings );
71 mCamera->setParent( mRoot );
75 mOffscreenSurface =
new QOffscreenSurface();
77 QSurfaceFormat format;
80 if ( QCoreApplication::instance() && QCoreApplication::instance()->testAttribute( Qt::AA_ShareOpenGLContexts ) )
82 format = QSurfaceFormat::defaultFormat();
87 format.setRenderableType( QSurfaceFormat::OpenGL );
89 format.setVersion( 4, 1 );
90 format.setProfile( QSurfaceFormat::CoreProfile );
92 format.setVersion( 4, 3 );
93 format.setProfile( QSurfaceFormat::CoreProfile );
95 format.setDepthBufferSize( 24 );
96 format.setSamples( 4 );
97 format.setStencilBufferSize( 8 );
100 mOffscreenSurface->setFormat( format );
101 mOffscreenSurface->create();
111 mAspectEngine->setRootEntity( Qt3DCore::QEntityPtr( mRoot ) );