Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #ifndef __SP_GBUFFER_H__
00009 #define __SP_GBUFFER_H__
00010 
00011 
00012 #include "Base/spStandard.hpp"
00013 
00014 #if defined(SP_COMPILE_WITH_DEFERREDRENDERER)
00015 
00016 
00017 #include "RenderSystem/spTextureBase.hpp"
00018 
00019 
00020 namespace sp
00021 {
00022 namespace video
00023 {
00024 
00025 
00034 class SP_EXPORT GBuffer
00035 {
00036     
00037     public:
00038         
00039         
00040         
00042         enum ERenderTargets
00043         {
00044             RENDERTARGET_DIFFUSE_AND_SPECULAR = 0,  
00045             RENDERTARGET_NORMAL_AND_DEPTH,          
00046             
00047             RENDERTARGET_ILLUMINATION,              
00048             
00049             RENDERTARGET_COUNT                      
00050         };
00051         
00052         
00053         
00054         GBuffer();
00055         virtual ~GBuffer();
00056         
00057         
00058         
00067         bool createGBuffer(
00068             const dim::size2di &Resolution, s32 MultiSampling = 0, bool UseIllumination = false
00069         );
00071         void deleteGBuffer();
00072         
00092         void bindRenderTargets();
00093         
00097         void drawDeferredShading();
00098         
00099         
00100         
00102         inline const dim::size2di& getResolution() const
00103         {
00104             return Resolution_;
00105         }
00106         
00112         inline Texture* getTexture(const ERenderTargets Type)
00113         {
00114             return Type < RENDERTARGET_COUNT ? RenderTargets_[Type] : 0;
00115         }
00116         
00117         inline bool useIllumination() const
00118         {
00119             return UseIllumination_;
00120         }
00121         
00122     private:
00123         
00124         
00125         
00126         bool setupMultiRenderTargets(s32 MultiSampling);
00127         
00128         
00129         
00130         dim::size2di Resolution_;
00131         
00132         Texture* RenderTargets_[RENDERTARGET_COUNT];
00133         
00134         bool UseIllumination_;
00135         
00136 };
00137 
00138 
00139 } 
00140 
00141 } 
00142 
00143 
00144 #endif
00145 
00146 #endif
00147 
00148 
00149 
00150