summaryrefslogtreecommitdiff
path: root/indra/newview/lldynamictexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldynamictexture.cpp')
-rw-r--r--indra/newview/lldynamictexture.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index f2981625f7..f3821a8b7a 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -47,6 +47,7 @@ LLDynamicTexture::LLDynamicTexture(S32 width, S32 height, S32 components, EOrder
//-----------------------------------------------------------------------------
LLDynamicTexture::~LLDynamicTexture()
{
+ releaseGLTexture();
for( S32 order = 0; order < ORDER_COUNT; order++ )
{
LLDynamicTexture::sInstances[order].removeData(this); // will fail in all but one case.
@@ -54,19 +55,23 @@ LLDynamicTexture::~LLDynamicTexture()
}
//-----------------------------------------------------------------------------
-// generateGLTexture()
+// releaseGLTexture()
//-----------------------------------------------------------------------------
-void LLDynamicTexture::generateGLTexture()
+void LLDynamicTexture::releaseGLTexture()
{
- if (mComponents < 1 || mComponents > 4)
+ if (mTexture.notNull())
{
- llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl;
+// llinfos << "RELEASING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl;
+ mTexture = NULL;
}
+}
- LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents);
- mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE);
- mTexture->createGLTexture(0, raw_image);
- mTexture->setClamp(mClamp, mClamp);
+//-----------------------------------------------------------------------------
+// generateGLTexture()
+//-----------------------------------------------------------------------------
+void LLDynamicTexture::generateGLTexture()
+{
+ generateGLTexture(-1, 0, 0, FALSE);
}
void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes)
@@ -75,10 +80,14 @@ void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum prima
{
llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl;
}
-
+ releaseGLTexture();
LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents);
mTexture = new LLImageGL(mWidth, mHeight, mComponents, FALSE);
- mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes);
+ if (internal_format >= 0)
+ {
+ mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes);
+ }
+// llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl;
mTexture->createGLTexture(0, raw_image);
mTexture->setClamp(mClamp, mClamp);
}