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.cpp99
1 files changed, 36 insertions, 63 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index f562a9458b..9bda4bbf92 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -228,6 +228,7 @@ extern BOOL gDebugClicks;
extern BOOL gDisplaySwapBuffers;
extern BOOL gDepthDirty;
extern BOOL gResizeScreenTexture;
+extern BOOL gCubeSnapshot;
LLViewerWindow *gViewerWindow = NULL;
@@ -5267,29 +5268,30 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_
return true;
}
-BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap)
+void display_cube_face();
+
+BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face)
{
// NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot
LL_PROFILE_ZONE_SCOPED_CATEGORY_APP;
llassert(LLPipeline::sRenderDeferred);
+ llassert(!gCubeSnapshot); //assert a snapshot isn't already in progress
- U32 res = cubemap->getResolution();
+ U32 res = LLRenderTarget::sCurResX;
llassert(res <= gPipeline.mDeferredScreen.getWidth());
llassert(res <= gPipeline.mDeferredScreen.getHeight());
-
-
// save current view/camera settings so we can restore them afterwards
S32 old_occlusion = LLPipeline::sUseOcclusion;
// set new parameters specific to the 360 requirements
LLPipeline::sUseOcclusion = 0;
LLViewerCamera* camera = LLViewerCamera::getInstance();
- LLVector3 old_origin = camera->getOrigin();
- F32 old_fov = camera->getView();
- F32 old_aspect = camera->getAspect();
- F32 old_yaw = camera->getYaw();
+
+ LLViewerCamera saved_camera = LLViewerCamera::instance();
+ glh::matrix4f saved_proj = get_current_projection();
+ glh::matrix4f saved_mod = get_current_modelview();
// camera constants for the square, cube map capture image
camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV
@@ -5297,8 +5299,6 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap)
camera->yaw(0.0);
camera->setOrigin(origin);
- gDisplaySwapBuffers = FALSE;
-
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE;
@@ -5306,55 +5306,38 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap)
{
LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI);
}
-
- LLPipeline::sShowHUDAttachments = FALSE;
- LLRect window_rect = getWorldViewRectRaw();
-
- LLRenderTarget scratch_space; // TODO: hold onto "scratch space" render target and allocate oncer per session (allocate takes > 1ms)
- U32 color_fmt = GL_RGBA;
- const bool use_depth_buffer = true;
- const bool use_stencil_buffer = true;
- if (scratch_space.allocate(res, res, color_fmt, use_depth_buffer, use_stencil_buffer))
- {
- mWorldViewRectRaw.set(0, res, res, 0);
- scratch_space.bindTarget();
- }
- else
+ BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
+ if (prev_draw_particles)
{
- return FALSE;
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
}
+ LLPipeline::sShowHUDAttachments = FALSE;
+ LLRect window_rect = getWorldViewRectRaw();
- // "target" parameter of glCopyTexImage2D for each side of cubemap
- U32 targets[6] = {
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
- GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
- };
+ mWorldViewRectRaw.set(0, res, res, 0);
- // these are the 6 directions we will point the camera, see LLCubeMap::mTargets
+ // these are the 6 directions we will point the camera, see LLCubeMapArray::sTargets
LLVector3 look_dirs[6] = {
- LLVector3(-1, 0, 0),
LLVector3(1, 0, 0),
- LLVector3(0, -1, 0),
+ LLVector3(-1, 0, 0),
LLVector3(0, 1, 0),
- LLVector3(0, 0, -1),
- LLVector3(0, 0, 1)
+ LLVector3(0, -1, 0),
+ LLVector3(0, 0, 1),
+ LLVector3(0, 0, -1)
};
LLVector3 look_upvecs[6] = {
LLVector3(0, -1, 0),
LLVector3(0, -1, 0),
- LLVector3(0, 0, -1),
LLVector3(0, 0, 1),
+ LLVector3(0, 0, -1),
LLVector3(0, -1, 0),
LLVector3(0, -1, 0)
};
// for each of six sides of cubemap
- for (int i = 0; i < 6; ++i)
+ //for (int i = 0; i < 6; ++i)
+ int i = face;
{
// set up camera to look in each direction
camera->lookDir(look_dirs[i], look_upvecs[i]);
@@ -5368,22 +5351,12 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap)
gDisplaySwapBuffers = FALSE;
// actually render the scene
- const U32 subfield = 0;
- const bool do_rebuild = true;
- const F32 zoom = 1.0;
- const bool for_snapshot = TRUE;
- display(do_rebuild, zoom, subfield, for_snapshot);
-
- // copy results to cube map face
- cubemap->enable(0);
- cubemap->bind();
- glCopyTexImage2D(targets[i], 0, GL_RGB, 0, 0, res, res, 0);
- gGL.getTexUnit(0)->disable();
- cubemap->disable();
+ gCubeSnapshot = TRUE;
+ display_cube_face();
+ gCubeSnapshot = FALSE;
}
- gDisplaySwapBuffers = FALSE;
- gDepthDirty = TRUE;
+ gDisplaySwapBuffers = TRUE;
if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
{
@@ -5393,23 +5366,23 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap)
}
}
+ if (prev_draw_particles)
+ {
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
+ }
+
LLPipeline::sShowHUDAttachments = TRUE;
gPipeline.resetDrawOrders();
mWorldViewRectRaw = window_rect;
- scratch_space.flush();
- scratch_space.release();
// restore original view/camera/avatar settings settings
- camera->setAspect(old_aspect);
- camera->setView(old_fov);
- camera->yaw(old_yaw);
- camera->setOrigin(old_origin);
-
+ *camera = saved_camera;
+ set_current_modelview(saved_mod);
+ set_current_projection(saved_proj);
LLPipeline::sUseOcclusion = old_occlusion;
// ====================================================
-
return true;
}