| [7015] | 1 | /* COPYRIGHT: this code comes from http://www.ogre3d.org/wiki/index.php/High_resolution_screenshots */ | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #ifndef __ScreenshotManager_h__ | 
|---|
|  | 4 | #define __ScreenshotManager_h__ | 
|---|
|  | 5 |  | 
|---|
| [7041] | 6 | #include "DesignToolsPrereqs.h" | 
|---|
|  | 7 |  | 
|---|
| [7015] | 8 | #include <string> | 
|---|
| [7041] | 9 | #include <cstring> | 
|---|
|  | 10 | #include <cstdlib> | 
|---|
|  | 11 |  | 
|---|
| [7015] | 12 | #include <OgrePrerequisites.h> | 
|---|
|  | 13 | #include <OgreTexture.h> | 
|---|
|  | 14 | #include <OgreHardwarePixelBuffer.h> | 
|---|
|  | 15 |  | 
|---|
| [7041] | 16 | #include "util/Singleton.h" | 
|---|
|  | 17 | #include "core/OrxonoxClass.h" | 
|---|
|  | 18 |  | 
|---|
| [7015] | 19 | namespace orxonox | 
|---|
|  | 20 | { | 
|---|
|  | 21 |  | 
|---|
|  | 22 |  | 
|---|
| [7076] | 23 | /* Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. | 
|---|
| [7015] | 24 | *  pRenderWindow:    Pointer to the render window.  This could be "mWindow" from the ExampleApplication, | 
|---|
|  | 25 | *              the window automatically created obtained when calling | 
|---|
|  | 26 | *              Ogre::Root::getSingletonPtr()->initialise(false) and retrieved by calling | 
|---|
|  | 27 | *              "Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()", or the manually created | 
|---|
|  | 28 | *              window from calling "mRoot->createRenderWindow()". | 
|---|
|  | 29 | *  gridSize:      The magnification factor.  A 2 will create a 2x2 grid, doubling the size of the | 
|---|
|  | 30 | screenshot.  A 3 will create a 3x3 grid, tripling the size of the screenshot. | 
|---|
|  | 31 | *  fileExtension:    The extension of the screenshot file name, hence the type of graphics file to generate. | 
|---|
|  | 32 | *              To generate "MyScreenshot.png" this parameter would contain ".png". | 
|---|
|  | 33 | */ | 
|---|
| [7041] | 34 | class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> | 
|---|
| [7015] | 35 | { | 
|---|
| [7041] | 36 | friend class Singleton<ScreenshotManager>; | 
|---|
|  | 37 |  | 
|---|
| [7015] | 38 | public: | 
|---|
| [7041] | 39 | ScreenshotManager(); | 
|---|
| [7015] | 40 | ~ScreenshotManager(); | 
|---|
|  | 41 |  | 
|---|
|  | 42 | /* Creates a screenshot with the given camera. | 
|---|
|  | 43 | * @param camera Pointer to the camera "looking at" the scene of interest | 
|---|
|  | 44 | * @param fileName the filename of the screenshot file. | 
|---|
|  | 45 | */ | 
|---|
| [7041] | 46 | void makeScreenshot() const; | 
|---|
|  | 47 |  | 
|---|
|  | 48 | static void makeScreenshot_s() | 
|---|
|  | 49 | { getInstance().makeScreenshot(); } | 
|---|
| [7076] | 50 |  | 
|---|
| [7015] | 51 | protected: | 
|---|
| [7044] | 52 | static std::string getTimestamp(); | 
|---|
| [7041] | 53 |  | 
|---|
| [7039] | 54 | std::string    mFileExtension; | 
|---|
| [7015] | 55 | unsigned int   mGridSize, mWindowWidth, mWindowHeight; | 
|---|
|  | 56 | bool           mDisableOverlays; | 
|---|
|  | 57 | //temp texture with current screensize | 
|---|
|  | 58 | Ogre::TexturePtr mTempTex; | 
|---|
|  | 59 | Ogre::RenderTexture* mRT; | 
|---|
|  | 60 | Ogre::HardwarePixelBufferSharedPtr mBuffer; | 
|---|
|  | 61 | //PixelBox for a large Screenshot, if grid size is > 1 | 
|---|
|  | 62 | Ogre::PixelBox  mFinalPicturePB; | 
|---|
|  | 63 | uint8_t* data_; | 
|---|
| [7041] | 64 |  | 
|---|
|  | 65 | static ScreenshotManager* singletonPtr_s; | 
|---|
| [7015] | 66 | }; | 
|---|
|  | 67 |  | 
|---|
|  | 68 | } | 
|---|
|  | 69 |  | 
|---|
|  | 70 | #endif  // __ScreenshotManager_h__ | 
|---|