diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llrender/llrendertarget.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llrender/llrendertarget.cpp')
-rw-r--r-- | linden/indra/llrender/llrendertarget.cpp | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp index 974e0a2..d95c8aa 100644 --- a/linden/indra/llrender/llrendertarget.cpp +++ b/linden/indra/llrender/llrendertarget.cpp | |||
@@ -49,8 +49,9 @@ LLRenderTarget::~LLRenderTarget() | |||
49 | release(); | 49 | release(); |
50 | } | 50 | } |
51 | 51 | ||
52 | void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL force_fbo) | 52 | void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo) |
53 | { | 53 | { |
54 | stop_glerror(); | ||
54 | mResX = resx; | 55 | mResX = resx; |
55 | mResY = resy; | 56 | mResY = resy; |
56 | 57 | ||
@@ -79,32 +80,45 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 | |||
79 | 80 | ||
80 | stop_glerror(); | 81 | stop_glerror(); |
81 | 82 | ||
82 | if (sUseFBO || force_fbo) | 83 | if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) |
83 | { | 84 | { |
85 | |||
84 | if (depth) | 86 | if (depth) |
85 | { | 87 | { |
86 | glGenRenderbuffersEXT(1, (GLuint *) &mDepth); | 88 | stop_glerror(); |
87 | glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth); | 89 | allocateDepth(); |
88 | glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,mResX,mResY); | 90 | stop_glerror(); |
89 | glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | glGenFramebuffersEXT(1, (GLuint *) &mFBO); | 93 | glGenFramebuffersEXT(1, (GLuint *) &mFBO); |
94 | |||
93 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); | 95 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); |
94 | 96 | ||
95 | if (mDepth) | 97 | if (mDepth) |
96 | { | 98 | { |
97 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, | 99 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); |
98 | GL_RENDERBUFFER_EXT, mDepth); | 100 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); |
101 | stop_glerror(); | ||
99 | } | 102 | } |
103 | |||
100 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, | 104 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, |
101 | mUsage, mTex, 0); | 105 | mUsage, mTex, 0); |
102 | 106 | stop_glerror(); | |
103 | 107 | ||
104 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 108 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
109 | stop_glerror(); | ||
105 | } | 110 | } |
106 | } | 111 | } |
107 | 112 | ||
113 | void LLRenderTarget::allocateDepth() | ||
114 | { | ||
115 | glGenTextures(1, (GLuint *) &mDepth); | ||
116 | glBindTexture(mUsage, mDepth); | ||
117 | glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
118 | glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
119 | glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); | ||
120 | } | ||
121 | |||
108 | void LLRenderTarget::release() | 122 | void LLRenderTarget::release() |
109 | { | 123 | { |
110 | if (mFBO) | 124 | if (mFBO) |
@@ -121,7 +135,7 @@ void LLRenderTarget::release() | |||
121 | 135 | ||
122 | if (mDepth) | 136 | if (mDepth) |
123 | { | 137 | { |
124 | glDeleteRenderbuffersEXT(1, (GLuint *) &mDepth); | 138 | glDeleteTextures(1, (GLuint *) &mDepth); |
125 | mDepth = 0; | 139 | mDepth = 0; |
126 | } | 140 | } |
127 | } | 141 | } |
@@ -141,7 +155,7 @@ void LLRenderTarget::clear() | |||
141 | U32 mask = GL_COLOR_BUFFER_BIT; | 155 | U32 mask = GL_COLOR_BUFFER_BIT; |
142 | if (mUseDepth) | 156 | if (mUseDepth) |
143 | { | 157 | { |
144 | mask |= GL_DEPTH_BUFFER_BIT; | 158 | mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; |
145 | } | 159 | } |
146 | if (mFBO) | 160 | if (mFBO) |
147 | { | 161 | { |
@@ -160,13 +174,34 @@ void LLRenderTarget::bindTexture() | |||
160 | glBindTexture(mUsage, mTex); | 174 | glBindTexture(mUsage, mTex); |
161 | } | 175 | } |
162 | 176 | ||
163 | void LLRenderTarget::flush() | 177 | void LLRenderTarget::bindDepth() |
178 | { | ||
179 | glBindTexture(mUsage, mDepth); | ||
180 | } | ||
181 | |||
182 | |||
183 | void LLRenderTarget::flush(BOOL fetch_depth) | ||
164 | { | 184 | { |
165 | gGL.flush(); | 185 | gGL.flush(); |
166 | if (!mFBO) | 186 | if (!mFBO) |
167 | { | 187 | { |
168 | bindTexture(); | 188 | bindTexture(); |
169 | glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); | 189 | glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); |
190 | |||
191 | if (fetch_depth) | ||
192 | { | ||
193 | if (!mDepth) | ||
194 | { | ||
195 | allocateDepth(); | ||
196 | } | ||
197 | |||
198 | bindDepth(); | ||
199 | glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||
170 | } | 205 | } |
171 | } | 206 | } |
172 | 207 | ||