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_TMP1_WITH_DS, 36 FBO_HALF1_R, 37 FBO_HALF1, 38 FBO_HALF2, 39 40 FBO_RGBA_3, // MLAA 41 42 FBO_SSAO, // SSAO 43 FBO_LINEAR_DEPTH, // SSAO 44 FBO_HALF2_R, // SSAO 45 46 FBO_QUARTER1, // Glow || God Ray 47 FBO_QUARTER2, // God Ray 48 49 FBO_BLOOM_1024, // The reset is for bloom only (may be optimized layer) 50 FBO_BLOOM_512, 51 FBO_TMP_512, 52 FBO_LENS_512, 53 54 FBO_BLOOM_256, 55 FBO_TMP_256, 56 FBO_LENS_256, 57 58 FBO_BLOOM_128, 59 FBO_TMP_128, 60 FBO_LENS_128, 61 FBO_COUNT 62 }; 63 64 enum TypeRTT : unsigned int 65 { 66 RTT_COLOR = 0, 67 RTT_NORMAL_AND_DEPTH, 68 RTT_SP_DIFF_COLOR, // RGBA 69 RTT_RGBA_2, 70 RTT_DIFFUSE, 71 RTT_SPECULAR, 72 RTT_TMP1, 73 RTT_HALF1, 74 RTT_HALF1_R, 75 RTT_HALF2, 76 77 RTT_RGBA_3, 78 79 RTT_SSAO, 80 RTT_LINEAR_DEPTH, 81 RTT_HALF2_R, 82 83 RTT_QUARTER1, 84 RTT_QUARTER2, 85 86 RTT_BLOOM_1024, 87 RTT_BLOOM_512, 88 RTT_TMP_512, 89 RTT_LENS_512, 90 RTT_BLOOM_256, 91 RTT_TMP_256, 92 RTT_LENS_256, 93 RTT_BLOOM_128, 94 RTT_TMP_128, 95 RTT_LENS_128, 96 97 RTT_COUNT 98 }; 99 100 class RTT 101 { 102 public: 103 RTT(unsigned int width, unsigned int height, float rtt_scale = 1.0f, 104 bool use_default_fbo_only = false); 105 ~RTT(); 106 getWidth() const107 unsigned int getWidth () const { return m_width ; } getHeight() const108 unsigned int getHeight() const { return m_height; } 109 getShadowFrameBuffer()110 FrameBufferLayer* getShadowFrameBuffer() { return m_shadow_fbo; } getDepthStencilTexture() const111 unsigned getDepthStencilTexture() const 112 { 113 assert(m_depth_stencil_tex != 0); 114 return m_depth_stencil_tex; 115 } getRenderTarget(enum TypeRTT target) const116 unsigned getRenderTarget(enum TypeRTT target) const 117 { 118 assert(m_render_target_textures[target] != 0); 119 return m_render_target_textures[target]; 120 } getFBO(enum TypeFBO fbo)121 FrameBuffer& getFBO(enum TypeFBO fbo) 122 { 123 assert(m_frame_buffers[fbo] != NULL); 124 return *m_frame_buffers[fbo]; 125 } 126 127 private: 128 unsigned m_render_target_textures[RTT_COUNT] = {}; 129 FrameBuffer* m_frame_buffers[FBO_COUNT] = {}; 130 unsigned m_depth_stencil_tex = 0; 131 132 unsigned int m_width; 133 unsigned int m_height; 134 135 unsigned m_shadow_depth_tex = 0; 136 FrameBufferLayer* m_shadow_fbo; 137 138 LEAK_CHECK(); 139 }; 140 141 #endif 142 143