ScummVM API documentation
RendererPostEffects.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_RENDERER_POST_EFFECTS_H
29 #define HPL_RENDERER_POST_EFFECTS_H
30 
31 #include "common/list.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/math/MathTypes.h"
34 #include "hpl1/std/set.h"
35 
36 namespace hpl {
37 
38 #define kFilterProgramNum (1)
39 
40 class iLowLevelGraphics;
41 class LowLevelResources;
42 class iGpuProgram;
43 class cResources;
44 class iTexture;
45 class cGpuProgramManager;
46 class cRenderList;
47 class cRenderer3D;
48 
49 enum ePostEffectFilter {
50  ePostEffectFilter_Offset,
51  ePostEffectFilter_LastEnum
52 };
53 
54 enum ePostEffectProgram {
55  ePostEffectProgram_Offset,
56  ePostEffectProgram_LastEnum
57 };
58 
60 public:
61  cImageTrailEffect() : mbActive(false), mbFirstPass(false), mlCurrentBuffer(0) {}
62 
63  bool mbActive;
64  bool mbFirstPass;
65  int mlCurrentBuffer;
66  float mfAmount;
67 };
68 
69 class cResources;
70 
72 public:
73  cRendererPostEffects(iLowLevelGraphics *apLowLevelGraphics, cResources *apResources,
74  cRenderList *apRenderList, cRenderer3D *apRenderer3D);
76 
80  void Render();
81 
82  void SetImageTrailActive(bool abX) {
83  if (!mImageTrailData.mbActive && abX)
84  mImageTrailData.mbFirstPass = true;
85  mImageTrailData.mbActive = abX;
86  }
87  bool GetImageTrailActive() { return mImageTrailData.mbActive; }
92  void SetImageTrailAmount(float afAmount) { mImageTrailData.mfAmount = afAmount; }
93 
94  iTexture *GetScreenBuffer(int alNum) { return mpScreenBuffer[alNum]; }
95 
96  void SetActive(bool abX) { mbActive = abX; }
97  bool GetActive() { return mbActive; }
98 
99  void SetBloomActive(bool abX);
100  bool GetBloomActive() { return mbBloomActive; }
101 
102  void SetBloomSpread(float afX) { mfBloomSpread = afX; }
103  float GetBloomSpread() { return mfBloomSpread; }
104 
105  void SetMotionBlurActive(bool abX);
106  bool GetMotionBlurActive() { return mbMotionBlurActive; }
107 
108  void SetMotionBlurAmount(float afX) { mfMotionBlurAmount = afX; }
109  float GetMotionBlurAmount() { return mfMotionBlurAmount; }
110 
111  void SetDepthOfFieldActive(bool abX) { mbDofActive = abX; }
112  void SetDepthOfFieldMaxBlur(float afX) { mfDofMaxBlur = afX; }
113  void SetDepthOfFieldFocalPlane(float afX) { mfDofFocalPlane = afX; }
114  void SetDepthOfFieldNearPlane(float afX) { mfDofNearPlane = afX; }
115  void SetDepthOfFieldFarPlane(float afX) { mfDofFarPlane = afX; }
116 
117  bool GetDepthOfFieldActive() { return mbDofActive; }
118  float GetDepthOfFieldMaxBlur() { return mfDofMaxBlur; }
119  float GetDepthOfFieldFocalPlane() { return mfDofFocalPlane; }
120  float GetDepthOfFieldNearPlane() { return mfDofNearPlane; }
121  float GetDepthOfFieldFarPlane() { return mfDofFarPlane; }
122 
123  iTexture *GetFreeScreenTexture() { return mpScreenBuffer[mImageTrailData.mlCurrentBuffer == 0 ? 1 : 0]; }
124 
125  void RenderBlurTexture(iTexture *apDestination, iTexture *apSource, float afBlurAmount);
126 
127 private:
128  void RenderImageTrail();
129 
130  void RenderBloom();
131 
132  void RenderMotionBlur();
133 
134  void RenderDepthOfField();
135 
136  iLowLevelGraphics *mpLowLevelGraphics;
137  LowLevelResources *mpLowLevelResources;
138  cResources *mpResources;
139  cGpuProgramManager *mpGpuManager;
140  cRenderer3D *mpRenderer3D;
141 
142  cRenderList *mpRenderList;
143 
144  cVector2f mvScreenSize;
145 
146  iTexture *mpScreenBuffer[2];
147 
148  cImageTrailEffect mImageTrailData;
149 
150  iGpuProgram *_blur2DProgram;
151  iGpuProgram *_blurRectProgram;
152  bool mbBlurFallback;
153 
154  iGpuProgram *_bloomProgram;
155 
156  iTexture *mpBloomBlurTexture;
157 
158  iGpuProgram *_motionBlurProgram;
159 
160  iGpuProgram *_depthOfFieldProgram;
161  iTexture *mpDofBlurTexture;
162 
163  tVertexVec mvTexRectVtx;
164 
165  bool mbBloomActive;
166  float mfBloomSpread;
167 
168  bool mbMotionBlurActive;
169  float mfMotionBlurAmount;
170  bool mbMotionBlurFirstTime;
171 
172  bool mbDofActive;
173  float mfDofMaxBlur;
174  float mfDofFocalPlane;
175  float mfDofNearPlane;
176  float mfDofFarPlane;
177 
178  bool mbActive;
179 };
180 
181 } // namespace hpl
182 
183 #endif // HPL_RENDERER_POST_EFFECTS_H
Definition: AI.h:36
Definition: GpuProgramManager.h:39
Definition: Texture.h:88
void SetImageTrailAmount(float afAmount)
Definition: RendererPostEffects.h:92
Definition: RendererPostEffects.h:59
Definition: low_level_resources.h:40
Definition: RendererPostEffects.h:71
Definition: Renderer3D.h:139
Definition: RenderList.h:145
Definition: Resources.h:160
Definition: LowLevelGraphics.h:200
Definition: GPUProgram.h:62