Commit 84a57269 by Philipp Adolf

Rename variables in mesh.{cpp,h}

parent 88c169ea
......@@ -9,29 +9,29 @@ QDebug operator<< (QDebug d, const Vertex &v) {
Mesh::SubdivEntry::SubdivEntry()
{
VB_handle = 0xFFFFFFFF;
IB_handle = 0xFFFFFFFF;
IB_Regular = 0xFFFFFFFF;
IB_irregular_handle = 0xFFFFFFFF;
IB_regular_handle = 0xFFFFFFFF;
}
Mesh::SubdivEntry::~SubdivEntry()
{
qDebug()<<"FIXME: Delete Called: num vertex:"<<vertices.size();
/*f->glDeleteBuffers(1, &VB_handle);
f->glDeleteBuffers(1, &IB_handle);
f->glDeleteBuffers(1, &IB_Regular);
f->glDeleteBuffers(1, &IB_irregular_handle);
f->glDeleteBuffers(1, &IB_regular_handle);
*/
}
void Mesh::SubdivEntry::updateIndices() {
f->glDeleteBuffers(1, &IB_handle);
f->glGenBuffers(1, &IB_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices.size(), &indices[0], GL_STATIC_DRAW);
f->glDeleteBuffers(1, &IB_Regular);
f->glGenBuffers(1, &IB_Regular);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_Regular);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indicesRegular.size(), &indicesRegular[0], GL_STATIC_DRAW);
f->glDeleteBuffers(1, &IB_irregular_handle);
f->glGenBuffers(1, &IB_irregular_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_irregular_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices_irregular.size(), &indices_irregular[0], GL_STATIC_DRAW);
f->glDeleteBuffers(1, &IB_regular_handle);
f->glGenBuffers(1, &IB_regular_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_regular_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices_regular.size(), &indices_regular[0], GL_STATIC_DRAW);
}
void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertices,
......@@ -51,19 +51,19 @@ void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f, GLuint VB_handle, QVe
this->VB_handle = VB_handle;
vertices = Vertices;
indices = Indices_irregular;
indicesRegular = patches;
indices_irregular = Indices_irregular;
indices_regular = patches;
qDebug() << "Vertices" << vertices.length();
qDebug() << "Indices irregular" << indices.length();
qDebug() << "Indices irregular" << indices_irregular.length();
qDebug() << "Indices patches" << patches.length();
f->glGenBuffers(1, &IB_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices.size(), &indices[0], GL_STATIC_DRAW);
f->glGenBuffers(1, &IB_irregular_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_irregular_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices_irregular.size(), &indices_irregular[0], GL_STATIC_DRAW);
f->glGenBuffers(1, &IB_Regular);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_Regular);
f->glGenBuffers(1, &IB_regular_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB_regular_handle);
f->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * patches.size(), &patches[0], GL_STATIC_DRAW);
}
......@@ -471,25 +471,25 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
// Draw Vertex Array
// qDebug()<<"Render"<<subdivision<<entry->indices;
// qDebug()<<"Render"<<subdivision<<entry->indices_irregular;
if(regular){
if (!entry->indicesRegular.isEmpty()) {
if (!entry->indices_regular.isEmpty()) {
f->glBindBuffer(GL_ARRAY_BUFFER, entry->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_Regular);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_regular_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 12);
f->glDrawElements(GL_PATCHES, entry->indicesRegular.size(), GL_UNSIGNED_INT, 0);
f->glDrawElements(GL_PATCHES, entry->indices_regular.size(), GL_UNSIGNED_INT, 0);
}
} else {
if (!entry->indices.isEmpty()) {
if (!entry->indices_irregular.isEmpty()) {
f->glBindBuffer(GL_ARRAY_BUFFER, entry->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_irregular_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 3);
f->glDrawElements(GL_PATCHES, entry->indices.size(), GL_UNSIGNED_INT, 0);
f->glDrawElements(GL_PATCHES, entry->indices_irregular.size(), GL_UNSIGNED_INT, 0);
}
}
}
......
......@@ -60,12 +60,12 @@ public:
~SubdivEntry();
GLuint VB_handle;
GLuint IB_handle;
GLuint IB_Regular;
GLuint IB_irregular_handle;
GLuint IB_regular_handle;
QVector<Vertex> vertices;
QVector<unsigned int> indices;
QVector<unsigned int> indicesRegular;
QVector<unsigned int> indices_irregular;
QVector<unsigned int> indices_regular;
QOpenGLFunctions_4_3_Core *f;
......
......@@ -69,10 +69,10 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
input.vb_handle = entry->VB_handle;
input.vertex_buffer = entry->vertices;
input.index_buffer = entry->indices;
input.index_buffer = entry->indices_irregular;
if (input.index_buffer.isEmpty()) {
current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indicesRegular);
current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
} else {
Tables tables = precomputeTables(input);
Result result = runShader(input, tables);
......@@ -388,12 +388,12 @@ void Subdivision::splitRegular(Mesh *mesh) {
QVector<unsigned int> regular;
QVector<unsigned int> irregular;
findRegular(current_mesh->buffers[0]->indices, current_mesh->buffers[0]->vertices, regular, irregular);
findRegular(current_mesh->buffers[0]->indicesRegular, current_mesh->buffers[0]->vertices, regular, irregular);
findRegular(current_mesh->buffers[0]->indices_irregular, current_mesh->buffers[0]->vertices, regular, irregular);
findRegular(current_mesh->buffers[0]->indices_regular, current_mesh->buffers[0]->vertices, regular, irregular);
QVector<unsigned int> patches = getPatchIndexBuffer(regular);
current_mesh->buffers[0]->indicesRegular = patches;
current_mesh->buffers[0]->indices = irregular;
current_mesh->buffers[0]->indices_regular = patches;
current_mesh->buffers[0]->indices_irregular = irregular;
current_mesh->buffers[0]->updateIndices();
qDebug() << "regular: " << regular.length();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment