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 00061 void unbind(); 00062 00067 unsigned int getFboHandle() 00068 { 00069 return m_FboHandle; 00070 } 00071 00075 unsigned int getTextureHandle() 00076 { 00077 return m_TextureHandle; 00078 } 00079 00084 void saveImage(std::string filename); 00085 00089 void renderToFullScreen(); 00090 00094 void renderToLowerRightQuad(); 00095 00099 void renderToLowerLeftQuad(); 00100 00101 private: 00102 00108 const int getNextPowerOfTwo(const int number) 00109 { 00110 int iPowerOfTwo = 1; 00111 00112 while (iPowerOfTwo < number) 00113 iPowerOfTwo = iPowerOfTwo * 2; 00114 00115 return iPowerOfTwo; 00116 }; 00117 00118 unsigned int m_FboHandle; 00119 unsigned int m_TextureHandle; 00120 unsigned int m_RenderBufferHandle; 00121 int m_Width; 00122 int m_Height; 00123 unsigned int m_TextureType; 00124 00125 static VProgram m_RenderToScreen; 00127 static bool m_ProgramLoaded; 00129 }; 00130 00131 #endif //__v_framebuffer_object_h