[8232] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * This code comes from http://www.ogre3d.org/tikiwiki/High+resolution+screenshots which is Public Domain. |
---|
| 24 | * Co-authors: |
---|
| 25 | * Oli Scheuss |
---|
| 26 | * Damian 'Mozork' Frick |
---|
| 27 | * |
---|
| 28 | */ |
---|
[7015] | 29 | |
---|
[8232] | 30 | /** |
---|
| 31 | @file ScreenshotManager.h |
---|
| 32 | @brief Definition of the ScreenshotManager class. |
---|
| 33 | @ingroup Designtools |
---|
| 34 | */ |
---|
| 35 | |
---|
[7015] | 36 | #ifndef __ScreenshotManager_h__ |
---|
| 37 | #define __ScreenshotManager_h__ |
---|
| 38 | |
---|
[7041] | 39 | #include "DesignToolsPrereqs.h" |
---|
| 40 | |
---|
[7015] | 41 | #include <OgrePrerequisites.h> |
---|
| 42 | #include <OgreTexture.h> |
---|
| 43 | #include <OgreHardwarePixelBuffer.h> |
---|
| 44 | |
---|
[7041] | 45 | #include "util/Singleton.h" |
---|
[9667] | 46 | #include "core/config/Configurable.h" |
---|
[7041] | 47 | |
---|
[7015] | 48 | namespace orxonox |
---|
| 49 | { |
---|
| 50 | |
---|
[8079] | 51 | /** |
---|
| 52 | @brief |
---|
[8232] | 53 | Class encapsulates screenshot functionality and provides a method for making multi grid (i.e. HD) screenshots. |
---|
| 54 | |
---|
| 55 | @author |
---|
| 56 | This code comes from http://www.ogre3d.org/tikiwiki/High+resolution+screenshots which is Public Domain. |
---|
| 57 | @author |
---|
| 58 | Oli Scheuss |
---|
| 59 | @author |
---|
| 60 | Damian 'Mozork' Frick |
---|
| 61 | @ingroup Designtools |
---|
[7015] | 62 | */ |
---|
[9667] | 63 | class ScreenshotManager : public Configurable, public Singleton<ScreenshotManager> |
---|
[7015] | 64 | { |
---|
[7041] | 65 | friend class Singleton<ScreenshotManager>; |
---|
| 66 | |
---|
[8079] | 67 | public: |
---|
| 68 | ScreenshotManager(); |
---|
| 69 | virtual ~ScreenshotManager(); |
---|
[8232] | 70 | void setConfigValues(void); // Sets some config values. |
---|
[7015] | 71 | |
---|
[8232] | 72 | void makeScreenshot(); // Make a screenshot. |
---|
| 73 | Ogre::Image* getScreenshot(); // Creates a screenshot and returns it. |
---|
| 74 | Ogre::Image* getScreenshot(Ogre::Camera* camera); // Creates a screenshot with the given camera and returns it. |
---|
[7041] | 75 | |
---|
[8079] | 76 | /** |
---|
[8232] | 77 | @brief Creates a screenshot. |
---|
[8079] | 78 | */ |
---|
[8232] | 79 | static void makeScreenshot_s() |
---|
| 80 | { ScreenshotManager::getInstance().makeScreenshot(); } |
---|
[7076] | 81 | |
---|
[8232] | 82 | void setGridSize(unsigned int size); // Set the size of the grid. |
---|
| 83 | /** |
---|
| 84 | @brief Get the current grid size. |
---|
| 85 | @return Returns the size of the grid. |
---|
| 86 | */ |
---|
| 87 | inline unsigned int getGridSize(void) |
---|
| 88 | { return this->gridSize_; } |
---|
[8413] | 89 | |
---|
| 90 | void cleanup(void); // Frees used memory. |
---|
[8232] | 91 | |
---|
[8079] | 92 | protected: |
---|
[8232] | 93 | void update(void); // Update internal parameters. |
---|
| 94 | |
---|
| 95 | static ScreenshotManager* singletonPtr_s; |
---|
[7041] | 96 | |
---|
[8232] | 97 | std::string fileExtension_; //!< The image extension used to save the screenshot. |
---|
| 98 | unsigned int gridSize_; //!< 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. |
---|
| 99 | unsigned int windowWidth_, windowHeight_; //!< The width and height of the window. |
---|
| 100 | bool disableOverlays_; //!< Whether overlays should be disabled. |
---|
[8079] | 101 | |
---|
[8232] | 102 | Ogre::TexturePtr tempTexture_; //!< Temporary texture with current screen size. |
---|
| 103 | Ogre::RenderTexture* renderTarget_; //!< Render target for the temporary texture. |
---|
| 104 | Ogre::HardwarePixelBufferSharedPtr buffer_; //!< Buffer for the temporary texture. |
---|
| 105 | |
---|
[8413] | 106 | Ogre::PixelBox* finalPicturePB_; //!< PixelBox for large screenshots, contains the screenshot for gridSize_ > 1. |
---|
[8232] | 107 | uint8_t* data_; //!< Data pointer for the PixelBox. |
---|
| 108 | |
---|
[7015] | 109 | }; |
---|
| 110 | |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | #endif // __ScreenshotManager_h__ |
---|