aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldynamictexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lldynamictexture.cpp')
-rw-r--r--linden/indra/newview/lldynamictexture.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/linden/indra/newview/lldynamictexture.cpp b/linden/indra/newview/lldynamictexture.cpp
index ad0cdec..8801d72 100644
--- a/linden/indra/newview/lldynamictexture.cpp
+++ b/linden/indra/newview/lldynamictexture.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -32,7 +32,6 @@
32#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
33 33
34#include "lldynamictexture.h" 34#include "lldynamictexture.h"
35#include "llimagegl.h"
36#include "llglheaders.h" 35#include "llglheaders.h"
37#include "llviewerwindow.h" 36#include "llviewerwindow.h"
38#include "llviewercamera.h" 37#include "llviewercamera.h"
@@ -105,7 +104,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima
105 } 104 }
106 releaseGLTexture(); 105 releaseGLTexture();
107 LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); 106 LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents);
108 mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE); 107 mTexture = new LLViewerImage(mWidth, mHeight, mComponents, FALSE);
109 if (internal_format >= 0) 108 if (internal_format >= 0)
110 { 109 {
111 mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); 110 mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes);
@@ -113,6 +112,7 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima
113// llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; 112// llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl;
114 mTexture->createGLTexture(0, raw_image); 113 mTexture->createGLTexture(0, raw_image);
115 mTexture->setClamp(mClamp, mClamp); 114 mTexture->setClamp(mClamp, mClamp);
115 mTexture->setGLTextureCreated(false);
116} 116}
117 117
118//----------------------------------------------------------------------------- 118//-----------------------------------------------------------------------------
@@ -144,7 +144,7 @@ void LLDynamicTexture::preRender(BOOL clear_depth)
144 mOrigin.mY = llmax(mOrigin.mY, 0) ; 144 mOrigin.mY = llmax(mOrigin.mY, 0) ;
145 } 145 }
146 146
147 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 147 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
148 } 148 }
149 // Set up camera 149 // Set up camera
150 mCamera.setOrigin(*LLViewerCamera::getInstance()); 150 mCamera.setOrigin(*LLViewerCamera::getInstance());
@@ -184,19 +184,6 @@ void LLDynamicTexture::postRender(BOOL success)
184} 184}
185 185
186//----------------------------------------------------------------------------- 186//-----------------------------------------------------------------------------
187// bindTexture()
188//-----------------------------------------------------------------------------
189void LLDynamicTexture::bindTexture()
190{
191 LLViewerImage::bindTexture(mTexture,0);
192}
193
194void LLDynamicTexture::unbindTexture()
195{
196 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
197}
198
199//-----------------------------------------------------------------------------
200// static 187// static
201// updateDynamicTextures() 188// updateDynamicTextures()
202// Calls update on each dynamic texture. Calls each group in order: "first," then "middle," then "last." 189// Calls update on each dynamic texture. Calls each group in order: "first," then "middle," then "last."
@@ -210,6 +197,7 @@ BOOL LLDynamicTexture::updateAllInstances()
210 } 197 }
211 198
212 BOOL result = FALSE; 199 BOOL result = FALSE;
200 BOOL ret = FALSE ;
213 for( S32 order = 0; order < ORDER_COUNT; order++ ) 201 for( S32 order = 0; order < ORDER_COUNT; order++ )
214 { 202 {
215 for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin(); 203 for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin();
@@ -224,9 +212,10 @@ BOOL LLDynamicTexture::updateAllInstances()
224 212
225 gGL.color4f(1,1,1,1); 213 gGL.color4f(1,1,1,1);
226 dynamicTexture->preRender(); // Must be called outside of startRender() 214 dynamicTexture->preRender(); // Must be called outside of startRender()
227 215 result = FALSE;
228 if (dynamicTexture->render()) 216 if (dynamicTexture->render())
229 { 217 {
218 ret = TRUE ;
230 result = TRUE; 219 result = TRUE;
231 sNumRenders++; 220 sNumRenders++;
232 } 221 }
@@ -238,7 +227,19 @@ BOOL LLDynamicTexture::updateAllInstances()
238 } 227 }
239 } 228 }
240 229
241 return result; 230 return ret;
231}
232
233//virtual
234void LLDynamicTexture::restoreGLTexture()
235{
236 generateGLTexture() ;
237}
238
239//virtual
240void LLDynamicTexture::destroyGLTexture()
241{
242 releaseGLTexture() ;
242} 243}
243 244
244//----------------------------------------------------------------------------- 245//-----------------------------------------------------------------------------
@@ -247,6 +248,15 @@ BOOL LLDynamicTexture::updateAllInstances()
247//----------------------------------------------------------------------------- 248//-----------------------------------------------------------------------------
248void LLDynamicTexture::destroyGL() 249void LLDynamicTexture::destroyGL()
249{ 250{
251 for( S32 order = 0; order < ORDER_COUNT; order++ )
252 {
253 for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin();
254 iter != LLDynamicTexture::sInstances[order].end(); ++iter)
255 {
256 LLDynamicTexture *dynamicTexture = *iter;
257 dynamicTexture->destroyGLTexture() ;
258 }
259 }
250} 260}
251 261
252//----------------------------------------------------------------------------- 262//-----------------------------------------------------------------------------
@@ -255,4 +265,18 @@ void LLDynamicTexture::destroyGL()
255//----------------------------------------------------------------------------- 265//-----------------------------------------------------------------------------
256void LLDynamicTexture::restoreGL() 266void LLDynamicTexture::restoreGL()
257{ 267{
268 if (gGLManager.mIsDisabled)
269 {
270 return ;
271 }
272
273 for( S32 order = 0; order < ORDER_COUNT; order++ )
274 {
275 for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin();
276 iter != LLDynamicTexture::sInstances[order].end(); ++iter)
277 {
278 LLDynamicTexture *dynamicTexture = *iter;
279 dynamicTexture->restoreGLTexture() ;
280 }
281 }
258} 282}