Beispiel #1
0
void Channel::frameClear( const eq::uint128_t& /*frameID*/ )
{
    if( stopRendering( ))
        return;

    _initJitter();
    resetRegions();

    const FrameData& frameData = _getFrameData();
    const int32_t eyeIndex = lunchbox::getIndexOfLastBit( getEye() );
    if( _isDone() && !_accum[ eyeIndex ].transfer )
        return;

    applyBuffer();
    applyViewport();

    const eq::View* view = getView();
    if( view && frameData.getCurrentViewID() == view->getID( ))
        glClearColor( 1.f, 1.f, 1.f, 0.f );
#ifndef NDEBUG
    else if( getenv( "EQ_TAINT_CHANNELS" ))
    {
        const eq::Vector3ub color = getUniqueColor();
        glClearColor( color.r()/255.f, color.g()/255.f, color.b()/255.f, 0.f );
    }
#endif // NDEBUG
    else
        glClearColor( 0.f, 0.f, 0.f, 0.0f );

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
Beispiel #2
0
void Channel::frameReadback( const eq::uint128_t& frameID,
                             const eq::Frames& frames )
{
    if( stopRendering() || _isDone( ))
        return;

    const FrameData& frameData = _getFrameData();
    for( eq::FramesCIter i = frames.begin(); i != frames.end(); ++i )
    {
        eq::Frame* frame = *i;
        // OPT: Drop alpha channel from all frames during network transport
        frame->setAlphaUsage( false );

        if( frameData.isIdle( ))
            frame->setQuality( eq::Frame::BUFFER_COLOR, 1.f );
        else
            frame->setQuality( eq::Frame::BUFFER_COLOR, frameData.getQuality());

        if( frameData.useCompression( ))
            frame->useCompressor( eq::Frame::BUFFER_COLOR, EQ_COMPRESSOR_AUTO );
        else
            frame->useCompressor( eq::Frame::BUFFER_COLOR, EQ_COMPRESSOR_NONE );
    }

    eq::Channel::frameReadback( frameID, frames );
}
Beispiel #3
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 );
}
Beispiel #4
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();
}
Beispiel #5
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();
}
Beispiel #6
0
void Channel::frameDraw( const eq::uint128_t& frameID )
{
    if( stopRendering( ))
        return;

    _initJitter();
    if( _isDone( ))
        return;

    Window* window = static_cast< Window* >( getWindow( ));
    VertexBufferState& state = window->getState();
    const Model* oldModel = _model;
    const Model* model = _getModel();

    if( oldModel != model )
        state.setFrustumCulling( false ); // create all display lists/VBOs

    if( model )
        _updateNearFar( model->getBoundingSphere( ));

    eq::Channel::frameDraw( frameID ); // Setup OpenGL state

    glLightfv( GL_LIGHT0, GL_POSITION, lightPosition );
    glLightfv( GL_LIGHT0, GL_AMBIENT,  lightAmbient  );
    glLightfv( GL_LIGHT0, GL_DIFFUSE,  lightDiffuse  );
    glLightfv( GL_LIGHT0, GL_SPECULAR, lightSpecular );

    glMaterialfv( GL_FRONT, GL_AMBIENT,   materialAmbient );
    glMaterialfv( GL_FRONT, GL_DIFFUSE,   materialDiffuse );
    glMaterialfv( GL_FRONT, GL_SPECULAR,  materialSpecular );
    glMateriali(  GL_FRONT, GL_SHININESS, materialShininess );

    const FrameData& frameData = _getFrameData();
    glPolygonMode( GL_FRONT_AND_BACK,
                   frameData.useWireframe() ? GL_LINE : GL_FILL );

    const eq::Vector3f& position = frameData.getCameraPosition();

    glMultMatrixf( frameData.getCameraRotation().array );
    glTranslatef( position.x(), position.y(), position.z() );
    glMultMatrixf( frameData.getModelRotation().array );

    if( frameData.getColorMode() == COLOR_DEMO )
    {
        const eq::Vector3ub color = getUniqueColor();
        glColor3ub( color.r(), color.g(), color.b() );
    }
    else
        glColor3f( .75f, .75f, .75f );

    if( model )
        _drawModel( model );
    else
    {
        glNormal3f( 0.f, -1.f, 0.f );
        glBegin( GL_TRIANGLE_STRIP );
            glVertex3f(  .25f, 0.f,  .25f );
            glVertex3f( -.25f, 0.f,  .25f );
            glVertex3f(  .25f, 0.f, -.25f );
            glVertex3f( -.25f, 0.f, -.25f );
        glEnd();
    }

    state.setFrustumCulling( true );
    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( getEye()) ];
    accum.stepsDone = LB_MAX( accum.stepsDone,
                              getSubPixel().size * getPeriod( ));
    accum.transfer = true;
}
void THChunkRenderer::decodeChunks(const unsigned char* data, int datalen, bool complex)
{
    if(complex)
    {
        while(!_isDone() && datalen > 0)
        {
            unsigned char b = *data;
            --datalen;
            ++data;
            if(b == 0)
            {
                chunkFillToEndOfLine(0xFF);
            }
            else if(b < 0x40)
            {
                int amt = b;
                if(datalen < amt)
                    amt = datalen;
                chunkCopy(amt, data);
                data += amt;
                datalen -= amt;
            }
            else if((b & 0xC0) == 0x80)
            {
                chunkFill(b - 0x80, 0xFF);
            }
            else
            {
                int amt;
                unsigned char colour = 0;
                if(b == 0xFF)
                {
                    if(datalen < 2)
                    {
                        break;
                    }
                    amt = (int)data[0];
                    colour = data[1];
                    data += 2;
                    datalen -= 2;
                }
                else
                {
                    amt = b - 60 - (b & 0x80) / 2;
                    if(datalen > 0)
                    {
                        colour = *data;
                        ++data;
                        --datalen;
                    }
                }
                chunkFill(amt, colour);
            }
        }
    }
    else
    {
        while(!_isDone() && datalen > 0)
        {
            unsigned char b = *data;
            --datalen;
            ++data;
            if(b == 0)
            {
                chunkFillToEndOfLine(0xFF);
            }
            else if(b < 0x80)
            {
                int amt = b;
                if(datalen < amt)
                    amt = datalen;
                chunkCopy(amt, data);
                data += amt;
                datalen -= amt;
            }
            else
            {
                chunkFill(0x100 - b, 0xFF);
            }
        }
    }
    chunkFinish(0xFF);
}
vector< vector<Envelope> >  TileBoundsCalculator::calculateTiles()
{
  size_t width = 1;
  vector<PixelBox> boxes;
  boxes.resize(1);
  boxes[0] = PixelBox(0, _r1.cols - 1, 0, _r1.rows - 1);

  double nodeCount = _sumPixels(boxes[0]);
  LOG_INFO("w: " << _r1.cols << " h: " << _r1.rows);
  LOG_INFO("Total node count: " << nodeCount);

  while (!_isDone(boxes))
  {
    width *= 2;

    vector<PixelBox> nextLayer;
    nextLayer.resize(width * width);

    //LOG_INFO("width: " << width);
    for (size_t i = 0; i < boxes.size(); i++)
    {
      PixelBox& b = boxes[i];
      double splitX = _calculateSplitX(b);
      int tx = i % (width / 2);
      int ty = i / (width / 2);
      //LOG_INFO("  i: " << i << " tx: " << tx << " ty: " << ty);

      double splitYLeft = _calculateSplitY(PixelBox(b.minX, splitX, b.minY, b.maxY));
      nextLayer[(tx * 2 + 0) + (ty * 2 + 0) * width] = PixelBox(b.minX, splitX, b.minY,
        splitYLeft);
      nextLayer[(tx * 2 + 0) + (ty * 2 + 1) * width] = PixelBox(b.minX, splitX, splitYLeft + 1,
        b.maxY);

      double splitYRight = _calculateSplitY(PixelBox(splitX + 1, b.maxX, b.minY, b.maxY));
      nextLayer[(tx * 2 + 1) + (ty * 2 + 0) * width] = PixelBox(splitX + 1, b.maxX, b.minY,
        splitYRight);
      nextLayer[(tx * 2 + 1) + (ty * 2 + 1) * width] = PixelBox(splitX + 1, b.maxX, splitYRight + 1,
        b.maxY);
    }

    boxes = nextLayer;
  }

  vector< vector<Envelope> > result;

  long maxNodeCount = 0;
  result.resize(width);
  for (size_t tx = 0; tx < width; tx++)
  {
    result[tx].resize(width);
    for (size_t ty = 0; ty < width; ty++)
    {
      PixelBox& pb = boxes[tx + ty * width];
      maxNodeCount = std::max(maxNodeCount, _sumPixels(pb));
      if (pb.getWidth() < 3 || pb.getHeight() < 3)
      {
        throw HootException("PixelBox must be at least 3 pixels wide and tall.");
      }
      result[tx][ty] = _toEnvelope(pb);
    }
  }
  LOG_INFO("Max node count in one tile: " << maxNodeCount);
  _exportResult(boxes, "tmp/result.png");

  return result;
}