00001 /*************************************************************************** 00002 * Copyright (c) 2008 Art Tevs * 00003 * * 00004 * This library is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU Lesser General Public License as * 00006 * published by the Free Software Foundation; either version 3 of * 00007 * the License, or (at your option) any later version. * 00008 * * 00009 * This library is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU Lesse General Public License for more details. * 00013 * * 00014 * The full license is in LICENSE file included with this distribution. * 00015 ***************************************************************************/ 00016 00017 #ifndef _C_UNIT_CAPTURE__H_ 00018 #define _C_UNIT_CAPTURE__H_ 00019 00020 00021 //------------------------------------------------------------------------- 00022 // Includes 00023 //------------------------------------------------------------------------- 00024 #include <osgPPU/Export.h> 00025 #include <osgPPU/UnitOut.h> 00026 00027 namespace osgPPU 00028 { 00029 //! Capture the content of the input texture to a file 00030 /** 00031 * Screen capturing ppu. The input texture is captured into a file. 00032 * This ppu allows to render out in higher resolution than your 00033 * monitor supports. This can be only achieved if your rendering 00034 * is going completely through ppu pipeline, so renderer in offscreen mode. 00035 **/ 00036 class OSGPPU_EXPORT UnitOutCapture : public UnitOut { 00037 public: 00038 META_Node(osgPPU,UnitOutCapture); 00039 00040 //! Create default ppfx 00041 UnitOutCapture(); 00042 UnitOutCapture(const UnitOutCapture&, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 00043 00044 //! Release it and used memory 00045 virtual ~UnitOutCapture(); 00046 00047 //! Set path were to store the screenshots 00048 void setPath(const std::string& path) { mPath = path; } 00049 00050 //! set extension 00051 void setFileExtension(const std::string& ext) { mExtension = ext; } 00052 00053 //! get currently used path 00054 inline const std::string& getPath() const { return mPath; } 00055 00056 //! get currently used extension 00057 inline const std::string& getFileExtension() const { return mExtension; } 00058 00059 /** 00060 * Set if the output should be generated only once. 00061 * The unit will be activated only for one frame. 00062 * You will need to reactivate the unit, if you would like to have continous frame capturing 00063 * after one frame shot. 00064 **/ 00065 inline void setShotOnce(bool b) { mShotOnce = b; if (b) setActive(true); } 00066 00067 //! Check if the unit will shot once on the next traversion 00068 inline bool getShotOnce() { return mShotOnce; } 00069 00070 //! Direct function, which can be used to take a screenshot. 00071 virtual void captureInput(osg::State* state); 00072 00073 //! Initialze the default Processoring unit 00074 virtual void init(); 00075 00076 /** 00077 * Specify whenever the pixel format of the image to store should be the same as the internal format 00078 * of input texture. This might be helpful if you want to store directly as it is, without converting. 00079 * However if you want for example store a float texture to JPG files, you might need to disable 00080 * this feature allowing the plugin to handle the texture data. 00081 * 00082 * Per default this feature is disabled. 00083 **/ 00084 inline void setUseInputTextureInternalFormat(bool use) { mUseInputTextureInternalFormat = use; } 00085 00086 //! Check whenever internal format of input texture is used as pixel format for storing 00087 inline bool getUseInputTextureInternalFormat() const { return mUseInputTextureInternalFormat; } 00088 00089 protected: 00090 00091 //! path were to store the files 00092 std::string mPath; 00093 00094 //! Current number of the capture file 00095 std::map<int,int> mCaptureNumber; 00096 00097 //! file extensions 00098 std::string mExtension; 00099 00100 //! Do only one screenshot 00101 bool mShotOnce; 00102 00103 //! Store with the same pixel format as used by the input textures 00104 bool mUseInputTextureInternalFormat; 00105 }; 00106 00107 }; 00108 00109 #endif
Copyright (C) 2008 by Art Tevs (LGPL)