43 mCamera =
new Qt3DRender::QCamera;
44 mCamera->lens()->setPerspectiveProjection( 45.0f,
float( mSize.width() ) /
float( mSize.height() ), 0.1f, 1000.0f );
45 mCamera->setPosition( QVector3D( 0, 0, 20.0f ) );
46 mCamera->setUpVector( QVector3D( 0, 1, 0 ) );
47 mCamera->setViewCenter( QVector3D( 0, 0, 0 ) );
50 mAspectEngine =
new Qt3DCore::QAspectEngine();
52#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
53 mRenderAspect =
new Qt3DRender::QRenderAspect( Qt3DRender::QRenderAspect::Threaded );
55 mRenderAspect =
new Qt3DRender::QRenderAspect();
58 mLogicAspect =
new Qt3DLogic::QLogicAspect();
60 mAspectEngine->registerAspect( mRenderAspect );
61 mAspectEngine->registerAspect( mLogicAspect );
68 mRoot =
new Qt3DCore::QEntity;
69 mRenderSettings =
new Qt3DRender::QRenderSettings( mRoot );
70 mRoot->addComponent( mRenderSettings );
72 mCamera->setParent( mRoot );
76 mOffscreenSurface =
new QOffscreenSurface();
78 QSurfaceFormat format;
81 if ( QCoreApplication::instance() && QCoreApplication::instance()->testAttribute( Qt::AA_ShareOpenGLContexts ) )
83 format = QSurfaceFormat::defaultFormat();
88 format.setRenderableType( QSurfaceFormat::OpenGL );
90 format.setVersion( 4, 1 );
91 format.setProfile( QSurfaceFormat::CoreProfile );
93 format.setVersion( 4, 3 );
94 format.setProfile( QSurfaceFormat::CoreProfile );
96 format.setDepthBufferSize( 24 );
97 format.setSamples( 4 );
98 format.setStencilBufferSize( 8 );
101 mOffscreenSurface->setFormat( format );
102 mOffscreenSurface->create();
112 mAspectEngine->setRootEntity( Qt3DCore::QEntityPtr( mRoot ) );