Esempio n. 1
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 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() );
    }
}
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 );
}