Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 11, 2011, 7:37:00 PM (13 years ago)
Author:
dafrick
Message:

Extending and reorganizing ScreenshotManager and SkyboxGenerator.
The SkyboxGenerator now takes HD screenshots, thus the size of the faces generated by the SkyboxGenerator can now be specified freely (through a config value).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/designtools/ScreenshotManager.h

    r8079 r8232  
    1 /* COPYRIGHT: this code comes from http://www.ogre3d.org/wiki/index.php/High_resolution_screenshots */
     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*/
    235
    336#ifndef __ScreenshotManager_h__
     
    538
    639#include "DesignToolsPrereqs.h"
    7 
    8 #include <string>
    9 #include <cstring>
    10 #include <cstdlib>
    1140
    1241#include <OgrePrerequisites.h>
     
    2251    /**
    2352    @brief
    24         Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots.
     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
    2563    */
    2664    class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager>
     
    3169            ScreenshotManager();
    3270            virtual ~ScreenshotManager();
     71            void setConfigValues(void); // Sets some config values.
    3372
    34             void makeScreenshot() const; //!< Creates a screenshot with the given camera.
     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.
    3576
    3677            /**
    37             @brief Creates a screenshot with a given size.
    38             @param size Size is factor by which the current screen size is scaled.
     78            @brief Creates a screenshot.
    3979            */
    40             static void makeScreenshot_s(unsigned int size)
    41                 { getInstance().setGridSize(size); getInstance().makeScreenshot(); }
     80            static void makeScreenshot_s()
     81                { ScreenshotManager::getInstance().makeScreenshot(); }
    4282
    43             void setGridSize(unsigned int size); //!< Set the size of the grid.
     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           
     91        protected:
     92            void update(void); // Update internal parameters.
     93           
     94            static ScreenshotManager* singletonPtr_s;
    4495
    45         protected:
    46             static std::string getTimestamp();
     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.
    47100
    48             std::string mFileExtension_;
    49             unsigned int mGridSize_; //!< 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.
    50             unsigned int mWindowWidth_, mWindowHeight_;
    51             bool mDisableOverlays_;
    52             //! temp texture with current screensize
    53             Ogre::TexturePtr mTempTex_;
    54             Ogre::RenderTexture* mRT_;
    55             Ogre::HardwarePixelBufferSharedPtr mBuffer_;
    56             //! PixelBox for a large Screenshot, if grid size is > 1
    57             Ogre::PixelBox  mFinalPicturePB_;
    58             uint8_t* data_;
     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.
    59107
    60             static ScreenshotManager* singletonPtr_s;
    61108    };
    62109
Note: See TracChangeset for help on using the changeset viewer.