code format
This commit is contained in:
@@ -19,19 +19,19 @@
|
||||
#ifndef GLVBO_H
|
||||
#define GLVBO_H
|
||||
|
||||
#include "gltypes.h"
|
||||
#include "chunkstream.h"
|
||||
#include "gltypes.h"
|
||||
|
||||
class GLVBO : protected QOpenGLFunctions
|
||||
{
|
||||
class GLVBO: protected QOpenGLFunctions {
|
||||
friend class GLObjectBase;
|
||||
friend QDataStream & operator <<(QDataStream & s, const GLVBO & m);
|
||||
friend QDataStream & operator >>(QDataStream & s, GLVBO & m);
|
||||
friend QDataStream & operator<<(QDataStream & s, const GLVBO & m);
|
||||
friend QDataStream & operator>>(QDataStream & s, GLVBO & m);
|
||||
|
||||
public:
|
||||
GLVBO(GLenum usage = GL_DYNAMIC_DRAW);
|
||||
~GLVBO();
|
||||
|
||||
//GLVBO & operator =(const GLVBO & o) {return *this;}
|
||||
// GLVBO & operator =(const GLVBO & o) {return *this;}
|
||||
|
||||
void init();
|
||||
void destroy();
|
||||
@@ -39,15 +39,27 @@ public:
|
||||
void draw(GLenum type, QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
void clear();
|
||||
|
||||
GLuint buffer() const {return buffer_;}
|
||||
int verticesCount() const {return vertices_.size() / 3;}
|
||||
bool isInit() const {return buffer_ != 0;}
|
||||
bool isEmpty() const {return vertices_.size() < 3;}
|
||||
GLuint buffer() const { return buffer_; }
|
||||
int verticesCount() const { return vertices_.size() / 3; }
|
||||
bool isInit() const { return buffer_ != 0; }
|
||||
bool isEmpty() const { return vertices_.size() < 3; }
|
||||
|
||||
QVector<GLfloat> & vertices() {changed = true; return vertices_;}
|
||||
QVector<GLfloat> & normals() {changed = true; return normals_;}
|
||||
QVector<GLfloat> & texcoords() {changed = true; return texcoords_;}
|
||||
QVector<GLfloat> & colors() {changed = true; return colors_;}
|
||||
QVector<GLfloat> & vertices() {
|
||||
changed = true;
|
||||
return vertices_;
|
||||
}
|
||||
QVector<GLfloat> & normals() {
|
||||
changed = true;
|
||||
return normals_;
|
||||
}
|
||||
QVector<GLfloat> & texcoords() {
|
||||
changed = true;
|
||||
return texcoords_;
|
||||
}
|
||||
QVector<GLfloat> & colors() {
|
||||
changed = true;
|
||||
return colors_;
|
||||
}
|
||||
|
||||
void translatePoints(const QVector3D & dp);
|
||||
void scalePoints(const QVector3D & dp);
|
||||
@@ -66,29 +78,30 @@ private:
|
||||
GLuint buffer_, va_;
|
||||
int vert_count;
|
||||
bool changed, has_normals, has_texcoords, has_colors, has_binormals;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const GLVBO & m) {
|
||||
inline QDataStream & operator<<(QDataStream & s, const GLVBO & m) {
|
||||
ChunkStream cs;
|
||||
//qDebug() << "place VBO" << m.vertices_.size() << m.normals_.size() << m.texcoords_.size() << m.colors_.size() << "...";
|
||||
cs << cs.chunk(1, m.vertices_) << cs.chunk(2, m.normals_) << cs.chunk(3, m.texcoords_) << cs.chunk(4, m.colors_) << cs.chunk(5, m.usage);
|
||||
//qDebug() << "place VBO done" << cs.data().size() << "...";
|
||||
s << qCompress(cs.data()); return s;
|
||||
// qDebug() << "place VBO" << m.vertices_.size() << m.normals_.size() << m.texcoords_.size() << m.colors_.size() << "...";
|
||||
cs << cs.chunk(1, m.vertices_) << cs.chunk(2, m.normals_) << cs.chunk(3, m.texcoords_) << cs.chunk(4, m.colors_)
|
||||
<< cs.chunk(5, m.usage);
|
||||
// qDebug() << "place VBO done" << cs.data().size() << "...";
|
||||
s << qCompress(cs.data());
|
||||
return s;
|
||||
}
|
||||
inline QDataStream & operator >>(QDataStream & s, GLVBO & m) {
|
||||
inline QDataStream & operator>>(QDataStream & s, GLVBO & m) {
|
||||
QByteArray ba;
|
||||
s >> ba;
|
||||
ba = qUncompress(ba);
|
||||
ChunkStream cs(ba);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: m.vertices_ = cs.getData<QVector<GLfloat> >(); break;
|
||||
case 2: m.normals_ = cs.getData<QVector<GLfloat> >(); break;
|
||||
case 3: m.texcoords_ = cs.getData<QVector<GLfloat> >(); break;
|
||||
case 4: m.colors_ = cs.getData<QVector<GLfloat> >(); break;
|
||||
case 5: m.usage = cs.getData<GLenum>(); break;
|
||||
case 1: m.vertices_ = cs.getData<QVector<GLfloat>>(); break;
|
||||
case 2: m.normals_ = cs.getData<QVector<GLfloat>>(); break;
|
||||
case 3: m.texcoords_ = cs.getData<QVector<GLfloat>>(); break;
|
||||
case 4: m.colors_ = cs.getData<QVector<GLfloat>>(); break;
|
||||
case 5: m.usage = cs.getData<GLenum>(); break;
|
||||
}
|
||||
}
|
||||
m.changed = true;
|
||||
|
||||
Reference in New Issue
Block a user