From 51d6d0258c8d1fe0608045986792ac5601f8613f Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 22 Jul 2013 16:51:18 +0300 Subject: Fancy curve example and other stuff. Change-Id: Id090ed0bedb3bec96ab6ba64b9af8205c1998f12 Reviewed-by: Mika Salmela --- src/datavis3d/utils/abstractobjecthelper.cpp | 5 +++++ src/datavis3d/utils/abstractobjecthelper_p.h | 3 +++ src/datavis3d/utils/objecthelper.cpp | 1 + src/datavis3d/utils/surfaceobject.cpp | 23 ++++++++++++----------- src/datavis3d/utils/surfaceobject_p.h | 4 ++-- 5 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/datavis3d/utils') diff --git a/src/datavis3d/utils/abstractobjecthelper.cpp b/src/datavis3d/utils/abstractobjecthelper.cpp index d80e416b..c75d9cf5 100644 --- a/src/datavis3d/utils/abstractobjecthelper.cpp +++ b/src/datavis3d/utils/abstractobjecthelper.cpp @@ -98,4 +98,9 @@ GLuint AbstractObjectHelper::indexCount() return m_indexCount; } +GLuint AbstractObjectHelper::indicesType() +{ + return m_indicesType; +} + QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3d/utils/abstractobjecthelper_p.h b/src/datavis3d/utils/abstractobjecthelper_p.h index 4fa9d0ec..fd565b10 100644 --- a/src/datavis3d/utils/abstractobjecthelper_p.h +++ b/src/datavis3d/utils/abstractobjecthelper_p.h @@ -69,6 +69,7 @@ public: GLuint uvBuf(); GLuint elementBuf(); GLuint indexCount(); + GLuint indicesType(); public: GLuint m_vertexbuffer; @@ -78,6 +79,8 @@ public: GLuint m_indexCount; GLboolean m_meshDataLoaded; + + GLuint m_indicesType; }; QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3d/utils/objecthelper.cpp b/src/datavis3d/utils/objecthelper.cpp index df77d395..aef1ddd0 100644 --- a/src/datavis3d/utils/objecthelper.cpp +++ b/src/datavis3d/utils/objecthelper.cpp @@ -51,6 +51,7 @@ QT_DATAVIS3D_BEGIN_NAMESPACE ObjectHelper::ObjectHelper(const QString &objectFile) : m_objectFile(objectFile) { + m_indicesType = GL_UNSIGNED_SHORT; } ObjectHelper::~ObjectHelper() diff --git a/src/datavis3d/utils/surfaceobject.cpp b/src/datavis3d/utils/surfaceobject.cpp index 32d6b65c..8fe14aee 100644 --- a/src/datavis3d/utils/surfaceobject.cpp +++ b/src/datavis3d/utils/surfaceobject.cpp @@ -51,6 +51,7 @@ QT_DATAVIS3D_BEGIN_NAMESPACE SurfaceObject::SurfaceObject() { + m_indicesType = GL_UNSIGNED_INT; } SurfaceObject::~SurfaceObject() @@ -99,10 +100,10 @@ void SurfaceObject::setUpSmoothData(QList series, int columns, int rows, vertices.at(p - columns - 1))); // Create indice table - GLushort *indices = 0; + GLint *indices = 0; if (changeGeometry) { m_indexCount = 6 * (columns - 1) * (rows - 1); - indices = new GLushort[m_indexCount]; + indices = new GLint[m_indexCount]; p = 0; for (int row = 0; row < (rows - 1) * columns; row += columns) { for (int j = 0; j < columns - 1; j++) { @@ -120,10 +121,10 @@ void SurfaceObject::setUpSmoothData(QList series, int columns, int rows, } // Create line element indices - GLushort *gridIndices = 0; + GLint *gridIndices = 0; if (changeGeometry) { m_gridIndexCount = 2 * columns * (rows - 1) + 2 * rows * (columns - 1); - gridIndices = new GLushort[m_gridIndexCount]; + gridIndices = new GLint[m_gridIndexCount]; p = 0; for (int i = 0, row = 0; i < rows; i++, row += columns) { for (int j = 0; j < columns - 1; j++) { @@ -174,11 +175,11 @@ void SurfaceObject::setUpData(QList series, int columns, int rows, GLfloa QVector normals; int doubleColumns = columns * 2 - 2; - GLushort *indices = 0; + GLint *indices = 0; int p = 0; if (changeGeometry) { m_indexCount = 6 * (columns - 1) * (rows - 1); - indices = new GLushort[m_indexCount]; + indices = new GLint[m_indexCount]; } for (int row = 0, upperRow = doubleColumns; @@ -211,7 +212,7 @@ void SurfaceObject::setUpData(QList series, int columns, int rows, GLfloa // Create grid line element indices m_gridIndexCount = 2 * columns * (rows - 1) + 2 * rows * (columns - 1); - GLushort *gridIndices = new GLushort[m_gridIndexCount]; + GLint *gridIndices = new GLint[m_gridIndexCount]; p = 0; int rowLimit = (rows - 1) * doubleColumns; for (int row = 0; row < rows * doubleColumns; row += doubleColumns) { @@ -240,8 +241,8 @@ void SurfaceObject::setUpData(QList series, int columns, int rows, GLfloa void SurfaceObject::createBuffers(const QVector &vertices, const QVector &uvs, - const QVector &normals, const GLushort *indices, - const GLushort *gridIndices, bool changeGeometry) + const QVector &normals, const GLint *indices, + const GLint *gridIndices, bool changeGeometry) { initializeOpenGLFunctions(); if (m_meshDataLoaded) { @@ -274,12 +275,12 @@ void SurfaceObject::createBuffers(const QVector &vertices, const QVec glGenBuffers(1, &m_elementbuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indexCount * sizeof(GLushort), + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indexCount * sizeof(GLint), indices, GL_STATIC_DRAW); glGenBuffers(1, &m_gridElementbuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_gridElementbuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_gridIndexCount * sizeof(GLushort), + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_gridIndexCount * sizeof(GLint), gridIndices, GL_STATIC_DRAW); } diff --git a/src/datavis3d/utils/surfaceobject_p.h b/src/datavis3d/utils/surfaceobject_p.h index 3ebac514..7ca422de 100644 --- a/src/datavis3d/utils/surfaceobject_p.h +++ b/src/datavis3d/utils/surfaceobject_p.h @@ -72,8 +72,8 @@ public: private: QVector3D normal(const QVector3D &a, const QVector3D &b, const QVector3D &c); void createBuffers(const QVector &vertices, const QVector &uvs, - const QVector &normals, const GLushort *indices, - const GLushort *gridIndices, bool changeGeometry); + const QVector &normals, const GLint *indices, + const GLint *gridIndices, bool changeGeometry); private: QList m_series; -- cgit v1.2.3