summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp240
1 files changed, 172 insertions, 68 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 0bb2cb8194..2aff4281ad 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -168,6 +168,7 @@
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
+#include "llviewershadermgr.h"
#include "llviewerstats.h"
#include "llvoavatar.h"
#include "llvovolume.h"
@@ -218,6 +219,7 @@ LLVector3 gDebugRaycastIntersection;
LLVector2 gDebugRaycastTexCoord;
LLVector3 gDebugRaycastNormal;
LLVector3 gDebugRaycastBinormal;
+S32 gDebugRaycastFaceHit;
// HUD display lines in lower right
BOOL gDisplayWindInfo = FALSE;
@@ -1102,6 +1104,7 @@ void LLViewerWindow::handleQuit(LLWindow *window)
void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height)
{
reshape(width, height);
+ mResDirty = true;
}
// The top-level window has gained focus (e.g. via ALT-TAB)
@@ -1258,7 +1261,8 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating)
{
- if (!activating) gAgent.changeCameraToDefault();
+ //if (!activating) gAgent.changeCameraToDefault();
+
LLViewerJoystick::getInstance()->setNeedsReset(true);
return FALSE;
}
@@ -1411,7 +1415,11 @@ LLViewerWindow::LLViewerWindow(
mHideCursorPermanent( FALSE ),
mCursorHidden(FALSE),
mIgnoreActivate( FALSE ),
- mHoverPick()
+ mHoverPick(),
+ mResDirty(false),
+ mStatesDirty(false),
+ mIsFullscreenChecked(false),
+ mCurrResolutionIndex(0)
{
// Default to application directory.
LLViewerWindow::sSnapshotBaseName = "Snapshot";
@@ -1546,7 +1554,7 @@ void LLViewerWindow::initGLDefaults()
glPixelStorei(GL_PACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
- glEnable(GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
// lights for objects
glShadeModel( GL_SMOOTH );
@@ -3043,8 +3051,9 @@ BOOL LLViewerWindow::handlePerFrameHover()
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST))
{
- gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1,
- NULL,
+ gDebugRaycastFaceHit = -1;
+ gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
+ &gDebugRaycastFaceHit,
&gDebugRaycastIntersection,
&gDebugRaycastTexCoord,
&gDebugRaycastNormal,
@@ -3185,7 +3194,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
// Render light for editing
if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit())
{
- LLImageGL::unbindTexture(0);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLEnable gls_blend(GL_BLEND);
LLGLEnable gls_cull(GL_CULL_FACE);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
@@ -3399,7 +3408,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info)
llassert_always(pick_info.mScreenRegion.notNull());
mPicks.push_back(pick_info);
- S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]);
+ /*S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]);
S32 scaled_y = llround((F32)pick_info.mMousePt.mY * mDisplayScale.mV[VY]);
// Default to not hitting anything
@@ -3468,7 +3477,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info)
setup3DRender();
setup2DRender();
- setupViewport();
+ setupViewport();*/
// delay further event processing until we receive results of pick
mWindow->delayInputProcessing();
@@ -3530,6 +3539,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans
LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 depth,
LLViewerObject *this_object,
S32 this_face,
+ BOOL pick_transparent,
S32* face_hit,
LLVector3 *intersection,
LLVector2 *uv,
@@ -3563,7 +3573,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
{
if (this_object->isHUDAttachment()) // is a HUD object?
{
- if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face,
+ if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, binormal))
{
found = this_object;
@@ -3572,7 +3582,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
else // is a world object
{
- if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face,
+ if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, binormal))
{
found = this_object;
@@ -3582,13 +3592,13 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
else // check ALL objects
{
- found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end,
+ found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, pick_transparent,
face_hit, intersection, uv, normal, binormal);
if (!found) // if not found in HUD, look in world:
{
- found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end,
+ found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, pick_transparent,
face_hit, intersection, uv, normal, binormal);
}
@@ -3812,13 +3822,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image)
return FALSE;
}
- std::string extension("." + image->getExtension());
- if (extension.empty())
- {
- extension = (gSavedSettings.getBOOL("CompressSnapshotsToDisk")) ? ".j2c" : ".bmp";
- }
-
LLFilePicker::ESaveFilter pick_type;
+ std::string extension("." + image->getExtension());
if (extension == ".j2c")
pick_type = LLFilePicker::FFSAVE_J2C;
else if (extension == ".bmp")
@@ -3836,7 +3841,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image)
if ( ! isSnapshotLocSet())
{
std::string proposed_name( sSnapshotBaseName );
- proposed_name.append( extension );
+
+ // getSaveFile will append an appropriate extension to the proposed name, based on the ESaveFilter constant passed in.
// pick a directory in which to save
LLFilePicker& picker = LLFilePicker::instance();
@@ -4153,7 +4159,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
snapshot_width = image_width;
snapshot_height = image_height;
- target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE);
+ target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE, TRUE);
window_width = snapshot_width;
window_height = snapshot_height;
scale_factor = 1.f;
@@ -4381,7 +4387,7 @@ void LLViewerWindow::drawMouselookInstructions()
llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD));
{
- LLGLSNoTexture gls_no_texture;
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.color4f( 0.9f, 0.9f, 0.9f, 1.0f );
gl_rect_2d( instructions_rect );
}
@@ -4648,9 +4654,97 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height)
}
}
+bool LLViewerWindow::updateResolution()
+{
+ if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio"))
+ {
+ getWindow()->setNativeAspectRatio(0.f);
+ }
+ else
+ {
+ getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio"));
+ }
+
+ reshape(getWindowDisplayWidth(), getWindowDisplayHeight());
+
+ // Screen resolution
+ S32 num_resolutions;
+ LLWindow::LLWindowResolution* supported_resolutions = getWindow()->getSupportedResolutions(num_resolutions);
+
+ // check if resolution has changed
+ BOOL targetFullscreen;
+ S32 targetWidth;
+ S32 targetHeight;
+
+ getTargetWindow(targetFullscreen, targetWidth, targetHeight);
+
+ if ((mIsFullscreenChecked != (bool) targetFullscreen) ||
+ (mIsFullscreenChecked &&
+ (supported_resolutions[mCurrResolutionIndex].mWidth != targetWidth ||
+ supported_resolutions[mCurrResolutionIndex].mHeight != targetHeight)
+ ))
+ {
+ // change fullscreen resolution or switch in/out of windowed mode
+ BOOL result;
+
+ BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
+ if (mIsFullscreenChecked)
+ {
+ result = changeDisplaySettings(TRUE,
+ LLCoordScreen( supported_resolutions[mCurrResolutionIndex].mWidth,
+ supported_resolutions[mCurrResolutionIndex].mHeight),
+ gSavedSettings.getBOOL("DisableVerticalSync"),
+ logged_in);
+ }
+ else
+ {
+ result = changeDisplaySettings(FALSE,
+ LLCoordScreen(gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight")),
+ TRUE,
+ logged_in);
+ }
+ if (!result)
+ {
+
+ // GL is non-existent at this point, so we can't continue.
+ llerrs << "LLPanelDisplay::apply() failed" << llendl;
+ }
+ }
+
+ // force aspect ratio
+ if (mIsFullscreenChecked)
+ {
+ LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() );
+ }
+ return true;
+}
+
+void LLViewerWindow::requestResolutionUpdate(bool fullscreen_checked, U32 resolution_index)
+{
+ mResDirty = true;
+ mIsFullscreenChecked = fullscreen_checked;
+ mCurrResolutionIndex = resolution_index;
+}
+
BOOL LLViewerWindow::checkSettings()
{
+ if (mStatesDirty)
+ {
+ gGL.refreshState();
+ LLViewerShaderMgr::instance()->setShaders();
+ mStatesDirty = false;
+ }
+
+ // We want to update the resolution AFTER the states getting refreshed not before.
+ if (mResDirty)
+ {
+ updateResolution();
+ mResDirty = false;
+ // This will force a state update the next frame.
+ mStatesDirty = true;
+ }
+
BOOL is_fullscreen = mWindow->getFullscreen();
if (is_fullscreen && !mWantFullscreen)
{
@@ -4659,6 +4753,7 @@ BOOL LLViewerWindow::checkSettings()
gSavedSettings.getS32("WindowHeight")),
TRUE,
mShowFullscreenProgress);
+ mStatesDirty = true;
return TRUE;
}
else if (!is_fullscreen && mWantFullscreen)
@@ -4678,6 +4773,7 @@ BOOL LLViewerWindow::checkSettings()
LLGLState::checkStates();
LLGLState::checkTextureChannels();
+ mStatesDirty = true;
return TRUE;
}
return FALSE;
@@ -5104,25 +5200,34 @@ LLPickInfo::~LLPickInfo()
void LLPickInfo::fetchResults()
{
+
+ S32 face_hit = -1;
+ LLVector3 intersection, normal, binormal;
+ LLVector2 uv;
+
+ LLViewerObject* hit_object = gViewerWindow->cursorIntersect(-1, -1, 512.f,
+ NULL, -1, mPickTransparent, &face_hit,
+ &intersection, &uv, &normal, &binormal);
+
// read back colors and depth values from buffer
- glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer);
- glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, mPickDepthBuffer );
+ //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer);
+ //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mPickDepthBuffer );
// find pick region that is fully onscreen
LLCoordGL scaled_pick_point;;
scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH);
scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH);
- S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH;
- S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2];
- F32 depth = mPickDepthBuffer[pixel_index];
+ //S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH;
+ //S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2];
+ //F32 depth = mPickDepthBuffer[pixel_index];
- S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]);
- S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]);
+ //S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]);
+ //S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]);
mPickPt = mMousePt;
// we hit nothing, scan surrounding pixels for something useful
- if (!pick_id)
+ /*if (!pick_id)
{
S32 closest_distance = 10000;
//S32 closest_pick_name = 0;
@@ -5143,25 +5248,21 @@ void LLPickInfo::fetchResults()
}
}
}
- }
+ }*/
- U32 te_offset = ((U32)pick_id >> 20);
- pick_id &= 0x000fffff;
- //unproject relative clicked coordinate from window coordinate using GL
- GLint viewport[4];
- GLdouble modelview[16];
- GLdouble projection[16];
- GLfloat winX, winY;
- GLdouble posX, posY, posZ;
+ U32 te_offset = face_hit > -1 ? face_hit : 0;
+ //pick_id &= 0x000fffff;
- LLViewerObject* objectp = gObjectList.getSelectedObject(pick_id);
+ //unproject relative clicked coordinate from window coordinate using GL
+
+ LLViewerObject* objectp = hit_object;
- if (pick_id == (S32)GL_NAME_PARCEL_WALL)
- {
- mPickType = PICK_PARCEL_WALL;
- }
- else if (objectp)
+ //if (pick_id == (S32)GL_NAME_PARCEL_WALL)
+ //{
+ // mPickType = PICK_PARCEL_WALL;
+ //}
+ if (objectp)
{
if( objectp->getPCode() == LLViewerObject::LL_VO_SURFACE_PATCH )
{
@@ -5187,11 +5288,11 @@ void LLPickInfo::fetchResults()
{
mPickType = PICK_OBJECT;
}
- mObjectOffset = gAgent.calcFocusOffset(objectp, mPickPt.mX, mPickPt.mY);
+ mObjectOffset = gAgent.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY);
mObjectID = objectp->mID;
mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset;
- glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix);
+ /*glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix);
for(U32 i = 0; i < 16; ++i)
{
@@ -5203,9 +5304,9 @@ void LLPickInfo::fetchResults()
winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX];
winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY];
- gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ);
+ gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ);*/
- mPosGlobal = gAgent.getPosGlobalFromAgent(LLVector3(posX, posY, posZ));
+ mPosGlobal = gAgent.getPosGlobalFromAgent(intersection);
if (mWantSurfaceInfo)
{
@@ -5213,16 +5314,16 @@ void LLPickInfo::fetchResults()
}
}
}
- else
- {
+ //else
+ //{
// was this name referring to a hud icon?
- mHUDIcon = LLHUDIcon::handlePick(pick_id);
- if (mHUDIcon)
- {
- mPickType = PICK_ICON;
- mPosGlobal = mHUDIcon->getPositionGlobal();
- }
- }
+ // mHUDIcon = LLHUDIcon::handlePick(pick_id);
+ // if (mHUDIcon)
+ // {
+ // mPickType = PICK_ICON;
+ // mPosGlobal = mHUDIcon->getPositionGlobal();
+ // }
+ //}
if (mPickCallback)
{
@@ -5237,16 +5338,19 @@ LLPointer<LLViewerObject> LLPickInfo::getObject() const
void LLPickInfo::updateXYCoords()
{
- const LLTextureEntry* tep = getObject()->getTE(mObjectFace);
- LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID());
- if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull())
+ if (mObjectFace > -1)
{
- LLCoordGL coords;
-
- coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth());
- coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight());
+ const LLTextureEntry* tep = getObject()->getTE(mObjectFace);
+ LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID());
+ if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull())
+ {
+ LLCoordGL coords;
+
+ coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth());
+ coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight());
- gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords);
+ gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords);
+ }
}
}
@@ -5257,7 +5361,7 @@ void LLPickInfo::drawPickBuffer() const
gGL.pushMatrix();
LLGLDisable no_blend(GL_BLEND);
LLGLDisable no_alpha_test(GL_ALPHA_TEST);
- LLGLSNoTexture no_texture;
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glPixelZoom(10.f, 10.f);
LLVector2 display_scale = gViewerWindow->getDisplayScale();
glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f),
@@ -5309,7 +5413,7 @@ void LLPickInfo::getSurfaceInfo()
if (objectp)
{
if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f,
- objectp, -1,
+ objectp, -1, mPickTransparent,
&mObjectFace,
&mIntersection,
&mSTCoords,
@@ -5318,7 +5422,7 @@ void LLPickInfo::getSurfaceInfo()
{
// if we succeeded with the intersect above, compute the texture coordinates:
- if (objectp->mDrawable.notNull())
+ if (objectp->mDrawable.notNull() && mObjectFace > -1)
{
LLFace* facep = objectp->mDrawable->getFace(mObjectFace);