[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" |
---|
| 46 | #include "core/OrxonoxClass.h" |
---|
| 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 | |
---|
| 56 | @author |
---|
| 57 | This code comes from http://www.ogre3d.org/tikiwiki/High+resolution+screenshots which is Public Domain. |
---|
| 58 | @author |
---|
| 59 | Oli Scheuss |
---|
| 60 | @author |
---|
| 61 | Damian 'Mozork' Frick |
---|
| 62 | @ingroup Designtools |
---|
[7015] | 63 | */ |
---|
[7041] | 64 | class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> |
---|
[7015] | 65 | { |
---|
[7041] | 66 | friend class Singleton<ScreenshotManager>; |
---|
| 67 | |
---|
[8079] | 68 | public: |
---|
| 69 | ScreenshotManager(); |
---|
| 70 | virtual ~ScreenshotManager(); |
---|
[8232] | 71 | void setConfigValues(void); // Sets some config values. |
---|
[7015] | 72 | |
---|
[8232] | 73 | void makeScreenshot(); // Make a screenshot. |
---|
| 74 | Ogre::Image* getScreenshot(); // Creates a screenshot and returns it. |
---|
| 75 | Ogre::Image* getScreenshot(Ogre::Camera* camera); // Creates a screenshot with the given camera and returns it. |
---|
[7041] | 76 | |
---|
[8079] | 77 | /** |
---|
[8232] | 78 | @brief Creates a screenshot. |
---|
[8079] | 79 | */ |
---|
[8232] | 80 | static void makeScreenshot_s() |
---|
| 81 | { ScreenshotManager::getInstance().makeScreenshot(); } |
---|
[7076] | 82 | |
---|
[8232] | 83 | void setGridSize(unsigned int size); // Set the size of the grid. |
---|
| 84 | /** |
---|
| 85 | @brief Get the current grid size. |
---|
| 86 | @return Returns the size of the grid. |
---|
| 87 | */ |
---|
| 88 | inline unsigned int getGridSize(void) |
---|
| 89 | { return this->gridSize_; } |
---|
| 90 | |
---|
[8079] | 91 | protected: |
---|
[8232] | 92 | void update(void); // Update internal parameters. |
---|
| 93 | |
---|
| 94 | static ScreenshotManager* singletonPtr_s; |
---|
[7041] | 95 | |
---|
[8232] | 96 | std::string fileExtension_; //!< The image extension used to save the screenshot. |
---|
| 97 | 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. |
---|
| 98 | unsigned int windowWidth_, windowHeight_; //!< The width and height of the window. |
---|
| 99 | bool disableOverlays_; //!< Whether overlays should be disabled. |
---|
[8079] | 100 | |
---|
[8232] | 101 | Ogre::TexturePtr tempTexture_; //!< Temporary texture with current screen size. |
---|
| 102 | Ogre::RenderTexture* renderTarget_; //!< Render target for the temporary texture. |
---|
| 103 | Ogre::HardwarePixelBufferSharedPtr buffer_; //!< Buffer for the temporary texture. |
---|
| 104 | |
---|
| 105 | Ogre::PixelBox finalPicturePB_; //!< PixelBox for large screenshots, contains the screenshot for gridSize_ > 1. |
---|
| 106 | uint8_t* data_; //!< Data pointer for the PixelBox. |
---|
| 107 | |
---|
[7015] | 108 | }; |
---|
| 109 | |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | #endif // __ScreenshotManager_h__ |
---|