diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterimagepreview.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 8f592b2..4a8c66e 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2004&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2004&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2004-2008, Linden Research, Inc. | 7 | * Copyright (c) 2004-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 |
@@ -75,7 +75,7 @@ LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : | |||
75 | { | 75 | { |
76 | mLastMouseX = 0; | 76 | mLastMouseX = 0; |
77 | mLastMouseY = 0; | 77 | mLastMouseY = 0; |
78 | mGLName = 0; | 78 | mImagep = NULL ; |
79 | loadImage(mFilenameAndPath); | 79 | loadImage(mFilenameAndPath); |
80 | } | 80 | } |
81 | 81 | ||
@@ -138,10 +138,7 @@ LLFloaterImagePreview::~LLFloaterImagePreview() | |||
138 | delete mAvatarPreview; | 138 | delete mAvatarPreview; |
139 | delete mSculptedPreview; | 139 | delete mSculptedPreview; |
140 | 140 | ||
141 | if (mGLName) | 141 | mImagep = NULL ; |
142 | { | ||
143 | glDeleteTextures(1, &mGLName ); | ||
144 | } | ||
145 | } | 142 | } |
146 | 143 | ||
147 | //static | 144 | //static |
@@ -224,28 +221,16 @@ void LLFloaterImagePreview::draw() | |||
224 | gl_rect_2d_checkerboard(mPreviewRect); | 221 | gl_rect_2d_checkerboard(mPreviewRect); |
225 | LLGLDisable gls_alpha(GL_ALPHA_TEST); | 222 | LLGLDisable gls_alpha(GL_ALPHA_TEST); |
226 | 223 | ||
227 | GLenum format_options[4] = { GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; | 224 | if(mImagep.notNull()) |
228 | GLenum format = format_options[mRawImagep->getComponents()-1]; | ||
229 | |||
230 | GLenum internal_format_options[4] = { GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8 }; | ||
231 | GLenum internal_format = internal_format_options[mRawImagep->getComponents()-1]; | ||
232 | |||
233 | if (mGLName) | ||
234 | { | 225 | { |
235 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); | 226 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); |
236 | } | 227 | } |
237 | else | 228 | else |
238 | { | 229 | { |
239 | glGenTextures(1, &mGLName ); | 230 | mImagep = new LLImageGL(mRawImagep, FALSE) ; |
240 | stop_glerror(); | 231 | |
241 | 232 | gGL.getTexUnit(0)->unbind(mImagep->getTarget()) ; | |
242 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); | 233 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); |
243 | stop_glerror(); | ||
244 | |||
245 | glTexImage2D( | ||
246 | GL_TEXTURE_2D, 0, internal_format, | ||
247 | mRawImagep->getWidth(), mRawImagep->getHeight(), | ||
248 | 0, format, GL_UNSIGNED_BYTE, mRawImagep->getData()); | ||
249 | stop_glerror(); | 234 | stop_glerror(); |
250 | 235 | ||
251 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 236 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
@@ -254,8 +239,8 @@ void LLFloaterImagePreview::draw() | |||
254 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); | 239 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); |
255 | if (mAvatarPreview) | 240 | if (mAvatarPreview) |
256 | { | 241 | { |
257 | mAvatarPreview->setTexture(mGLName); | 242 | mAvatarPreview->setTexture(mImagep->getTexName()); |
258 | mSculptedPreview->setTexture(mGLName); | 243 | mSculptedPreview->setTexture(mImagep->getTexName()); |
259 | } | 244 | } |
260 | } | 245 | } |
261 | 246 | ||