void TransportApp::draw() {
	
    gl::enableAlphaBlending();
    
    gl::clear( Color( 0, 0, 0 ) );
    
    if ( DRAW_BACKGROUND ) {
        gl::draw( background, getWindowBounds() );
    }
    
    bool airports_drawn = true;
//    if ( this->gonna_draw_airports ) {
        for ( list<Airport>::iterator a = active_airports.begin(); a != active_airports.end(); ++a ) {
            a->step();
            a->draw();
            airports_drawn = airports_drawn && a->isComplete();
        }
        
        if ( airports_drawn ) {
            airports_drawn = airports_drawn && !( pushAirports() );
            if ( airports_drawn && this->gonna_draw_airports ) {
//                writeImage( "/tmp/airports.png", copyWindowSurface() );
                this->gonna_draw_airports = false;
            }
        }
//    }
    
    if ( airports_drawn ) {
//        bool routes_drawn = true;
        for ( list<Route>::iterator ari = routes.begin(); ari != routes.end(); ++ari ) {
            ari->step();
            ari->draw();
//            routes_drawn = routes_drawn && ari->isComplete();
        }

//        if ( routes_drawn ) {
//            routes_drawn = routes_drawn && !( pushRoutes() );
//        }
        
//        if ( getElapsedSeconds() > 1000 ) {
            if ( WRITE_MOVIE ) {
                if ( getElapsedSeconds() > 600 ) {
                    movie.finish();
                    quit();
                }
            }
//            writeImage( "/tmp/routes.png", copyWindowSurface() );
//            quit();
//        }
    }

    gl::color( Color( 1.0f, 1.0f, 1.0f ) );
    
    if ( WRITE_MOVIE ) {
        movie.addFrame( copyWindowSurface() );
    }
}
Esempio n. 2
0
void reflection_animationApp::keyUp( KeyEvent event )
{
    if (event.getCode() == KeyEvent::KEY_TAB) {
        m_showInterface = !m_showInterface;
    }
    
    if (event.getCode() == KeyEvent::KEY_SPACE) {
        Surface frame = copyWindowSurface();
        stringstream filename;
        filename << "geometry_screenshot_" << (getElapsedFrames()) << ".png";
        writeImage( m_path / filename.str(), frame);
    }
    
    if (event.getCode() == KeyEvent::KEY_r) {
        if (m_recording) {
            m_movieWriter.finish();
        }
        if (!m_recording) {
            stringstream filename;
            filename << "geometry_animation_" << (getElapsedFrames()) << ".mov";
            m_movieWriter = qtime::MovieWriter( m_path / filename.str(), getWindowWidth(), getWindowHeight() );
        }
        m_recording = !m_recording;
    }
}
    void handleQuit() {
#ifdef MOVIESAVE
        movie.finish();
#endif
        setFullScreen(0);
        showCursor();
        quit();
    }
void AnimatedRevealApp::update()
{
    if( ( ! mDoc ) || mDone )
        return;

    // we'll stop drawing filled after we've drawn new pixels that are 1% of the size of the image
    size_t imageSize, minArea;
    if( mDoc->getWidth() && mDoc->getHeight() )
        imageSize = mDoc->getWidth() * mDoc->getHeight();
    else
        imageSize = 640 * 480;
    minArea = 1 + imageSize * 0.01f;

    Surface frame = renderCairo( mDoc, SlowFillVisitor( mMinRenderElement, minArea, &mMinRenderElement, &mDone ) );
#if defined( RECORD_MOVIE )
    mMovie.addFrame( frame );
    if( mDone ) {
        mMovie.addFrame( frame ); // otherwise we seem to lose the last frame
        mMovie.finish();
    }
#endif
    mTex = gl::Texture::create( frame );
}
Esempio n. 5
0
void reflection_animationApp::draw()
{
    
	// BACKGROUND
    
	gl::clear( Color( 0.0025f, 0.0025f, 0.0025f ) ); 
	
	gl::enableDepthWrite( false );
	gl::enableDepthRead( false );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
    // RENDER MODE
    
    switch (m_renderMode) {
        case ALPHA:
            gl::enableAlphaBlending();
            break;
        case ADDITIVE:
            gl::enableAdditiveBlending();
            break;
        default:
            gl::enableAlphaBlending();
            break;
    }
    
    // DRAW

	// camera
	//m_eye        = Vec3f( 0.0f, 0.0f, m_cameraDistance );
	//m_camPers.lookAt( m_eye, m_center, m_up );
    
	// matrices
	gl::setMatrices( m_mayaCam.getCamera() );

	// draw pyramid
	m_structure.draw();
	
	// GUI
    
    if (m_recording) {
        Surface frame = copyWindowSurface();
        m_movieWriter.addFrame( frame );
    }
    
    
	if(m_showInterface) params::InterfaceGl::draw();
}