Changeset 7041
- Timestamp:
- May 31, 2010, 1:30:58 PM (14 years ago)
- Location:
- code/branches/presentation3/src/modules/designtools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/designtools/ScreenshotManager.cc
r7039 r7041 1 1 /* COPYRIGHT: this code comes from http://www.ogre3d.org/wiki/index.php/High_resolution_screenshots */ 2 2 3 //#include <stdafx.h>4 3 #include "ScreenshotManager.h" 4 5 5 #include <OgreRenderWindow.h> 6 6 #include <OgreViewport.h> … … 10 10 11 11 #include "core/GraphicsManager.h" 12 #include "core/PathConfig.h" 13 #include "core/ScopedSingletonManager.h" 14 #include "core/ConsoleCommand.h" 12 15 13 //using namespace Ogre; 16 #include "CameraManager.h" 17 #include "graphics/Camera.h" 14 18 15 19 namespace orxonox 16 20 { 21 ManageScopedSingleton(ScreenshotManager, ScopeID::Graphics, false); 22 SetConsoleCommandAlias(ScreenshotManager, makeScreenshot_s, "printScreenHD", true); 17 23 18 ScreenshotManager::ScreenshotManager( Ogre::RenderWindow* pRenderWindow, int gridSize, std::string fileExtension, bool overlayFlag)24 ScreenshotManager::ScreenshotManager() 19 25 { 26 Ogre::RenderWindow* pRenderWindow = GraphicsManager::getInstance().getRenderWindow(); 27 int gridSize = 3; 28 std::string fileExtension = ".png"; 29 bool overlayFlag = true; 30 20 31 //set file extension for the Screenshot files 21 mFileExtension = fileExtension;32 mFileExtension = fileExtension; 22 33 // the gridsize 23 mGridSize 34 mGridSize = gridSize; 24 35 // flag for overlay rendering 25 mDisableOverlays 36 mDisableOverlays = overlayFlag; 26 37 //get current window size 27 38 mWindowWidth = pRenderWindow->getWidth(); … … 47 58 ScreenshotManager::~ScreenshotManager() 48 59 { 49 delete[] data_; 60 // Don't delete data_. Somehow this pointer points anywhere but to memory location. 61 //delete[] data_; 50 62 } 51 63 … … 55 67 * @param fileName the filename of the screenshot file. 56 68 */ 57 void ScreenshotManager::makeScreenshot( Ogre::Camera* camera, std::string fileName) const69 void ScreenshotManager::makeScreenshot() const 58 70 { 71 Ogre::Camera* camera = CameraManager::getInstance().getActiveCamera()->getOgreCamera(); 72 std::string fileName = PathConfig::getInstance().getLogPathString() + "screenshot_" + this->getTimestamp(); 59 73 60 74 //Remove all viewports, so the added Viewport(camera) ist the only … … 143 157 } 144 158 159 std::string ScreenshotManager::getTimestamp() 160 { 161 struct tm *pTime; 162 time_t ctTime; time(&ctTime); 163 pTime = localtime( &ctTime ); 164 std::ostringstream oss; 165 oss << std::setw(2) << std::setfill('0') << (pTime->tm_mon + 1) 166 << std::setw(2) << std::setfill('0') << pTime->tm_mday 167 << std::setw(2) << std::setfill('0') << (pTime->tm_year + 1900) 168 << "_" << std::setw(2) << std::setfill('0') << pTime->tm_hour 169 << std::setw(2) << std::setfill('0') << pTime->tm_min 170 << std::setw(2) << std::setfill('0') << pTime->tm_sec; 171 return oss.str(); 172 } 173 145 174 } -
code/branches/presentation3/src/modules/designtools/ScreenshotManager.h
r7039 r7041 4 4 #define __ScreenshotManager_h__ 5 5 6 #include "DesignToolsPrereqs.h" 7 6 8 #include <string> 9 #include <cstring> 10 #include <cstdlib> 11 7 12 #include <OgrePrerequisites.h> 8 13 #include <OgreTexture.h> 9 14 #include <OgreHardwarePixelBuffer.h> 10 #include "OrxonoxConfig.h" 11 #include <cstring>12 #include <cstdlib>15 16 #include "util/Singleton.h" 17 #include "core/OrxonoxClass.h" 13 18 14 19 namespace orxonox … … 27 32 * To generate "MyScreenshot.png" this parameter would contain ".png". 28 33 */ 29 class ScreenshotManager 34 class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> 30 35 { 36 friend class Singleton<ScreenshotManager>; 37 31 38 public: 32 ScreenshotManager( Ogre::RenderWindow* pRenderWindow, int gridSize, std::string fileExtension, bool overlayFlag);39 ScreenshotManager(); 33 40 ~ScreenshotManager(); 34 41 … … 37 44 * @param fileName the filename of the screenshot file. 38 45 */ 39 void makeScreenshot(Ogre::Camera* camera, Ogre::String fileName) const; 46 void makeScreenshot() const; 47 48 static void makeScreenshot_s() 49 { getInstance().makeScreenshot(); } 40 50 41 51 protected: 52 static std::string ScreenshotManager::getTimestamp(); 53 42 54 std::string mFileExtension; 43 55 unsigned int mGridSize, mWindowWidth, mWindowHeight; … … 50 62 Ogre::PixelBox mFinalPicturePB; 51 63 uint8_t* data_; 64 65 static ScreenshotManager* singletonPtr_s; 52 66 }; 53 67
Note: See TracChangeset
for help on using the changeset viewer.