summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/tessellation-modes/tessellatedquadmesh.cpp2
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser.cpp2
-rw-r--r--src/render/backend/renderer.cpp2
-rw-r--r--src/render/frontend/qcuboidmesh.cpp2
-rw-r--r--src/render/frontend/qcylindermesh.cpp2
-rw-r--r--src/render/frontend/qplanemesh.cpp2
-rw-r--r--src/render/frontend/qspheremesh.cpp2
-rw-r--r--src/render/frontend/qtorusmesh.cpp2
-rw-r--r--src/render/io/gltfparser.cpp2
-rw-r--r--src/render/io/objloader.cpp2
-rw-r--r--src/render/io/qmeshdata.cpp8
-rw-r--r--src/render/io/qmeshdata.h19
12 files changed, 29 insertions, 18 deletions
diff --git a/examples/tessellation-modes/tessellatedquadmesh.cpp b/examples/tessellation-modes/tessellatedquadmesh.cpp
index b6dfe2cf2..b90c89644 100644
--- a/examples/tessellation-modes/tessellatedquadmesh.cpp
+++ b/examples/tessellation-modes/tessellatedquadmesh.cpp
@@ -74,7 +74,7 @@ public:
vertexBuffer->setUsage(QOpenGLBuffer::StaticDraw);
vertexBuffer->setData(positionBytes);
- Qt3D::QMeshDataPtr mesh(new Qt3D::QMeshData(GL_PATCHES));
+ Qt3D::QMeshDataPtr mesh(new Qt3D::QMeshData(Qt3D::QMeshData::Patches));
mesh->addAttribute(Qt3D::QMeshData::defaultPositionAttributeName(),
Qt3D::AttributePtr(new Qt3D::Attribute(vertexBuffer, GL_FLOAT_VEC3, nVerts)));
mesh->setVerticesPerPatch(4);
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp
index 68a11337f..1afe1856f 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp
@@ -454,7 +454,7 @@ void AssimpParser::loadMesh(uint meshIndex)
aiMesh *mesh = m_scene->m_aiScene->mMeshes[meshIndex];
// Primitive are always triangles with the current Assimp's configuration
- QMeshDataPtr meshData(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr meshData(new QMeshData(QMeshData::Triangles));
// Mesh Name
QString meshName = QString::fromUtf8(mesh->mName.data);
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 65dfedf05..5d0b462d9 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -668,7 +668,7 @@ void Renderer::executeCommands(const QVector<RenderCommand *> &commands)
GLint primCount = meshData->primitiveCount();
GLint indexType = drawIndexed ? meshData->indexAttribute()->type() : 0;
- if (primType == GL_PATCHES && meshData->verticesPerPatch() != 0)
+ if (primType == QMeshData::Patches && meshData->verticesPerPatch() != 0)
m_graphicsContext->setVerticesPerPatch(meshData->verticesPerPatch());
if (drawIndexed) {
diff --git a/src/render/frontend/qcuboidmesh.cpp b/src/render/frontend/qcuboidmesh.cpp
index 03fefef5a..5186999bb 100644
--- a/src/render/frontend/qcuboidmesh.cpp
+++ b/src/render/frontend/qcuboidmesh.cpp
@@ -496,7 +496,7 @@ QMeshDataPtr createCuboidMesh(float xExtent,
indexBuffer->setUsage(QOpenGLBuffer::StaticDraw);
indexBuffer->setData(indexBytes);
- QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr mesh(new QMeshData(QMeshData::Triangles));
quint32 offset = 0;
mesh->addAttribute(QMeshData::defaultPositionAttributeName(),
AttributePtr(new Attribute(vertexBuffer, GL_FLOAT_VEC3, nVerts, offset, stride)));
diff --git a/src/render/frontend/qcylindermesh.cpp b/src/render/frontend/qcylindermesh.cpp
index dc5240a3e..1908ec67b 100644
--- a/src/render/frontend/qcylindermesh.cpp
+++ b/src/render/frontend/qcylindermesh.cpp
@@ -172,7 +172,7 @@ float QCylinderMesh::length() const
QMeshDataPtr assembleMesh(const QByteArray &verticesBytes, quint32 vertexSize, int verticesCount,
const QByteArray &indicesBytes, int indicesCount)
{
- QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr mesh(new QMeshData(QMeshData::Triangles));
BufferPtr verticesBuffer(new Buffer(QOpenGLBuffer::VertexBuffer));
verticesBuffer->setUsage(QOpenGLBuffer::StaticDraw);
diff --git a/src/render/frontend/qplanemesh.cpp b/src/render/frontend/qplanemesh.cpp
index ad473421f..261e1186d 100644
--- a/src/render/frontend/qplanemesh.cpp
+++ b/src/render/frontend/qplanemesh.cpp
@@ -224,7 +224,7 @@ QMeshDataPtr createPlaneMesh(float w, float h, const QSize &resolution)
buf->setData(bufferBytes);
// Create the mesh data, specify the vertex format and data
- QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr mesh(new QMeshData(QMeshData::Triangles));
quint32 offset = 0;
mesh->addAttribute(QMeshData::defaultPositionAttributeName(),
AttributePtr(new Attribute(buf, GL_FLOAT_VEC3, nVerts, offset, stride)));
diff --git a/src/render/frontend/qspheremesh.cpp b/src/render/frontend/qspheremesh.cpp
index bb0a3f9ce..b4b530983 100644
--- a/src/render/frontend/qspheremesh.cpp
+++ b/src/render/frontend/qspheremesh.cpp
@@ -176,7 +176,7 @@ float QSphereMesh::radius() const
QMeshDataPtr createSphereMesh(double radius, int rings, int slices, bool hasTangents)
{
- QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr mesh(new QMeshData(QMeshData::Triangles));
int nVerts = ( slices + 1 ) * ( rings + 1 ); // One extra line of latitude
QByteArray bufferBytes;
diff --git a/src/render/frontend/qtorusmesh.cpp b/src/render/frontend/qtorusmesh.cpp
index a8bc9b624..49f476c19 100644
--- a/src/render/frontend/qtorusmesh.cpp
+++ b/src/render/frontend/qtorusmesh.cpp
@@ -170,7 +170,7 @@ float QTorusMesh::minorRadius() const
QMeshDataPtr createTorusMesh(double radius, double minorRadius,
int rings, int sides)
{
- QMeshDataPtr mesh(new QMeshData(GL_TRIANGLES));
+ QMeshDataPtr mesh(new QMeshData(QMeshData::Triangles));
int nVerts = sides * ( rings + 1 );
QByteArray bufferBytes;
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index f41a5ed23..649482412 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -700,7 +700,7 @@ void GLTFParser::processJSONMesh( QString id, QJsonObject jsonObj )
continue;
}
- QMeshDataPtr md( new QMeshData( type ) );
+ QMeshDataPtr md( new QMeshData( static_cast<QMeshData::PrimitiveTypes>(type) ) );
m_meshMaterialDict[md.data()] = material;
QJsonObject attrs = primObj.value(KEY_ATTRIBUTES).toObject();
diff --git a/src/render/io/objloader.cpp b/src/render/io/objloader.cpp
index 4afadfae3..db4741c1f 100644
--- a/src/render/io/objloader.cpp
+++ b/src/render/io/objloader.cpp
@@ -214,7 +214,7 @@ bool ObjLoader::load(::QIODevice *ioDev)
QMeshData *ObjLoader::mesh() const
{
- QMeshData *mesh = new QMeshData(GL_TRIANGLES);
+ QMeshData *mesh = new QMeshData(QMeshData::Triangles);
QByteArray bufferBytes;
const int count = m_points.size();
diff --git a/src/render/io/qmeshdata.cpp b/src/render/io/qmeshdata.cpp
index 3cc848c64..d4f9e542c 100644
--- a/src/render/io/qmeshdata.cpp
+++ b/src/render/io/qmeshdata.cpp
@@ -56,7 +56,7 @@ QMeshDataPrivate::QMeshDataPrivate(QMeshData *qq)
{
}
-QMeshData::QMeshData(int primitiveType)
+QMeshData::QMeshData(PrimitiveTypes primitiveType)
: d_ptr(new QMeshDataPrivate(this))
{
setPrimitiveType(primitiveType);
@@ -164,13 +164,9 @@ AxisAlignedBoundingBox QMeshData::boundingBox() const
return d->m_bbox;
}
-void QMeshData::setPrimitiveType(int primitiveType)
+void QMeshData::setPrimitiveType(PrimitiveTypes primitiveType)
{
Q_D(QMeshData);
- Q_ASSERT((primitiveType == GL_TRIANGLES) ||
- (primitiveType == GL_LINES) ||
- (primitiveType == GL_POINTS) ||
- (primitiveType == GL_PATCHES));
d->m_primitiveType = primitiveType;
}
diff --git a/src/render/io/qmeshdata.h b/src/render/io/qmeshdata.h
index 0165c3ac3..a742231dd 100644
--- a/src/render/io/qmeshdata.h
+++ b/src/render/io/qmeshdata.h
@@ -60,7 +60,22 @@ typedef QSharedPointer<QAbstractBuffer> QAbstractBufferPtr;
class QT3DRENDERERSHARED_EXPORT QMeshData
{
public:
- explicit QMeshData(int primitiveType = 0);
+ enum PrimitiveTypes {
+ Points = 0x0000,
+ Lines = 0x0001,
+ LineLoop = 0x0002,
+ LineStrip = 0x0003,
+ Triangles = 0x0004,
+ TriangleStrip = 0x0005,
+ TriangleFan = 0x0006,
+ LinesAdjacency = 0x000A,
+ TrianglesAdjacency = 0x000C,
+ LineStripAdjacency = 0x000B,
+ TriangleStripAdjacency = 0x000D,
+ Patches = 0x000E
+ };
+
+ explicit QMeshData(PrimitiveTypes primitiveType = Triangles);
virtual ~QMeshData();
void addAttribute(const QString& name, QAbstractAttributePtr attr);
@@ -76,7 +91,7 @@ public:
static const QString defaultTextureCoordinateAttributeName() { return QStringLiteral("vertexTexCoord"); }
static const QString defaultTangentAttributeName() { return QStringLiteral("vertexTangent"); }
- void setPrimitiveType(int primitiveType);
+ void setPrimitiveType(PrimitiveTypes primitiveType);
int primitiveType() const;
void setVerticesPerPatch(int verticesPerPatch);