00001 #pragma once 00002 00003 #ifndef __v_framebuffer_object_h 00004 #define __v_framebuffer_object_h 00005 00006 #include <iostream> 00007 00008 #include "VProgram.h" 00012 class VFramebufferObject 00013 { 00014 public: 00015 00019 static void checkFramebufferObjectStatus(); 00020 00021 static bool devIlInitialised; 00023 static VProgram * getRenderToScreenProgram(); 00024 00028 static bool initialiseDevIl(); 00029 00033 VFramebufferObject(int width, int height, unsigned int texturetype); 00034 00038 ~VFramebufferObject() 00039 { 00040 destroy(); 00041 } 00042 00046 void init(); 00047 00051 void destroy(); 00052 00056 void bind(); 00057 00058 00062 void bindWithoutClear(); 00063 00067 void unbind(); 00068 00073 unsigned int getFboHandle() 00074 { 00075 return m_FboHandle; 00076 } 00077 00081 unsigned int getTextureHandle() 00082 { 00083 return m_TextureHandle; 00084 } 00085 00090 void saveImage(std::string filename); 00091 00095 void renderToFullScreen(); 00096 00100 void renderToLowerRightQuad(); 00101 00105 void renderToLowerLeftQuad(); 00106 00110 int getHeight() 00111 { 00112 return m_Height; 00113 } 00114 00118 int getWidth() 00119 { 00120 return m_Width; 00121 } 00122 00123 private: 00124 00130 const int getNextPowerOfTwo(const int number) 00131 { 00132 int iPowerOfTwo = 1; 00133 00134 while (iPowerOfTwo < number) 00135 iPowerOfTwo = iPowerOfTwo * 2; 00136 00137 return iPowerOfTwo; 00138 }; 00139 00140 unsigned int m_FboHandle; 00141 unsigned int m_TextureHandle; 00142 unsigned int m_RenderBufferHandle; 00143 int m_Width; 00144 int m_Height; 00145 unsigned int m_TextureType; 00146 00147 static VProgram m_RenderToScreen; 00149 static bool m_ProgramLoaded; 00151 }; 00152 00153 #endif //__v_framebuffer_object_h