Torque3D Documentation / _generateds / videoCaptureD3D9.h

videoCaptureD3D9.h

Engine/source/gfx/D3D9/videoCaptureD3D9.h

More...

Classes:

Detailed Description

 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
24#ifndef _GFX_D3D_VIDEOCAPTURED3D9_H_
25#define _GFX_D3D_VIDEOCAPTURED3D9_H_
26
27#ifndef _VIDEOCAPTURE_H_
28#include "gfx/video/videoCapture.h"
29#endif
30
31#ifndef _GFXDEVICE_H_
32#include "gfx/gfxDevice.h"
33#endif
34
35
36class VideoFrameGrabberD3D9 : public VideoFrameGrabber
37{
38protected:   
39   enum CaptureStage {
40      eReadyToCapture,         
41      eInVideoMemory,       
42      eInSystemMemory,
43      eNumStages
44   };
45
46   // Contains all elements involved in single frame capture and
47   // is used to spread the multiple "stages" needed to capture a bitmap
48   // over various frames to keep GPU resources from locking the CPU.
49   struct CaptureResource {
50      GFXTexHandle vidMemTex; //Video memory texture
51      GFXTexHandle sysMemTex; //System memory texture
52      CaptureStage stage;     //This resource's capture stage
53
54      CaptureResource() : stage(eReadyToCapture) {};
55      ~CaptureResource()
56      {
57         vidMemTex.free();         
58         sysMemTex.free();
59      }
60   };
61
62   // Capture resource array. One item for each capture pipeline stage
63   CaptureResource mCapture[eNumStages];
64
65   // Current capture index
66   S32 mCurrentCapture;
67   
68   // Copies a capture's video memory content to system memory
69   void copyToSystemMemory(CaptureResource &capture);
70
71   // Copies a capture's syste memory content to a new bitmap
72   void copyToBitmap(CaptureResource &capture);
73
74   bool _handleGFXEvent(GFXDevice::GFXDeviceEventType event);
75      
76   //------------------------------------------------
77   // Overloaded from VideoFrameGrabber
78   //------------------------------------------------
79   void captureBackBuffer();
80   void makeBitmap();
81   void releaseTextures();
82
83public:
84   VideoFrameGrabberD3D9();
85   ~VideoFrameGrabberD3D9();
86};
87
88#endif // _GFX_D3D_VIDEOCAPTURED3D9_H_
89