From 68964b2cc2f6ae1c1ab35de37ea787382ad1bdcb Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 20 Jan 2011 13:58:22 +0200 Subject: [PATCH] Changed: #1193 The status bar displays profiling information. Particle texture widget displays texture name. --- .../src/graphics_viewport.cpp | 1 + .../3d/object_viewer_qt/src/main_window.cpp | 25 +++++++++++++++++-- .../3d/object_viewer_qt/src/main_window.h | 7 ++++++ .../3d/object_viewer_qt/src/object_viewer.cpp | 19 +------------- .../src/particle_property_dialog.cpp | 2 -- .../src/particle_texture_widget.cpp | 1 + 6 files changed, 33 insertions(+), 22 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp index dc8a81dc8..f6edfd7e2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/graphics_viewport.cpp @@ -49,6 +49,7 @@ namespace NLQT CGraphicsViewport::CGraphicsViewport(QWidget *parent) : QNLWidget(parent) { + this->setStatusTip("Status ready"); } CGraphicsViewport::~CGraphicsViewport() diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp index 25475ed0c..80a486b15 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp @@ -106,8 +106,10 @@ CMainWindow::CMainWindow(QWidget *parent) _statusBarTimer = new QTimer(this); connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); - _statusBarTimer->start(5000); + _statusBarTimer->start(1000); + _statusInfo = new QLabel(this); + this->statusBar()->addPermanentWidget(_statusInfo); Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled)); } @@ -216,7 +218,13 @@ void CMainWindow::about() void CMainWindow::updateStatusBar() { if (_isGraphicsInitialized) - statusBar()->showMessage(QString(Modules::objView().getDriver()->getVideocardInformation())); + { + _statusInfo->setText(QString("%1, Nb tri: %2, Texture used (Mb): %3, fps: %4 ").arg( + Modules::objView().getDriver()->getVideocardInformation()).arg( + _numTri).arg( + _texMem, 0,'f',4).arg( + _fps, 0,'f',2)); + } } void CMainWindow::updateInitialization(bool visible) @@ -615,6 +623,12 @@ void CMainWindow::updateRender() // 14. Update Debug (stuff for dev) // ... + + // 15. Calc FPS + static sint64 lastTime = NLMISC::CTime::getPerformanceTime (); + sint64 newTime = NLMISC::CTime::getPerformanceTime (); + _fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)); + lastTime = newTime; if (_isGraphicsInitialized && !Modules::objView().getDriver()->isLost()) { @@ -643,6 +657,13 @@ void CMainWindow::updateRender() // 09. Render Debug 2D (stuff for dev) Modules::objView().renderDebug2D(); + // 10. Get profile information + NL3D::CPrimitiveProfile in, out; + Modules::objView().getDriver()->profileRenderedPrimitives (in, out); + + _numTri = in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips; + _texMem = float(Modules::objView().getDriver()->getUsedTextureMemory() / float(1024*1024)); + // swap 3d buffers Modules::objView().getDriver()->swapBuffers(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/main_window.h index b7801a117..9abf29e0a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.h @@ -24,6 +24,7 @@ // Qt includes #include +#include // NeL includes #include @@ -140,6 +141,12 @@ private: QAction *_settingsAction; QAction *_aboutAction; QAction *_aboutQtAction; + + QLabel *_statusInfo; + + float _fps; + uint _numTri; + float _texMem; };/* class CMainWindow */ } /* namespace NLQT */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp index ac8d56d5b..780d5fc60 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp @@ -84,6 +84,7 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h) // initialize the window with config file values _Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32)); + _Driver->enableUsedTextureMemorySum(); _Light = ULight::createLight(); @@ -175,24 +176,6 @@ void CObjectViewer::updateInput() { _Driver->EventServer.pump(); - // Test some keys - if (_Driver->AsyncListener.isKeyPushed(KeyQ)) - { - // Change render mode - switch (_Driver->getPolygonMode()) - { - case UDriver::Filled: - _Driver->setPolygonMode (UDriver::Line); - break; - case UDriver::Line: - _Driver->setPolygonMode (UDriver::Point); - break; - case UDriver::Point: - _Driver->setPolygonMode (UDriver::Filled); - break; - } - } - // New matrix from camera _Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix); _Scene->getCam().setMatrix (_MouseListener->getViewMatrix()); diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_property_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_property_dialog.cpp index 0a62bd210..f87fb4afe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_property_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_property_dialog.cpp @@ -21,7 +21,6 @@ #include "particle_property_dialog.h" // Qt includes - // Project includes #include "modules.h" @@ -42,7 +41,6 @@ CPropertyDialog::~CPropertyDialog() void CPropertyDialog::setupUi() { setObjectName(QString::fromUtf8("CPropertyDialog")); - QIcon icon; icon.addFile(QString::fromUtf8(":/images/pqrticles.png"), QSize(), QIcon::Normal, QIcon::Off); setWindowIcon(icon); diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_texture_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_texture_widget.cpp index e2e88e434..42f172866 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_texture_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_texture_widget.cpp @@ -117,6 +117,7 @@ void CParticleTextureWidget::updateTexture() if (dynamic_cast(_Wrapper->get())) { std::string texName = (static_cast(_Wrapper->get()))->getFileName().c_str(); + _ui.nameLabel->setText(tr("Name: %1").arg(texName.c_str())); if (!NLMISC::CFile::getFilename(texName).empty()) _ui.imageLabel->setPixmap(QPixmap(NLMISC::CPath::lookup(texName).c_str())); else