// draw callback // Purposes: // - Load the navigation matrix to reflect frame's navigation // - Use OpenGL to generate computer graphics. void draw(arMasterSlaveFramework& framework) { // Load the navigation matrix. framework.loadNavMatrix(); // Generate graphics. if(selectionMode == 2) { renderPrimitive(-2.5f); // draws square with quadrants drawObjects(-2.5f); // draw the mini versions } vector<arInteractable*>::iterator i; for(i=objects.begin(); i != objects.end(); ++i) { Object* oby = ((Object*)(*i)); oby->draw(); } // Draw the effectors. rightHand.draw(); leftHand.draw(); }
void doSceneGraph( arMasterSlaveFramework &fw ) { static int loops = 0; static ar_timeval starttime = ar_time(); static ar_timeval lastdrawtime = ar_time(); ar_timeval now = ar_time(); long long curtime = ( now.sec * 1000000 ) + now.usec, lasttime = ( lastdrawtime.sec * 1000000 ) + lastdrawtime.usec; long long sleeptime = 2000 - ( curtime - lasttime ); ar_usleep( max( (int)sleeptime, 1 ) ); fw.loadNavMatrix(); glClearColor( 0, 0.749, 1, 0 ); primary.draw(); secondary.draw(); sg->drawSceneGraph(); if( menuOn ) drawMenu( menu, fw ); lastdrawtime = ar_time(); loops++; if( lastdrawtime.sec > starttime.sec ) { cout << "fps=" << loops << endl; starttime = lastdrawtime; loops = 0; } }