summaryrefslogtreecommitdiff
path: root/indra/newview/lltexlayer.cpp
diff options
context:
space:
mode:
authorMark Palange <palange@lindenlab.com>2009-01-13 03:46:56 +0000
committerMark Palange <palange@lindenlab.com>2009-01-13 03:46:56 +0000
commit446c55538e1fb12d8a1feb541edf99c16bb29121 (patch)
tree022ca3c10bd2e0326098719cdffb65f9465ab08f /indra/newview/lltexlayer.cpp
parent5476aca88e4b34d4d145f3a0b04fce95402c7b1f (diff)
svn merge -r106055-107012 svn+ssh://svn.lindenlab.com/svn/linden/branches/viewer/viewer_1-22/
merge RC5 changes into trunk, plus add'l localization xml (all newly added) files that should have been added with RC0-RC4 merge, but weren't.
Diffstat (limited to 'indra/newview/lltexlayer.cpp')
-rw-r--r--indra/newview/lltexlayer.cpp85
1 files changed, 56 insertions, 29 deletions
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index baff4a2d3f..709fcd166b 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -94,17 +94,59 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h
mNeedsUpdate( TRUE ),
mNeedsUpload( FALSE ),
mUploadPending( FALSE ), // Not used for any logic here, just to sync sending of updates
- mTexLayerSet( owner ),
- mBumpTexName(0)
+ mTexLayerSet( owner )
{
LLTexLayerSetBuffer::sGLByteCount += getSize();
+ mHasBump = has_bump ;
+ mBumpTex = NULL ;
- if( has_bump )
+ createBumpTexture() ;
+}
+
+LLTexLayerSetBuffer::~LLTexLayerSetBuffer()
+{
+ LLTexLayerSetBuffer::sGLByteCount -= getSize();
+
+ if( mBumpTex.notNull())
+ {
+ mBumpTex = NULL ;
+ LLImageGL::sGlobalTextureMemory -= mWidth * mHeight * 4;
+ LLTexLayerSetBuffer::sGLBumpByteCount -= mWidth * mHeight * 4;
+ }
+}
+//virtual
+void LLTexLayerSetBuffer::restoreGLTexture()
+{
+ createBumpTexture() ;
+ LLDynamicTexture::restoreGLTexture() ;
+}
+
+//virtual
+void LLTexLayerSetBuffer::destroyGLTexture()
+{
+ if( mBumpTex.notNull() )
+ {
+ mBumpTex = NULL ;
+ LLImageGL::sGlobalTextureMemory -= mWidth * mHeight * 4;
+ LLTexLayerSetBuffer::sGLBumpByteCount -= mWidth * mHeight * 4;
+ }
+
+ LLDynamicTexture::destroyGLTexture() ;
+}
+
+void LLTexLayerSetBuffer::createBumpTexture()
+{
+ if( mHasBump )
{
LLGLSUIDefault gls_ui;
- glGenTextures(1, (GLuint*) &mBumpTexName);
+ mBumpTex = new LLImageGL(FALSE) ;
+ if(!mBumpTex->createGLTexture())
+ {
+ mBumpTex = NULL ;
+ return ;
+ }
- gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTex->getTexName());
stop_glerror();
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
@@ -112,7 +154,7 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
stop_glerror();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
@@ -122,21 +164,6 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer( LLTexLayerSet* owner, S32 width, S32 h
}
}
-LLTexLayerSetBuffer::~LLTexLayerSetBuffer()
-{
- LLTexLayerSetBuffer::sGLByteCount -= getSize();
-
- if( mBumpTexName )
- {
- glDeleteTextures(1, (GLuint*) &mBumpTexName);
- stop_glerror();
- mBumpTexName = 0;
-
- LLImageGL::sGlobalTextureMemory -= mWidth * mHeight * 4;
- LLTexLayerSetBuffer::sGLBumpByteCount -= mWidth * mHeight * 4;
- }
-}
-
// static
void LLTexLayerSetBuffer::dumpTotalByteCount()
{
@@ -245,7 +272,7 @@ BOOL LLTexLayerSetBuffer::render()
BOOL success = TRUE;
// Composite bump
- if( mBumpTexName )
+ if( mBumpTex.notNull() )
{
// Composite the bump data
success &= mTexLayerSet->renderBump( mOrigin.mX, mOrigin.mY, mWidth, mHeight );
@@ -256,7 +283,7 @@ BOOL LLTexLayerSetBuffer::render()
LLGLSUIDefault gls_ui;
// read back into texture (this is done externally for the color data)
- gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTex->getTexName());
stop_glerror();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mOrigin.mX, mOrigin.mY, mWidth, mHeight);
@@ -296,7 +323,7 @@ BOOL LLTexLayerSetBuffer::render()
gGL.setSceneBlendType(LLRender::BT_ALPHA);
// we have valid texture data now
- mTexture->setInitialized(true);
+ mTexture->setGLTextureCreated(true);
mNeedsUpdate = FALSE;
return success;
@@ -304,7 +331,7 @@ BOOL LLTexLayerSetBuffer::render()
bool LLTexLayerSetBuffer::isInitialized(void) const
{
- return mTexture->isInitialized();
+ return mTexture.notNull() && mTexture->isGLTextureCreated();
}
BOOL LLTexLayerSetBuffer::updateImmediate()
@@ -352,11 +379,11 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
// writes into baked_color_data
const char* comment_text = NULL;
- S32 baked_image_components = mBumpTexName ? 5 : 4; // red green blue [bump] clothing
+ S32 baked_image_components = mBumpTex.notNull() ? 5 : 4; // red green blue [bump] clothing
LLPointer<LLImageRaw> baked_image = new LLImageRaw( mWidth, mHeight, baked_image_components );
U8* baked_image_data = baked_image->getData();
- if( mBumpTexName )
+ if( mBumpTex.notNull() )
{
comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // 5 channels: rgb, heightfield/alpha, mask
@@ -555,9 +582,9 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* user
void LLTexLayerSetBuffer::bindBumpTexture( U32 stage )
{
- if( mBumpTexName )
+ if( mBumpTex.notNull() )
{
- gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTexName);
+ gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTex->getTexName());
gGL.getTexUnit(0)->activate();
if( mLastBindTime != LLImageGL::sLastFrameTime )