source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/Hierarchical Systems Demo [OpenGL]/RESOURCES/include/RttRes/RenderTexture.h @ 3255

Revision 3255, 2.3 KB checked in by szirmay, 15 years ago (diff)
Line 
1#pragma once
2#include "pbuffer.h"
3#include <gl/glext.h>
4
5class RenderTexture
6{
7public:
8        RenderTexture(void);
9        ~RenderTexture(void);
10private:
11        GLenum m_textype;       
12        PBuffer *m_pBuffer;
13        int width;
14        int height;
15        GLuint m_pbufferColorTextureID;
16        GLuint m_pbufferDepthTextureID;
17        GLuint m_pbufferAux1ID;
18        GLuint m_pbufferAux2ID;
19        GLuint m_pbufferAux3ID;
20        GLuint m_pbufferAux4ID;
21
22public:
23        int Initialize(int width, int height,const char *strMode, bool rect=true, bool linearfilter=false);
24        int EnableTarget(void);
25        int DisableTarget(void);
26
27        void EnablewithColorRelease(){ReleaseColorBuffer();EnableTarget();}
28        void DisablewithColorBind(){DisableTarget();BindColorBuffer();}
29
30        int BindColorBuffer(){glBindTexture(m_textype, m_pbufferColorTextureID);
31                                                        return m_pBuffer->Bind(WGL_FRONT_LEFT_ARB);}
32        int BindDepthBuffer(){glBindTexture(m_textype, m_pbufferDepthTextureID);
33                                                        return m_pBuffer->Bind(WGL_DEPTH_COMPONENT_NV);}
34        void BindAUXBuffers(){glBindTexture(m_textype, m_pbufferAux1ID);
35                                                                        m_pBuffer->Bind(WGL_AUX0_ARB);
36                                                                glBindTexture(m_textype, m_pbufferAux2ID);
37                                                                        m_pBuffer->Bind(WGL_AUX1_ARB);
38                                                                glBindTexture(m_textype, m_pbufferAux3ID);
39                                                                        m_pBuffer->Bind(WGL_AUX2_ARB);
40                                                                glBindTexture(m_textype, m_pbufferAux4ID);
41                                                                        m_pBuffer->Bind(WGL_AUX3_ARB);}
42        int ReleaseColorBuffer(){glBindTexture(m_textype, m_pbufferColorTextureID);
43                                                                return m_pBuffer->Release(WGL_FRONT_LEFT_ARB);}
44        int ReleaseDepthBuffer(){glBindTexture(m_textype, m_pbufferDepthTextureID);
45                                                                return m_pBuffer->Release(WGL_DEPTH_COMPONENT_NV);}
46        void ReleaseAUXBuffers(){glBindTexture(m_textype, m_pbufferAux1ID);
47                                                                        m_pBuffer->Release(WGL_AUX0_ARB);
48                                                                glBindTexture(m_textype, m_pbufferAux2ID);
49                                                                        m_pBuffer->Release(WGL_AUX1_ARB);
50                                                                glBindTexture(m_textype, m_pbufferAux3ID);
51                                                                        m_pBuffer->Release(WGL_AUX2_ARB);
52                                                                glBindTexture(m_textype, m_pbufferAux4ID);
53                                                                        m_pBuffer->Release(WGL_AUX3_ARB);}
54
55        GLuint getColorTextureID(void);
56        GLuint getDepthTextureID(void);
57
58        GLuint getAuxTextureID(int i)
59        {
60                switch(i)
61                {
62                case 0:
63                        return m_pbufferAux1ID;
64                        break;
65                case 1:
66                        return m_pbufferAux2ID;
67                        break;
68                case 2:
69                        return m_pbufferAux3ID;
70                        break;
71                case 3:
72                        return m_pbufferAux4ID;
73                        break;
74                }
75        }
76};
Note: See TracBrowser for help on using the repository browser.