diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterimagepreview.cpp | 117 |
1 files changed, 57 insertions, 60 deletions
diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 912a4fc..8f592b2 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp | |||
@@ -232,14 +232,14 @@ void LLFloaterImagePreview::draw() | |||
232 | 232 | ||
233 | if (mGLName) | 233 | if (mGLName) |
234 | { | 234 | { |
235 | LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D ); | 235 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); |
236 | } | 236 | } |
237 | else | 237 | else |
238 | { | 238 | { |
239 | glGenTextures(1, &mGLName ); | 239 | glGenTextures(1, &mGLName ); |
240 | stop_glerror(); | 240 | stop_glerror(); |
241 | 241 | ||
242 | LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D ); | 242 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mGLName); |
243 | stop_glerror(); | 243 | stop_glerror(); |
244 | 244 | ||
245 | glTexImage2D( | 245 | glTexImage2D( |
@@ -251,8 +251,7 @@ void LLFloaterImagePreview::draw() | |||
251 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 251 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
252 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 252 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
253 | 253 | ||
254 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 254 | gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); |
255 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
256 | if (mAvatarPreview) | 255 | if (mAvatarPreview) |
257 | { | 256 | { |
258 | mAvatarPreview->setTexture(mGLName); | 257 | mAvatarPreview->setTexture(mGLName); |
@@ -261,7 +260,7 @@ void LLFloaterImagePreview::draw() | |||
261 | } | 260 | } |
262 | 261 | ||
263 | gGL.color3f(1.f, 1.f, 1.f); | 262 | gGL.color3f(1.f, 1.f, 1.f); |
264 | gGL.begin( LLVertexBuffer::QUADS ); | 263 | gGL.begin( LLRender::QUADS ); |
265 | { | 264 | { |
266 | gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); | 265 | gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); |
267 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 266 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
@@ -274,7 +273,7 @@ void LLFloaterImagePreview::draw() | |||
274 | } | 273 | } |
275 | gGL.end(); | 274 | gGL.end(); |
276 | 275 | ||
277 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); | 276 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
278 | 277 | ||
279 | stop_glerror(); | 278 | stop_glerror(); |
280 | } | 279 | } |
@@ -285,11 +284,15 @@ void LLFloaterImagePreview::draw() | |||
285 | gGL.color3f(1.f, 1.f, 1.f); | 284 | gGL.color3f(1.f, 1.f, 1.f); |
286 | 285 | ||
287 | if (selected == 9) | 286 | if (selected == 9) |
288 | mSculptedPreview->bindTexture(); | 287 | { |
288 | gGL.getTexUnit(0)->bind(mSculptedPreview->getTexture()); | ||
289 | } | ||
289 | else | 290 | else |
290 | mAvatarPreview->bindTexture(); | 291 | { |
292 | gGL.getTexUnit(0)->bind(mAvatarPreview->getTexture()); | ||
293 | } | ||
291 | 294 | ||
292 | gGL.begin( LLVertexBuffer::QUADS ); | 295 | gGL.begin( LLRender::QUADS ); |
293 | { | 296 | { |
294 | gGL.texCoord2f(0.f, 1.f); | 297 | gGL.texCoord2f(0.f, 1.f); |
295 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 298 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
@@ -302,10 +305,7 @@ void LLFloaterImagePreview::draw() | |||
302 | } | 305 | } |
303 | gGL.end(); | 306 | gGL.end(); |
304 | 307 | ||
305 | if (selected == 9) | 308 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
306 | mSculptedPreview->unbindTexture(); | ||
307 | else | ||
308 | mAvatarPreview->unbindTexture(); | ||
309 | } | 309 | } |
310 | } | 310 | } |
311 | } | 311 | } |
@@ -774,7 +774,9 @@ LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLDynami | |||
774 | LLVolumeParams volume_params; | 774 | LLVolumeParams volume_params; |
775 | volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); | 775 | volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); |
776 | volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE); | 776 | volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE); |
777 | mVolume = new LLVolume(volume_params, (F32) MAX_LOD); | 777 | |
778 | F32 const HIGHEST_LOD = 4.0f; | ||
779 | mVolume = new LLVolume(volume_params, HIGHEST_LOD); | ||
778 | 780 | ||
779 | /* | 781 | /* |
780 | mDummyAvatar = new LLVOAvatar(LLUUID::null, LL_PCODE_LEGACY_AVATAR, gAgent.getRegion()); | 782 | mDummyAvatar = new LLVOAvatar(LLUUID::null, LL_PCODE_LEGACY_AVATAR, gAgent.getRegion()); |
@@ -811,7 +813,36 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) | |||
811 | { | 813 | { |
812 | mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0); | 814 | mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0); |
813 | } | 815 | } |
814 | 816 | ||
817 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); | ||
818 | U32 num_indices = vf.mIndices.size(); | ||
819 | U32 num_vertices = vf.mVertices.size(); | ||
820 | |||
821 | mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL, 0); | ||
822 | mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE); | ||
823 | |||
824 | LLStrider<LLVector3> vertex_strider; | ||
825 | LLStrider<LLVector3> normal_strider; | ||
826 | LLStrider<U16> index_strider; | ||
827 | |||
828 | mVertexBuffer->getVertexStrider(vertex_strider); | ||
829 | mVertexBuffer->getNormalStrider(normal_strider); | ||
830 | mVertexBuffer->getIndexStrider(index_strider); | ||
831 | |||
832 | // build vertices and normals | ||
833 | for (U32 i = 0; (S32)i < num_vertices; i++) | ||
834 | { | ||
835 | *(vertex_strider++) = vf.mVertices[i].mPosition; | ||
836 | LLVector3 normal = vf.mVertices[i].mNormal; | ||
837 | normal.normalize(); | ||
838 | *(normal_strider++) = normal; | ||
839 | } | ||
840 | |||
841 | // build indices | ||
842 | for (U16 i = 0; i < num_indices; i++) | ||
843 | { | ||
844 | *(index_strider++) = vf.mIndices[i]; | ||
845 | } | ||
815 | } | 846 | } |
816 | 847 | ||
817 | 848 | ||
@@ -846,7 +877,7 @@ BOOL LLImagePreviewSculpted::render() | |||
846 | glMatrixMode(GL_MODELVIEW); | 877 | glMatrixMode(GL_MODELVIEW); |
847 | gGL.popMatrix(); | 878 | gGL.popMatrix(); |
848 | 879 | ||
849 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 880 | glClear(GL_DEPTH_BUFFER_BIT); |
850 | 881 | ||
851 | LLVector3 target_pos(0, 0, 0); | 882 | LLVector3 target_pos(0, 0, 0); |
852 | 883 | ||
@@ -865,55 +896,21 @@ BOOL LLImagePreviewSculpted::render() | |||
865 | LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); | 896 | LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); |
866 | LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); | 897 | LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); |
867 | 898 | ||
868 | gPipeline.enableLightsAvatar(); | ||
869 | |||
870 | gGL.pushMatrix(); | ||
871 | glScalef(0.5, 0.5, 0.5); | ||
872 | |||
873 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); | 899 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); |
874 | U32 num_indices = vf.mIndices.size(); | 900 | U32 num_indices = vf.mIndices.size(); |
875 | U32 num_vertices = vf.mVertices.size(); | 901 | |
876 | 902 | mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL); | |
877 | if (num_vertices > 0 && num_indices > 0) | ||
878 | { | ||
879 | glEnableClientState(GL_NORMAL_ARRAY); | ||
880 | // build vertices and normals | ||
881 | F32* vertices = new F32[num_vertices * 3]; | ||
882 | F32* normals = new F32[num_vertices * 3]; | ||
883 | |||
884 | for (U32 i = 0; (S32)i < num_vertices; i++) | ||
885 | { | ||
886 | LLVector3 position = vf.mVertices[i].mPosition; | ||
887 | vertices[i*3] = position.mV[VX]; | ||
888 | vertices[i*3+1] = position.mV[VY]; | ||
889 | vertices[i*3+2] = position.mV[VZ]; | ||
890 | |||
891 | LLVector3 normal = vf.mVertices[i].mNormal; | ||
892 | normals[i*3] = normal.mV[VX]; | ||
893 | normals[i*3+1] = normal.mV[VY]; | ||
894 | normals[i*3+2] = normal.mV[VZ]; | ||
895 | } | ||
896 | 903 | ||
897 | // build indices | 904 | gPipeline.enableLightsAvatar(); |
898 | U16* indices = new U16[num_indices]; | 905 | gGL.pushMatrix(); |
899 | for (U16 i = 0; i < num_indices; i++) | 906 | const F32 SCALE = 1.25f; |
900 | { | 907 | gGL.scalef(SCALE, SCALE, SCALE); |
901 | indices[i] = vf.mIndices[i]; | 908 | const F32 BRIGHTNESS = 0.9f; |
902 | } | 909 | gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); |
910 | mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0); | ||
903 | 911 | ||
904 | gGL.color3f(0.4f, 0.4f, 0.4f); | 912 | gGL.popMatrix(); |
905 | glVertexPointer(3, GL_FLOAT, 0, (void *)vertices); | ||
906 | glNormalPointer(GL_FLOAT, 0, (void *)normals); | ||
907 | glDrawRangeElements(GL_TRIANGLES, 0, num_vertices-1, num_indices, GL_UNSIGNED_SHORT, (void *)indices); | ||
908 | 913 | ||
909 | gGL.popMatrix(); | ||
910 | glDisableClientState(GL_NORMAL_ARRAY); | ||
911 | |||
912 | delete [] indices; | ||
913 | delete [] vertices; | ||
914 | delete [] normals; | ||
915 | } | ||
916 | |||
917 | return TRUE; | 914 | return TRUE; |
918 | } | 915 | } |
919 | 916 | ||