22 , mPositionAttribute( new
Qt3DRender::QAttribute( this ) )
23 #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
26 , mVertexBuffer( new
Qt3DRender::QBuffer( this ) )
30 mPositionAttribute->setAttributeType( Qt3DRender::QAttribute::VertexAttribute );
31 mPositionAttribute->setBuffer( mVertexBuffer );
32 mPositionAttribute->setVertexBaseType( Qt3DRender::QAttribute::Float );
33 mPositionAttribute->setVertexSize( 3 );
34 mPositionAttribute->setByteOffset( 0 );
35 mPositionAttribute->setByteStride( 3 *
sizeof(
float ) );
36 mPositionAttribute->setName( Qt3DRender::QAttribute::defaultPositionAttributeName() );
38 addAttribute( mPositionAttribute );
44 QByteArray vertexBufferData;
45 vertexBufferData.resize( vertices.size() * 3 *
sizeof(
float ) );
46 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
48 for (
const auto &v : vertices )
50 rawVertexArray[idx++] = v.x();
51 rawVertexArray[idx++] = v.y();
52 rawVertexArray[idx++] = v.z();
55 mVertexCount = vertices.count();
56 mVertexBuffer->setData( vertexBufferData );