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 | */ |
---|
29 | |
---|
30 | /** |
---|
31 | @file ScreenshotManager.h |
---|
32 | @brief Definition of the ScreenshotManager class. |
---|
33 | @ingroup Designtools |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef __ScreenshotManager_h__ |
---|
37 | #define __ScreenshotManager_h__ |
---|
38 | |
---|
39 | #include "DesignToolsPrereqs.h" |
---|
40 | |
---|
41 | #include <OgrePrerequisites.h> |
---|
42 | #include <OgreTexture.h> |
---|
43 | #include <OgreHardwarePixelBuffer.h> |
---|
44 | |
---|
45 | #include "util/Singleton.h" |
---|
46 | #include "core/config/Configurable.h" |
---|
47 | |
---|
48 | namespace orxonox |
---|
49 | { |
---|
50 | |
---|
51 | /** |
---|
52 | @brief |
---|
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 |
---|
62 | */ |
---|
63 | class ScreenshotManager : public Configurable, public Singleton<ScreenshotManager> |
---|
64 | { |
---|
65 | friend class Singleton<ScreenshotManager>; |
---|
66 | |
---|
67 | public: |
---|
68 | ScreenshotManager(); |
---|
69 | virtual ~ScreenshotManager(); |
---|
70 | void setConfigValues(void); // Sets some config values. |
---|
71 | |
---|
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. |
---|
75 | |
---|
76 | /** |
---|
77 | @brief Creates a screenshot. |
---|
78 | */ |
---|
79 | static void makeScreenshot_s() |
---|
80 | { ScreenshotManager::getInstance().makeScreenshot(); } |
---|
81 | |
---|
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_; } |
---|
89 | |
---|
90 | void cleanup(void); // Frees used memory. |
---|
91 | |
---|
92 | protected: |
---|
93 | void update(void); // Update internal parameters. |
---|
94 | |
---|
95 | static ScreenshotManager* singletonPtr_s; |
---|
96 | |
---|
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. |
---|
101 | |
---|
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 | |
---|
106 | Ogre::PixelBox* finalPicturePB_; //!< PixelBox for large screenshots, contains the screenshot for gridSize_ > 1. |
---|
107 | uint8_t* data_; //!< Data pointer for the PixelBox. |
---|
108 | |
---|
109 | }; |
---|
110 | |
---|
111 | } |
---|
112 | |
---|
113 | #endif // __ScreenshotManager_h__ |
---|