- Timestamp:
- 04/30/08 13:24:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2669 r2670 123 123 } 124 124 125 125 126 // reimplemented here so that we can snap the error windows 126 127 float QtGlRendererBuffer::GetPixelError(int &pvsSize) … … 128 129 MakeCurrent(); 129 130 130 cout << "stencil: " << format().stencil() << endl; 131 cout << "depth: " << format().depth() << endl; 132 cout << "rgba: " << format().rgba() << endl; 133 cout << "double: " << format().doubleBuffer() << endl; 131 if (0) 132 { 133 cout << "stencil: " << format().stencil() << endl; 134 cout << "depth: " << format().depth() << endl; 135 cout << "rgba: " << format().rgba() << endl; 136 cout << "double: " << format().doubleBuffer() << endl; 137 } 138 139 ++ mCurrentFrame; 134 140 135 141 float pErrorPixels = -1.0f; … … 144 150 return -1.0f; 145 151 146 KdNode::NewMail2();147 Intersectable::NewMail();148 149 ObjectPvs pvs;150 151 152 bool evaluateFilter; 152 153 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluateFilter", evaluateFilter); 154 155 ObjectPvs pvs; 153 156 154 157 if (!evaluateFilter) … … 169 172 if (mSnapErrorFrames) 170 173 { 171 172 174 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 173 175 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 174 176 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 175 177 176 GLfloat light_position[] = //{278.0f, 548.8f,279.0f, 1.0f};177 {0.f,0.f,0.f, 1.0f};178 //GLfloat light_position[] = {278.0f, 548.8f,279.0f, 1.0f}; 179 GLfloat light_position[] = {0.f,0.f,0.f, 1.0f}; 178 180 179 181 glEnable(GL_LIGHT0); … … 208 210 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 209 211 210 212 KdNode::NewMail2(); 213 Intersectable::NewMail(); 214 215 KdNode::NewMail2(); 216 Intersectable::NewMail(); 217 KdNode::NewMail2(); 218 Intersectable::NewMail(); 219 211 220 // render pvs once 212 221 RenderPvs(pvs); … … 228 237 query->BeginQuery(); 229 238 239 ++ mCurrentFrame; 240 230 241 RenderScene(); 231 242 232 243 query->EndQuery(); 233 244 glDisable(GL_STENCIL_TEST); 234 235 236 // reenable other state237 int wait = 0;238 while (0 && !query->ResultAvailable())239 wait ++;240 245 241 246 pixelCount = query->GetQueryResult(); 242 247 248 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 249 243 250 if (pixelCount > 0) 244 251 { 245 252 cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 246 } 247 248 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 249 250 251 if (mSnapErrorFrames && (pixelCount > 0)) 252 { 253 glReadBuffer(GL_BACK); 254 //glReadBuffer(GL_FRONT); 255 256 char filename[256]; 257 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 258 QImage im = toImage(); 259 string str = mSnapPrefix + filename; 260 QString qstr(str.c_str()); 261 262 im.save(qstr, "PNG"); 263 if (0) { //0 && mFrame == 1543) { 264 int x,y; 265 int lastIndex = -1; 266 for (y=0; y < im.height(); y++) 267 for (x=0; x < im.width(); x++) { 268 QRgb p = im.pixel(x,y); 269 int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 270 if (qGreen(p) != 255 && index!=0) { 271 if (index != lastIndex) { 272 // Debug<<"ei="<<index<<" "; 273 lastIndex = index; 274 } 275 } 276 } 277 } 278 279 280 #if 0 281 mUseFalseColors = false; 282 283 glPushAttrib(GL_CURRENT_BIT); 284 glColor3f(0, 1, 0); 285 286 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 287 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 288 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 289 290 KdNode::NewMail2(); 291 Intersectable::NewMail(); 292 293 RenderPvs(pvs); 294 295 glFinish(); 296 297 mUseForcedColors = false; 298 299 im = toImage(); 300 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 301 str = mSnapPrefix + filename; 302 qstr = str.c_str(); 303 im.save(qstr, "PNG"); 304 305 glPopAttrib(); 306 #endif 253 254 if (mSnapErrorFrames) 255 { 256 glReadBuffer(GL_BACK); 257 //glReadBuffer(GL_FRONT); 258 259 ////////////// 260 //-- output error visualization 261 262 char filename[256]; 263 sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 264 QImage im = toImage(); 265 string str = mSnapPrefix + filename; 266 QString qstr(str.c_str()); 267 268 im.save(qstr, "PNG"); 269 270 271 /////////// 272 //-- output computed pvs 273 274 mUseFalseColors = false; 275 276 glPushAttrib(GL_CURRENT_BIT); 277 glColor3f(0, 1, 0); 278 279 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 280 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 281 282 KdNode::NewMail2(); 283 Intersectable::NewMail(); 284 285 ++ mCurrentFrame; 286 // render pvs once 287 RenderPvs(pvs); 288 289 mUseForcedColors = false; 290 291 im = toImage(); 292 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 293 str = mSnapPrefix + filename; 294 qstr = str.c_str(); 295 im.save(qstr, "PNG"); 296 297 glPopAttrib(); 298 } 307 299 } 308 300 … … 497 489 498 490 499 void QtGlRendererWidget::PreparePvs 2(const ObjectPvs &pvs)491 void QtGlRendererWidget::PreparePvs(const ObjectPvs &pvs) 500 492 { 501 493 int indexBufferSize = 0; 502 494 503 // super hack: mal not working with multiple threads495 // hack: mail not working with multiple threads 504 496 KdNode::NewMail2(); 505 //Intersectable::NewMail();506 497 507 498 mPvsSize = pvs.GetSize(); … … 546 537 547 538 548 549 550 void QtGlRendererWidget::RenderPvs() 539 void QtGlRendererWidget::VisualizePvs() 551 540 { 552 541 if (mUseVbos) … … 600 589 #else 601 590 602 PreparePvs 2(viewcell->GetPvs());591 PreparePvs(viewcell->GetPvs()); 603 592 emit PvsUpdated(); 604 593 605 594 #endif 606 607 595 608 596 // Render PVS … … 662 650 663 651 // Render PVS 664 RenderPvs();652 VisualizePvs(); 665 653 666 654 glEnable(GL_STENCIL_TEST); … … 696 684 int pixelCount = query->GetQueryResult(); 697 685 pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 686 698 687 if (0) cout << "error pixels=" << pixelCount << endl; 699 688 … … 826 815 } 827 816 828 void 829 QtGlRendererWidget::paintGL()817 818 void QtGlRendererWidget::paintGL() 830 819 { 831 820 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 843 832 { 844 833 glColor3f(0.6f, 0.6f, 0.6f); 845 RenderPvs();834 VisualizePvs(); 846 835 } 847 836
Note: See TracChangeset
for help on using the changeset viewer.