#pragma once #include "pbuffer.h" #include class RenderTexture { public: RenderTexture(void); ~RenderTexture(void); private: GLenum m_textype; PBuffer *m_pBuffer; int width; int height; GLuint m_pbufferColorTextureID; GLuint m_pbufferDepthTextureID; GLuint m_pbufferAux1ID; GLuint m_pbufferAux2ID; GLuint m_pbufferAux3ID; GLuint m_pbufferAux4ID; public: int Initialize(int width, int height,const char *strMode, bool rect=true); int EnableTarget(void); int DisableTarget(void); void EnablewithColorRelease(){ReleaseColorBuffer();EnableTarget();} void DisablewithColorBind(){DisableTarget();BindColorBuffer();} int BindColorBuffer(){glBindTexture(m_textype, m_pbufferColorTextureID); return m_pBuffer->Bind(WGL_FRONT_LEFT_ARB);} int BindDepthBuffer(){glBindTexture(m_textype, m_pbufferDepthTextureID); return m_pBuffer->Bind(WGL_DEPTH_COMPONENT_NV);} void BindAUXBuffers(){glBindTexture(m_textype, m_pbufferAux1ID); m_pBuffer->Bind(WGL_AUX0_ARB); glBindTexture(m_textype, m_pbufferAux2ID); m_pBuffer->Bind(WGL_AUX1_ARB); glBindTexture(m_textype, m_pbufferAux3ID); m_pBuffer->Bind(WGL_AUX2_ARB); glBindTexture(m_textype, m_pbufferAux4ID); m_pBuffer->Bind(WGL_AUX3_ARB);} int ReleaseColorBuffer(){glBindTexture(m_textype, m_pbufferColorTextureID); return m_pBuffer->Release(WGL_FRONT_LEFT_ARB);} int ReleaseDepthBuffer(){glBindTexture(m_textype, m_pbufferDepthTextureID); return m_pBuffer->Release(WGL_DEPTH_COMPONENT_NV);} void ReleaseAUXBuffers(){glBindTexture(m_textype, m_pbufferAux1ID); m_pBuffer->Release(WGL_AUX0_ARB); glBindTexture(m_textype, m_pbufferAux2ID); m_pBuffer->Release(WGL_AUX1_ARB); glBindTexture(m_textype, m_pbufferAux3ID); m_pBuffer->Release(WGL_AUX2_ARB); glBindTexture(m_textype, m_pbufferAux4ID); m_pBuffer->Release(WGL_AUX3_ARB);} GLuint getColorTextureID(void); GLuint getDepthTextureID(void); GLuint getAuxTextureID(int i) { switch(i) { case 0: return m_pbufferAux1ID; break; case 1: return m_pbufferAux2ID; break; case 2: return m_pbufferAux3ID; break; case 3: return m_pbufferAux4ID; break; } } };