SuperTuxKart
rtts.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2014-2015 SuperTuxKart-Team
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef HEADER_RTTS_HPP
19 #define HEADER_RTTS_HPP
20 
21 #include "utils/leak_check.hpp"
22 #include <cassert>
23 
24 class FrameBuffer;
25 class FrameBufferLayer;
26 
27 enum TypeFBO
28 {
29  FBO_COLORS,
30  FBO_NORMAL_AND_DEPTHS,
31  FBO_SP,
32  FBO_RGBA_1,
33  FBO_RGBA_2,
34  FBO_COMBINED_DIFFUSE_SPECULAR,
35  FBO_DISPLACE_SSR,
36 
37  FBO_TMP1_WITH_DS,
38  FBO_HALF1_R,
39  FBO_HALF1,
40  FBO_HALF2,
41 
42  FBO_RGBA_3, // MLAA
43 
44  FBO_SSAO, // SSAO
45  FBO_LINEAR_DEPTH, // SSAO
46  FBO_HALF2_R, // SSAO
47 
48  FBO_QUARTER1, // Glow || God Ray
49  FBO_QUARTER2, // God Ray
50 
51  FBO_BLOOM_1024, // The reset is for bloom only (may be optimized layer)
52  FBO_BLOOM_512,
53  FBO_TMP_512,
54  FBO_LENS_512,
55 
56  FBO_BLOOM_256,
57  FBO_TMP_256,
58  FBO_LENS_256,
59 
60  FBO_BLOOM_128,
61  FBO_TMP_128,
62  FBO_LENS_128,
63  FBO_COUNT
64 };
65 
66 enum TypeRTT : unsigned int
67 {
68  RTT_COLOR = 0,
69  RTT_NORMAL_AND_DEPTH,
70  RTT_SP_DIFF_COLOR, // RGBA
71  RTT_RGBA_2,
72  RTT_DIFFUSE,
73  RTT_SPECULAR,
74  RTT_TMP1,
75  RTT_HALF1,
76  RTT_HALF1_R,
77  RTT_HALF2,
78  RTT_R,
79 
80  RTT_RGBA_3,
81 
82  RTT_SSAO,
83  RTT_LINEAR_DEPTH,
84  RTT_HALF2_R,
85 
86  RTT_QUARTER1,
87  RTT_QUARTER2,
88 
89  RTT_BLOOM_1024,
90  RTT_BLOOM_512,
91  RTT_TMP_512,
92  RTT_LENS_512,
93  RTT_BLOOM_256,
94  RTT_TMP_256,
95  RTT_LENS_256,
96  RTT_BLOOM_128,
97  RTT_TMP_128,
98  RTT_LENS_128,
99 
100  RTT_COUNT
101 };
102 
103 class RTT
104 {
105 public:
106  RTT(unsigned int width, unsigned int height, float rtt_scale = 1.0f,
107  bool use_default_fbo_only = false);
108  ~RTT();
109 
110  unsigned int getWidth () const { return m_width ; }
111  unsigned int getHeight() const { return m_height; }
112 
113  FrameBufferLayer* getShadowFrameBuffer() { return m_shadow_fbo; }
114  unsigned getDepthStencilTexture() const
115  {
116  assert(m_depth_stencil_tex != 0);
117  return m_depth_stencil_tex;
118  }
119  unsigned getRenderTarget(enum TypeRTT target) const
120  {
121  assert(m_render_target_textures[target] != 0);
122  return m_render_target_textures[target];
123  }
124  FrameBuffer& getFBO(enum TypeFBO fbo)
125  {
126  assert(m_frame_buffers[fbo] != NULL);
127  return *m_frame_buffers[fbo];
128  }
129 
130 private:
131  unsigned m_render_target_textures[RTT_COUNT] = {};
132  FrameBuffer* m_frame_buffers[FBO_COUNT] = {};
133  unsigned m_depth_stencil_tex = 0;
134 
135  unsigned int m_width;
136  unsigned int m_height;
137 
138  unsigned m_shadow_depth_tex = 0;
139  FrameBufferLayer* m_shadow_fbo;
140 
141  LEAK_CHECK();
142 };
143 
144 #endif
145 
Definition: frame_buffer_layer.hpp:26
Definition: frame_buffer.hpp:33
Definition: rtts.hpp:104