diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloaterimagepreview.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llfloaterimagepreview.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterimagepreview.cpp | 130 |
1 files changed, 79 insertions, 51 deletions
diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 4c0b096..551ae95 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp | |||
@@ -43,6 +43,7 @@ | |||
43 | #include "llcombobox.h" | 43 | #include "llcombobox.h" |
44 | #include "lldrawable.h" | 44 | #include "lldrawable.h" |
45 | #include "lldrawpoolavatar.h" | 45 | #include "lldrawpoolavatar.h" |
46 | #include "llglimmediate.h" | ||
46 | #include "llface.h" | 47 | #include "llface.h" |
47 | #include "lltextbox.h" | 48 | #include "lltextbox.h" |
48 | #include "lltoolmgr.h" | 49 | #include "lltoolmgr.h" |
@@ -258,19 +259,19 @@ void LLFloaterImagePreview::draw() | |||
258 | } | 259 | } |
259 | } | 260 | } |
260 | 261 | ||
261 | glColor3f(1.f, 1.f, 1.f); | 262 | gGL.color3f(1.f, 1.f, 1.f); |
262 | glBegin( GL_QUADS ); | 263 | gGL.begin( GL_QUADS ); |
263 | { | 264 | { |
264 | glTexCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); | 265 | gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); |
265 | glVertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 266 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
266 | glTexCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mBottom); | 267 | gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mBottom); |
267 | glVertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); | 268 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); |
268 | glTexCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); | 269 | gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); |
269 | glVertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); | 270 | gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); |
270 | glTexCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); | 271 | gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); |
271 | glVertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 272 | gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
272 | } | 273 | } |
273 | glEnd(); | 274 | gGL.end(); |
274 | 275 | ||
275 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); | 276 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); |
276 | 277 | ||
@@ -280,25 +281,25 @@ void LLFloaterImagePreview::draw() | |||
280 | { | 281 | { |
281 | if ((mAvatarPreview) && (mSculptedPreview)) | 282 | if ((mAvatarPreview) && (mSculptedPreview)) |
282 | { | 283 | { |
283 | glColor3f(1.f, 1.f, 1.f); | 284 | gGL.color3f(1.f, 1.f, 1.f); |
284 | 285 | ||
285 | if (selected == 9) | 286 | if (selected == 9) |
286 | mSculptedPreview->bindTexture(); | 287 | mSculptedPreview->bindTexture(); |
287 | else | 288 | else |
288 | mAvatarPreview->bindTexture(); | 289 | mAvatarPreview->bindTexture(); |
289 | 290 | ||
290 | glBegin( GL_QUADS ); | 291 | gGL.begin( GL_QUADS ); |
291 | { | 292 | { |
292 | glTexCoord2f(0.f, 1.f); | 293 | gGL.texCoord2f(0.f, 1.f); |
293 | glVertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 294 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
294 | glTexCoord2f(0.f, 0.f); | 295 | gGL.texCoord2f(0.f, 0.f); |
295 | glVertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); | 296 | gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); |
296 | glTexCoord2f(1.f, 0.f); | 297 | gGL.texCoord2f(1.f, 0.f); |
297 | glVertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); | 298 | gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); |
298 | glTexCoord2f(1.f, 1.f); | 299 | gGL.texCoord2f(1.f, 1.f); |
299 | glVertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); | 300 | gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT); |
300 | } | 301 | } |
301 | glEnd(); | 302 | gGL.end(); |
302 | 303 | ||
303 | if (selected == 9) | 304 | if (selected == 9) |
304 | mSculptedPreview->unbindTexture(); | 305 | mSculptedPreview->unbindTexture(); |
@@ -615,7 +616,7 @@ LLImagePreviewAvatar::LLImagePreviewAvatar(S32 width, S32 height) : LLDynamicTex | |||
615 | mDummyAvatar->slamPosition(); | 616 | mDummyAvatar->slamPosition(); |
616 | mDummyAvatar->updateJointLODs(); | 617 | mDummyAvatar->updateJointLODs(); |
617 | mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); | 618 | mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); |
618 | gPipeline.markVisible(mDummyAvatar->mDrawable, *gCamera); | 619 | // gPipeline.markVisible(mDummyAvatar->mDrawable, *gCamera); |
619 | 620 | ||
620 | mTextureName = 0; | 621 | mTextureName = 0; |
621 | } | 622 | } |
@@ -669,25 +670,26 @@ BOOL LLImagePreviewAvatar::render() | |||
669 | LLVOAvatar* avatarp = mDummyAvatar; | 670 | LLVOAvatar* avatarp = mDummyAvatar; |
670 | 671 | ||
671 | glMatrixMode(GL_PROJECTION); | 672 | glMatrixMode(GL_PROJECTION); |
672 | glPushMatrix(); | 673 | gGL.pushMatrix(); |
673 | glLoadIdentity(); | 674 | glLoadIdentity(); |
674 | glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); | 675 | glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); |
675 | 676 | ||
676 | glMatrixMode(GL_MODELVIEW); | 677 | glMatrixMode(GL_MODELVIEW); |
677 | glPushMatrix(); | 678 | gGL.pushMatrix(); |
678 | glLoadIdentity(); | 679 | glLoadIdentity(); |
679 | 680 | ||
680 | LLGLSUIDefault def; | 681 | LLGLSUIDefault def; |
681 | glColor4f(0.15f, 0.2f, 0.3f, 1.f); | 682 | gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); |
682 | 683 | ||
683 | gl_rect_2d_simple( mWidth, mHeight ); | 684 | gl_rect_2d_simple( mWidth, mHeight ); |
684 | 685 | ||
685 | glMatrixMode(GL_PROJECTION); | 686 | glMatrixMode(GL_PROJECTION); |
686 | glPopMatrix(); | 687 | gGL.popMatrix(); |
687 | 688 | ||
688 | glMatrixMode(GL_MODELVIEW); | 689 | glMatrixMode(GL_MODELVIEW); |
689 | glPopMatrix(); | 690 | gGL.popMatrix(); |
690 | 691 | ||
692 | gGL.stop(); | ||
691 | LLVector3 target_pos = mTargetJoint->getWorldPosition(); | 693 | LLVector3 target_pos = mTargetJoint->getWorldPosition(); |
692 | 694 | ||
693 | LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * | 695 | LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * |
@@ -720,6 +722,8 @@ BOOL LLImagePreviewAvatar::render() | |||
720 | avatarPoolp->renderAvatars(avatarp); // renders only one avatar | 722 | avatarPoolp->renderAvatars(avatarp); // renders only one avatar |
721 | } | 723 | } |
722 | 724 | ||
725 | gGL.start(); | ||
726 | |||
723 | return TRUE; | 727 | return TRUE; |
724 | } | 728 | } |
725 | 729 | ||
@@ -826,23 +830,23 @@ BOOL LLImagePreviewSculpted::render() | |||
826 | LLGLDepthTest depth(GL_TRUE); | 830 | LLGLDepthTest depth(GL_TRUE); |
827 | 831 | ||
828 | glMatrixMode(GL_PROJECTION); | 832 | glMatrixMode(GL_PROJECTION); |
829 | glPushMatrix(); | 833 | gGL.pushMatrix(); |
830 | glLoadIdentity(); | 834 | glLoadIdentity(); |
831 | glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); | 835 | glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); |
832 | 836 | ||
833 | glMatrixMode(GL_MODELVIEW); | 837 | glMatrixMode(GL_MODELVIEW); |
834 | glPushMatrix(); | 838 | gGL.pushMatrix(); |
835 | glLoadIdentity(); | 839 | glLoadIdentity(); |
836 | 840 | ||
837 | glColor4f(0.15f, 0.2f, 0.3f, 1.f); | 841 | gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); |
838 | 842 | ||
839 | gl_rect_2d_simple( mWidth, mHeight ); | 843 | gl_rect_2d_simple( mWidth, mHeight ); |
840 | 844 | ||
841 | glMatrixMode(GL_PROJECTION); | 845 | glMatrixMode(GL_PROJECTION); |
842 | glPopMatrix(); | 846 | gGL.popMatrix(); |
843 | 847 | ||
844 | glMatrixMode(GL_MODELVIEW); | 848 | glMatrixMode(GL_MODELVIEW); |
845 | glPopMatrix(); | 849 | gGL.popMatrix(); |
846 | 850 | ||
847 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 851 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
848 | 852 | ||
@@ -863,31 +867,55 @@ BOOL LLImagePreviewSculpted::render() | |||
863 | gCamera->setView(gCamera->getDefaultFOV() / mCameraZoom); | 867 | gCamera->setView(gCamera->getDefaultFOV() / mCameraZoom); |
864 | gCamera->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); | 868 | gCamera->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); |
865 | 869 | ||
866 | gPipeline.enableLightsAvatar(0.0); | 870 | gPipeline.enableLightsAvatar(); |
867 | |||
868 | 871 | ||
869 | glPushMatrix(); | 872 | gGL.pushMatrix(); |
870 | glScalef(0.5, 0.5, 0.5); | 873 | glScalef(0.5, 0.5, 0.5); |
871 | 874 | ||
872 | glBegin(GL_TRIANGLES); | ||
873 | glColor3f(0.8f, 0.8f, 0.8f); | ||
874 | |||
875 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); | 875 | const LLVolumeFace &vf = mVolume->getVolumeFace(0); |
876 | S32 num_indices = (S32)vf.mIndices.size(); | 876 | U32 num_indices = vf.mIndices.size(); |
877 | for (U32 i = 0; (S32)i < num_indices; i++) | 877 | U32 num_vertices = vf.mVertices.size(); |
878 | |||
879 | if (num_vertices > 0 && num_indices > 0) | ||
878 | { | 880 | { |
879 | LLVector3 normal = vf.mVertices[vf.mIndices[i]].mNormal; | 881 | glEnableClientState(GL_NORMAL_ARRAY); |
880 | normal.normVec(); | 882 | // build vertices and normals |
881 | glNormal3f(normal.mV[VX], normal.mV[VY], normal.mV[VZ]); | 883 | F32* vertices = new F32[num_vertices * 3]; |
884 | F32* normals = new F32[num_vertices * 3]; | ||
882 | 885 | ||
883 | LLVector3 position = vf.mVertices[vf.mIndices[i]].mPosition; | 886 | for (U32 i = 0; (S32)i < num_vertices; i++) |
884 | glVertex3f(position.mV[VX], position.mV[VY], position.mV[VZ]); | 887 | { |
885 | } | 888 | LLVector3 position = vf.mVertices[i].mPosition; |
889 | vertices[i*3] = position.mV[VX]; | ||
890 | vertices[i*3+1] = position.mV[VY]; | ||
891 | vertices[i*3+2] = position.mV[VZ]; | ||
892 | |||
893 | LLVector3 normal = vf.mVertices[i].mNormal; | ||
894 | normals[i*3] = normal.mV[VX]; | ||
895 | normals[i*3+1] = normal.mV[VY]; | ||
896 | normals[i*3+2] = normal.mV[VZ]; | ||
897 | } | ||
898 | |||
899 | // build indices | ||
900 | U16* indices = new U16[num_indices]; | ||
901 | for (U16 i = 0; i < num_indices; i++) | ||
902 | { | ||
903 | indices[i] = vf.mIndices[i]; | ||
904 | } | ||
905 | |||
906 | gGL.color3f(0.4f, 0.4f, 0.4f); | ||
907 | glVertexPointer(3, GL_FLOAT, 0, (void *)vertices); | ||
908 | glNormalPointer(GL_FLOAT, 0, (void *)normals); | ||
909 | glDrawRangeElements(GL_TRIANGLES, 0, num_indices-1, num_indices, GL_UNSIGNED_SHORT, (void *)indices); | ||
886 | 910 | ||
887 | glEnd(); | 911 | gGL.popMatrix(); |
888 | 912 | glDisableClientState(GL_NORMAL_ARRAY); | |
889 | glPopMatrix(); | 913 | |
890 | 914 | delete [] indices; | |
915 | delete [] vertices; | ||
916 | delete [] normals; | ||
917 | } | ||
918 | |||
891 | return TRUE; | 919 | return TRUE; |
892 | } | 920 | } |
893 | 921 | ||