diff options
Diffstat (limited to 'indra/newview/llglsandbox.cpp')
| -rw-r--r-- | indra/newview/llglsandbox.cpp | 449 |
1 files changed, 98 insertions, 351 deletions
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 6459cd5033..d43b3a5d6e 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -2,30 +2,25 @@ * @file llglsandbox.cpp * @brief GL functionality access * - * $LicenseInfo:firstyear=2003&license=viewergpl$ - * - * Copyright (c) 2003-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -39,7 +34,7 @@ #include "llviewercontrol.h" #include "llgl.h" -#include "llglimmediate.h" +#include "llrender.h" #include "llglheaders.h" #include "llparcel.h" #include "llui.h" @@ -48,16 +43,16 @@ #include "lltextureentry.h" #include "llviewercamera.h" -#include "llvoavatar.h" +#include "llvoavatarself.h" #include "llagent.h" #include "lltoolmgr.h" #include "llselectmgr.h" #include "llhudmanager.h" -#include "llsphere.h" +#include "llhudtext.h" +#include "llrendersphere.h" #include "llviewerobjectlist.h" #include "lltoolselectrect.h" #include "llviewerwindow.h" -#include "llcompass.h" #include "llsurface.h" #include "llwind.h" #include "llworld.h" @@ -67,101 +62,9 @@ #include "llresmgr.h" #include "pipeline.h" #include "llspatialpartition.h" - -BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) -{ - if(object && object->isAttachment()) - { - LLViewerObject* parent = object; - while(parent) - { - if (parent == mAvatarObject) - { - // looking at an attachment on ourselves, which we don't want to do - object = mAvatarObject; - position.clearVec(); - } - parent = (LLViewerObject*)parent->getParent(); - } - } - if(!mLookAt || mLookAt->isDead()) - { - mLookAt = (LLHUDEffectLookAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); - mLookAt->setSourceObject(mAvatarObject); - } - - return mLookAt->setLookAt(target_type, object, position); -} - -BOOL LLAgent::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position) -{ - // disallow pointing at attachments and avatars - if (object && (object->isAttachment() || object->isAvatar())) - { - return FALSE; - } - - if(!mPointAt || mPointAt->isDead()) - { - mPointAt = (LLHUDEffectPointAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); - mPointAt->setSourceObject(mAvatarObject); - } - - return mPointAt->setPointAt(target_type, object, position); -} - -ELookAtType LLAgent::getLookAtType() -{ - if (mLookAt) - { - return mLookAt->getLookAtType(); - } - - return LOOKAT_TARGET_NONE; -} - -EPointAtType LLAgent::getPointAtType() -{ - if (mPointAt) - { - return mPointAt->getPointAtType(); - } - - return POINTAT_TARGET_NONE; -} - -// Draw a representation of current autopilot target -void LLAgent::renderAutoPilotTarget() -{ - if (mAutoPilot) - { - F32 height_meters; - LLVector3d target_global; - - glMatrixMode(GL_MODELVIEW); - gGL.pushMatrix(); - - // not textured - LLGLSNoTexture no_texture; - - // lovely green - glColor4f(0.f, 1.f, 1.f, 1.f); - - target_global = mAutoPilotTargetGlobal; - - gGL.translatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ])); - - height_meters = 1.f; - - glScalef(height_meters, height_meters, height_meters); - gSphere.render(1500.f); - - gGL.popMatrix(); - } -} - -extern BOOL gDebugSelect; +// Height of the yellow selection highlight posts for land +const F32 PARCEL_POST_HEIGHT = 0.666f; // Returns true if you got at least one object void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) @@ -181,8 +84,8 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) top = llround((F32) top * LLUI::sGLScaleFactor.mV[VY]); bottom = llround((F32) bottom * LLUI::sGLScaleFactor.mV[VY]); - F32 old_far_plane = gCamera->getFar(); - F32 old_near_plane = gCamera->getNear(); + F32 old_far_plane = LLViewerCamera::getInstance()->getFar(); + F32 old_near_plane = LLViewerCamera::getInstance()->getNear(); S32 width = right - left + 1; S32 height = top - bottom + 1; @@ -220,17 +123,17 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { // ...select distance from control LLVector3 relative_av_pos = av_pos; - relative_av_pos -= gCamera->getOrigin(); + relative_av_pos -= LLViewerCamera::getInstance()->getOrigin(); - F32 new_far = relative_av_pos * gCamera->getAtAxis() + gSavedSettings.getF32("MaxSelectDistance"); - F32 new_near = relative_av_pos * gCamera->getAtAxis() - gSavedSettings.getF32("MaxSelectDistance"); + F32 new_far = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() + gSavedSettings.getF32("MaxSelectDistance"); + F32 new_near = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() - gSavedSettings.getF32("MaxSelectDistance"); new_near = llmax(new_near, 0.1f); - gCamera->setFar(new_far); - gCamera->setNear(new_near); + LLViewerCamera::getInstance()->setFar(new_far); + LLViewerCamera::getInstance()->setNear(new_near); } - gCamera->setPerspective(FOR_SELECTION, + LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, center_x-width/2, center_y-height/2, width, height, limit_select_distance); @@ -245,17 +148,17 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { return true; } - S32 result = gCamera->sphereInFrustum(drawable->getPositionAgent(), drawable->getRadius()); + S32 result = LLViewerCamera::getInstance()->sphereInFrustum(drawable->getPositionAgent(), drawable->getRadius()); switch (result) { case 0: - gSelectMgr->unhighlightObjectOnly(vobjp); + LLSelectMgr::getInstance()->unhighlightObjectOnly(vobjp); break; case 1: // check vertices - if (!gCamera->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) + if (!LLViewerCamera::getInstance()->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) { - gSelectMgr->unhighlightObjectOnly(vobjp); + LLSelectMgr::getInstance()->unhighlightObjectOnly(vobjp); } break; default: @@ -264,15 +167,15 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) return true; } } func; - gSelectMgr->getHighlightedObjects()->applyToObjects(&func); + LLSelectMgr::getInstance()->getHighlightedObjects()->applyToObjects(&func); } if (grow_selection) { std::vector<LLDrawable*> potentials; - for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); - iter != gWorldp->getRegionList().end(); ++iter) + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); + iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* region = *iter; for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) @@ -280,7 +183,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) LLSpatialPartition* part = region->getSpatialPartition(i); if (part) { - part->cull(*gCamera, &potentials, TRUE); + part->cull(*LLViewerCamera::getInstance(), &potentials, TRUE); } } } @@ -304,20 +207,20 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) continue; } - S32 result = gCamera->sphereInFrustum(drawable->getPositionAgent(), drawable->getRadius()); + S32 result = LLViewerCamera::getInstance()->sphereInFrustum(drawable->getPositionAgent(), drawable->getRadius()); if (result) { switch (result) { case 1: // check vertices - if (gCamera->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) + if (LLViewerCamera::getInstance()->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) { - gSelectMgr->highlightObjectOnly(vobjp); + LLSelectMgr::getInstance()->highlightObjectOnly(vobjp); } break; case 2: - gSelectMgr->highlightObjectOnly(vobjp); + LLSelectMgr::getInstance()->highlightObjectOnly(vobjp); break; default: break; @@ -332,146 +235,22 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) glMatrixMode(GL_MODELVIEW); // restore camera - gCamera->setFar(old_far_plane); - gCamera->setNear(old_near_plane); + LLViewerCamera::getInstance()->setFar(old_far_plane); + LLViewerCamera::getInstance()->setNear(old_near_plane); gViewerWindow->setup3DRender(); } - -const F32 COMPASS_SIZE = 64; -static const F32 COMPASS_RANGE = 0.33f; - -void LLCompass::draw() -{ -// S32 left, top, right, bottom; - - if (!getVisible()) return; - - glMatrixMode(GL_MODELVIEW); - gGL.pushMatrix(); - - S32 width = 32; - S32 height = 32; - - LLGLSUIDefault gls_ui; - - gGL.translatef( COMPASS_SIZE/2.f, COMPASS_SIZE/2.f, 0.f); - - if (mBkgndTexture) - { - mBkgndTexture->bind(); - gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); - - gGL.begin(GL_QUADS); - - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(width, height); - - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(-width, height); - - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(-width, -height); - - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(width, -height); - - gGL.end(); - } - - // rotate subsequent draws to agent rotation - F32 rotation = atan2( gAgent.getFrameAgent().getAtAxis().mV[VX], gAgent.getFrameAgent().getAtAxis().mV[VY] ); - glRotatef( - rotation * RAD_TO_DEG, 0.f, 0.f, -1.f); - - if (mTexture) - { - mTexture->bind(); - gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); - - gGL.begin(GL_QUADS); - - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(width, height); - - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(-width, height); - - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(-width, -height); - - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(width, -height); - - gGL.end(); - } - - gGL.popMatrix(); - -} - - - -void LLHorizontalCompass::draw() -{ - if (!getVisible()) return; - - LLGLSUIDefault gls_ui; - - S32 width = getRect().getWidth(); - S32 height = getRect().getHeight(); - S32 half_width = width / 2; - - if( mTexture ) - { - const LLVector3& at_axis = gCamera->getAtAxis(); - F32 center = atan2( at_axis.mV[VX], at_axis.mV[VY] ); - - center += F_PI; - center = llclamp( center, 0.0f, F_TWO_PI ); // probably not necessary... - center /= F_TWO_PI; - F32 left = center - COMPASS_RANGE; - F32 right = center + COMPASS_RANGE; - - mTexture->bind(); - gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f ); - gGL.begin( GL_QUADS ); - - gGL.texCoord2f(right, 1.f); - gGL.vertex2i(width, height); - - gGL.texCoord2f(left, 1.f); - gGL.vertex2i(0, height); - - gGL.texCoord2f(left, 0.f); - gGL.vertex2i(0, 0); - - gGL.texCoord2f(right, 0.f); - gGL.vertex2i(width, 0); - - gGL.end(); - } - - // Draw the focus line - { - LLGLSNoTexture gls_no_texture; - gGL.color4fv( mFocusColor.mV ); - gl_line_2d( half_width, 0, half_width, height ); - } -} - - const F32 WIND_ALTITUDE = 180.f; - void LLWind::renderVectors() { // Renders the wind as vectors (used for debug) S32 i,j; F32 x,y; - F32 region_width_meters = gWorldPointer->getRegionWidthInMeters(); + F32 region_width_meters = LLWorld::getInstance()->getRegionWidthInMeters(); - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.pushMatrix(); LLVector3 origin_agent; origin_agent = gAgent.getPosAgentFromGlobal(mOriginGlobal); @@ -485,11 +264,11 @@ void LLWind::renderVectors() gGL.pushMatrix(); gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); gGL.color3f(0,1,0); - gGL.begin(GL_POINTS); + gGL.begin(LLRender::POINTS); gGL.vertex3f(0,0,0); gGL.end(); gGL.color3f(1,0,0); - gGL.begin(GL_LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(x * 0.1f, y * 0.1f ,0.f); gGL.vertex3f(x, y, 0.f); gGL.end(); @@ -507,7 +286,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, const LLVector3d &east_north_top_global ) { LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLVector3 west_south_bottom_agent = gAgent.getPosAgentFromGlobal(west_south_bottom_global); @@ -524,10 +303,10 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, // resolves correctly so we can get a height value. const F32 FUDGE = 0.01f; - F32 sw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); - F32 se_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); - F32 ne_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); - F32 nw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); + F32 sw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); + F32 se_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); + F32 ne_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); + F32 nw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); F32 sw_top = sw_bottom + PARCEL_POST_HEIGHT; F32 se_top = se_bottom + PARCEL_POST_HEIGHT; @@ -538,7 +317,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, gGL.color4f(1.f, 1.f, 0.f, 1.f); // Cheat and give this the same pick-name as land - gGL.begin(GL_LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -555,7 +334,7 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, gGL.end(); gGL.color4f(1.f, 1.f, 0.f, 0.2f); - gGL.begin(GL_QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -601,10 +380,10 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) // resolves correctly so we can get a height value. const F32 FUDGE = 0.01f; - F32 sw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); - F32 se_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); - F32 ne_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); - F32 nw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); + F32 sw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); + F32 se_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); + F32 ne_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); + F32 nw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); // little hack to make nearby lines not Z-fight east -= 0.1f; @@ -615,14 +394,14 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) F32 ne_top = ne_bottom + POST_HEIGHT; F32 nw_top = nw_bottom + POST_HEIGHT; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); LLUI::setLineWidth(2.f); gGL.color4f(0.f, 1.f, 1.f, 1.f); // Cheat and give this the same pick-name as land - gGL.begin(GL_LINES); + gGL.begin(LLRender::LINES); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -639,7 +418,7 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) gGL.end(); gGL.color4f(0.f, 1.f, 1.f, 0.2f); - gGL.begin(GL_QUADS); + gGL.begin(LLRender::QUADS); gGL.vertex3f(west, north, nw_bottom); gGL.vertex3f(west, north, nw_top); @@ -765,7 +544,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi bool has_segments = false; LLGLSUIDefault gls_ui; - LLGLSNoTexture gls_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); gGL.color4f(1.f, 1.f, 0.f, 0.2f); @@ -792,7 +571,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(GL_QUADS); + gGL.begin(LLRender::QUADS); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp); } @@ -808,7 +587,7 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi if (!has_segments) { has_segments = true; - gGL.begin(GL_QUADS); + gGL.begin(LLRender::QUADS); } renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp); } @@ -856,14 +635,14 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV if (use_pass && (mCollisionBanned == BA_NOT_ON_LIST)) { - LLViewerImage::bindTexture( getPassImage() ); + gGL.getTexUnit(0)->bind(mPassImage); } else { - LLViewerImage::bindTexture( getBlockedImage() ); + gGL.getTexUnit(0)->bind(mBlockedImage); } - gGL.begin(GL_QUADS); + gGL.begin(LLRender::QUADS); for (y = 0; y < STRIDE; y++) { @@ -1012,29 +791,32 @@ void LLViewerObjectList::renderObjectBeacons() return; } - S32 i; - //const LLFontGL *font = gResMgr->getRes(LLFONT_SANSSERIF); - LLGLSUIDefault gls_ui; - S32 last_line_width = -1; - { - LLGLSNoTexture gls_ui_no_texture; - gGL.begin(GL_LINES); - for (i = 0; i < mDebugBeacons.count(); i++) + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + S32 last_line_width = -1; + // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) + + BOOL flush = FALSE; + for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter) { - const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; + const LLDebugBeacon &debug_beacon = *iter; LLColor4 color = debug_beacon.mColor; color.mV[3] *= 0.25f; S32 line_width = debug_beacon.mLineWidth; if (line_width != last_line_width) { - gGL.end(); + if (flush) + { + gGL.end(); + } + flush = TRUE; gGL.flush(); glLineWidth( (F32)line_width ); last_line_width = line_width; - gGL.begin(GL_LINES); + gGL.begin(LLRender::LINES); } const LLVector3 &thisline = debug_beacon.mPositionAgent; @@ -1052,23 +834,29 @@ void LLViewerObjectList::renderObjectBeacons() } { - LLGLSNoTexture gls_ui_no_texture; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDepthTest gls_depth(GL_TRUE); - gGL.begin(GL_LINES); - last_line_width = -1; - for (i = 0; i < mDebugBeacons.count(); i++) + S32 last_line_width = -1; + // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) + + BOOL flush = FALSE; + for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter) { - const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; + const LLDebugBeacon &debug_beacon = *iter; S32 line_width = debug_beacon.mLineWidth; if (line_width != last_line_width) { - gGL.end(); + if (flush) + { + gGL.end(); + } + flush = TRUE; gGL.flush(); glLineWidth( (F32)line_width ); last_line_width = line_width; - gGL.begin(GL_LINES); + gGL.begin(LLRender::LINES); } const LLVector3 &thisline = debug_beacon.mPositionAgent; @@ -1082,14 +870,14 @@ void LLViewerObjectList::renderObjectBeacons() draw_line_cube(0.10f, thisline); } + gGL.end(); - gGL.flush(); glLineWidth(1.f); - for (i = 0; i < mDebugBeacons.count(); i++) + for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter) { - LLDebugBeacon &debug_beacon = mDebugBeacons[i]; + LLDebugBeacon &debug_beacon = *iter; if (debug_beacon.mString == "") { continue; @@ -1101,7 +889,7 @@ void LLViewerObjectList::renderObjectBeacons() color = debug_beacon.mTextColor; color.mV[3] *= 1.f; - hud_textp->setString(utf8str_to_wstring(debug_beacon.mString.c_str())); + hud_textp->setString(debug_beacon.mString); hud_textp->setColor(color); hud_textp->setPositionAgent(debug_beacon.mPositionAgent); debug_beacon.mHUDObject = hud_textp; @@ -1110,44 +898,3 @@ void LLViewerObjectList::renderObjectBeacons() } -void pre_show_depth_buffer() -{ - glClear(GL_STENCIL_BUFFER_BIT); - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS,0,0); - glStencilOp(GL_INCR,GL_INCR,GL_INCR); -} - -void post_show_depth_buffer() -{ - int xsize =500, ysize =500; - U8 *buf = new U8[xsize*ysize]; - - glReadPixels(0,0,xsize,ysize,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE, buf); - - int total = 0; - int i; - for (i=0;i<xsize*ysize;i++) - { - total += buf[i]; - buf[i] <<= 3; - } - - float DC = (float)total/(float)(ysize*xsize); - int DCline = llfloor((xsize-20) * DC / 10.0f); - int stride = xsize / 10; - - int y = 2; - - for (i=0;i<DCline;i++) - { - if (i % stride == 0) i+=2; - if (i > xsize) y=6; - buf[ysize*(y+0)+i]=255; - buf[ysize*(y+1)+i]=255; - buf[ysize*(y+2)+i]=255; - } - glDrawPixels(xsize,ysize,GL_RED,GL_UNSIGNED_BYTE,buf); - - delete [] buf; -} |
