41 QSurfaceFormat format;
47 format.setRenderableType( QSurfaceFormat::OpenGLES );
49 if ( QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL )
51 format.setVersion( 4, 3 );
52 format.setProfile( QSurfaceFormat::CoreProfile );
56 format.setMajorVersion( 3 );
57 format.setDepthBufferSize( 32 );
58 format.setSamples( 8 );
59 QSurfaceFormat::setDefaultFormat( format );
62 mCamera =
new Qt3DRender::QCamera;
63 mCamera->lens()->setPerspectiveProjection( 45.0f,
float( mSize.width() ) /
float( mSize.height() ), 0.1f, 1000.0f );
64 mCamera->setPosition( QVector3D( 0, 0, 20.0f ) );
65 mCamera->setUpVector( QVector3D( 0, 1, 0 ) );
66 mCamera->setViewCenter( QVector3D( 0, 0, 0 ) );
69 mAspectEngine =
new Qt3DCore::QAspectEngine();
71#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
72 mRenderAspect =
new Qt3DRender::QRenderAspect( Qt3DRender::QRenderAspect::Threaded );
74 mRenderAspect =
new Qt3DRender::QRenderAspect();
77 mLogicAspect =
new Qt3DLogic::QLogicAspect();
79 mAspectEngine->registerAspect( mRenderAspect );
80 mAspectEngine->registerAspect( mLogicAspect );
87 mRoot =
new Qt3DCore::QEntity;
88 mRenderSettings =
new Qt3DRender::QRenderSettings( mRoot );
89 mRoot->addComponent( mRenderSettings );
91 mCamera->setParent( mRoot );
95 mOffscreenSurface =
new QOffscreenSurface();
96 mOffscreenSurface->setFormat( QSurfaceFormat::defaultFormat() );
97 mOffscreenSurface->create();
107 mAspectEngine->setRootEntity( Qt3DCore::QEntityPtr( mRoot ) );