// redraw the window void display(void) { WindowPtr win = mgr->getWindow(); //mgr->redraw(); win->activate(); win->frameInit(); //RenderAction *rAct = (RenderAction*)mgr->getAction(); if (multipass) { RenderAction *rAct = RenderAction::create(); fbo_vp->setParent(win); rAct->setWindow(get_pointer(win)); fbo_vp->render(rAct); fbo_vp->setParent(NullFC); delete rAct; //multipass = false; } win->getPort(0)->render(dynamic_cast<RenderAction *>(mgr->getAction())); //win->renderAllViewports(rAct); win->swap(); win->frameExit(); win->deactivate(); }
/** get graphics performance * * This is a rough estimation of rendering costst for visible faces, * faces outside of the viewport and size dependent rendering costs. * <pre> * // face cost calculation * cost = invisible * invisibleFaceCost + * max( visible * visibleFaceCost + * pixel * pixelCost) * </pre> * **/ void RenderNode::determinePerformance( WindowPtr &window ) { int c; double faces=0; double A,B,C; double t; setVendor((const char*)glGetString(GL_VENDOR)); setRenderer((const char*)glGetString(GL_RENDERER)); // try to find precalculated values for(c=0;_prefefined[c]!=NULL;++c) { if(_prefefined[c]->getVendor() == getVendor() && _prefefined[c]->getRenderer() == getRenderer()) { SLOG << "Predefined performance values used." << endl; *this=*_prefefined[c]; return; } } SLOG << "Start rendering benchmark" << endl; window->activate(); // create display list GLuint dList1 = glGenLists(1); glNewList(dList1, GL_COMPILE); float step = .1; int count = 400; for(float y=0;y<(1-step/2);y+=step) { glBegin(GL_TRIANGLE_STRIP); glVertex3f(0,y ,-1); glVertex3f(0,y+step,-1); for(float x=step;x<(1+step/2);x+=step) { glVertex3f(x,y ,-1); glVertex3f(x,y+step,-1); faces+=2; } glEnd(); } glEndList(); glFinish(); GLuint dList2 = glGenLists(1); glNewList(dList2, GL_COMPILE); for(c=0;c<count;++c) { glCallList(dList1); } glEndList(); glFlush(); t=runFaceBench(dList2,128,128,1.0); count=(int)(count/t); glNewList(dList2, GL_COMPILE); for(c=0;c<count;++c) { glCallList(dList1); } glEndList(); runFaceBench(dList2,1,1,1.0); glFinish(); Real32 aSize=2; Real32 bSize=2; Real32 cSize=128; do { for(A=0,c=0;A<1.0;++c) { A += runFaceBench(dList2,aSize,aSize,1.000); } A/=c*count; for(B=0,c=0;B<1.0;++c) { B += runFaceBench(dList2,bSize,bSize,0.001); } B/=c*count; C = runFaceBench(dList2,cSize,cSize,1.000)/count; } while(A>C); _visibleFaceCost =A/faces; _invisibleFaceCost =B/faces; _drawPixelCost =C/(cSize*cSize); glViewport(0, 0, window->getWidth(), window->getHeight()); UInt32 width,height; // test write performance glPixelStorei(GL_PACK_ALIGNMENT,1); glPixelStorei(GL_UNPACK_ALIGNMENT,1); vector<UInt8> pixels; width =window->getWidth(); height=window->getHeight(); pixels.resize(width*height*4); glFlush(); t=-getSystemTime(); for(c=0;c<2;++c) glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,&pixels[0]); glFlush(); t+=getSystemTime(); _readPixelCost=t/(c*width*height); // test write performance glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0,width,0,height); glRasterPos2i(0,0); glDisable(GL_DEPTH_TEST); glFlush(); t=-getSystemTime(); for(c=0;c<2;++c) glDrawPixels(width,height,GL_RGB,GL_UNSIGNED_BYTE,&pixels[0]); glFlush(); t+=getSystemTime(); _writePixelCost=t/(c*width*height); glEnable(GL_DEPTH_TEST); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); SLOG << "End rendering benchmark" << endl; glDeleteLists(dList2,1); glDeleteLists(dList1,1); }