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 ); }
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(); } } _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 ); }
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(); }
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(); }
void Channel::frameViewFinish( const uint128_t& frameID ) { const ViewData* data = getViewData(); EQASSERT( data ); if( !data || !data->getStatistics( )) return; applyBuffer(); applyViewport(); drawStatistics(); }
void Channel::frameClear( const eq::uint128_t& frameID ) { applyBuffer(); applyViewport(); if( getRange() == eq::Range::ALL ) glClearColor( _bgColor.r(), _bgColor.g(), _bgColor.b(), 1.0f ); else glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT ); }
void Channel::frameViewFinish(const uint128_t& frameID) { const ViewData* data = getViewData(); LBASSERT(data); if (data && data->getStatistics()) { applyBuffer(); applyViewport(); drawStatistics(); } eq::Channel::frameViewFinish(frameID); }
void Channel::frameDraw( const eq::uint128_t& ) { // Setup frustum EQ_GL_CALL( applyBuffer( )); EQ_GL_CALL( applyViewport( )); EQ_GL_CALL( glMatrixMode( GL_PROJECTION )); EQ_GL_CALL( glLoadIdentity( )); EQ_GL_CALL( applyFrustum( )); EQ_GL_CALL( glMatrixMode( GL_MODELVIEW )); EQ_GL_CALL( glLoadIdentity( )); // Setup lights before applying head transform, so the light will be // consistent in the cave const FrameData& frameData = _getFrameData(); const eq::Matrix4f& rotation = frameData.getRotation(); const eq::Vector3f& translation = frameData.getTranslation(); eq::Matrix4f invRotationM; rotation.inverse( invRotationM ); setLights( invRotationM ); EQ_GL_CALL( applyHeadTransform( )); glTranslatef( translation.x(), translation.y(), translation.z() ); glMultMatrixf( rotation.array ); Pipe* pipe = static_cast<Pipe*>( getPipe( )); Renderer* renderer = pipe->getRenderer(); LBASSERT( renderer ); const eq::Matrix4f& modelview = _computeModelView(); // set fancy data colors const eq::Vector4f taintColor = _getTaintColor( frameData.getColorMode(), getUniqueColor( )); const int normalsQuality = _getFrameData().getNormalsQuality(); const eq::Range& range = getRange(); renderer->render( range, modelview, invRotationM, taintColor, normalsQuality ); checkError( "error during rendering " ); _drawRange = range; #ifndef NDEBUG outlineViewport(); #endif }
void Channel::frameDraw( const eq::uint128_t& frameID ) { // Setup frustum EQ_GL_CALL( applyBuffer( )); EQ_GL_CALL( applyViewport( )); EQ_GL_CALL( glMatrixMode( GL_PROJECTION )); EQ_GL_CALL( glLoadIdentity( )); EQ_GL_CALL( applyFrustum( )); EQ_GL_CALL( glMatrixMode( GL_MODELVIEW )); EQ_GL_CALL( glLoadIdentity( )); // Setup lights before applying head transform, so the light will be // consistent in the cave const FrameData& frameData = _getFrameData(); const eq::Matrix4f& rotation = frameData.getRotation(); const eq::Vector3f& translation = frameData.getTranslation(); eq::Matrix4f invRotationM; rotation.inverse( invRotationM ); setLights( invRotationM ); EQ_GL_CALL( applyHeadTransform( )); glTranslatef( translation.x(), translation.y(), translation.z() ); glMultMatrixf( rotation.array ); Pipe* pipe = static_cast<Pipe*>( getPipe( )); Renderer* renderer = pipe->getRenderer(); EQASSERT( renderer ); eq::Matrix4f modelviewM; // modelview matrix eq::Matrix3f modelviewITM; // modelview inversed transposed matrix _calcMVandITMV( modelviewM, modelviewITM ); const eq::Range& range = getRange(); renderer->render( range, modelviewM, modelviewITM, invRotationM ); checkError( "error during rendering " ); _drawRange = range; #ifndef NDEBUG outlineViewport(); #endif }
void Presentation::drawScroller(Presentation *prs, const char *image1, const char *image2, const char *image3, IplImage* leftArrow, IplImage *rightArrow){ char filepath[80]; snprintf(filepath, sizeof(filepath), "tmp/1/%s", image1); IplImage *img1 = cvLoadImage(filepath, CV_LOAD_IMAGE_UNCHANGED); snprintf(filepath, sizeof(filepath), "tmp/1/%s", image2); IplImage *img2 = cvLoadImage(filepath, CV_LOAD_IMAGE_UNCHANGED); snprintf(filepath, sizeof(filepath), "tmp/1/%s", image3); IplImage *img3 = cvLoadImage(filepath, CV_LOAD_IMAGE_UNCHANGED); /* Each image occupies 17% of scroller height and 67% of scroller lenght * Each arrow occupies 7% of scroller height and 50% of scroller lenght * Space between images and images and arrows - 7% */ //calculations of relative coordinates putImage(cvPoint(prs->scrollerUL[0].x, prs->scrollerUL[0].y), cvPoint(prs->scrollerBR[0].x, prs->scrollerBR[0].y), leftArrow); putImage(cvPoint(prs->scrollerUL[1].x, prs->scrollerUL[1].y), cvPoint(prs->scrollerBR[1].x, prs->scrollerBR[1].y), img1); putImage(cvPoint(prs->scrollerUL[2].x, prs->scrollerUL[2].y), cvPoint(prs->scrollerBR[2].x, prs->scrollerBR[2].y), img2); putImage(cvPoint(prs->scrollerUL[3].x, prs->scrollerUL[3].y), cvPoint(prs->scrollerBR[3].x, prs->scrollerBR[3].y), img3); putImage(cvPoint(prs->scrollerUL[4].x, prs->scrollerUL[4].y), cvPoint(prs->scrollerBR[4].x, prs->scrollerBR[4].y), rightArrow); applyBuffer(); }
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(); }
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( )); }
void Channel::_startAssemble() { applyBuffer(); applyViewport(); setupAssemblyState(); }