aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerdisplay.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llviewerdisplay.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/newview/llviewerdisplay.cpp')
-rw-r--r--linden/indra/newview/llviewerdisplay.cpp245
1 files changed, 190 insertions, 55 deletions
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp
index f09e34c..071b699 100644
--- a/linden/indra/newview/llviewerdisplay.cpp
+++ b/linden/indra/newview/llviewerdisplay.cpp
@@ -63,6 +63,9 @@
63#include "llfloatertools.h" 63#include "llfloatertools.h"
64#include "llviewerimagelist.h" 64#include "llviewerimagelist.h"
65#include "llfocusmgr.h" 65#include "llfocusmgr.h"
66#include "llcubemap.h"
67#include "llviewerregion.h"
68#include "lldrawpoolwater.h"
66 69
67extern U32 gFrameCount; 70extern U32 gFrameCount;
68extern LLPointer<LLImageGL> gStartImageGL; 71extern LLPointer<LLImageGL> gStartImageGL;
@@ -103,8 +106,12 @@ void display_startup()
103 return; 106 return;
104 } 107 }
105 108
106 LLDynamicTexture::updateAllInstances(); 109 // Required for HTML update in login screen
107 110 static S32 frame_count = 0;
111 if (frame_count++ > 1) // make sure we have rendered a frame first
112 {
113 LLDynamicTexture::updateAllInstances();
114 }
108 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 115 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
109 LLGLSDefault gls_default; 116 LLGLSDefault gls_default;
110 LLGLSUIDefault gls_ui; 117 LLGLSUIDefault gls_ui;
@@ -174,11 +181,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
174 // Clean up memory the pools may have allocated 181 // Clean up memory the pools may have allocated
175 if (rebuild) 182 if (rebuild)
176 { 183 {
177 if (!gViewerWindow->renderingFastFrame()) 184 gFrameStats.start(LLFrameStats::REBUILD);
178 { 185 gPipeline.rebuildPools();
179 gFrameStats.start(LLFrameStats::REBUILD);
180 gPipeline.rebuildPools();
181 }
182 } 186 }
183 return; 187 return;
184 } 188 }
@@ -378,14 +382,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
378 } 382 }
379 } 383 }
380 384
381 if (rebuild)
382 {
383 if (gViewerWindow->renderingFastFrame())
384 {
385 gFrameStats.start(LLFrameStats::STATE_SORT);
386 gFrameStats.start(LLFrameStats::REBUILD);
387 }
388 }
389 385
390 ///////////////////////////// 386 /////////////////////////////
391 // 387 //
@@ -394,6 +390,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
394 // 390 //
395 391
396 gCamera->setZoomParameters(zoom_factor, subfield); 392 gCamera->setZoomParameters(zoom_factor, subfield);
393 gCamera->setNear(MIN_NEAR_PLANE);
397 394
398 ////////////////////////// 395 //////////////////////////
399 // 396 //
@@ -409,6 +406,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
409 else if (!gViewerWindow->isPickPending()) 406 else if (!gViewerWindow->isPickPending())
410 { 407 {
411 glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); 408 glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
409 //DEBUG TEMPORARY
410 glClear(GL_COLOR_BUFFER_BIT);
412 } 411 }
413 gViewerWindow->setupViewport(); 412 gViewerWindow->setupViewport();
414 413
@@ -429,7 +428,13 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
429 glClearColor(0.5f, 0.5f, 0.5f, 0.f); 428 glClearColor(0.5f, 0.5f, 0.5f, 0.f);
430 glClear(GL_COLOR_BUFFER_BIT); 429 glClear(GL_COLOR_BUFFER_BIT);
431 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 430 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
431 LLPipeline::sUseOcclusion = FALSE;
432 } 432 }
433 else
434 {
435 LLPipeline::sUseOcclusion = gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery;
436 }
437
433 stop_glerror(); 438 stop_glerror();
434 439
435 /////////////////////////////////////// 440 ///////////////////////////////////////
@@ -442,7 +447,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
442 glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one); 447 glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one);
443 stop_glerror(); 448 stop_glerror();
444 449
445 //LLGLState::verify(); 450 //Increment drawable frame counter
451 LLDrawable::incrementVisible();
446 452
447 ///////////////////////////////////// 453 /////////////////////////////////////
448 // 454 //
@@ -452,6 +458,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
452 // 458 //
453 if (!gDisconnected) 459 if (!gDisconnected)
454 { 460 {
461 if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
462 { //don't draw hud objects in this frame
463 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
464 }
465
455 LLFastTimer t(LLFastTimer::FTM_WORLD_UPDATE); 466 LLFastTimer t(LLFastTimer::FTM_WORLD_UPDATE);
456 stop_glerror(); 467 stop_glerror();
457 display_update_camera(); 468 display_update_camera();
@@ -467,34 +478,41 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
467 gPipeline.updateGeom(max_geom_update_time); 478 gPipeline.updateGeom(max_geom_update_time);
468 stop_glerror(); 479 stop_glerror();
469 480
481 LLSpatialPartition* part = gPipeline.getSpatialPartition(LLPipeline::PARTITION_VOLUME);
482 part->processImagery(gCamera);
483
484 display_update_camera();
485
470 gFrameStats.start(LLFrameStats::UPDATE_CULL); 486 gFrameStats.start(LLFrameStats::UPDATE_CULL);
471 gPipeline.updateCull(); 487 gPipeline.updateCull(*gCamera);
472 stop_glerror(); 488 stop_glerror();
473 489
474 if (rebuild && !gViewerWindow->renderingFastFrame()) 490 ///////////////////////////////////
491 //
492 // StateSort
493 //
494 // Responsible for taking visible objects, and adding them to the appropriate draw orders.
495 // In the case of alpha objects, z-sorts them first.
496 // Also creates special lists for outlines and selected face rendering.
497 //
475 { 498 {
476 LLFastTimer t(LLFastTimer::FTM_REBUILD); 499 LLFastTimer t(LLFastTimer::FTM_REBUILD);
477
478 ///////////////////////////////////
479 //
480 // StateSort
481 //
482 // Responsible for taking visible objects, and adding them to the appropriate draw orders.
483 // In the case of alpha objects, z-sorts them first.
484 // Also creates special lists for outlines and selected face rendering.
485 //
486 gFrameStats.start(LLFrameStats::STATE_SORT);
487 gPipeline.stateSort();
488 stop_glerror();
489 500
490 ////////////////////////////////////// 501 gFrameStats.start(LLFrameStats::STATE_SORT);
491 // 502 gPipeline.stateSort(*gCamera);
492 // rebuildPools
493 //
494 //
495 gFrameStats.start(LLFrameStats::REBUILD);
496 gPipeline.rebuildPools();
497 stop_glerror(); 503 stop_glerror();
504
505 if (rebuild)
506 {
507 //////////////////////////////////////
508 //
509 // rebuildPools
510 //
511 //
512 gFrameStats.start(LLFrameStats::REBUILD);
513 gPipeline.rebuildPools();
514 stop_glerror();
515 }
498 } 516 }
499 } 517 }
500 518
@@ -535,19 +553,74 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
535 // glPopMatrix(); 553 // glPopMatrix();
536 //} 554 //}
537 555
538 if (gViewerWindow->renderingFastFrame()) 556 if (!(gLogoutRequestSent && gHaveSavedSnapshot)
539 {
540 gFrameStats.start(LLFrameStats::RENDER_SYNC);
541 gFrameStats.start(LLFrameStats::RENDER_GEOM);
542 }
543 else if (!(gLogoutRequestSent && gHaveSavedSnapshot)
544 && !gRestoreGL 557 && !gRestoreGL
545 && !gDisconnected) 558 && !gDisconnected)
546 { 559 {
547 gPipeline.renderGeom(); 560 gPipeline.renderGeom(*gCamera);
548 stop_glerror(); 561 stop_glerror();
549 } 562 }
550 563
564 //render hud attachments
565 glMatrixMode(GL_PROJECTION);
566 glPushMatrix();
567 glMatrixMode(GL_MODELVIEW);
568 glPushMatrix();
569 if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices(FALSE))
570 {
571 LLCamera hud_cam = *gCamera;
572 glClear(GL_DEPTH_BUFFER_BIT);
573 LLVector3 origin = hud_cam.getOrigin();
574 hud_cam.setOrigin(-1.f,0,0);
575 hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1));
576 LLViewerCamera::updateFrustumPlanes(hud_cam, TRUE);
577 //only render hud objects
578 U32 mask = gPipeline.getRenderTypeMask();
579 gPipeline.setRenderTypeMask(0);
580 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
581
582 BOOL has_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
583 if (has_ui)
584 {
585 gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
586 }
587
588 BOOL use_occlusion = gSavedSettings.getBOOL("UseOcclusion");
589 gSavedSettings.setBOOL("UseOcclusion", FALSE);
590
591 //cull, sort, and render hud objects
592 gPipeline.updateCull(hud_cam);
593
594 gPipeline.toggleRenderType(LLDrawPool::POOL_ALPHA_POST_WATER);
595 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_BUMP);
596 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_SIMPLE);
597 gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME);
598
599 {
600 LLFastTimer ftm(LLFastTimer::FTM_REBUILD);
601 gPipeline.stateSort(hud_cam);
602 }
603
604 if (LLVertexBuffer::sEnableVBOs)
605 {
606 LLImageGL::sBoundTextureMemory += LLVertexBuffer::sAllocatedBytes;
607 }
608
609 gPipeline.renderGeom(hud_cam);
610
611 //restore type mask
612 gPipeline.setRenderTypeMask(mask);
613 if (has_ui)
614 {
615 gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
616 }
617 gSavedSettings.setBOOL("UseOcclusion", use_occlusion);
618 }
619 glMatrixMode(GL_PROJECTION);
620 glPopMatrix();
621 glMatrixMode(GL_MODELVIEW);
622 glPopMatrix();
623
551 gFrameStats.start(LLFrameStats::RENDER_UI); 624 gFrameStats.start(LLFrameStats::RENDER_UI);
552 625
553 if (gHandleKeysAsync) 626 if (gHandleKeysAsync)
@@ -570,6 +643,64 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
570 643
571} 644}
572 645
646BOOL setup_hud_matrices(BOOL for_select)
647{
648 LLVOAvatar* my_avatarp = gAgent.getAvatarObject();
649 if (my_avatarp && my_avatarp->hasHUDAttachment())
650 {
651 if (!for_select)
652 {
653 // clamp target zoom level to reasonable values
654 my_avatarp->mHUDTargetZoom = llclamp(my_avatarp->mHUDTargetZoom, 0.1f, 1.f);
655 // smoothly interpolate current zoom level
656 my_avatarp->mHUDCurZoom = lerp(my_avatarp->mHUDCurZoom, my_avatarp->mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f));
657 }
658
659 F32 zoom_level = my_avatarp->mHUDCurZoom;
660 // clear z buffer and set up transform for hud
661 if (!for_select)
662 {
663 glClear(GL_DEPTH_BUFFER_BIT);
664 }
665 LLBBox hud_bbox = my_avatarp->getHUDBBox();
666
667 // set up transform to encompass bounding box of HUD
668 glMatrixMode(GL_PROJECTION);
669 glLoadIdentity();
670 F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
671 if (for_select)
672 {
673 //RN: reset viewport to window extents so ortho screen is calculated with proper reference frame
674 gViewerWindow->setupViewport();
675 }
676 glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
677
678 // apply camera zoom transform (for high res screenshots)
679 F32 zoom_factor = gCamera->getZoomFactor();
680 S16 sub_region = gCamera->getZoomSubRegion();
681 if (zoom_factor > 1.f)
682 {
683 float offset = zoom_factor - 1.f;
684 int pos_y = sub_region / llceil(zoom_factor);
685 int pos_x = sub_region - (pos_y*llceil(zoom_factor));
686 glTranslatef(gCamera->getAspect() * 0.5f * (offset - (F32)pos_x * 2.f), 0.5f * (offset - (F32)pos_y * 2.f), 0.f);
687 glScalef(zoom_factor, zoom_factor, 1.f);
688 }
689
690 glMatrixMode(GL_MODELVIEW);
691 glLoadIdentity();
692 glLoadMatrixf(OGL_TO_CFR_ROTATION); // Load Cory's favorite reference frame
693 glTranslatef(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f);
694 glScalef(zoom_level, zoom_level, zoom_level);
695
696 return TRUE;
697 }
698 else
699 {
700 return FALSE;
701 }
702}
703
573 704
574void render_ui_and_swap() 705void render_ui_and_swap()
575{ 706{
@@ -581,11 +712,11 @@ void render_ui_and_swap()
581 { 712 {
582 LLGLSUIDefault gls_ui; 713 LLGLSUIDefault gls_ui;
583 gPipeline.disableLights(); 714 gPipeline.disableLights();
584 715 LLVertexBuffer::startRender();
585 if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) 716 if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
586 { 717 {
587 LLFastTimer t(LLFastTimer::FTM_RENDER_UI); 718 LLFastTimer t(LLFastTimer::FTM_RENDER_UI);
588 if (!gViewerWindow->renderingFastFrame() && !gDisconnected) 719 if (!gDisconnected)
589 { 720 {
590 render_ui_3d(); 721 render_ui_3d();
591#ifndef LL_RELEASE_FOR_DOWNLOAD 722#ifndef LL_RELEASE_FOR_DOWNLOAD
@@ -598,6 +729,8 @@ void render_ui_and_swap()
598 LLGLState::checkStates(); 729 LLGLState::checkStates();
599#endif 730#endif
600 } 731 }
732 LLVertexBuffer::stopRender();
733 glFlush();
601 734
602 // now do the swap buffer 735 // now do the swap buffer
603 if (gDisplaySwapBuffers) 736 if (gDisplaySwapBuffers)
@@ -605,9 +738,13 @@ void render_ui_and_swap()
605 LLFastTimer t(LLFastTimer::FTM_SWAP); 738 LLFastTimer t(LLFastTimer::FTM_SWAP);
606 gViewerWindow->mWindow->swapBuffers(); 739 gViewerWindow->mWindow->swapBuffers();
607 } 740 }
608 }
609 741
610 gViewerWindow->finishFirstFastFrame(); 742 {
743 LLFastTimer ftm(LLFastTimer::FTM_CLIENT_COPY);
744 LLVertexBuffer::clientCopy(0.016);
745 }
746
747 }
611} 748}
612 749
613void render_ui_3d() 750void render_ui_3d()
@@ -622,8 +759,6 @@ void render_ui_3d()
622 // 759 //
623 760
624 // Render selections 761 // Render selections
625
626 glDisableClientState(GL_VERTEX_ARRAY);
627 glDisableClientState(GL_COLOR_ARRAY); 762 glDisableClientState(GL_COLOR_ARRAY);
628 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 763 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
629 glDisableClientState(GL_NORMAL_ARRAY); 764 glDisableClientState(GL_NORMAL_ARRAY);
@@ -680,7 +815,6 @@ void render_ui_2d()
680 LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeight() * (F32)pos_y / zoom_factor); 815 LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeight() * (F32)pos_y / zoom_factor);
681 } 816 }
682 817
683
684 stop_glerror(); 818 stop_glerror();
685 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 819 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
686 820
@@ -781,11 +915,12 @@ void render_disconnected_background()
781 { 915 {
782 llinfos << "Loading last bitmap..." << llendl; 916 llinfos << "Loading last bitmap..." << llendl;
783 917
784 char temp_str[MAX_PATH]; 918 char temp_str[MAX_PATH]; /* Flawfinder: ignore */
785 strcpy(temp_str, gDirUtilp->getLindenUserDir().c_str()); 919 strncpy(temp_str, gDirUtilp->getLindenUserDir().c_str(), MAX_PATH -1); /* Flawfinder: ignore */
786 strcat(temp_str, gDirUtilp->getDirDelimiter().c_str()); 920 temp_str[MAX_PATH -1] = '\0';
921 strncat(temp_str, gDirUtilp->getDirDelimiter().c_str(), MAX_PATH - strlen(temp_str) -1); /* Flawfinder: ignore */
787 922
788 strcat(temp_str, SCREEN_LAST_FILENAME); 923 strcat(temp_str, SCREEN_LAST_FILENAME); /* Flawfinder: ignore */
789 924
790 LLPointer<LLImageBMP> image_bmp = new LLImageBMP; 925 LLPointer<LLImageBMP> image_bmp = new LLImageBMP;
791 if( !image_bmp->load(temp_str) ) 926 if( !image_bmp->load(temp_str) )