Changeset 2664 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 04/29/08 16:20:37 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2663 r2664 131 131 mDetectEmptyViewSpace); 132 132 133 mSnapErrorFrames = false; 133 //mSnapErrorFrames = false; 134 mSnapErrorFrames = true; 134 135 mSnapPrefix = "snap/"; 135 136 mUseForcedColors = false; … … 706 707 for (q = 0; ((j + q) < (int)mObjects.size()) && (q < numQ); ++ q) 707 708 { 708 //glFinish();709 709 mOcclusionQueries[q]->BeginQuery(); 710 710 … … 712 712 713 713 mOcclusionQueries[q]->EndQuery(); 714 //glFinish();715 714 } 716 715 //cout << "q: " << q << endl; … … 1417 1416 void GlRendererBuffer::InitGL() 1418 1417 { 1419 MakeCurrent();1418 //MakeCurrent(); 1420 1419 GlRenderer::InitGL(); 1421 1420 1421 #if 0 1422 1422 // initialise dual depth buffer textures 1423 1423 glGenTextures(1, &frontDepthMap); … … 1442 1442 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 1443 1443 1444 #if 0 1444 1445 1445 #ifdef USE_CG 1446 1446 … … 1480 1480 #endif 1481 1481 #endif 1482 DoneCurrent();1482 //DoneCurrent(); 1483 1483 } 1484 1484 … … 1514 1514 SetupProjection(GetWidth(), GetHeight()); 1515 1515 1516 cout <<"Random Pvs STATS, mPvsStatFrames="<<mPvsStatFrames<<endl;1516 cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl; 1517 1517 1518 1518 for (int i=0; i < mPvsStatFrames; i++) { … … 1537 1537 1538 1538 1539 if (mPvsErrorBuffer[i].mError > 0.0f) { 1540 int pvsSize; 1541 1542 float error = GetPixelError(pvsSize); 1543 1544 mPvsErrorBuffer[i].mError = error; 1545 mPvsErrorBuffer[i].mPvsSize = pvsSize; 1546 1547 // emit UpdatePvsErrorItem(i, 1548 // mPvsErrorBuffer[i]); 1549 cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 1550 // swapBuffers(); 1551 } 1552 1539 if (mPvsErrorBuffer[i].mError > 0.0f) { 1540 int pvsSize; 1541 1542 float error = GetPixelError(pvsSize); 1543 1544 mPvsErrorBuffer[i].mError = error; 1545 mPvsErrorBuffer[i].mPvsSize = pvsSize; 1546 1547 cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 1548 } 1549 1553 1550 err = mPvsErrorBuffer[i].mError; 1554 1551 … … 1630 1627 { 1631 1628 // compute the pixel error 1632 float error = GetPixelError(pvsSize);1629 const float error = GetPixelError(pvsSize); 1633 1630 1634 1631 mPvsErrorBuffer[i].mError = error; 1635 1632 mPvsErrorBuffer[i].mPvsSize = pvsSize; 1636 1633 1637 int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 1638 1634 const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 1639 1635 if (0 && (pixelError > 0) && (pvsSize > 0)) 1640 1636 { 1641 cout << "!err: " << i << "," << mViewPoint << "," << mViewDirection << " " << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 1637 cout << "err: " << i << "," << mViewPoint << "," << mViewDirection << " " 1638 << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 1642 1639 } 1643 1640 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2663 r2664 168 168 virtual bool ValidViewPoint(); 169 169 170 virtual float 171 GetPixelError(int &pvsSize); 172 173 virtual void 174 EvalPvsStat(); 170 virtual float GetPixelError(int &pvsSize); 171 172 virtual void EvalPvsStat(); 175 173 176 174 void PreparePvs(const ObjectPvs &pvs); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2663 r2664 74 74 QtGlRendererBuffer::MakeCurrent() 75 75 { 76 76 makeCurrent(); 77 77 } 78 78 … … 80 80 QtGlRendererBuffer::DoneCurrent() 81 81 { 82 82 doneCurrent(); 83 83 } 84 84 85 85 86 QtGlRendererBuffer::QtGlRendererBuffer(const int w, 87 const int h, 86 QtGlRendererBuffer::QtGlRendererBuffer(int w, int h, 88 87 SceneGraph *sceneGraph, 89 88 ViewCellsManager *viewcells, 90 89 KdTree *tree): 91 QGLPixelBuffer(QSize(w, h)), 92 GlRendererBuffer(sceneGraph, viewcells, tree) 93 { 94 mUseVbos = true; 95 MakeCurrent(); 96 InitGL(); 97 DoneCurrent(); 98 } 99 100 void 101 QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs) 90 QGLPixelBuffer(QSize(w, h), QGLFormat(QGL::SampleBuffers)), 91 GlRendererBuffer(sceneGraph, viewcells, tree) 92 { 93 mUseVbos = true; 94 //mUseVbos = false; 95 96 MakeCurrent(); 97 glViewport(0, 0, w, h); 98 glMatrixMode(GL_PROJECTION); 99 glLoadIdentity(); 100 glOrtho(-1, 1, -1, 1, -99, 99); 101 //glTranslatef(-0.5f, -0.5f, 0.0f); 102 glMatrixMode(GL_MODELVIEW); 103 glLoadIdentity(); 104 105 InitGL(); 106 DoneCurrent(); 107 } 108 109 110 void QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs) 102 111 { 103 112 PreparePvs(pvs); … … 112 121 113 122 // reimplemented here so that we can snap the error windows 114 float 115 QtGlRendererBuffer::GetPixelError(int &pvsSize) 116 { 117 123 float QtGlRendererBuffer::GetPixelError(int &pvsSize) 124 { 118 125 MakeCurrent(); 119 126 127 /* 128 SetupCamera(); 129 RenderScene(); 130 */ 120 131 float pErrorPixels = -1.0f; 121 132 … … 127 138 128 139 if (viewcell == NULL) 129 return 0.0f;140 return -1.0f; 130 141 131 142 ObjectPvs pvs; … … 143 154 144 155 SetupCamera(); 156 145 157 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 146 158 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); … … 156 168 pvsSize = pvs.GetSize(); 157 169 170 if (pvsSize == 0) 171 return 0.0f; 172 158 173 RenderPvs(pvs); 159 174 … … 178 193 // reenable other state 179 194 int wait = 0; 180 181 195 while (0 && !query->ResultAvailable()) 182 {183 196 wait ++; 184 } 185 186 197 187 198 pixelCount = query->GetQueryResult(); 188 199 189 if ( (pixelCount > 0) && (pvsSize > 0))200 if (pixelCount > 0) 190 201 { 191 202 cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; … … 195 206 196 207 197 if (mSnapErrorFrames && (pixelCount > 0)) { 208 if (mSnapErrorFrames && (pixelCount > 0)) 209 { 198 210 glReadBuffer(GL_BACK); 199 211 //glReadBuffer(GL_FRONT); … … 226 238 glColor3f(0,1,0); 227 239 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 228 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 240 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 241 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 229 242 230 243 RenderPvs(pvs); … … 412 425 glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 413 426 glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 427 414 428 #if DYNAMIC_OBJECTS_HACK 415 429 // handle dynamic objects 416 430 DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 417 418 431 419 432 for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) … … 541 554 if (mUseSpatialFilter && mRenderBoxes) 542 555 { 543 for ( int i=0; i < mPvsCache.filteredBoxes.size(); ++ i)556 for (size_t i=0; i < mPvsCache.filteredBoxes.size(); ++ i) 544 557 { 545 558 RenderBox(mPvsCache.filteredBoxes[i]); … … 559 572 RenderIntersectable(viewcell); 560 573 561 /*glPushMatrix();562 glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z);563 glScalef(5.0f,5.0f,5.0f);564 glPushAttrib(GL_CURRENT_BIT);565 glColor3f(1.0f, 0.0f, 0.0f);566 // gluSphere((::GLUquadric *)mSphere,567 // 1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6);568 glPopAttrib();569 glPopMatrix();570 */571 574 mWireFrame = false; 572 575 } … … 575 578 else 576 579 { 577 //O bjectContainer::const_iterator oi = mObjects.begin();578 // for (; oi != mObjects.end(); oi++)579 // RenderIntersectable(*oi);580 //OcclusionQuery *query = mOcclusionQueries[0]; 581 //query->BeginQuery(); 582 580 583 RenderScene(); 584 585 //query->EndQuery(); 586 //int pixels = query->GetQueryResult(); 587 //cout << " pixels: " << pixels; 581 588 } 582 589 … … 611 618 612 619 glColor3f(1.0f, 0.0f, 0.0f); 613 614 620 615 621 OcclusionQuery *query = mOcclusionQueries[0]; … … 634 640 635 641 int pixelCount = query->GetQueryResult(); 636 pErrorPixels = ((float)pixelCount) /(GetWidth()*GetHeight());637 if (0) cout <<"error pixels="<<pixelCount<<endl;642 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 643 if (0) cout << "error pixels=" << pixelCount << endl; 638 644 639 645 mRenderError = pErrorPixels; … … 2335 2341 // set up the pbuffer context 2336 2342 mRenderBuffer->makeCurrent(); 2337 /*mRenderBuffer->InitGL(); 2338 2339 glViewport(0, 0, mRenderBuffer->size().width(), mRenderBuffer->size().height()); 2340 glMatrixMode(GL_PROJECTION); 2341 glLoadIdentity(); 2342 glOrtho(-1, 1, -1, 1, -99, 99); 2343 glTranslatef(-0.5f, -0.5f, 0.0f); 2344 glMatrixMode(GL_MODELVIEW); 2345 glLoadIdentity(); 2346 2347 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);*/ 2348 2343 2349 2344 // generate a texture that has the same size/format as the pbuffer 2350 2345 dynamicTexture = mRenderBuffer->generateDynamicTexture(); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2657 r2664 54 54 Q_OBJECT 55 55 public: 56 QtGlRendererBuffer(const int w, 57 const int h, 58 SceneGraph *sceneGraph, 59 ViewCellsManager *viewcells, 60 KdTree *tree); 61 62 ~QtGlRendererBuffer() {} 63 64 virtual void MakeCurrent(); 65 virtual void DoneCurrent(); 66 67 virtual int GetWidth() const { return width(); } 68 virtual int GetHeight() const { return height(); } 69 70 int ComputePvs() const { return 0; } 71 72 void 73 RenderPvs(const ObjectPvs &pvs); 74 75 float 76 GetPixelError(int &pvsSize); 77 78 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 79 80 81 82 56 QtGlRendererBuffer(int w, int h, 57 SceneGraph *sceneGraph, 58 ViewCellsManager *viewcells, 59 KdTree *tree); 60 61 ~QtGlRendererBuffer() {} 62 63 virtual void MakeCurrent(); 64 virtual void DoneCurrent(); 65 66 virtual int GetWidth() const { return width(); } 67 virtual int GetHeight() const { return height(); } 68 69 int ComputePvs() const { return 0; } 70 71 void RenderPvs(const ObjectPvs &pvs); 72 73 float GetPixelError(int &pvsSize); 74 75 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 76 83 77 public: 84 signals: 85 void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 78 79 signals: 80 void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 86 81 }; 87 82 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2615 r2664 24 24 25 25 QtGlViewer::QtGlViewer(QWidget *parent, 26 QtGlRendererWidget *renderer) :27 26 QtGlRendererWidget *renderer) 27 : QGLWidget(parent), mRenderer(renderer) 28 28 { 29 29 scale = 1.0f; … … 42 42 } 43 43 44 44 45 QSize QtGlViewer::minimumSizeHint() const 45 46 { -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2660 r2664 309 309 if (evalPixelError && (importRandomViewCells || frames)) 310 310 { 311 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) 312 { 313 cerr << "this system does not support OpenGL/pbuffers" << endl; 314 315 QMessageBox::information(0, "OpenGL pbuffers", 316 "This system does not support OpenGL/pbuffers.", 317 QMessageBox::Ok); 318 319 return NULL; 320 } 321 311 322 QGLFormat f; 312 323 f.setStencil(true); … … 329 340 330 341 if (exportRandomViewCells) 331 342 { 332 343 cout << "exporting random view cells" << endl; 333 344 preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 334 345 cout << "finished" << endl; 335 346 } 336 347 337 348 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) … … 348 359 if (!rendererWidget) 349 360 { 350 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 351 cout << "damn" << endl; 361 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) 362 { 363 cerr << "this system does not support OpenGL/pbuffers" << endl; 364 352 365 QMessageBox::information(0, "OpenGL pbuffers", 353 366 "This system does not support OpenGL/pbuffers.", 354 367 QMessageBox::Ok); 368 355 369 return NULL; 356 370 } … … 378 392 } 379 393 380 381 /*bool evaluatePixelError;382 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError", evaluatePixelError);383 384 if (evaluatePixelError)385 {386 cout << "evaluating pixel error" << endl;387 preprocessor->ComputeRenderError();388 }*/389 390 394 qApp->exec(); 391 395 } 392 #else // USE_Q UT393 394 / /#if USE_THREADS395 //pt = new BoostPreprocessorThread(preprocessor);396 //#else396 #else // USE_QT 397 398 /*#if USE_THREADS 399 pt = new BoostPreprocessorThread(preprocessor); 400 #else 397 401 // use a dummy thread 398 402 pt = new DummyPreprocessorThread(preprocessor); 399 //#endif 403 #endif 404 */ 400 405 #endif 401 406
Note: See TracChangeset
for help on using the changeset viewer.