summaryrefslogtreecommitdiffstats
path: root/src/datavis3d/utils
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-07-22 16:51:18 +0300
committerMika Salmela <mika.salmela@digia.com>2013-07-22 16:52:38 +0300
commit51d6d0258c8d1fe0608045986792ac5601f8613f (patch)
tree95956d8f7e2f61ce2a56fc88ee094b51047078b9 /src/datavis3d/utils
parent2ba572295f102ad06ae95ec676c064909775011f (diff)
Fancy curve example and other stuff.
Change-Id: Id090ed0bedb3bec96ab6ba64b9af8205c1998f12 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavis3d/utils')
-rw-r--r--src/datavis3d/utils/abstractobjecthelper.cpp5
-rw-r--r--src/datavis3d/utils/abstractobjecthelper_p.h3
-rw-r--r--src/datavis3d/utils/objecthelper.cpp1
-rw-r--r--src/datavis3d/utils/surfaceobject.cpp23
-rw-r--r--src/datavis3d/utils/surfaceobject_p.h4
5 files changed, 23 insertions, 13 deletions
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<qreal> 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<qreal> 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<qreal> series, int columns, int rows, GLfloa
QVector<QVector3D> 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<qreal> 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<qreal> series, int columns, int rows, GLfloa
void SurfaceObject::createBuffers(const QVector<QVector3D> &vertices, const QVector<QVector2D> &uvs,
- const QVector<QVector3D> &normals, const GLushort *indices,
- const GLushort *gridIndices, bool changeGeometry)
+ const QVector<QVector3D> &normals, const GLint *indices,
+ const GLint *gridIndices, bool changeGeometry)
{
initializeOpenGLFunctions();
if (m_meshDataLoaded) {
@@ -274,12 +275,12 @@ void SurfaceObject::createBuffers(const QVector<QVector3D> &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<QVector3D> &vertices, const QVector<QVector2D> &uvs,
- const QVector<QVector3D> &normals, const GLushort *indices,
- const GLushort *gridIndices, bool changeGeometry);
+ const QVector<QVector3D> &normals, const GLint *indices,
+ const GLint *gridIndices, bool changeGeometry);
private:
QList<qreal> m_series;