1

I'm trying to embedd Cesium in a QT 5.2 application,

I'm loading an html file, stored in the qrc resources, that create a Cesium.Viewer widget and monitors its framePerSecond performance with stats.min.js.

Viewer.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Use correct character set. -->
  <meta charset="utf-8">
  <!-- Tell IE to use the latest, best version (or Chrome Frame if pre-IE11). -->
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-    scale=1, minimum-scale=1, user-scalable=no">
  <title>Hello World!</title>
  <script src="Cesium/Cesium.js"></script>
  <script src="stats.min.js"></script>      
  <style>
  @import url(Cesium/Widgets/widgets.css);

  #cesiumContainer {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
      margin: 0;
      overflow: hidden;
      padding: 0;
      font-family: sans-serif;
  }

  body {
      padding: 0;
      margin: 0;
      overflow: hidden;
  }
  </style>
  </head>
  <body>
  <div id="cesiumContainer"></div>
  <script>

  var stats = new Stats();
  // Align top-left
  stats.domElement.style.position = 'absolute';
  stats.domElement.style.left = '0px';
  stats.domElement.style.top = '0px';
  document.body.appendChild( stats.domElement );
  setInterval( function () {
      stats.update();
  }, 1000 / 60 );

  var widget = new Cesium.Viewer('cesiumContainer');

  </script>
  </body>
  </html>

On the QT side I have this code:

#include <QApplication>
#include <QWebView>
#include <QWebPage>
#include <QGraphicsView>
#include <QGraphicsWebView>
#include <QGLWidget>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QGraphicsView *gview;
    QGraphicsScene *scene;
    QGraphicsWebView *web_view;

    QWebSettings::globalSettings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
    gview = new QGraphicsView();
    gview->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    gview->setViewport(new QGLWidget());

    scene = new QGraphicsScene(gview);
    web_view = new QGraphicsWebView();

    scene->addItem(web_view);
    gview->setScene(scene);
    web_view->load(QUrl("qrc:/Resources/Viewer.html"));

    web_view->resize(1500, 900);
    gview->resize(1550, 950);
    gview->show();

    return a.exec();
 }

I'm having a problem with the framePerSecond rate, using a QWebView widget the fps value doesn't exceed 20 fps, using a QGraphicsView, QGraphicsWebView (as above) the fps value goes better but doesn't exceed 30 fps. If I add geometries to the viewer the fps rate slows down.

The 60 fps rate of the browser seems to be unreachable. I'm doing wrong with QT settings? Any idea?.

user3657277
  • 21
  • 1
  • 3
  • Using a `setInterval`-based FPS tracker is not necessarily reflective of the FPS the Cesium render loop is getting. Try setting `viewer.scene.debugShowFramesPerSecond = true;` to turn on the built-in FPS display and see if you are getting similar results. – paraquat May 20 '14 at 17:45
  • Thaks but results don't change, the fluency of the globe dramatically slows down just with the CesiumViewer only, moreover if I try to load a more complex code like this one: http://cesiumjs.org/LotsOfSatellites/ my QT application tries to load it but freezes – user3657277 May 21 '14 at 09:37

0 Answers0