aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llimagegl.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index 5ea7322..8386e95 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -134,6 +134,15 @@ void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target)
134 sCurrentBoundTextures[stage] = 0; 134 sCurrentBoundTextures[stage] = 0;
135} 135}
136 136
137// static (duplicated for speed and to avoid GL_TEXTURE_2D default argument which requires GL header dependency)
138void LLImageGL::unbindTexture(S32 stage)
139{
140 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
141 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage);
142 glBindTexture(GL_TEXTURE_2D, 0);
143 sCurrentBoundTextures[stage] = 0;
144}
145
137// static 146// static
138void LLImageGL::updateStats(F32 current_time) 147void LLImageGL::updateStats(F32 current_time)
139{ 148{
@@ -390,13 +399,8 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
390 llwarns << "Trying to bind a texture while GL is disabled!" << llendl; 399 llwarns << "Trying to bind a texture while GL is disabled!" << llendl;
391 } 400 }
392 401
393 stop_glerror();
394
395 glActiveTextureARB(GL_TEXTURE0_ARB + stage); 402 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
396 //glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); 403
397
398 stop_glerror();
399
400 if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName) 404 if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName)
401 { 405 {
402 // already set! 406 // already set!
@@ -411,7 +415,6 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
411 415
412 glBindTexture(mBindTarget, mTexName); 416 glBindTexture(mBindTarget, mTexName);
413 sCurrentBoundTextures[stage] = mTexName; 417 sCurrentBoundTextures[stage] = mTexName;
414 stop_glerror();
415 418
416 if (mLastBindTime != sLastFrameTime) 419 if (mLastBindTime != sLastFrameTime)
417 { 420 {
@@ -650,6 +653,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
650 } 653 }
651 mHasMipMaps = FALSE; 654 mHasMipMaps = FALSE;
652 } 655 }
656 glFlush();
653 stop_glerror(); 657 stop_glerror();
654} 658}
655 659
@@ -664,6 +668,11 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
664 llwarns << "Setting subimage on image without GL texture" << llendl; 668 llwarns << "Setting subimage on image without GL texture" << llendl;
665 return FALSE; 669 return FALSE;
666 } 670 }
671 if (datap == NULL)
672 {
673 llwarns << "Setting subimage on image with NULL datap" << llendl;
674 return FALSE;
675 }
667 676
668 if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight()) 677 if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight())
669 { 678 {
@@ -676,7 +685,9 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
676 dump(); 685 dump();
677 llerrs << "setSubImage called with mipmapped image (not supported)" << llendl; 686 llerrs << "setSubImage called with mipmapped image (not supported)" << llendl;
678 } 687 }
679 llassert(mCurrentDiscardLevel == 0); 688 llassert_always(mCurrentDiscardLevel == 0);
689 llassert_always(x_pos >= 0 && y_pos >= 0);
690
680 if (((x_pos + width) > getWidth()) || 691 if (((x_pos + width) > getWidth()) ||
681 (y_pos + height) > getHeight()) 692 (y_pos + height) > getHeight())
682 { 693 {
@@ -717,9 +728,12 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
717 728
718 datap += (y_pos * data_width + x_pos) * getComponents(); 729 datap += (y_pos * data_width + x_pos) * getComponents();
719 // Update the GL texture 730 // Update the GL texture
720 llverify(bindTextureInternal(0)); 731 BOOL res = bindTextureInternal(0);
732 if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl;
721 stop_glerror(); 733 stop_glerror();
722 734
735 LLGLEnable tex( GL_TEXTURE_2D );
736
723 glTexSubImage2D(mTarget, 0, x_pos, y_pos, 737 glTexSubImage2D(mTarget, 0, x_pos, y_pos,
724 width, height, mFormatPrimary, mFormatType, datap); 738 width, height, mFormatPrimary, mFormatType, datap);
725 stop_glerror(); 739 stop_glerror();
@@ -733,7 +747,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
733 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 747 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
734 stop_glerror(); 748 stop_glerror();
735 } 749 }
736 750 glFlush();
737 return TRUE; 751 return TRUE;
738} 752}
739 753