screenshot.h

Engine/source/gfx/screenshot.h

More...

Classes:

Public Variables

Detailed Description

Public Variables

ScreenShot * gScreenShot 
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23#ifndef _SCREENSHOT_H_
 24#define _SCREENSHOT_H_
 25
 26#include "gfx/gfxDevice.h"
 27
 28class GuiCanvas;
 29class Point2I;
 30class Frustum;
 31
 32//**************************************************************************
 33/*!
 34   This class will eventually support various capabilities such as panoramics,
 35   high rez captures, and cubemap captures.
 36   
 37   Right now it just captures standard screenshots, but it does support
 38   captures from multisample back buffers, so antialiased captures will work.
 39*/
 40//**************************************************************************
 41
 42class ScreenShot
 43{
 44   /// This is overloaded to copy the current GFX 
 45   /// backbuffer to a new bitmap.
 46   virtual GBitmap* _captureBackBuffer() { return NULL; }
 47
 48   /// This is set to toggle the capture.
 49   bool mPending;
 50
 51   /// If true write the file as a JPG else its a PNG.
 52   bool mWriteJPG;
 53
 54   /// The full path to the screenshot file to write.
 55   char mFilename[256];
 56
 57   /// The number of times to tile the backbuffer to 
 58   /// generate screenshots larger than normally possible.
 59   U32 mTiles;
 60
 61   /// How much pixel percentage overlap between tiles
 62   Point2F mPixelOverlap;
 63
 64   /// How much the frustum must be adjusted for overlap
 65   Point2F mFrustumOverlap;
 66
 67   /// The current tile we're rendering.
 68   Point2I mCurrTile;
 69
 70   /// Helper for taking simple single tile screenshots and
 71   /// outputing it as a single file to disk.
 72   void _singleCapture( GuiCanvas *canvas );
 73   
 74public:
 75  
 76   /// Constructor.
 77   ScreenShot();
 78   virtual ~ScreenShot() { }
 79
 80   /// Used to start the screenshot capture.
 81   void setPending( const char *filename, bool writeJPG, S32 tiles, F32 overlap );
 82
 83   /// Returns true if we're in the middle of screenshot capture.
 84   bool isPending() const { return mPending; }
 85
 86   /// Prepares the view frustum for tiled screenshot rendering.
 87   /// @see GuiTSCtrl::setupFrustum
 88   void tileFrustum( Frustum& frustum );
 89
 90   ///
 91   void tileGui( const Point2I &screenSize );
 92
 93   /// Called from the canvas to capture a pending screenshot.
 94   /// @see GuiCanvas::onRenderEvent
 95   void capture( GuiCanvas *canvas );
 96
 97};
 98
 99extern ScreenShot *gScreenShot;
100
101#endif  // _SCREENSHOT_H_
102