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->setName( Qt3DRender::QAttribute::defaultPositionAttributeName() );
36 addAttribute( mPositionAttribute );
42 QByteArray vertexBufferData;
43 vertexBufferData.resize( vertices.size() * 3 *
sizeof(
float ) );
44 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
46 for (
const auto &v : vertices )
48 rawVertexArray[idx++] = v.x();
49 rawVertexArray[idx++] = v.y();
50 rawVertexArray[idx++] = v.z();
53 mVertexCount = vertices.count();
54 mVertexBuffer->setData( vertexBufferData );