PixelLightAPI  .
Screenshot.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Screenshot.h                                   *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLENGINE_TOOLS_SCREENSHOT_H__
00024 #define __PLENGINE_TOOLS_SCREENSHOT_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include "PLEngine/PLEngine.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039     class RendererContext;
00040     class SurfacePainter;
00041 }
00042 
00043 
00044 //[-------------------------------------------------------]
00045 //[ Namespace                                             ]
00046 //[-------------------------------------------------------]
00047 namespace PLEngine {
00048 
00049 
00050 //[-------------------------------------------------------]
00051 //[ Classes                                               ]
00052 //[-------------------------------------------------------]
00053 /**
00054 *  @brief
00055 *    Class offering screenshot functionality
00056 */
00057 class Screenshot : public PLCore::Object {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ RTTI interface                                        ]
00062     //[-------------------------------------------------------]
00063     pl_class(PL_RTTI_EXPORT, Screenshot, "PLEngine", PLCore::Object, "Class offering screenshot functionality")
00064         #ifdef PLENGINE_EXPORTS // The following is only required when compiling PLEngine
00065             // Methods
00066             pl_method_0(GetScreenshotDirectory, pl_ret_type(PLCore::String),                            "Get screenshot directory in which the screenshots are saved",                                                                                                                                                                                                                                                          "")
00067             pl_method_1(SetScreenshotDirectory, pl_ret_type(void),              const PLCore::String&,  "Set screenshot directory, directory in which the screenshots are saved as first parameter (if set to \"\", the current directory will be used)",                                                                                                                                                                       "")
00068             pl_method_1(SaveScreenshot,         pl_ret_type(bool),              const PLCore::String&,  "Save screenshot from current render target, screenshot filename (e.g. \"Screenshot.png\") as first parameter (if string is empty, GetScreenshotFilename() will be used). Returns 'true' if all went fine, else 'false'. Uses the dimension of the current render target.",                                             "")
00069             pl_method_1(GetScreenshotFilename,  pl_ret_type(PLCore::String),    const PLCore::String&,  "Get a screenshot filename recommendation, file name extension (for example \"png\") as first parameter. Returns the recommended screenshot filename, empty string on error. The screenshot filename is automatically generated: \"/_Screenshots/Screenshot_0.png\", \"/_Screenshots/Screenshot_1.png\" and so on...",  "")
00070         #endif
00071     pl_class_end
00072 
00073 
00074     //[-------------------------------------------------------]
00075     //[ Public functions                                      ]
00076     //[-------------------------------------------------------]
00077     public:
00078         /**
00079         *  @brief
00080         *    Constructor
00081         *
00082         *  @param[in] pRendererContext
00083         *    Renderer context from which to create screenshots, can be a null pointer
00084         *  @param[in] pPainter
00085         *    Surface painter, can be a null pointer (only needed for extended screenshot functionality)
00086         */
00087         PL_API Screenshot(PLRenderer::RendererContext *pRendererContext = nullptr, PLRenderer::SurfacePainter *pPainter = nullptr);
00088 
00089         /**
00090         *  @brief
00091         *    Destructor
00092         */
00093         PL_API virtual ~Screenshot();
00094 
00095         /**
00096         *  @brief
00097         *    Get renderer context
00098         *
00099         *  @return
00100         *    Renderer context from which to create screenshots, can be a null pointer
00101         */
00102         PL_API PLRenderer::RendererContext *GetRendererContext() const;
00103 
00104         /**
00105         *  @brief
00106         *    Set renderer context
00107         *
00108         *  @param[in] pRendererContext
00109         *    Renderer context from which to create screenshots, can be a null pointer
00110         */
00111         PL_API void SetRendererContext(PLRenderer::RendererContext *pRendererContext);
00112 
00113         /**
00114         *  @brief
00115         *    Get surface painter
00116         *
00117         *  @return
00118         *    Surface painter used to create screenshots, can be a null pointer
00119         */
00120         PL_API PLRenderer::SurfacePainter *GetPainter() const;
00121 
00122         /**
00123         *  @brief
00124         *    Set surface painter
00125         *
00126         *  @param[in] pSurfacePainter
00127         *    Surface painter used to create screenshots, can be a null pointer
00128         */
00129         PL_API void SetPainter(PLRenderer::SurfacePainter *pSurfacePainter);
00130 
00131         /**
00132         *  @brief
00133         *    Get screenshot directory
00134         *
00135         *  @return
00136         *    Directory in which the screenshots are saved
00137         */
00138         PL_API PLCore::String GetScreenshotDirectory() const;
00139 
00140         /**
00141         *  @brief
00142         *    Set screenshot directory
00143         *
00144         *  @param[in] sPath
00145         *    Directory in which the screenshots are saved
00146         *
00147         *  @note
00148         *    - If set to "", the current directory will be used
00149         */
00150         PL_API void SetScreenshotDirectory(const PLCore::String &sPath);
00151 
00152         /**
00153         *  @brief
00154         *    Save screenshot from current render target
00155         *
00156         *  @param[in] sFilename
00157         *    Screenshot filename (e.g. "Screenshot.png"), if string is empty, GetScreenshotFilename() will be used
00158         *
00159         *  @return
00160         *    'true' if all went fine, else 'false'
00161         *
00162         *  @note
00163         *    - Uses the dimension of the current render target
00164         */
00165         PL_API bool SaveScreenshot(const PLCore::String &sFilename = "") const;
00166 
00167         /**
00168         *  @brief
00169         *    Save screenshot by using the surface painter of the current render target surface
00170         *
00171         *  @param[in] sFilename
00172         *    Screenshot filename (e.g. "Screenshot.png"), if string is empty, GetScreenshotFilename() will be used
00173         *  @param[in] nWidth
00174         *    Width of the screenshot (1..<hardware limitation>)
00175         *  @param[in] nHeight
00176         *    Height of screenshot (1..<hardware limitation>)
00177         *  @param[in] nFormat
00178         *    Texture buffer pixel format for creating the screenshot (example: 'TextureBuffer::R8G8B8')
00179         *  @param[in] nFlags
00180         *    Texture buffer surface flags (see PLRenderer::SurfaceTextureBuffer::EFlags) for creating the screenshot
00181         *    (example: 'SurfaceTextureBuffer::Depth')
00182         *
00183         *  @return
00184         *    'true' if all went fine, else 'false'
00185         *
00186         *  @remarks
00187         *    Unlike the simple 'SaveScreenshot()'-function from above, this function is rendering again by
00188         *    using an own render target allowing a more or less 'free choice' of the screenshot dimension.
00189         *    This dimension is only limited by the 'render to texture' capabilities of the hardware - most
00190         *    'current' hardware supports dimensions up to 8192x8192. Use the renderer capabilities to figure
00191         *    out the maximum supported rectangle texture dimension.
00192         */
00193         PL_API bool SaveCustomScreenshot(const PLCore::String &sFilename, PLCore::uint16 nWidth, PLCore::uint16 nHeight,
00194                                          PLRenderer::TextureBuffer::EPixelFormat nFormat, PLCore::uint32 nFlags) const;
00195 
00196         /**
00197         *  @brief
00198         *    Get a screenshot filename recommendation
00199         *
00200         *  @param[in] sExtension
00201         *    File name extension (for example "png")
00202         *
00203         *  @remarks
00204         *    The screenshot filename is automatically generated:
00205         *    "/_Screenshots/Screenshot_0.png", "/_Screenshots/Screenshot_1.png" and so on...
00206         *
00207         *  @return
00208         *    The recommended screenshot filename, empty string on error
00209         */
00210         PL_API PLCore::String GetScreenshotFilename(const PLCore::String &sExtension = "png") const;
00211 
00212 
00213     //[-------------------------------------------------------]
00214     //[ Private data                                          ]
00215     //[-------------------------------------------------------]
00216     private:
00217         PLRenderer::RendererContext *m_pRendererContext;        /**< Used renderer context, can be a null pointer */
00218         PLRenderer::SurfacePainter  *m_pSurfacePainter;         /**< Used surface painter, can be a null pointer */
00219         PLCore::String               m_sScreenshotDirectory;    /**< Screenshot directory */
00220 
00221 
00222 };
00223 
00224 
00225 //[-------------------------------------------------------]
00226 //[ Namespace                                             ]
00227 //[-------------------------------------------------------]
00228 } // PLEngine
00229 
00230 
00231 #endif // __PLENGINE_TOOLS_SCREENSHOT_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported