Changeset 4628 for geovis/trunk/Renderer.cpp
- Timestamp:
- Aug 27, 2014, 1:08:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Renderer.cpp
r4575 r4628 20 20 #include <sys/time.h> 21 21 #endif 22 23 //#define USE_OSGEARTH_TRUNK24 #define USE_CACHE25 22 26 23 #include <osgDB/FileUtils> … … 89 86 _bgColor[1] = 0; 90 87 _bgColor[2] = 0; 91 _minFrameTime = 1.0/30.0; 88 //setMaximumFrameRateInHertz(15.0); 89 // 100MBit 90 setMaximumBitrate(1.0e8); 92 91 _lastFrameTime = _minFrameTime; 92 TRACE("Bandwidth target: %.2f MBit", (float)(getMaximumBitrate()/1.0e6)); 93 TRACE("Frame rate target: %.2f Hz", (float)getMaximumFrameRateInHertz()); 93 94 94 95 char *base = getenv("MAP_BASE_URI"); … … 1026 1027 } 1027 1028 1028 voidRenderer::addImageLayer(const char *name,1029 bool Renderer::addImageLayer(const char *name, 1029 1030 osgEarth::TileSourceOptions& opts, 1030 1031 bool makeShared, … … 1033 1034 if (!_map.valid()) { 1034 1035 ERROR("No map"); 1035 return ;1036 return false; 1036 1037 } 1037 1038 TRACE("layer: %s", name); … … 1046 1047 layerOpts.visible() = false; 1047 1048 } 1048 _map->addImageLayer(new osgEarth::ImageLayer(layerOpts)); 1049 osg::ref_ptr<osgEarth::ImageLayer> layer = new osgEarth::ImageLayer(layerOpts); 1050 _map->addImageLayer(layer.get()); 1051 if (layer->getTileSource() == NULL || !layer->getTileSource()->isOK()) { 1052 ERROR("Failed to add image layer: %s", name); 1053 _map->removeImageLayer(layer.get()); 1054 return false; 1055 } 1049 1056 _needsRedraw = true; 1057 return true; 1050 1058 } 1051 1059 … … 1307 1315 TRACE("Setting window size to %dx%d", width, height); 1308 1316 1317 double origBitrate = getMaximumBitrate(); 1318 1309 1319 _windowWidth = width; 1310 1320 _windowHeight = height; 1321 1322 setMaximumBitrate(origBitrate); 1323 TRACE("Bandwidth target: %.2f MBit", (float)(getMaximumBitrate()/1.0e6)); 1324 TRACE("Frame rate target: %.2f Hz", (float)getMaximumFrameRateInHertz()); 1325 1311 1326 if (_viewer.valid()) { 1312 1327 #ifdef USE_OFFSCREEN_RENDERING … … 1647 1662 } 1648 1663 1664 void Renderer::markFrameStart() 1665 { 1666 _startFrameTime = osg::Timer::instance()->tick(); 1667 } 1668 1669 void Renderer::markFrameEnd() 1670 { 1671 osg::Timer_t endFrameTick = osg::Timer::instance()->tick(); 1672 _lastFrameTime = osg::Timer::instance()->delta_s(_startFrameTime, endFrameTick); 1673 TRACE("Frame time: %g sec", _lastFrameTime); 1674 #ifdef USE_THROTTLING_SLEEP 1675 if (_lastFrameTime < _minFrameTime) { 1676 TRACE("Sleeping for %g secs", _minFrameTime - _lastFrameTime); 1677 OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(_minFrameTime - _lastFrameTime))); 1678 } 1679 #endif 1680 } 1681 1649 1682 /** 1650 1683 * \brief Cause the rendering to render a new image if needed … … 1657 1690 if (_viewer.valid() && checkNeedToDoFrame()) { 1658 1691 TRACE("Enter needsRedraw=%d", _needsRedraw ? 1 : 0); 1692 #ifndef SLEEP_AFTER_QUEUE_FRAME 1659 1693 osg::Timer_t startFrameTick = osg::Timer::instance()->tick(); 1694 #endif 1660 1695 TRACE("Before frame()"); 1661 1696 _viewer->frame(); 1662 1697 TRACE("After frame()"); 1698 #ifndef SLEEP_AFTER_QUEUE_FRAME 1663 1699 osg::Timer_t endFrameTick = osg::Timer::instance()->tick(); 1664 1700 _lastFrameTime = osg::Timer::instance()->delta_s(startFrameTick, endFrameTick); 1665 1701 TRACE("Frame time: %g sec", _lastFrameTime); 1666 #if 0 1667 if (frameTime < minFrameTime) { 1668 TRACE("Sleeping for %g secs", minFrameTime-frameTime); 1669 OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(minFrameTime-frameTime))); 1670 } 1702 #ifdef USE_THROTTLING_SLEEP 1703 if (_lastFrameTime < _minFrameTime) { 1704 TRACE("Sleeping for %g secs", _minFrameTime - _lastFrameTime); 1705 OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(_minFrameTime - _lastFrameTime))); 1706 } 1707 #endif 1671 1708 #endif 1672 1709 #ifdef WANT_TRACE
Note: See TracChangeset
for help on using the changeset viewer.