Orxonox  0.0.5 Codename: Arcturus
ScreenshotManager.h
Go to the documentation of this file.
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 
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"
47 
48 namespace orxonox
49 {
50 
63  class ScreenshotManager : public Configurable, public Singleton<ScreenshotManager>
64  {
66 
67  public:
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 
79  static void makeScreenshot_s()
80  { ScreenshotManager::getInstance().makeScreenshot(); }
81 
82  void setGridSize(unsigned int size); // Set the size of the grid.
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 
96 
98  unsigned int gridSize_;
99  unsigned int windowWidth_, windowHeight_;
101 
102  Ogre::TexturePtr tempTexture_;
103  Ogre::RenderTexture* renderTarget_;
104  Ogre::HardwarePixelBufferSharedPtr buffer_;
105 
106  Ogre::PixelBox* finalPicturePB_;
107  uint8_t* data_;
108 
109  };
110 
111 }
112 
113 #endif // __ScreenshotManager_h__
static void makeScreenshot_s()
Creates a screenshot.
Definition: ScreenshotManager.h:79
std::string fileExtension_
The image extension used to save the screenshot.
Definition: ScreenshotManager.h: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.
Definition: ScreenshotManager.h:98
::std::string string
Definition: gtest-port.h:756
ScreenshotManager()
Constructor.
Definition: ScreenshotManager.cc:71
void setConfigValues(void)
Sets some config values.
Definition: ScreenshotManager.cc:110
This is the base class of all objects which may contain config values.
Definition: Configurable.h:47
unsigned int windowHeight_
The width and height of the window.
Definition: ScreenshotManager.h:99
Ogre::Image * getScreenshot()
Creates a screenshot and returns it.
Definition: ScreenshotManager.cc:173
unsigned int getGridSize(void)
Get the current grid size.
Definition: ScreenshotManager.h:87
Ogre::HardwarePixelBufferSharedPtr buffer_
Buffer for the temporary texture.
Definition: ScreenshotManager.h:104
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
virtual ~ScreenshotManager()
Definition: ScreenshotManager.cc:81
Class encapsulates screenshot functionality and provides a method for making multi grid (i...
Definition: ScreenshotManager.h:63
bool disableOverlays_
Whether overlays should be disabled.
Definition: ScreenshotManager.h:100
Declaration of Configurable, the base class of all objects which may contain config values...
Ogre::TexturePtr tempTexture_
Temporary texture with current screen size.
Definition: ScreenshotManager.h:102
Ogre::RenderTexture * renderTarget_
Render target for the temporary texture.
Definition: ScreenshotManager.h:103
uint8_t * data_
Data pointer for the PixelBox.
Definition: ScreenshotManager.h:107
void cleanup(void)
Frees used memory.
Definition: ScreenshotManager.cc:90
Definition of the Singleton template that is used as base class for classes that allow only one insta...
Shared library macros, enums, constants and forward declarations for the pong module ...
void makeScreenshot()
Make a screenshot.
Definition: ScreenshotManager.cc:149
void setGridSize(unsigned int size)
Set the size of the grid.
Definition: ScreenshotManager.cc:289
unsigned int windowWidth_
Definition: ScreenshotManager.h:99
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
static ScreenshotManager * singletonPtr_s
Definition: ScreenshotManager.h:95
void update(void)
Update internal parameters.
Definition: ScreenshotManager.cc:122
Ogre::PixelBox * finalPicturePB_
PixelBox for large screenshots, contains the screenshot for gridSize_ > 1.
Definition: ScreenshotManager.h:106