コード例 #1
0
ファイル: main.cpp プロジェクト: raedwulf/pipeline
void QtMinimalWidget::paintGL()
{
  ++m_benchmarkFrameCount;

  SceniXQGLSceneRendererWidget::paintGL();

  if ( getContinuousUpdate() && ( m_orbitRadians != 0.0f ) )
  {
    DP_ASSERT( getViewState() && getViewState()->getCamera() );
    getViewState()->getCamera()->orbitY( getViewState()->getCamera()->getFocusDistance(), m_orbitRadians );
  }

  // fps counter
  if ( m_showFPS )
  {
    if ( m_benchmarkFrameCount == 1 )
    {
      m_frameRateTimer.start();
    }
    else
    {
      DP_ASSERT( 1 < m_benchmarkFrameCount );
      double elapsedSeconds = m_frameRateTimer.getTime();
      ++m_frameCount;

      if ( elapsedSeconds > 1.0 )
      {
        double fps = double(m_frameCount) / elapsedSeconds;
        m_benchmarkTime += elapsedSeconds;

        std::ostringstream windowTitle;
        windowTitle.precision(2);
        windowTitle.setf( std::ios::fixed, std::ios::floatfield );
        windowTitle << m_windowTitle << ", " << fps << " FPS";

        if ( m_benchmarkFrames != ~0 )
        {
          windowTitle << " Benchmark " << m_benchmarkFrameCount-1 << "/" << m_benchmarkFrames;
        }
        else if ( 0.0 < m_benchmarkDuration )
        {
          windowTitle << " Benchmark " << m_benchmarkTime << "/" << m_benchmarkDuration;
        }

        setWindowTitle( windowTitle.str().c_str() );

        m_frameCount = 0;
        m_frameRateTimer.restart();
      }
    }
  }
  if (  ( ( m_benchmarkFrames != ~0 ) && ( m_benchmarkFrames == m_benchmarkFrameCount-1 ) )
     || ( ( 0.0 < m_benchmarkDuration ) && ( m_benchmarkDuration <= m_benchmarkTime ) ) )
  {
    m_frameRateTimer.stop();
    QCoreApplication::instance()->exit( int(100 * double(m_benchmarkFrameCount-1) / m_benchmarkTime) );
  }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: raedwulf/pipeline
void TerrainRenderer::paint()
{
  dp::sg::renderer::rix::gl::SceneRendererSharedPtr renderer = getSceneRenderer().staticCast<dp::sg::renderer::rix::gl::SceneRenderer>();
  if ( !m_renderEngine.empty() && renderer->getRenderEngine() != m_renderEngine )
  {
    std::cout << "Setting renderengine: " << m_renderEngine << std::endl;
    renderer->setRenderEngine( m_renderEngine );
  }

  renderer->setShaderManager( m_shaderManager);

  glPatchParameteri( GL_PATCH_VERTICES, 1 ); // TODO temporary, terrain patch has only 1 'virtual' vertex per patch
  //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

  dp::util::FrameProfiler::instance().beginFrame();
  if ( m_benchmarkFrames != ~0 || m_duration != 0.0 )
  {
    if ( m_renderedFrames == 1 )
    {
      m_benchmarkTimer.start();
      m_benchmarkProgressTimer.start();
    }

    SceneRendererWidget::paint();

    if ( m_benchmarkProgressTimer.getTime() > 1.0 )
    {
      m_benchmarkProgressTimer.restart();
      std::ostringstream os;
      os << "Benchmark Progress: ";
      if ( m_benchmarkFrames != ~0 )
      {
        os << m_renderedFrames << "/" << m_benchmarkFrames;
      }
      else
      {
        os << std::setprecision(2) << m_benchmarkTimer.getTime() << "/" << m_duration;
      }
      setWindowTitle( os.str() );
    }
    if ( (m_benchmarkFrames != ~0 && m_renderedFrames == m_benchmarkFrames) || (m_duration > 0.0 && m_benchmarkTimer.getTime() > m_duration) )
    {
      m_benchmarkTimer.stop();
      m_exitCode = int(double(m_renderedFrames) / m_benchmarkTimer.getTime());
      glutLeaveMainLoop();
    }

    // at the end since the first frame does not count
    ++m_renderedFrames;
  }
  else
  {
    SceneRendererWidget::paint();
  }
  dp::util::FrameProfiler::instance().endFrame();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: MatzJB/pipeline
void GLUTAnimationWidget::paint()
{
  dp::util::FrameProfiler::instance().beginFrame();
  if ( m_animateColors )
  {
    m_animatedScene->update( dp::checked_cast<float>(m_animationTimer.getTime()) );
  }
  if ( m_animateTransforms )
  {
    m_animatedScene->updateTransforms( dp::checked_cast<float>(m_animationTimer.getTime()) );
  }
  dp::sg::ui::glut::SceneRendererWidget::paint();

  // fps counter
  if ( m_framesInSecond == ~0 )
  {
    m_elapsedTimer.start();
    m_framesInSecond = 0;
  }
  if ( m_elapsedTimer.getTime() > 1.0)
  {
    double fps = double(m_framesInSecond) / m_elapsedTimer.getTime();
    std::ostringstream windowTitle;
    windowTitle.precision(2);
    windowTitle.setf( std::ios::fixed, std::ios::floatfield );
    windowTitle<< "AnimationTest: " << fps << " FPS";
    setWindowTitle(windowTitle.str().c_str());
    m_framesInSecond = 0;
    m_elapsedTimer.restart();
  }
  ++m_framesInSecond;

  if( m_frames > 0 )
  {
    --m_frames;
  }

  if ( m_frames == 0 )
  {
    exit(0);
  }

  dp::util::FrameProfiler::instance().endFrame();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: MatzJB/pipeline
void GLUTMinimalCFR::paint()
{
  //std::cout << "paint\n";
#if 1
  //std::cout << "NOT using m_paintTimes\n";
#else
  double time = m_globalTimer.getTime();
  if( m_paintTimes.empty() )
  {
    glutLeaveMainLoop();
    return;
  }
  if( time < m_paintTimes.front() )
  {
    if( getContinuousUpdate() )
    {
      glutPostRedisplay();
    }
    return;
  }
  m_paintTimes.pop_front();
  file << "paint() " << time << "\n";
#endif

  dp::util::FrameProfiler::instance().beginFrame();
  if ( m_benchmarkFrames != ~0 || m_duration != 0.0 )
  {
    if ( m_renderedFrames == 1 )
    {
      m_benchmarkTimer.start();
      m_benchmarkProgressTimer.start();
    }

    SceneRendererWidget::paint();

    if ( m_benchmarkProgressTimer.getTime() > 1.0 )
    {
      m_benchmarkProgressTimer.restart();
      std::ostringstream os;
      os << "Benchmark Progress: ";
      if ( m_benchmarkFrames != ~0 )
      {
        os << m_renderedFrames << "/" << m_benchmarkFrames;
      }
      else
      {
        os << std::setprecision(2) << m_benchmarkTimer.getTime() << "/" << m_duration;
      }
      setWindowTitle( os.str() );
    }
    if ( (m_benchmarkFrames != ~0 && m_renderedFrames == m_benchmarkFrames) || (m_duration > 0.0 && m_benchmarkTimer.getTime() > m_duration) )
    {
      m_benchmarkTimer.stop();
      m_exitCode = int(double(m_renderedFrames) / m_benchmarkTimer.getTime());
      glutLeaveMainLoop();
    }

    // at the end since the first frame does not count
    ++m_renderedFrames;
  }
  else
  {
    SceneRendererWidget::paint();
  }
  dp::util::FrameProfiler::instance().endFrame();
}
コード例 #5
0
ファイル: main.cpp プロジェクト: raedwulf/pipeline
void GLUTMinimal::paint()
{
  try
  {
    dp::sg::renderer::rix::gl::SceneRendererSharedPtr renderer = getSceneRenderer().staticCast<dp::sg::renderer::rix::gl::SceneRenderer>();
    if ( !m_renderEngine.empty() && renderer->getRenderEngine() != m_renderEngine )
    {
      std::cout << "Setting renderengine: " << m_renderEngine << std::endl;
      renderer->setRenderEngine( m_renderEngine );
    }

    renderer->setShaderManager( m_shaderManager);

    dp::util::FrameProfiler::instance().beginFrame();
    if ( m_benchmarkFrames != ~0 || m_duration != 0.0 )
    {
      if ( m_renderedFrames == 1 )
      {
        m_benchmarkTimer.start();
        m_benchmarkProgressTimer.start();
      }

      SceneRendererWidget::paint();

      if ( m_benchmarkProgressTimer.getTime() > 1.0 )
      {
        m_benchmarkProgressTimer.restart();
        std::ostringstream os;
        os << "Benchmark Progress: ";
        if ( m_benchmarkFrames != ~0 )
        {
          os << m_renderedFrames << "/" << m_benchmarkFrames;
        }
        else
        {
          os << std::setprecision(2) << m_benchmarkTimer.getTime() << "/" << m_duration;
        }
        setWindowTitle( os.str() );
      }
      if ( (m_benchmarkFrames != ~0 && m_renderedFrames == m_benchmarkFrames) || (m_duration > 0.0 && m_benchmarkTimer.getTime() > m_duration) )
      {
        m_benchmarkTimer.stop();
        m_exitCode = int(double(m_renderedFrames) / m_benchmarkTimer.getTime());
        std::cout << "FPS: " << std::fixed << std::setprecision(2) << double(m_renderedFrames) / m_benchmarkTimer.getTime() << std::endl;
        glutLeaveMainLoop();
      }

      // at the end since the first frame does not count
      ++m_renderedFrames;
    }
    else
    {
      SceneRendererWidget::paint();
    }
    dp::util::FrameProfiler::instance().endFrame();
  }
  catch (std::exception &e)
  {
    std::cout << "caught exception: " << std::endl << e.what() << std::endl;
    glutLeaveMainLoop();
  }
  catch (...)
  {
    std::cout << "caught exception" << std::endl;
    glutLeaveMainLoop();
  }
}