- Timestamp:
- 06/01/06 18:57:28 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r997 r1000 470 470 } 471 471 472 472 std::ofstream outfile("try_100.txt"); 473 473 void 474 474 GlRendererBuffer::EvalQueryWithOcclusionQueries( … … 480 480 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 481 481 glDepthMask(GL_FALSE); 482 483 484 // simulate detectemptyviewspace using backface culling 485 /*if (mDetectEmptyViewSpace) 486 { 487 glEnable(GL_CULL_FACE); 488 cout << "culling" << endl; 489 } 490 else 491 { 492 cout << "not culling" << endl; 493 glDisable(GL_CULL_FACE); 494 }*/ 495 496 497 const int numQ = 500;//(int)mOcclusionQueries.size(); 498 499 //outfile << "\n**************" << endl; 500 glFinish(); 501 //-- now issue queries for all objects 502 for (int j = 0; j < (int)mObjects.size(); ++ j) 503 { 504 for (int q = 0; ((j + q) < (int)mObjects.size()) && (q < numQ); ++ q) 505 { 506 //glFinish(); 507 // outfile << "queries: " << mOcclusionQueries[q] << " "; 508 glBeginOcclusionQueryNV(mOcclusionQueries[q]); 509 510 RenderIntersectable(mObjects[j + q]); 482 511 483 // now issue queries for all objects 484 for (int j = 0; j < mObjects.size(); ++ j) 485 { 486 for (int q = 0; j + q < mObjects.size() && q < mOcclusionQueries.size(); ++ q) 487 { 488 glBeginOcclusionQueryNV(mOcclusionQueries[q]); 489 490 RenderIntersectable(mObjects[j + q]); 512 glFlush(); 491 513 glEndOcclusionQueryNV(); 514 //glFinish(); 492 515 } 493 516 517 // outfile << endl; 494 518 // collect results of the queries 495 for (int q = 0; j + q < mObjects.size() && q < mOcclusionQueries.size(); ++ q)519 for (int q = 0; ((j + q) < (int)mObjects.size()) && (q < numQ); ++ q) 496 520 { 497 521 unsigned int pixelCount; … … 501 525 do 502 526 { 503 glGetOcclusionQueryuivNV(mOcclusionQueries[q], 504 GL_PIXEL_COUNT_AVAILABLE_NV, 505 &pixelCount); 527 glGetOcclusionQueryuivNV(mOcclusionQueries[q], GL_PIXEL_COUNT_AVAILABLE_NV, &pixelCount); 506 528 507 if ( 0 && !pixelCount) cout << "W";529 if (pixelCount == 0) cout << "W"; 508 530 } 509 531 while (!pixelCount); 510 532 #endif 511 533 512 glGetOcclusionQueryuivNV(mOcclusionQueries[q], 513 GL_PIXEL_COUNT_NV, 514 &pixelCount); 515 516 // if (pixelCount) 517 // cout<<"q="<<mOcclusionQueries[q]<<" pc="<<pixelCount<<" "; 518 534 glGetOcclusionQueryuivNV(mOcclusionQueries[q], GL_PIXEL_COUNT_NV, &pixelCount); 535 536 if (pixelCount > 0) 537 outfile <<"o="<<j+q<<" q="<<mOcclusionQueries[q]<<" pc="<<pixelCount<<" "; 538 519 539 mObjects[j + q]->mCounter += pixelCount; 520 540 } … … 522 542 j += q; 523 543 } 524 544 545 glFinish(); 525 546 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 526 547 glDepthMask(GL_TRUE); 548 549 glEnable(GL_CULL_FACE); 527 550 } 528 551 … … 552 575 int i, j; 553 576 554 // reset object visibility 555 for (i=0; i < mObjects.size(); i++) 577 ObjectContainer::const_iterator it, it_end = mObjects.end(); 578 579 for (it = mObjects.begin(); it != it_end; ++ it) 556 580 { 557 mObjects[i]->mCounter = 0;581 (*it)->mCounter = 0; 558 582 } 559 583 … … 567 591 //else cout << "using item buffer" << endl; 568 592 569 glCullFace(GL_FRONT); 570 571 if (mDetectEmptyViewSpace) 572 { 573 glEnable(GL_CULL_FACE); 574 cout << "culling" << endl; 575 } 576 else 577 { 578 cout << "not culling" << endl; 579 glDisable(GL_CULL_FACE); 580 } 593 //glCullFace(GL_FRONT); 594 glCullFace(GL_BACK); 581 595 582 596 for (i = 0; i < 6; ++ i) … … 590 604 mUseFalseColors = true; 591 605 592 593 606 // the actual scene rendering 594 595 607 RenderScene(); 596 608 … … 618 630 sample.Reset(); 619 631 620 for ( j = 0; j < mObjects.size(); j++)632 for (it = mObjects.begin(); it != it_end; ++ it) 621 633 { 622 if (mObjects[j]->mCounter) 634 Intersectable *obj = *it; 635 if (obj->mCounter) 623 636 { 624 637 ++ sample.mVisibleObjects; 625 sample.mVisiblePixels += mObjects[j]->mCounter;638 sample.mVisiblePixels += obj->mCounter; 626 639 } 627 640 } 628 641 629 cout << "RS=" << sample.mVisibleObjects << " "; 630 } 642 outfile << "RS=" << sample.mVisibleObjects << " "; 643 } 644 631 645 632 646 void … … 646 660 halton.Reset(); 647 661 648 int i; 649 int numQ = 500; 650 651 652 if (mOcclusionQueries.size() < numQ) 662 // the number of queries simultanosly allocated 663 const int numQ = 400; 664 //const int numQ = 3; 665 #if 1 666 for (int i = (int)mOcclusionQueries.size(); i < numQ; ++ i) 667 { 668 unsigned int query; 669 glGenOcclusionQueriesNV(1, &query); 670 mOcclusionQueries.push_back(query); 671 //mOcclusionQueries[i] = queries[i]; 672 } 673 #else 674 if ((int)mOcclusionQueries.size() < numQ) 653 675 { 654 676 cout << "allocating occ queries..." << endl; … … 657 679 658 680 // matt: ? 659 for (i = 0; i < numQ; ++ i)681 for (int i = 0; i < numQ; ++ i) 660 682 queries[i] = 111; 661 683 662 684 glGenOcclusionQueriesNV(numQ, queries); 663 664 685 mOcclusionQueries.resize(numQ); 665 666 for (i = 0; i < numQ; ++ i) 667 { 668 mOcclusionQueries[i] = queries[i]; 669 } 686 670 687 671 DEL_PTR(queries); 672 } 673 674 for (i = 0; i < n; ++ i) 688 for (int i = 0; i < numQ; ++ i) 689 { 690 mOcclusionQueries[i] = queries[i]; 691 } 692 693 DEL_PTR(queries); 694 } 695 #endif 696 697 for (int i = 0; i < n; ++ i) 675 698 { 676 699 EvalRenderCostSample(samples[i]); -
GTP/trunk/Lib/Vis/Preprocessing/src/RenderSampler.cpp
r997 r1000 37 37 38 38 39 //-- Evaluate results 40 39 //-- Evaluate results 41 40 42 41 //-- compute histogram from the samples
Note: See TracChangeset
for help on using the changeset viewer.