示例#1
0
void Channel::frameDraw( const eq::uint128_t& frameID )
{
    //----- setup GL state
    applyBuffer();
    applyViewport();

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    applyFrustum();

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    applyHeadTransform();

    setupAssemblyState();

    _testFormats( 1.0f );
    _testFormats( 0.5f );
    _testFormats( 2.0f );
    _testTiledOperations();
    _testDepthAssemble();

    resetAssemblyState();
}
示例#2
0
void Channel::frameViewFinish( const eq::uint128_t& frameID )
{
    if( stopRendering( ))
        return;

    applyBuffer();

    const FrameData& frameData = _getFrameData();
    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( getEye()) ];

    if( accum.buffer )
    {
        const eq::PixelViewport& pvp = getPixelViewport();
        const bool isResized = accum.buffer->resize( pvp );

        if( isResized )
        {
            const View* view = static_cast< const View* >( getView( ));
            accum.buffer->clear();
            accum.step = view->getIdleSteps();
            accum.stepsDone = 0;
        }
        else if( frameData.isIdle( ))
        {
            setupAssemblyState();

            if( !_isDone() && accum.transfer )
                accum.buffer->accum();
            accum.buffer->display();

            resetAssemblyState();
        }
    }

    applyViewport();
    _drawOverlay();
    _drawHelp();

    if( frameData.useStatistics())
        drawStatistics();

    int32_t steps = 0;
    if( frameData.isIdle( ))
    {
        for( size_t i = 0; i < eq::NUM_EYES; ++i )
            steps = LB_MAX( steps, _accum[i].step );
    }
    else
    {
        const View* view = static_cast< const View* >( getView( ));
        steps = view ? view->getIdleSteps() : 0;
    }

    // if _jitterStep == 0 and no user redraw event happened, the app will exit
    // FSAA idle mode and block on the next redraw event.
    eq::Config* config = getConfig();
    config->sendEvent( IDLE_AA_LEFT ) << steps;

    eq::Channel::frameViewFinish( frameID );
}
示例#3
0
void Channel::frameAssemble( const eq::uint128_t& frameID )
{
    if( stopRendering( ))
        return;

    if( _isDone( ))
        return;

    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( getEye()) ];

    if( getPixelViewport() != _currentPVP )
    {
        accum.transfer = true;

        if( accum.buffer && !accum.buffer->usesFBO( ))
        {
            LBWARN << "Current viewport different from view viewport, "
                   << "idle anti-aliasing not implemented." << std::endl;
            accum.step = 0;
        }

        eq::Channel::frameAssemble( frameID );
        return;
    }
    // else
    
    accum.transfer = true;
    const eq::Frames& frames = getInputFrames();

    for( eq::Frames::const_iterator i = frames.begin(); i != frames.end(); ++i )
    {
        eq::Frame* frame = *i;
        const eq::SubPixel& curSubPixel = frame->getSubPixel();

        if( curSubPixel != eq::SubPixel::ALL )
            accum.transfer = false;

        accum.stepsDone = LB_MAX( accum.stepsDone, 
                                  frame->getSubPixel().size*frame->getPeriod( ));
    }

    applyBuffer();
    applyViewport();
    setupAssemblyState();

    try
    {
        eq::Compositor::assembleFrames( getInputFrames(), this, accum.buffer );
    }
    catch( const co::Exception& e )
    {
        LBWARN << e.what() << std::endl;
    }

    resetAssemblyState();
}
示例#4
0
void Channel::frameAssemble( const eq::uint128_t& frameID,
                             const eq::Frames& frames )
{
    if( stopRendering( ))
        return;

    if( _isDone( ))
        return;

    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( getEye()) ];

    if( getPixelViewport() != _currentPVP )
    {
        accum.transfer = true;

        if( accum.buffer && !accum.buffer->usesFBO( ))
        {
            LBWARN << "Current viewport different from view viewport, "
                   << "idle anti-aliasing not implemented." << std::endl;
            accum.step = 0;
        }

        eq::Channel::frameAssemble( frameID, frames );
        return;
    }
    // else

    accum.transfer = true;
    for( eq::Frame* frame : frames )
    {
        const eq::SubPixel& subPixel =
            frame->getFrameData()->getContext().subPixel;

        if( subPixel != eq::SubPixel::ALL )
            accum.transfer = false;

        accum.stepsDone = LB_MAX( accum.stepsDone, subPixel.size *
                                  frame->getFrameData()->getContext().period );
    }

    applyBuffer();
    applyViewport();
    setupAssemblyState();

    try
    {
        eq::Compositor::assembleFrames( frames, this, accum.buffer.get( ));
    }
    catch( const co::Exception& e )
    {
        LBWARN << e.what() << std::endl;
    }

    resetAssemblyState();
}
示例#5
0
void Channel::_drawHelp()
{
    const FrameData& frameData = _getFrameData();
    std::string message = frameData.getMessage();

    if( !frameData.showHelp() && message.empty( ))
        return;

    applyBuffer();
    applyViewport();
    setupAssemblyState();

    glLogicOp( GL_XOR );
    glEnable( GL_COLOR_LOGIC_OP );
    glDisable( GL_LIGHTING );
    glDisable( GL_DEPTH_TEST );

    glColor3f( 1.f, 1.f, 1.f );

    const eq::PixelViewport& pvp = getPixelViewport();
    const eq::Viewport& vp = getViewport();
    const float height = pvp.h / vp.h;

    if( !message.empty( ))
    {
        const eq::util::BitmapFont* font = getWindow()->getMediumFont();

        const float width = pvp.w / vp.w;
        const float xOffset = vp.x * width;

        const float yOffset = vp.y * height;
        const float yPos = 0.618f * height;
        float y = yPos - yOffset;

        for( size_t pos = message.find( '\n' ); pos != std::string::npos;
             pos = message.find( '\n' ))
        {
            glRasterPos3f( 10.f - xOffset, y, 0.99f );
            font->draw( message.substr( 0, pos ));
            message = message.substr( pos + 1 );
            y -= 22.f;
        }
        // last line
        glRasterPos3f( 10.f - xOffset, y, 0.99f );
        font->draw( message );
    }

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    applyScreenFrustum();
    glMatrixMode( GL_MODELVIEW );

    if( frameData.showHelp( ))
    {
        const eq::util::BitmapFont* font = getWindow()->getSmallFont();
        std::string help = EqPly::getHelp();
        float y = height - 16.f;

        for( size_t pos = help.find( '\n' ); pos != std::string::npos;
             pos = help.find( '\n' ))
        {
            glRasterPos3f( 10.f, y, 0.99f );

            font->draw( help.substr( 0, pos ));
            help = help.substr( pos + 1 );
            y -= 16.f;
        }
        // last line
        glRasterPos3f( 10.f, y, 0.99f );
        font->draw( help );
    }

    resetAssemblyState();
}
示例#6
0
void Channel::_drawHelp()
{
    const FrameData& frameData = _getFrameData();
    std::string message = frameData.getMessage();

    if( !frameData.showHelp() && message.empty( ))
        return;

    applyBuffer();
    applyViewport();
    setupAssemblyState();

    glDisable( GL_LIGHTING );
    glDisable( GL_DEPTH_TEST );

    glColor3f( 1.f, 1.f, 1.f );

    if( frameData.showHelp( ))
    {
        const eq::Window::Font* font = getWindow()->getSmallFont();
        std::string help = EVolve::getHelp();
        float y = 340.f;

        for( size_t pos = help.find( '\n' ); pos != std::string::npos;
             pos = help.find( '\n' ))
        {
            glRasterPos3f( 10.f, y, 0.99f );

            font->draw( help.substr( 0, pos ));
            help = help.substr( pos + 1 );
            y -= 16.f;
        }
        // last line
        glRasterPos3f( 10.f, y, 0.99f );
        font->draw( help );
    }

    if( !message.empty( ))
    {
        const eq::Window::Font* font = getWindow()->getMediumFont();

        const eq::Viewport& vp = getViewport();
        const eq::PixelViewport& pvp = getPixelViewport();

        const float width = pvp.w / vp.w;
        const float xOffset = vp.x * width;

        const float height = pvp.h / vp.h;
        const float yOffset = vp.y * height;
        const float yMiddle = 0.5f * height;
        float y = yMiddle - yOffset;

        for( size_t pos = message.find( '\n' ); pos != std::string::npos;
             pos = message.find( '\n' ))
        {
            glRasterPos3f( 10.f - xOffset, y, 0.99f );
            
            font->draw( message.substr( 0, pos ));
            message = message.substr( pos + 1 );
            y -= 22.f;
        }
        // last line
        glRasterPos3f( 10.f - xOffset, y, 0.99f );
        font->draw( message );
    }

    EQ_GL_CALL( resetAssemblyState( ));
}
示例#7
0
void Channel::frameAssemble( const eq::uint128_t& frameID )
{
    const bool composeOnly = (_drawRange == eq::Range::ALL);
    eq::FrameData* data = _frame.getData();

    _startAssemble();

    const eq::Frames& frames = getInputFrames();
    eq::PixelViewport  coveredPVP;
    eq::Frames    dbFrames;
    eq::Zoom           zoom( eq::Zoom::NONE );

    // Make sure all frames are ready and gather some information on them
    for( eq::Frames::const_iterator i = frames.begin();
         i != frames.end(); ++i )
    {
        eq::Frame* frame = *i;
        {
            eq::ChannelStatistics stat( eq::Statistic::CHANNEL_FRAME_WAIT_READY,
                                        this );
            frame->waitReady( );
        }
        const eq::Range& range = frame->getRange();
        if( range == eq::Range::ALL ) // 2D frame, assemble directly
            eq::Compositor::assembleFrame( frame, this );
        else
        {
            dbFrames.push_back( frame );
            zoom = frame->getZoom();
            _expandPVP( coveredPVP, frame->getImages(), frame->getOffset() );
        }
    }
    coveredPVP.intersect( getPixelViewport( ));

    if( dbFrames.empty( ))
    {
        resetAssemblyState();
        return;
    }

    // calculate correct frames sequence
    if( !composeOnly && coveredPVP.hasArea( ))
    {
        _frame.clear();
        data->setRange( _drawRange );
        dbFrames.push_back( &_frame );
    }

    _orderFrames( dbFrames );

    // check if current frame is in proper position, read back if not
    if( !composeOnly )
    {
        if( _bgColor == eq::Vector3f::ZERO && dbFrames.front() == &_frame )
            dbFrames.erase( dbFrames.begin( ));
        else if( coveredPVP.hasArea())
        {
            eq::Window::ObjectManager* glObjects = getObjectManager();

            _frame.setOffset( eq::Vector2i( 0, 0 ));
            _frame.setZoom( zoom );
            data->setPixelViewport( coveredPVP );
            _frame.readback( glObjects, getDrawableConfig( ));
            clearViewport( coveredPVP );

            // offset for assembly
            _frame.setOffset( eq::Vector2i( coveredPVP.x, coveredPVP.y ));
        }
    }

    // blend DB frames in order
    try
    {
        eq::Compositor::assembleFramesSorted( dbFrames, this, 0, 
                                              true /*blendAlpha*/ );
    }
    catch( eq::Exception e )
    {
        EQWARN << e << std::endl;
    }

    resetAssemblyState();

    // Update range
    _drawRange = getRange();
}
示例#8
0
void Channel::frameAssemble( const eq::uint128_t&, const eq::Frames& frames )
{
    _startAssemble();

    eq::PixelViewport  coveredPVP;
    eq::ImageOps       dbImages;
    eq::Zoom           zoom( eq::Zoom::NONE );

    // Make sure all frames are ready and gather some information on them
    for( eq::Frame* frame : frames )
    {
        {
            eq::ChannelStatistics stat( eq::Statistic::CHANNEL_FRAME_WAIT_READY,
                                        this );
            frame->waitReady( );
        }
        for( eq::Image* image : frame->getImages( ))
        {
            eq::ImageOp op( frame, image );
            op.offset = frame->getOffset();
            const eq::Range& range = image->getContext().range;
            if( range == eq::Range::ALL ) // 2D frame, assemble directly
                eq::Compositor::assembleImage( op, this );
            else
            {
                dbImages.emplace_back( op );
                zoom = frame->getZoom();
                coveredPVP.merge( image->getPixelViewport() + frame->getOffset());
            }
        }
    }
    if( dbImages.empty( ))
    {
        resetAssemblyState();
        return;
    }

    // calculate correct image sequence
    const bool dbCompose = _image.getContext().range != eq::Range::ALL;
    coveredPVP.intersect( getPixelViewport( ));
    if( dbCompose && coveredPVP.hasArea( ))
    {
        eq::ImageOp op;
        op.image = &_image;
        op.buffers = eq::Frame::BUFFER_COLOR;
        op.zoom = zoom;
        op.offset = eq::Vector2i( coveredPVP.x, coveredPVP.y );
        dbImages.emplace_back( op );
    }

    _orderImages( dbImages );

    // check if current image is in proper position, read back if not
    if( dbCompose )
    {
        if( _bgColor == eq::Vector3f() && dbImages.front().image == &_image)
            dbImages.erase( dbImages.begin( ));
        else if( coveredPVP.hasArea())
        {
            eq::util::ObjectManager& glObjects = getObjectManager();
            eq::PixelViewport pvp = getRegion();
            pvp.intersect( coveredPVP );

            // Update range
            eq::Range range( 1.f, 0.f );
            for( const eq::ImageOp& op : dbImages )
            {
                const eq::Range& r = op.image->getContext().range;
                range.start = std::min( range.start, r.start );
                range.end = std::max( range.end, r.end );
            }
            eq::RenderContext context = _image.getContext();
            context.range = range;

            if( _image.startReadback( eq::Frame::BUFFER_COLOR, pvp, context,
                                      zoom, glObjects ))
            {
                _image.finishReadback( glewGetContext( ));
            }
            clearViewport( coveredPVP );
        }
    }

    glEnable( GL_BLEND );
    LBASSERT( GLEW_EXT_blend_func_separate );
    glBlendFuncSeparate( GL_ONE, GL_SRC_ALPHA, GL_ZERO, GL_SRC_ALPHA );

    eq::Compositor::blendImages( dbImages, this, 0 );
    resetAssemblyState();
}