From b934115a6648086783c48b479d390c35f10ac772 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 7 Apr 2011 19:09:28 -0400 Subject: [PATCH] Incorporate Jose's patch and make vertexdatainterpreter work. --- gui/mainwindow.cpp | 2 +- gui/ui/mainwindow.ui | 8 ++++++ gui/vertexdatainterpreter.cpp | 47 ++++++++++++++++++++++------------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e02dbd8..380ef8a 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -57,7 +57,7 @@ MainWindow::MainWindow() connect(m_ui.vertexInterpretButton, SIGNAL(clicked()), m_vdataInterpreter, SLOT(interpretData())); - connect(m_ui.vertexTypeCB, SIGNAL(activated(const QString&)), + connect(m_ui.vertexTypeCB, SIGNAL(currentIndexChanged(const QString&)), m_vdataInterpreter, SLOT(setTypeFromString(const QString&))); connect(m_ui.vertexStrideSB, SIGNAL(valueChanged(int)), m_vdataInterpreter, SLOT(setStride(int))); diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index 6c7e25e..d0d1426 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -223,6 +223,11 @@ GL_FLOAT + + + GL_DOUBLE + + @@ -251,6 +256,9 @@ + + 1 + 256 diff --git a/gui/vertexdatainterpreter.cpp b/gui/vertexdatainterpreter.cpp index e00466b..7e3616e 100644 --- a/gui/vertexdatainterpreter.cpp +++ b/gui/vertexdatainterpreter.cpp @@ -7,6 +7,8 @@ #include +#include + static int sizeForType(int glType) { @@ -25,6 +27,8 @@ sizeForType(int glType) return sizeof(GLint); case GL_UNSIGNED_INT: return sizeof(GLuint); + case GL_DOUBLE: + return sizeof(GLdouble); default: return sizeof(GLint); } @@ -41,35 +45,39 @@ convertData(const QByteArray &dataArray, const char *data = dataArray.constData(); int typeSize = sizeForType(type); - int sizePerAttribute = typeSize; + int elementSize = numComponents * typeSize; + + if (!stride) + stride = elementSize; - if (stride) - sizePerAttribute = stride; + int numElements = dataArray.size() / stride; - int numElements = dataArray.size() / sizePerAttribute; + if ((numElements % numComponents) != 0) { + int temp = qFloor(dataArray.size() / (float)stride); + int fullElemSize = temp * stride; + if (fullElemSize + numComponents * typeSize <= dataArray.size()){ + /* num full elements plus the part of the buffer in which we fit */ + numElements = temp + 1; + } else { + numElements = temp; + } + } #if 0 qDebug() << "numElements = "<(m_data, m_type, m_stride, m_components); break; + case GL_DOUBLE: + lst = convertData(m_data, m_type, m_stride, m_components); + break; default: qDebug()<<"unkown gltype = "<