[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 | |
---|
[8079] | 22 | /** |
---|
| 23 | @brief |
---|
| 24 | Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. |
---|
[7015] | 25 | */ |
---|
[7041] | 26 | class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> |
---|
[7015] | 27 | { |
---|
[7041] | 28 | friend class Singleton<ScreenshotManager>; |
---|
| 29 | |
---|
[8079] | 30 | public: |
---|
| 31 | ScreenshotManager(); |
---|
| 32 | virtual ~ScreenshotManager(); |
---|
[7015] | 33 | |
---|
[8079] | 34 | void makeScreenshot() const; //!< Creates a screenshot with the given camera. |
---|
[7041] | 35 | |
---|
[8079] | 36 | /** |
---|
| 37 | @brief Creates a screenshot with a given size. |
---|
| 38 | @param size Size is factor by which the current screen size is scaled. |
---|
| 39 | */ |
---|
| 40 | static void makeScreenshot_s(unsigned int size) |
---|
| 41 | { getInstance().setGridSize(size); getInstance().makeScreenshot(); } |
---|
[7076] | 42 | |
---|
[8079] | 43 | void setGridSize(unsigned int size); //!< Set the size of the grid. |
---|
[7041] | 44 | |
---|
[8079] | 45 | protected: |
---|
| 46 | static std::string getTimestamp(); |
---|
[7041] | 47 | |
---|
[8079] | 48 | std::string mFileExtension_; |
---|
| 49 | unsigned int mGridSize_; //!< The magnification factor. A 2 will create a 2x2 grid, doubling the size of the screenshot. A 3 will create a 3x3 grid, tripling the size of the screenshot. |
---|
| 50 | unsigned int mWindowWidth_, mWindowHeight_; |
---|
| 51 | bool mDisableOverlays_; |
---|
| 52 | //! temp texture with current screensize |
---|
| 53 | Ogre::TexturePtr mTempTex_; |
---|
| 54 | Ogre::RenderTexture* mRT_; |
---|
| 55 | Ogre::HardwarePixelBufferSharedPtr mBuffer_; |
---|
| 56 | //! PixelBox for a large Screenshot, if grid size is > 1 |
---|
| 57 | Ogre::PixelBox mFinalPicturePB_; |
---|
| 58 | uint8_t* data_; |
---|
| 59 | |
---|
| 60 | static ScreenshotManager* singletonPtr_s; |
---|
[7015] | 61 | }; |
---|
| 62 | |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | #endif // __ScreenshotManager_h__ |
---|