QGLBuffer* Visualizer::WriteBufferData(QVector<QVector3D> vertices, QVector<QVector3D> colors) { QGLBuffer* tmp = new QGLBuffer; tmp->create(); tmp->bind(); int offset = 0; tmp->allocate(vertices.size() * (3+3) * sizeof (GLfloat)); tmp->write(offset, vertices.constData() , vertices.size() * 3 * sizeof (GLfloat)); offset += vertices.size() * 3 * sizeof (GLfloat); tmp->write(offset, colors.constData(), colors.size() * 3 * sizeof (GLfloat)); tmp->release(); return tmp; }
QGLBuffer *Visualizer::WriteBufferData(QVector<QVector3D> vertices, QVector<QVector3D> normals, QVector<QVector2D> textures) { QGLBuffer* tmp = new QGLBuffer; tmp->create(); tmp->bind(); int offset = 0; tmp->allocate(vertices.size() * (3+3+2) * sizeof (GLfloat)); tmp->write(offset, vertices.constData() , vertices.size() * 3 * sizeof (GLfloat)); offset += vertices.size() * 3 * sizeof (GLfloat); tmp->write(offset, normals.constData(), normals.size() * 3 * sizeof (GLfloat)); offset += normals.size() * 3 * sizeof (GLfloat); tmp->write(offset, textures.constData(), textures.size() * 2 * sizeof (GLfloat)); tmp->release(); return tmp; }