Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/modules/designtools/ScreenshotManager.h @ 8076

Last change on this file since 8076 was 8076, checked in by dafrick, 14 years ago

Adding screenshot to KeybindMenu and making "size" of screenhsot generated by printScreenshotHD adjustable.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
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
6#include "DesignToolsPrereqs.h"
7
8#include <string>
9#include <cstring>
10#include <cstdlib>
11
12#include <OgrePrerequisites.h>
13#include <OgreTexture.h>
14#include <OgreHardwarePixelBuffer.h>
15
16#include "util/Singleton.h"
17#include "core/OrxonoxClass.h"
18
19namespace orxonox
20{
21
22
23    /* Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots.
24    *  pRenderWindow:    Pointer to the render window.  This could be "mWindow" from the ExampleApplication,
25    *              the window automatically created obtained when calling
26    *              Ogre::Root::getSingletonPtr()->initialise(false) and retrieved by calling
27    *              "Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()", or the manually created
28    *              window from calling "mRoot->createRenderWindow()".
29    *  gridSize:      The magnification factor.  A 2 will create a 2x2 grid, doubling the size of the
30                screenshot.  A 3 will create a 3x3 grid, tripling the size of the screenshot.
31    *  fileExtension:    The extension of the screenshot file name, hence the type of graphics file to generate.
32    *              To generate "MyScreenshot.png" this parameter would contain ".png".
33    */
34    class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager>
35    {
36        friend class Singleton<ScreenshotManager>;
37
38    public:
39        ScreenshotManager();
40        ~ScreenshotManager();
41
42        /**
43         * @briefCreates a screenshot with the given camera.
44         * @param camera Pointer to the camera "looking at" the scene of interest
45         * @param fileName the filename of the screenshot file.
46         */
47        void makeScreenshot() const;
48
49        //static void makeScreenshot_s()
50        //    { getInstance().makeScreenshot(); }
51        static void makeScreenshot_s(unsigned int size)
52            { getInstance().setGridSize(size); getInstance().makeScreenshot(); }
53
54        void setGridSize(unsigned int size)
55        {
56            this->mGridSize_ = size;
57            uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3];
58            this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_);
59        }
60
61    protected:
62        static std::string getTimestamp();
63
64        std::string    mFileExtension_;
65        unsigned int   mGridSize_, mWindowWidth_, mWindowHeight_;
66        bool           mDisableOverlays_;
67        //temp texture with current screensize
68        Ogre::TexturePtr mTempTex_;
69        Ogre::RenderTexture* mRT_;
70        Ogre::HardwarePixelBufferSharedPtr mBuffer_;
71        //PixelBox for a large Screenshot, if grid size is > 1
72        Ogre::PixelBox  mFinalPicturePB_;
73        uint8_t* data_;
74
75        static ScreenshotManager* singletonPtr_s;
76    };
77
78}
79
80#endif  // __ScreenshotManager_h__
Note: See TracBrowser for help on using the repository browser.