20#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
21#include <Qt3DRender/QAttribute>
22#include <Qt3DRender/QBuffer>
23#include <Qt3DRender/QGeometry>
29#include <Qt3DCore/QAttribute>
30#include <Qt3DCore/QBuffer>
31#include <Qt3DCore/QGeometry>
38#include <Qt3DRender/QGeometryRenderer>
39#include <Qt3DRender/QTechnique>
40#include <Qt3DRender/QGraphicsApiFilter>
41#include <Qt3DRender/QDepthTest>
42#include <Qt3DRender/QEffect>
51 const QVector<float> vert = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f };
53 const QByteArray vertexArr( (
const char * ) vert.constData(), vert.size() *
sizeof(
float ) );
56 vertexBuffer->setData( vertexArr );
58 positionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
59 positionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
60 positionAttribute->setVertexSize( 3 );
61 positionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
62 positionAttribute->setBuffer( vertexBuffer );
63 positionAttribute->setByteOffset( 0 );
64 positionAttribute->setByteStride( 3 *
sizeof(
float ) );
65 positionAttribute->setCount( 6 );
67 geom->addAttribute( positionAttribute );
69 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer(
this );
70 renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::PrimitiveType::Triangles );
71 renderer->setGeometry( geom );
73 addComponent( renderer );
75 mMaterial =
new Qt3DRender::QMaterial(
this );
77 Qt3DRender::QEffect *effect =
new Qt3DRender::QEffect(
this );
78 Qt3DRender::QTechnique *technique =
new Qt3DRender::QTechnique(
this );
79 Qt3DRender::QGraphicsApiFilter *graphicsApiFilter = technique->graphicsApiFilter();
80 graphicsApiFilter->setApi( Qt3DRender::QGraphicsApiFilter::Api::OpenGL );
81 graphicsApiFilter->setProfile( Qt3DRender::QGraphicsApiFilter::OpenGLProfile::CoreProfile );
82 graphicsApiFilter->setMajorVersion( 3 );
83 graphicsApiFilter->setMinorVersion( 1 );
84 Qt3DRender::QRenderPass *renderPass =
new Qt3DRender::QRenderPass(
this );
85 mShader =
new Qt3DRender::QShaderProgram(
this );
87 renderPass->setShaderProgram(
mShader );
89 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest(
this );
90 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
92 renderPass->addRenderState( depthTest );
94 technique->addRenderPass( renderPass );
96 effect->addTechnique( technique );
101 mLayer =
new Qt3DRender::QLayer(
this );
102 mLayer->setRecursive(
true );
Qt3DRender::QLayer * mLayer
QgsRenderPassQuad(QNode *parent=nullptr)
Constructor.
Qt3DRender::QShaderProgram * mShader
Qt3DRender::QMaterial * mMaterial
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry