# HG changeset patch # User Santeri Piippo # Date 1397756911 -10800 # Node ID 46377d340c23ab357618f9855af313461bb0a86b # Parent 614b53aef8a99d1e8cbcbf3f8d196e114be7aa43 - more debug stuff.... diff -r 614b53aef8a9 -r 46377d340c23 src/glCompiler.cc --- a/src/glCompiler.cc Tue Apr 08 11:12:08 2014 +0300 +++ b/src/glCompiler.cc Thu Apr 17 20:48:31 2014 +0300 @@ -48,6 +48,7 @@ }; #include +#include #define CLOCK_INIT QTime t0; @@ -246,13 +247,34 @@ QVector vbodata; + /* + if (vbonum == vboNumber (VBOSF_Triangles, VBOCM_Surfaces)) + { + QFile f ("vbo.log"); + if (f.open (QIODevice::WriteOnly)) + { + for (auto it = m_objectInfo.begin(); it != m_objectInfo.end(); ++it) + { + if (it.key()->document() == getCurrentDocument()) + { + fprint (f, "----- #%1 (%2:%3)\n", it.key()->id(), + it.key()->document()->getDisplayName(), it.key()->lineNumber()); + const QVector& v = it.value().data[vbonum]; + + for (int i = 0; i < v.size() / 3; ++i) + fprint (f, "- %1, %2, %3\n", v[i * 3], v[1 * 3 + 1], v[1 * 3 + 2]); + } + } + + f.close(); + } + } + */ + for (auto it = m_objectInfo.begin(); it != m_objectInfo.end(); ++it) { - if (it.key()->document() == getCurrentDocument()) - { - print ("merge %1\n", it.key()->id()); + if (it.key()->document() == getCurrentDocument() && it.key()->isHidden() == false) vbodata += it->data[vbonum]; - } } glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); @@ -284,11 +306,8 @@ return; g_objectOrigins[obj] = obj->document()->getDisplayName() + ":" + QString::number (obj->lineNumber()); - - if (obj->id() == 563) - print ("compile %1\n", g_objectOrigins[obj]); - ObjectVBOInfo info; + info.isChanged = true; dropObject (obj); compileSubObject (obj, obj, &info); m_objectInfo[obj] = info; @@ -304,9 +323,9 @@ switch (poly.num) { + case 2: surface = VBOSF_Lines; numverts = 2; break; case 3: surface = VBOSF_Triangles; numverts = 3; break; case 4: surface = VBOSF_Quads; numverts = 4; break; - case 2: surface = VBOSF_Lines; numverts = 2; break; case 5: surface = VBOSF_CondLines; numverts = 2; break; default: @@ -315,6 +334,9 @@ assert (false); } + if (poly.num == 3) + print ("compile triangle %1 for #%2\n", poly.origin, topobj->id()); + for (int complement = 0; complement < VBOCM_NumComplements; ++complement) { const int vbonum = vboNumber (surface, (EVBOComplement) complement); @@ -408,8 +430,8 @@ // void GLCompiler::writeColor (QVector& array, const QColor& color) { - array << ((float) color.red()) / 255.0f - << ((float) color.green()) / 255.0f - << ((float) color.blue()) / 255.0f - << ((float) color.alpha()) / 255.0f; + array << ((GLfloat) color.red()) / 255.0f + << ((GLfloat) color.green()) / 255.0f + << ((GLfloat) color.blue()) / 255.0f + << ((GLfloat) color.alpha()) / 255.0f; } diff -r 614b53aef8a9 -r 46377d340c23 src/glCompiler.h --- a/src/glCompiler.h Tue Apr 08 11:12:08 2014 +0300 +++ b/src/glCompiler.h Thu Apr 17 20:48:31 2014 +0300 @@ -28,52 +28,53 @@ // class GLCompiler { - public: - struct ObjectVBOInfo - { - QVector data[g_numVBOs]; - }; +public: + struct ObjectVBOInfo + { + QVector data[g_numVBOs]; + bool isChanged; + }; - GLCompiler(); - ~GLCompiler(); - void compileDocument (LDDocument* doc); - void dropObject (LDObject* obj); - void initialize(); - QColor polygonColor (LDPolygon& poly, LDObject* topobj) const; - QColor indexColorForID (int id) const; - void needMerge(); - void prepareVBO (int vbonum); - void stageForCompilation (LDObject* obj); + GLCompiler(); + ~GLCompiler(); + void compileDocument (LDDocument* doc); + void dropObject (LDObject* obj); + void initialize(); + QColor polygonColor (LDPolygon& poly, LDObject* topobj) const; + QColor indexColorForID (int id) const; + void needMerge(); + void prepareVBO (int vbonum); + void stageForCompilation (LDObject* obj); - static uint32 colorToRGB (const QColor& color); + static uint32 colorToRGB (const QColor& color); - static inline int vboNumber (EVBOSurface surface, EVBOComplement complement) - { - return (surface * VBOCM_NumComplements) + complement; - } + static inline int vboNumber (EVBOSurface surface, EVBOComplement complement) + { + return (surface * VBOCM_NumComplements) + complement; + } - inline GLuint vbo (int vbonum) const - { - return m_vbo[vbonum]; - } + inline GLuint vbo (int vbonum) const + { + return m_vbo[vbonum]; + } - inline int vboCount (int vbonum) const - { - return m_vboSizes[vbonum] / 3; - } + inline int vboSize (int vbonum) const + { + return m_vboSizes[vbonum]; + } - private: - void compileStaged(); - void compileObject (LDObject* obj); - void compileSubObject (LDObject* obj, LDObject* topobj, GLCompiler::ObjectVBOInfo* objinfo); - void writeColor (QVector& array, const QColor& color); - void compilePolygon (LDPolygon& poly, LDObject* topobj, GLCompiler::ObjectVBOInfo* objinfo); +private: + void compileStaged(); + void compileObject (LDObject* obj); + void compileSubObject (LDObject* obj, LDObject* topobj, GLCompiler::ObjectVBOInfo* objinfo); + void writeColor (QVector& array, const QColor& color); + void compilePolygon (LDPolygon& poly, LDObject* topobj, GLCompiler::ObjectVBOInfo* objinfo); - QMap m_objectInfo; - LDObjectList m_staged; // Objects that need to be compiled - GLuint m_vbo[g_numVBOs]; - bool m_vboChanged[g_numVBOs]; - int m_vboSizes[g_numVBOs]; + QMap m_objectInfo; + LDObjectList m_staged; // Objects that need to be compiled + GLuint m_vbo[g_numVBOs]; + bool m_vboChanged[g_numVBOs]; + int m_vboSizes[g_numVBOs]; }; #define checkGLError() { checkGLError_private (__FILE__, __LINE__); } diff -r 614b53aef8a9 -r 46377d340c23 src/glRenderer.cc --- a/src/glRenderer.cc Tue Apr 08 11:12:08 2014 +0300 +++ b/src/glRenderer.cc Thu Apr 17 20:48:31 2014 +0300 @@ -468,7 +468,8 @@ m_compiler->prepareVBO (colornum); GLuint surfacevbo = m_compiler->vbo (surfacenum); GLuint colorvbo = m_compiler->vbo (colornum); - GLsizei count = m_compiler->vboCount (surfacevbo); + GLsizei count = m_compiler->vboSize (surfacevbo) / 3; + print ("Count: %1\n", (int) count ); if (count > 0) { @@ -576,12 +577,12 @@ return; #ifndef RELEASE - if (isPicking() == false) + if (not isPicking()) { QString text = format ("Rotation: (%1, %2, %3)\nPanning: (%4, %5), Zoom: %6", rot(X), rot(Y), rot(Z), pan(X), pan(Y), zoom()); QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); - + paint.setPen (textpen); paint.drawText ((width() - textSize.width()) / 2, height() - textSize.height(), textSize.width(), textSize.height(), Qt::AlignCenter, text); } @@ -1240,6 +1241,13 @@ // Go through each pixel read and add them to the selection. for (qint32 i = 0; i < numpixels; ++i) { + QList selfloats; + selfloats << ((float) pixelptr[0]) / 255.0f; + selfloats << ((float) pixelptr[1]) / 255.0f; + selfloats << ((float) pixelptr[2]) / 255.0f; + selfloats << ((float) pixelptr[3]) / 255.0f; + print ("selection: %1\n", selfloats); + qint32 idx = (*(pixelptr + 0) * 0x10000) + (*(pixelptr + 1) * 0x100) + @@ -1249,7 +1257,7 @@ if (idx == 0xFFFFFF) continue; // White is background; skip - dprint ("id: %1\n", idx); + dvalof (idx); LDObject* obj = LDObject::fromID (idx); assert (obj != null); diff -r 614b53aef8a9 -r 46377d340c23 src/ldDocument.cc --- a/src/ldDocument.cc Tue Apr 08 11:12:08 2014 +0300 +++ b/src/ldDocument.cc Thu Apr 17 20:48:31 2014 +0300 @@ -1306,7 +1306,6 @@ g_win->buildObjList(); g_win->updateTitle(); g_win->R()->setDocument (f); - g_win->R()->repaint(); g_win->R()->compiler()->needMerge(); print ("Changed file to %1", f->getDisplayName()); }