[845] | 1 | #include ".\rendertexture.h"
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | RenderTexture::RenderTexture(void)
|
---|
| 5 | {
|
---|
| 6 | }
|
---|
| 7 |
|
---|
| 8 | RenderTexture::~RenderTexture(void)
|
---|
| 9 | {
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | int RenderTexture::Initialize(int width, int height,const char *strMode, bool rect)
|
---|
| 13 | {
|
---|
| 14 | m_pBuffer=new PBuffer(strMode,false);
|
---|
| 15 | bool ret=m_pBuffer->Initialize(width,height,false,true);
|
---|
| 16 |
|
---|
| 17 | if(!ret)return 0;
|
---|
| 18 |
|
---|
| 19 | if(rect)m_textype=GL_TEXTURE_RECTANGLE_NV;
|
---|
| 20 | else m_textype=GL_TEXTURE_2D;
|
---|
| 21 |
|
---|
| 22 | glGenTextures(1, &m_pbufferColorTextureID);
|
---|
| 23 | glBindTexture(m_textype, m_pbufferColorTextureID);
|
---|
| 24 |
|
---|
| 25 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 26 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 27 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 28 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 29 |
|
---|
| 30 | if(m_pBuffer->m_HasDepthTexture)
|
---|
| 31 | {
|
---|
| 32 | glGenTextures(1, &m_pbufferDepthTextureID);
|
---|
| 33 | glBindTexture(m_textype, m_pbufferDepthTextureID);
|
---|
| 34 |
|
---|
| 35 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 36 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 37 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 38 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | if(m_pBuffer->m_HasAuxBuffers)
|
---|
| 42 | {
|
---|
| 43 | glGenTextures(1, &m_pbufferAux1ID);
|
---|
| 44 | glBindTexture(m_textype, m_pbufferAux1ID);
|
---|
| 45 |
|
---|
| 46 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 47 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 48 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 49 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 50 |
|
---|
| 51 | glGenTextures(1, &m_pbufferAux2ID);
|
---|
| 52 | glBindTexture(m_textype, m_pbufferAux1ID);
|
---|
| 53 |
|
---|
| 54 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 55 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 56 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 57 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 58 |
|
---|
| 59 | glGenTextures(1, &m_pbufferAux3ID);
|
---|
| 60 | glBindTexture(m_textype, m_pbufferAux1ID);
|
---|
| 61 |
|
---|
| 62 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 63 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 64 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 65 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 66 |
|
---|
| 67 | glGenTextures(1, &m_pbufferAux4ID);
|
---|
| 68 | glBindTexture(m_textype, m_pbufferAux1ID);
|
---|
| 69 |
|
---|
| 70 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
---|
| 71 | glTexParameteri(m_textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
---|
| 72 | glTexParameteri(m_textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
---|
| 73 | glTexParameteri(m_textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
---|
| 74 |
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | int RenderTexture::EnableTarget(void)
|
---|
| 80 | {
|
---|
| 81 | m_pBuffer->Activate();
|
---|
| 82 |
|
---|
| 83 | return 1;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | int RenderTexture::DisableTarget(void)
|
---|
| 87 | {
|
---|
| 88 | m_pBuffer->Deactivate();
|
---|
| 89 |
|
---|
| 90 | return 1;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | GLuint RenderTexture::getColorTextureID(void)
|
---|
| 94 | {
|
---|
| 95 | return m_pbufferColorTextureID;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | GLuint RenderTexture::getDepthTextureID(void)
|
---|
| 99 | {
|
---|
| 100 | return m_pbufferDepthTextureID;
|
---|
| 101 | }
|
---|