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/llviewerdisplay.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/llviewerdisplay.cpp')
-rw-r--r-- | linden/indra/newview/llviewerdisplay.cpp | 594 |
1 files changed, 390 insertions, 204 deletions
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp index e85b275..1e4958b 100644 --- a/linden/indra/newview/llviewerdisplay.cpp +++ b/linden/indra/newview/llviewerdisplay.cpp | |||
@@ -31,6 +31,11 @@ | |||
31 | 31 | ||
32 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
33 | 33 | ||
34 | #include "llviewerdisplay.h" | ||
35 | |||
36 | #include "llgl.h" | ||
37 | #include "llglimmediate.h" | ||
38 | #include "llglheaders.h" | ||
34 | #include "llagent.h" | 39 | #include "llagent.h" |
35 | #include "llviewercontrol.h" | 40 | #include "llviewercontrol.h" |
36 | #include "llcoord.h" | 41 | #include "llcoord.h" |
@@ -40,8 +45,6 @@ | |||
40 | #include "lldrawpoolalpha.h" | 45 | #include "lldrawpoolalpha.h" |
41 | #include "llfeaturemanager.h" | 46 | #include "llfeaturemanager.h" |
42 | #include "llframestats.h" | 47 | #include "llframestats.h" |
43 | #include "llgl.h" | ||
44 | #include "llglheaders.h" | ||
45 | #include "llhudmanager.h" | 48 | #include "llhudmanager.h" |
46 | #include "llimagebmp.h" | 49 | #include "llimagebmp.h" |
47 | #include "llimagegl.h" | 50 | #include "llimagegl.h" |
@@ -62,6 +65,7 @@ | |||
62 | #include "llvograss.h" | 65 | #include "llvograss.h" |
63 | #include "llworld.h" | 66 | #include "llworld.h" |
64 | #include "pipeline.h" | 67 | #include "pipeline.h" |
68 | #include "llspatialpartition.h" | ||
65 | #include "llappviewer.h" | 69 | #include "llappviewer.h" |
66 | #include "llstartup.h" | 70 | #include "llstartup.h" |
67 | #include "llfasttimer.h" | 71 | #include "llfasttimer.h" |
@@ -71,6 +75,9 @@ | |||
71 | #include "llcubemap.h" | 75 | #include "llcubemap.h" |
72 | #include "llviewerregion.h" | 76 | #include "llviewerregion.h" |
73 | #include "lldrawpoolwater.h" | 77 | #include "lldrawpoolwater.h" |
78 | #include "llwlparammanager.h" | ||
79 | #include "llwaterparammanager.h" | ||
80 | #include "llpostprocess.h" | ||
74 | 81 | ||
75 | extern LLPointer<LLImageGL> gStartImageGL; | 82 | extern LLPointer<LLImageGL> gStartImageGL; |
76 | extern BOOL gDisplaySwapBuffers; | 83 | extern BOOL gDisplaySwapBuffers; |
@@ -87,15 +94,19 @@ const F32 RESTORE_GL_TIME = 5.f; // Wait this long while reloading textures bef | |||
87 | 94 | ||
88 | BOOL gForceRenderLandFence = FALSE; | 95 | BOOL gForceRenderLandFence = FALSE; |
89 | BOOL gDisplaySwapBuffers = FALSE; | 96 | BOOL gDisplaySwapBuffers = FALSE; |
97 | BOOL gResizeScreenTexture = FALSE; | ||
98 | BOOL gSnapshot = FALSE; | ||
90 | 99 | ||
91 | // Rendering stuff | 100 | // Rendering stuff |
92 | void pre_show_depth_buffer(); | 101 | void pre_show_depth_buffer(); |
93 | void post_show_depth_buffer(); | 102 | void post_show_depth_buffer(); |
94 | void render_ui_and_swap(); | 103 | void render_ui_and_swap(); |
104 | void render_ui_and_swap_if_needed(); | ||
105 | void render_hud_attachments(); | ||
95 | void render_ui_3d(); | 106 | void render_ui_3d(); |
96 | void render_ui_2d(); | 107 | void render_ui_2d(); |
97 | void render_disconnected_background(); | 108 | void render_disconnected_background(); |
98 | 109 | void render_hud_elements(); | |
99 | void process_keystrokes_async(); | 110 | void process_keystrokes_async(); |
100 | 111 | ||
101 | void display_startup() | 112 | void display_startup() |
@@ -108,22 +119,43 @@ void display_startup() | |||
108 | return; | 119 | return; |
109 | } | 120 | } |
110 | 121 | ||
122 | LLGLSDefault gls_default; | ||
123 | |||
111 | // Required for HTML update in login screen | 124 | // Required for HTML update in login screen |
112 | static S32 frame_count = 0; | 125 | static S32 frame_count = 0; |
126 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
127 | LLGLState::checkStates(); | ||
128 | LLGLState::checkTextureChannels(); | ||
129 | #endif | ||
130 | |||
113 | if (frame_count++ > 1) // make sure we have rendered a frame first | 131 | if (frame_count++ > 1) // make sure we have rendered a frame first |
114 | { | 132 | { |
115 | LLDynamicTexture::updateAllInstances(); | 133 | LLDynamicTexture::updateAllInstances(); |
116 | } | 134 | } |
135 | |||
136 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
137 | LLGLState::checkStates(); | ||
138 | LLGLState::checkTextureChannels(); | ||
139 | #endif | ||
140 | |||
117 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 141 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
118 | LLGLSDefault gls_default; | ||
119 | LLGLSUIDefault gls_ui; | 142 | LLGLSUIDefault gls_ui; |
120 | gPipeline.disableLights(); | 143 | gPipeline.disableLights(); |
121 | 144 | ||
122 | gViewerWindow->setup2DRender(); | 145 | gViewerWindow->setup2DRender(); |
123 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 146 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
124 | 147 | ||
148 | gGL.start(); | ||
125 | gViewerWindow->draw(); | 149 | gViewerWindow->draw(); |
150 | gGL.stop(); | ||
151 | |||
152 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
153 | LLGLState::checkStates(); | ||
154 | LLGLState::checkTextureChannels(); | ||
155 | #endif | ||
156 | |||
126 | gViewerWindow->mWindow->swapBuffers(); | 157 | gViewerWindow->mWindow->swapBuffers(); |
158 | glClear(GL_DEPTH_BUFFER_BIT); | ||
127 | } | 159 | } |
128 | 160 | ||
129 | 161 | ||
@@ -141,6 +173,10 @@ void display_update_camera() | |||
141 | } | 173 | } |
142 | gCamera->setFar(final_far); | 174 | gCamera->setFar(final_far); |
143 | gViewerWindow->setup3DRender(); | 175 | gViewerWindow->setup3DRender(); |
176 | |||
177 | // update all the sky/atmospheric/water settings | ||
178 | LLWLParamManager::instance()->update(gCamera); | ||
179 | LLWaterParamManager::instance()->update(gCamera); | ||
144 | 180 | ||
145 | // Update land visibility too | 181 | // Update land visibility too |
146 | if (gWorldp) | 182 | if (gWorldp) |
@@ -151,15 +187,24 @@ void display_update_camera() | |||
151 | 187 | ||
152 | 188 | ||
153 | // Paint the display! | 189 | // Paint the display! |
154 | void display(BOOL rebuild, F32 zoom_factor, int subfield) | 190 | void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) |
155 | { | 191 | { |
156 | LLFastTimer t(LLFastTimer::FTM_RENDER); | 192 | LLFastTimer t(LLFastTimer::FTM_RENDER); |
157 | 193 | ||
194 | if (LLPipeline::sRenderFrameTest) | ||
195 | { | ||
196 | send_agent_pause(); | ||
197 | } | ||
198 | |||
199 | gSnapshot = for_snapshot; | ||
200 | |||
158 | LLGLSDefault gls_default; | 201 | LLGLSDefault gls_default; |
159 | LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); | 202 | LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); |
160 | 203 | ||
161 | // No clue where this is getting unset, but safe enough to reset it here. | 204 | // No clue where this is getting unset, but safe enough to reset it here. |
162 | LLGLState::resetTextureStates(); | 205 | //this causes frame stalls, try real hard not to uncomment this line - DaveP |
206 | //LLGLState::resetTextureStates(); | ||
207 | |||
163 | 208 | ||
164 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 209 | #ifndef LL_RELEASE_FOR_DOWNLOAD |
165 | LLGLState::checkStates(); | 210 | LLGLState::checkStates(); |
@@ -167,7 +212,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
167 | #endif | 212 | #endif |
168 | 213 | ||
169 | gPipeline.disableLights(); | 214 | gPipeline.disableLights(); |
170 | 215 | ||
171 | // Don't draw if the window is hidden or minimized. | 216 | // Don't draw if the window is hidden or minimized. |
172 | // In fact, must explicitly check the minimized state before drawing. | 217 | // In fact, must explicitly check the minimized state before drawing. |
173 | // Attempting to draw into a minimized window causes a GL error. JC | 218 | // Attempting to draw into a minimized window causes a GL error. JC |
@@ -185,7 +230,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
185 | } | 230 | } |
186 | 231 | ||
187 | gViewerWindow->checkSettings(); | 232 | gViewerWindow->checkSettings(); |
233 | |||
188 | gViewerWindow->performPick(); | 234 | gViewerWindow->performPick(); |
235 | |||
189 | 236 | ||
190 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 237 | #ifndef LL_RELEASE_FOR_DOWNLOAD |
191 | LLGLState::checkStates(); | 238 | LLGLState::checkStates(); |
@@ -235,7 +282,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
235 | stop_glerror(); | 282 | stop_glerror(); |
236 | 283 | ||
237 | LLImageGL::updateStats(gFrameTimeSeconds); | 284 | LLImageGL::updateStats(gFrameTimeSeconds); |
238 | 285 | ||
239 | LLVOAvatar::sRenderName = gSavedSettings.getS32("RenderName"); | 286 | LLVOAvatar::sRenderName = gSavedSettings.getS32("RenderName"); |
240 | LLVOAvatar::sRenderGroupTitles = gSavedSettings.getBOOL("RenderGroupTitleAll"); | 287 | LLVOAvatar::sRenderGroupTitles = gSavedSettings.getBOOL("RenderGroupTitleAll"); |
241 | gPipeline.mBackfaceCull = TRUE; | 288 | gPipeline.mBackfaceCull = TRUE; |
@@ -369,18 +416,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
369 | // Prepare for the next frame | 416 | // Prepare for the next frame |
370 | // | 417 | // |
371 | 418 | ||
372 | // Hmm... Should this be moved elsewhere? - djs 09/09/02 | ||
373 | // do render-to-texture stuff here | ||
374 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) | ||
375 | { | ||
376 | // LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); | ||
377 | if (LLDynamicTexture::updateAllInstances()) | ||
378 | { | ||
379 | glClear(GL_COLOR_BUFFER_BIT); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | |||
384 | ///////////////////////////// | 419 | ///////////////////////////// |
385 | // | 420 | // |
386 | // Update the camera | 421 | // Update the camera |
@@ -398,18 +433,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
398 | 433 | ||
399 | if (gDisconnected) | 434 | if (gDisconnected) |
400 | { | 435 | { |
401 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 436 | render_ui_and_swap_if_needed(); |
437 | gDisplaySwapBuffers = TRUE; | ||
438 | |||
402 | render_disconnected_background(); | 439 | render_disconnected_background(); |
403 | } | 440 | } |
404 | else if (!gViewerWindow->isPickPending()) | 441 | |
405 | { | ||
406 | glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); | ||
407 | //DEBUG TEMPORARY | ||
408 | glClear(GL_COLOR_BUFFER_BIT); | ||
409 | } | ||
410 | gViewerWindow->setupViewport(); | ||
411 | |||
412 | |||
413 | ////////////////////////// | 442 | ////////////////////////// |
414 | // | 443 | // |
415 | // Set rendering options | 444 | // Set rendering options |
@@ -421,18 +450,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
421 | pre_show_depth_buffer(); | 450 | pre_show_depth_buffer(); |
422 | } | 451 | } |
423 | 452 | ||
424 | if(gUseWireframe)//gSavedSettings.getBOOL("UseWireframe")) | ||
425 | { | ||
426 | glClearColor(0.5f, 0.5f, 0.5f, 0.f); | ||
427 | glClear(GL_COLOR_BUFFER_BIT); | ||
428 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||
429 | LLPipeline::sUseOcclusion = FALSE; | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | LLPipeline::sUseOcclusion = gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery && gFeatureManagerp->isFeatureAvailable("UseOcclusion"); | ||
434 | } | ||
435 | |||
436 | stop_glerror(); | 453 | stop_glerror(); |
437 | 454 | ||
438 | /////////////////////////////////////// | 455 | /////////////////////////////////////// |
@@ -444,16 +461,27 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
444 | F32 one[4] = {1.f, 1.f, 1.f, 1.f}; | 461 | F32 one[4] = {1.f, 1.f, 1.f, 1.f}; |
445 | glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one); | 462 | glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one); |
446 | stop_glerror(); | 463 | stop_glerror(); |
447 | 464 | ||
448 | //Increment drawable frame counter | ||
449 | LLDrawable::incrementVisible(); | ||
450 | |||
451 | ///////////////////////////////////// | 465 | ///////////////////////////////////// |
452 | // | 466 | // |
453 | // Render | 467 | // Render |
454 | // | 468 | // |
455 | // Actually push all of our triangles to the screen. | 469 | // Actually push all of our triangles to the screen. |
456 | // | 470 | // |
471 | |||
472 | // do render-to-texture stuff here | ||
473 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) | ||
474 | { | ||
475 | LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); | ||
476 | if (LLDynamicTexture::updateAllInstances()) | ||
477 | { | ||
478 | glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); | ||
479 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||
480 | } | ||
481 | } | ||
482 | |||
483 | gViewerWindow->setupViewport(); | ||
484 | |||
457 | if (!gDisconnected) | 485 | if (!gDisconnected) |
458 | { | 486 | { |
459 | if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) | 487 | if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) |
@@ -461,30 +489,106 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
461 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); | 489 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); |
462 | } | 490 | } |
463 | 491 | ||
464 | LLFastTimer t(LLFastTimer::FTM_WORLD_UPDATE); | 492 | //upkeep gl name pools |
493 | LLGLNamePool::upkeepPools(); | ||
494 | |||
465 | stop_glerror(); | 495 | stop_glerror(); |
466 | display_update_camera(); | 496 | display_update_camera(); |
467 | stop_glerror(); | 497 | stop_glerror(); |
468 | 498 | ||
469 | // *TODO: merge these two methods | 499 | // *TODO: merge these two methods |
470 | gHUDManager->updateEffects(); | 500 | gHUDManager->updateEffects(); |
471 | LLHUDObject::updateAll(); | 501 | LLHUDObject::updateAll(); |
472 | stop_glerror(); | 502 | stop_glerror(); |
473 | 503 | ||
474 | gFrameStats.start(LLFrameStats::UPDATE_GEOM); | 504 | gFrameStats.start(LLFrameStats::UPDATE_GEOM); |
475 | const F32 max_geom_update_time = 0.005f; // 5 ms update time | 505 | const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time |
476 | gPipeline.updateGeom(max_geom_update_time); | 506 | gPipeline.updateGeom(max_geom_update_time); |
477 | stop_glerror(); | 507 | stop_glerror(); |
478 | 508 | ||
479 | LLSpatialPartition* part = gPipeline.getSpatialPartition(LLPipeline::PARTITION_VOLUME); | 509 | gFrameStats.start(LLFrameStats::UPDATE_CULL); |
480 | part->processImagery(gCamera); | 510 | S32 water_clip = 0; |
511 | if (LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) > 1) | ||
512 | { | ||
513 | if (gCamera->cameraUnderWater()) | ||
514 | { | ||
515 | water_clip = -1; | ||
516 | } | ||
517 | else | ||
518 | { | ||
519 | water_clip = 1; | ||
520 | } | ||
521 | } | ||
481 | 522 | ||
482 | display_update_camera(); | 523 | //Increment drawable frame counter |
524 | LLDrawable::incrementVisible(); | ||
525 | |||
526 | LLPipeline::sUseOcclusion = | ||
527 | (!gUseWireframe | ||
528 | && gFeatureManagerp->isFeatureAvailable("UseOcclusion") | ||
529 | && gSavedSettings.getBOOL("UseOcclusion") | ||
530 | && gGLManager.mHasOcclusionQuery) ? 2 : 0; | ||
531 | LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha"); | ||
532 | LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip"); | ||
533 | LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible"); | ||
534 | |||
535 | S32 occlusion = LLPipeline::sUseOcclusion; | ||
536 | if (!gDisplaySwapBuffers) | ||
537 | { //depth buffer is invalid, don't overwrite occlusion state | ||
538 | LLPipeline::sUseOcclusion = llmin(occlusion, 1); | ||
539 | } | ||
483 | 540 | ||
484 | gFrameStats.start(LLFrameStats::UPDATE_CULL); | 541 | static LLCullResult result; |
485 | gPipeline.updateCull(*gCamera); | 542 | gPipeline.updateCull(*gCamera, result, water_clip); |
486 | stop_glerror(); | 543 | stop_glerror(); |
487 | 544 | ||
545 | BOOL to_texture = !for_snapshot && | ||
546 | gPipeline.canUseVertexShaders() && | ||
547 | LLPipeline::sRenderGlow && | ||
548 | gGLManager.mHasFramebufferObject; | ||
549 | |||
550 | // now do the swap buffer (just before rendering to framebuffer) | ||
551 | { //swap and flush state from previous frame | ||
552 | { | ||
553 | LLFastTimer ftm(LLFastTimer::FTM_CLIENT_COPY); | ||
554 | LLVertexBuffer::clientCopy(0.016); | ||
555 | } | ||
556 | |||
557 | if (gResizeScreenTexture) | ||
558 | { | ||
559 | gResizeScreenTexture = FALSE; | ||
560 | gPipeline.resizeScreenTexture(); | ||
561 | } | ||
562 | |||
563 | glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); | ||
564 | glClearColor(0,0,0,0); | ||
565 | |||
566 | if (!for_snapshot) | ||
567 | { | ||
568 | render_ui_and_swap_if_needed(); | ||
569 | gDisplaySwapBuffers = TRUE; | ||
570 | |||
571 | glh::matrix4f proj = glh_get_current_projection(); | ||
572 | glh::matrix4f mod = glh_get_current_modelview(); | ||
573 | glViewport(0,0,128,256); | ||
574 | LLVOAvatar::updateImpostors(); | ||
575 | glh_set_current_projection(proj); | ||
576 | glh_set_current_modelview(mod); | ||
577 | glMatrixMode(GL_PROJECTION); | ||
578 | glLoadMatrixf(proj.m); | ||
579 | glMatrixMode(GL_MODELVIEW); | ||
580 | glLoadMatrixf(mod.m); | ||
581 | gViewerWindow->setupViewport(); | ||
582 | } | ||
583 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | ||
584 | } | ||
585 | |||
586 | if (!for_snapshot) | ||
587 | { | ||
588 | gPipeline.processImagery(*gCamera); | ||
589 | gPipeline.generateWaterReflection(*gCamera); | ||
590 | } | ||
591 | |||
488 | /////////////////////////////////// | 592 | /////////////////////////////////// |
489 | // | 593 | // |
490 | // StateSort | 594 | // StateSort |
@@ -494,10 +598,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
494 | // Also creates special lists for outlines and selected face rendering. | 598 | // Also creates special lists for outlines and selected face rendering. |
495 | // | 599 | // |
496 | { | 600 | { |
497 | LLFastTimer t(LLFastTimer::FTM_REBUILD); | ||
498 | |||
499 | gFrameStats.start(LLFrameStats::STATE_SORT); | 601 | gFrameStats.start(LLFrameStats::STATE_SORT); |
500 | gPipeline.stateSort(*gCamera); | 602 | gPipeline.stateSort(*gCamera, result); |
501 | stop_glerror(); | 603 | stop_glerror(); |
502 | 604 | ||
503 | if (rebuild) | 605 | if (rebuild) |
@@ -512,67 +614,133 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
512 | stop_glerror(); | 614 | stop_glerror(); |
513 | } | 615 | } |
514 | } | 616 | } |
617 | |||
618 | LLPipeline::sUseOcclusion = occlusion; | ||
619 | |||
620 | { | ||
621 | LLFastTimer t(LLFastTimer::FTM_UPDATE_SKY); | ||
622 | gSky.updateSky(); | ||
623 | } | ||
624 | |||
625 | if(gUseWireframe) | ||
626 | { | ||
627 | glClearColor(0.5f, 0.5f, 0.5f, 0.f); | ||
628 | glClear(GL_COLOR_BUFFER_BIT); | ||
629 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||
630 | } | ||
631 | |||
632 | //// render frontmost floater opaque for occlusion culling purposes | ||
633 | //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); | ||
634 | //// assumes frontmost floater with focus is opaque | ||
635 | //if (frontmost_floaterp && gFocusMgr.childHasKeyboardFocus(frontmost_floaterp)) | ||
636 | //{ | ||
637 | // glMatrixMode(GL_MODELVIEW); | ||
638 | // glPushMatrix(); | ||
639 | // { | ||
640 | // LLGLSNoTexture gls_no_texture; | ||
641 | |||
642 | // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); | ||
643 | // glLoadIdentity(); | ||
644 | |||
645 | // LLRect floater_rect = frontmost_floaterp->getScreenRect(); | ||
646 | // // deflate by one pixel so rounding errors don't occlude outside of floater extents | ||
647 | // floater_rect.stretch(-1); | ||
648 | // LLRectf floater_3d_rect((F32)floater_rect.mLeft / (F32)gViewerWindow->getWindowWidth(), | ||
649 | // (F32)floater_rect.mTop / (F32)gViewerWindow->getWindowHeight(), | ||
650 | // (F32)floater_rect.mRight / (F32)gViewerWindow->getWindowWidth(), | ||
651 | // (F32)floater_rect.mBottom / (F32)gViewerWindow->getWindowHeight()); | ||
652 | // floater_3d_rect.translate(-0.5f, -0.5f); | ||
653 | // glTranslatef(0.f, 0.f, -gCamera->getNear()); | ||
654 | // glScalef(gCamera->getNear() * gCamera->getAspect() / sinf(gCamera->getView()), gCamera->getNear() / sinf(gCamera->getView()), 1.f); | ||
655 | // gGL.color4fv(LLColor4::white.mV); | ||
656 | // gGL.begin(GL_QUADS); | ||
657 | // { | ||
658 | // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mBottom, 0.f); | ||
659 | // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mTop, 0.f); | ||
660 | // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mTop, 0.f); | ||
661 | // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mBottom, 0.f); | ||
662 | // } | ||
663 | // gGL.end(); | ||
664 | // glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
665 | // } | ||
666 | // glPopMatrix(); | ||
667 | //} | ||
668 | |||
669 | if (to_texture) | ||
670 | { | ||
671 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
672 | gPipeline.mScreen.bindTarget(); | ||
673 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | ||
674 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); | ||
675 | } | ||
676 | |||
677 | if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) | ||
678 | && !gRestoreGL) | ||
679 | { | ||
680 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); | ||
681 | LLPipeline::sUnderWaterRender = gCamera->cameraUnderWater() ? TRUE : FALSE; | ||
682 | gPipeline.renderGeom(*gCamera, TRUE); | ||
683 | LLPipeline::sUnderWaterRender = FALSE; | ||
684 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
685 | |||
686 | //store this frame's modelview matrix for use | ||
687 | //when rendering next frame's occlusion queries | ||
688 | for (U32 i = 0; i < 16; i++) | ||
689 | { | ||
690 | gGLLastModelView[i] = gGLModelView[i]; | ||
691 | } | ||
692 | stop_glerror(); | ||
693 | } | ||
694 | |||
695 | render_hud_attachments(); | ||
696 | |||
697 | if (to_texture) | ||
698 | { | ||
699 | gPipeline.mScreen.flush(); | ||
700 | } | ||
701 | |||
702 | /// We copy the frame buffer straight into a texture here, | ||
703 | /// and then display it again with compositor effects. | ||
704 | /// Using render to texture would be faster/better, but I don't have a | ||
705 | /// grasp of their full display stack just yet. | ||
706 | // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); | ||
515 | } | 707 | } |
708 | gFrameStats.start(LLFrameStats::RENDER_UI); | ||
516 | 709 | ||
517 | //// render frontmost floater opaque for occlusion culling purposes | 710 | if (gHandleKeysAsync) |
518 | //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); | ||
519 | //// assumes frontmost floater with focus is opaque | ||
520 | //if (frontmost_floaterp && gFocusMgr.childHasKeyboardFocus(frontmost_floaterp)) | ||
521 | //{ | ||
522 | // glMatrixMode(GL_MODELVIEW); | ||
523 | // glPushMatrix(); | ||
524 | // { | ||
525 | // LLGLSNoTexture gls_no_texture; | ||
526 | |||
527 | // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); | ||
528 | // glLoadIdentity(); | ||
529 | |||
530 | // LLRect floater_rect = frontmost_floaterp->getScreenRect(); | ||
531 | // // deflate by one pixel so rounding errors don't occlude outside of floater extents | ||
532 | // floater_rect.stretch(-1); | ||
533 | // LLRectf floater_3d_rect((F32)floater_rect.mLeft / (F32)gViewerWindow->getWindowWidth(), | ||
534 | // (F32)floater_rect.mTop / (F32)gViewerWindow->getWindowHeight(), | ||
535 | // (F32)floater_rect.mRight / (F32)gViewerWindow->getWindowWidth(), | ||
536 | // (F32)floater_rect.mBottom / (F32)gViewerWindow->getWindowHeight()); | ||
537 | // floater_3d_rect.translate(-0.5f, -0.5f); | ||
538 | // glTranslatef(0.f, 0.f, -gCamera->getNear()); | ||
539 | // glScalef(gCamera->getNear() * gCamera->getAspect() / sinf(gCamera->getView()), gCamera->getNear() / sinf(gCamera->getView()), 1.f); | ||
540 | // glColor4fv(LLColor4::white.mV); | ||
541 | // glBegin(GL_QUADS); | ||
542 | // { | ||
543 | // glVertex3f(floater_3d_rect.mLeft, floater_3d_rect.mBottom, 0.f); | ||
544 | // glVertex3f(floater_3d_rect.mLeft, floater_3d_rect.mTop, 0.f); | ||
545 | // glVertex3f(floater_3d_rect.mRight, floater_3d_rect.mTop, 0.f); | ||
546 | // glVertex3f(floater_3d_rect.mRight, floater_3d_rect.mBottom, 0.f); | ||
547 | // } | ||
548 | // glEnd(); | ||
549 | // glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
550 | // } | ||
551 | // glPopMatrix(); | ||
552 | //} | ||
553 | |||
554 | if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) | ||
555 | && !gRestoreGL | ||
556 | && !gDisconnected) | ||
557 | { | 711 | { |
558 | gPipeline.renderGeom(*gCamera); | 712 | process_keystrokes_async(); |
559 | stop_glerror(); | 713 | stop_glerror(); |
560 | } | 714 | } |
561 | 715 | ||
562 | //render hud attachments | 716 | gFrameStats.start(LLFrameStats::MISC_END); |
717 | stop_glerror(); | ||
718 | |||
719 | if (LLPipeline::sRenderFrameTest) | ||
720 | { | ||
721 | send_agent_resume(); | ||
722 | LLPipeline::sRenderFrameTest = FALSE; | ||
723 | } | ||
724 | } | ||
725 | |||
726 | void render_hud_attachments() | ||
727 | { | ||
563 | glMatrixMode(GL_PROJECTION); | 728 | glMatrixMode(GL_PROJECTION); |
564 | glPushMatrix(); | 729 | glPushMatrix(); |
565 | glMatrixMode(GL_MODELVIEW); | 730 | glMatrixMode(GL_MODELVIEW); |
566 | glPushMatrix(); | 731 | glPushMatrix(); |
567 | 732 | ||
733 | glh::matrix4f current_proj = glh_get_current_projection(); | ||
734 | glh::matrix4f current_mod = glh_get_current_modelview(); | ||
735 | |||
568 | if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices(FALSE)) | 736 | if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices(FALSE)) |
569 | { | 737 | { |
570 | LLCamera hud_cam = *gCamera; | 738 | LLCamera hud_cam = *gCamera; |
571 | glClear(GL_DEPTH_BUFFER_BIT); | ||
572 | LLVector3 origin = hud_cam.getOrigin(); | 739 | LLVector3 origin = hud_cam.getOrigin(); |
573 | hud_cam.setOrigin(-1.f,0,0); | 740 | hud_cam.setOrigin(-1.f,0,0); |
574 | hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1)); | 741 | hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1)); |
575 | LLViewerCamera::updateFrustumPlanes(hud_cam, TRUE); | 742 | LLViewerCamera::updateFrustumPlanes(hud_cam, TRUE); |
743 | |||
576 | //only render hud objects | 744 | //only render hud objects |
577 | U32 mask = gPipeline.getRenderTypeMask(); | 745 | U32 mask = gPipeline.getRenderTypeMask(); |
578 | gPipeline.setRenderTypeMask(0); | 746 | gPipeline.setRenderTypeMask(0); |
@@ -584,22 +752,22 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
584 | gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); | 752 | gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); |
585 | } | 753 | } |
586 | 754 | ||
587 | BOOL use_occlusion = gSavedSettings.getBOOL("UseOcclusion"); | 755 | S32 use_occlusion = LLPipeline::sUseOcclusion; |
588 | gSavedSettings.setBOOL("UseOcclusion", FALSE); | 756 | LLPipeline::sUseOcclusion = 0; |
757 | LLPipeline::sDisableShaders = TRUE; | ||
589 | 758 | ||
590 | //cull, sort, and render hud objects | 759 | //cull, sort, and render hud objects |
591 | gPipeline.updateCull(hud_cam); | 760 | static LLCullResult result; |
761 | gPipeline.updateCull(hud_cam, result); | ||
592 | 762 | ||
593 | gPipeline.toggleRenderType(LLDrawPool::POOL_ALPHA_POST_WATER); | ||
594 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_BUMP); | 763 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_BUMP); |
595 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_SIMPLE); | 764 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_SIMPLE); |
596 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME); | 765 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME); |
766 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_GLOW); | ||
767 | gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA); | ||
597 | 768 | ||
598 | { | 769 | gPipeline.stateSort(hud_cam, result); |
599 | LLFastTimer ftm(LLFastTimer::FTM_REBUILD); | 770 | |
600 | gPipeline.stateSort(hud_cam); | ||
601 | } | ||
602 | |||
603 | gPipeline.renderGeom(hud_cam); | 771 | gPipeline.renderGeom(hud_cam); |
604 | 772 | ||
605 | //restore type mask | 773 | //restore type mask |
@@ -608,33 +776,16 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield) | |||
608 | { | 776 | { |
609 | gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); | 777 | gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI); |
610 | } | 778 | } |
611 | gSavedSettings.setBOOL("UseOcclusion", use_occlusion); | 779 | LLPipeline::sUseOcclusion = use_occlusion; |
780 | LLPipeline::sDisableShaders = FALSE; | ||
612 | } | 781 | } |
613 | glMatrixMode(GL_PROJECTION); | 782 | glMatrixMode(GL_PROJECTION); |
614 | glPopMatrix(); | 783 | glPopMatrix(); |
615 | glMatrixMode(GL_MODELVIEW); | 784 | glMatrixMode(GL_MODELVIEW); |
616 | glPopMatrix(); | 785 | glPopMatrix(); |
617 | |||
618 | gFrameStats.start(LLFrameStats::RENDER_UI); | ||
619 | |||
620 | if (gHandleKeysAsync) | ||
621 | { | ||
622 | process_keystrokes_async(); | ||
623 | stop_glerror(); | ||
624 | } | ||
625 | |||
626 | 786 | ||
627 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 787 | glh_set_current_projection(current_proj); |
628 | LLGLState::checkStates(); | 788 | glh_set_current_modelview(current_mod); |
629 | #endif | ||
630 | render_ui_and_swap(); | ||
631 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
632 | LLGLState::checkStates(); | ||
633 | #endif | ||
634 | |||
635 | gFrameStats.start(LLFrameStats::MISC_END); | ||
636 | stop_glerror(); | ||
637 | |||
638 | } | 789 | } |
639 | 790 | ||
640 | BOOL setup_hud_matrices(BOOL for_select) | 791 | BOOL setup_hud_matrices(BOOL for_select) |
@@ -654,22 +805,22 @@ BOOL setup_hud_matrices(BOOL for_select) | |||
654 | // clear z buffer and set up transform for hud | 805 | // clear z buffer and set up transform for hud |
655 | if (!for_select) | 806 | if (!for_select) |
656 | { | 807 | { |
657 | glClear(GL_DEPTH_BUFFER_BIT); | 808 | //glClear(GL_DEPTH_BUFFER_BIT); |
658 | } | 809 | } |
659 | LLBBox hud_bbox = my_avatarp->getHUDBBox(); | 810 | LLBBox hud_bbox = my_avatarp->getHUDBBox(); |
660 | 811 | ||
661 | 812 | ||
662 | // set up transform to encompass bounding box of HUD | 813 | // set up transform to encompass bounding box of HUD |
663 | glMatrixMode(GL_PROJECTION); | 814 | glMatrixMode(GL_PROJECTION); |
664 | glLoadIdentity(); | ||
665 | F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); | 815 | F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); |
666 | if (for_select) | 816 | if (for_select) |
667 | { | 817 | { |
668 | //RN: reset viewport to window extents so ortho screen is calculated with proper reference frame | 818 | //RN: reset viewport to window extents so ortho screen is calculated with proper reference frame |
669 | gViewerWindow->setupViewport(); | 819 | gViewerWindow->setupViewport(); |
670 | } | 820 | } |
671 | glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); | 821 | glh::matrix4f proj = gl_ortho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); |
672 | 822 | proj.element(2,2) = -0.01f; | |
823 | |||
673 | // apply camera zoom transform (for high res screenshots) | 824 | // apply camera zoom transform (for high res screenshots) |
674 | F32 zoom_factor = gCamera->getZoomFactor(); | 825 | F32 zoom_factor = gCamera->getZoomFactor(); |
675 | S16 sub_region = gCamera->getZoomSubRegion(); | 826 | S16 sub_region = gCamera->getZoomSubRegion(); |
@@ -678,16 +829,26 @@ BOOL setup_hud_matrices(BOOL for_select) | |||
678 | float offset = zoom_factor - 1.f; | 829 | float offset = zoom_factor - 1.f; |
679 | int pos_y = sub_region / llceil(zoom_factor); | 830 | int pos_y = sub_region / llceil(zoom_factor); |
680 | int pos_x = sub_region - (pos_y*llceil(zoom_factor)); | 831 | int pos_x = sub_region - (pos_y*llceil(zoom_factor)); |
681 | glTranslatef(gCamera->getAspect() * 0.5f * (offset - (F32)pos_x * 2.f), 0.5f * (offset - (F32)pos_y * 2.f), 0.f); | 832 | glh::matrix4f mat; |
682 | glScalef(zoom_factor, zoom_factor, 1.f); | 833 | mat.set_scale(glh::vec3f(zoom_factor, zoom_factor, 1.f)); |
834 | mat.set_translate(glh::vec3f(gCamera->getAspect() * 0.5f * (offset - (F32)pos_x * 2.f), 0.5f * (offset - (F32)pos_y * 2.f), 0.f)); | ||
835 | proj *= mat; | ||
683 | } | 836 | } |
684 | 837 | ||
838 | glLoadMatrixf(proj.m); | ||
839 | glh_set_current_projection(proj); | ||
840 | |||
685 | glMatrixMode(GL_MODELVIEW); | 841 | glMatrixMode(GL_MODELVIEW); |
686 | glLoadIdentity(); | 842 | glh::matrix4f model((GLfloat*) OGL_TO_CFR_ROTATION); |
687 | glLoadMatrixf(OGL_TO_CFR_ROTATION); // Load Cory's favorite reference frame | ||
688 | glTranslatef(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f); | ||
689 | glScalef(zoom_level, zoom_level, zoom_level); | ||
690 | 843 | ||
844 | glh::matrix4f mat; | ||
845 | mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); | ||
846 | mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level)); | ||
847 | |||
848 | model *= mat; | ||
849 | glLoadMatrixf(model.m); | ||
850 | glh_set_current_modelview(model); | ||
851 | |||
691 | return TRUE; | 852 | return TRUE; |
692 | } | 853 | } |
693 | else | 854 | else |
@@ -702,15 +863,31 @@ void render_ui_and_swap() | |||
702 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 863 | #ifndef LL_RELEASE_FOR_DOWNLOAD |
703 | LLGLState::checkStates(); | 864 | LLGLState::checkStates(); |
704 | #endif | 865 | #endif |
866 | |||
867 | { | ||
868 | BOOL to_texture = gPipeline.canUseVertexShaders() && | ||
869 | LLPipeline::sRenderGlow && | ||
870 | gGLManager.mHasFramebufferObject; | ||
871 | |||
872 | if (to_texture) | ||
873 | { | ||
874 | gPipeline.renderBloom(gSnapshot); | ||
875 | } | ||
876 | } | ||
705 | 877 | ||
706 | LLGLSDefault gls_default; | 878 | LLGLSDefault gls_default; |
879 | LLGLSUIDefault gls_ui; | ||
707 | { | 880 | { |
708 | LLGLSUIDefault gls_ui; | ||
709 | gPipeline.disableLights(); | 881 | gPipeline.disableLights(); |
882 | } | ||
883 | |||
884 | { | ||
710 | LLVertexBuffer::startRender(); | 885 | LLVertexBuffer::startRender(); |
886 | gGL.start(); | ||
711 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) | 887 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) |
712 | { | 888 | { |
713 | LLFastTimer t(LLFastTimer::FTM_RENDER_UI); | 889 | LLFastTimer t(LLFastTimer::FTM_RENDER_UI); |
890 | |||
714 | if (!gDisconnected) | 891 | if (!gDisconnected) |
715 | { | 892 | { |
716 | render_ui_3d(); | 893 | render_ui_3d(); |
@@ -724,71 +901,78 @@ void render_ui_and_swap() | |||
724 | LLGLState::checkStates(); | 901 | LLGLState::checkStates(); |
725 | #endif | 902 | #endif |
726 | } | 903 | } |
727 | LLVertexBuffer::stopRender(); | 904 | gGL.stop(); |
728 | glFlush(); | ||
729 | 905 | ||
730 | // now do the swap buffer | ||
731 | if (gDisplaySwapBuffers) | ||
732 | { | 906 | { |
733 | LLFastTimer t(LLFastTimer::FTM_SWAP); | 907 | gViewerWindow->setup2DRender(); |
734 | gViewerWindow->mWindow->swapBuffers(); | 908 | gViewerWindow->updateDebugText(); |
909 | gViewerWindow->drawDebugText(); | ||
735 | } | 910 | } |
736 | 911 | ||
912 | LLVertexBuffer::stopRender(); | ||
913 | } | ||
914 | } | ||
915 | |||
916 | void render_ui_and_swap_if_needed() | ||
917 | { | ||
918 | if (gDisplaySwapBuffers) | ||
919 | { | ||
920 | render_ui_and_swap(); | ||
921 | |||
737 | { | 922 | { |
738 | LLFastTimer ftm(LLFastTimer::FTM_CLIENT_COPY); | 923 | LLFastTimer t(LLFastTimer::FTM_SWAP); |
739 | LLVertexBuffer::clientCopy(0.016); | 924 | gViewerWindow->mWindow->swapBuffers(); |
740 | } | 925 | } |
741 | |||
742 | } | 926 | } |
743 | } | 927 | } |
744 | 928 | ||
745 | void renderCoordinateAxes() | 929 | void renderCoordinateAxes() |
746 | { | 930 | { |
747 | LLGLSNoTexture gls_no_texture; | 931 | LLGLSNoTexture gls_no_texture; |
748 | glBegin(GL_LINES); | 932 | gGL.begin(GL_LINES); |
749 | glColor3f(1.0f, 0.0f, 0.0f); // i direction = X-Axis = red | 933 | gGL.color3f(1.0f, 0.0f, 0.0f); // i direction = X-Axis = red |
750 | glVertex3f(0.0f, 0.0f, 0.0f); | 934 | gGL.vertex3f(0.0f, 0.0f, 0.0f); |
751 | glVertex3f(2.0f, 0.0f, 0.0f); | 935 | gGL.vertex3f(2.0f, 0.0f, 0.0f); |
752 | glVertex3f(3.0f, 0.0f, 0.0f); | 936 | gGL.vertex3f(3.0f, 0.0f, 0.0f); |
753 | glVertex3f(5.0f, 0.0f, 0.0f); | 937 | gGL.vertex3f(5.0f, 0.0f, 0.0f); |
754 | glVertex3f(6.0f, 0.0f, 0.0f); | 938 | gGL.vertex3f(6.0f, 0.0f, 0.0f); |
755 | glVertex3f(8.0f, 0.0f, 0.0f); | 939 | gGL.vertex3f(8.0f, 0.0f, 0.0f); |
756 | // Make an X | 940 | // Make an X |
757 | glVertex3f(11.0f, 1.0f, 1.0f); | 941 | gGL.vertex3f(11.0f, 1.0f, 1.0f); |
758 | glVertex3f(11.0f, -1.0f, -1.0f); | 942 | gGL.vertex3f(11.0f, -1.0f, -1.0f); |
759 | glVertex3f(11.0f, 1.0f, -1.0f); | 943 | gGL.vertex3f(11.0f, 1.0f, -1.0f); |
760 | glVertex3f(11.0f, -1.0f, 1.0f); | 944 | gGL.vertex3f(11.0f, -1.0f, 1.0f); |
761 | 945 | ||
762 | glColor3f(0.0f, 1.0f, 0.0f); // j direction = Y-Axis = green | 946 | gGL.color3f(0.0f, 1.0f, 0.0f); // j direction = Y-Axis = green |
763 | glVertex3f(0.0f, 0.0f, 0.0f); | 947 | gGL.vertex3f(0.0f, 0.0f, 0.0f); |
764 | glVertex3f(0.0f, 2.0f, 0.0f); | 948 | gGL.vertex3f(0.0f, 2.0f, 0.0f); |
765 | glVertex3f(0.0f, 3.0f, 0.0f); | 949 | gGL.vertex3f(0.0f, 3.0f, 0.0f); |
766 | glVertex3f(0.0f, 5.0f, 0.0f); | 950 | gGL.vertex3f(0.0f, 5.0f, 0.0f); |
767 | glVertex3f(0.0f, 6.0f, 0.0f); | 951 | gGL.vertex3f(0.0f, 6.0f, 0.0f); |
768 | glVertex3f(0.0f, 8.0f, 0.0f); | 952 | gGL.vertex3f(0.0f, 8.0f, 0.0f); |
769 | // Make a Y | 953 | // Make a Y |
770 | glVertex3f(1.0f, 11.0f, 1.0f); | 954 | gGL.vertex3f(1.0f, 11.0f, 1.0f); |
771 | glVertex3f(0.0f, 11.0f, 0.0f); | 955 | gGL.vertex3f(0.0f, 11.0f, 0.0f); |
772 | glVertex3f(-1.0f, 11.0f, 1.0f); | 956 | gGL.vertex3f(-1.0f, 11.0f, 1.0f); |
773 | glVertex3f(0.0f, 11.0f, 0.0f); | 957 | gGL.vertex3f(0.0f, 11.0f, 0.0f); |
774 | glVertex3f(0.0f, 11.0f, 0.0f); | 958 | gGL.vertex3f(0.0f, 11.0f, 0.0f); |
775 | glVertex3f(0.0f, 11.0f, -1.0f); | 959 | gGL.vertex3f(0.0f, 11.0f, -1.0f); |
776 | 960 | ||
777 | glColor3f(0.0f, 0.0f, 1.0f); // Z-Axis = blue | 961 | gGL.color3f(0.0f, 0.0f, 1.0f); // Z-Axis = blue |
778 | glVertex3f(0.0f, 0.0f, 0.0f); | 962 | gGL.vertex3f(0.0f, 0.0f, 0.0f); |
779 | glVertex3f(0.0f, 0.0f, 2.0f); | 963 | gGL.vertex3f(0.0f, 0.0f, 2.0f); |
780 | glVertex3f(0.0f, 0.0f, 3.0f); | 964 | gGL.vertex3f(0.0f, 0.0f, 3.0f); |
781 | glVertex3f(0.0f, 0.0f, 5.0f); | 965 | gGL.vertex3f(0.0f, 0.0f, 5.0f); |
782 | glVertex3f(0.0f, 0.0f, 6.0f); | 966 | gGL.vertex3f(0.0f, 0.0f, 6.0f); |
783 | glVertex3f(0.0f, 0.0f, 8.0f); | 967 | gGL.vertex3f(0.0f, 0.0f, 8.0f); |
784 | // Make a Z | 968 | // Make a Z |
785 | glVertex3f(-1.0f, 1.0f, 11.0f); | 969 | gGL.vertex3f(-1.0f, 1.0f, 11.0f); |
786 | glVertex3f(1.0f, 1.0f, 11.0f); | 970 | gGL.vertex3f(1.0f, 1.0f, 11.0f); |
787 | glVertex3f(1.0f, 1.0f, 11.0f); | 971 | gGL.vertex3f(1.0f, 1.0f, 11.0f); |
788 | glVertex3f(-1.0f, -1.0f, 11.0f); | 972 | gGL.vertex3f(-1.0f, -1.0f, 11.0f); |
789 | glVertex3f(-1.0f, -1.0f, 11.0f); | 973 | gGL.vertex3f(-1.0f, -1.0f, 11.0f); |
790 | glVertex3f(1.0f, -1.0f, 11.0f); | 974 | gGL.vertex3f(1.0f, -1.0f, 11.0f); |
791 | glEnd(); | 975 | gGL.end(); |
792 | } | 976 | } |
793 | 977 | ||
794 | 978 | ||
@@ -798,11 +982,11 @@ void draw_axes() | |||
798 | LLGLSNoTexture gls_no_texture; | 982 | LLGLSNoTexture gls_no_texture; |
799 | // A vertical white line at origin | 983 | // A vertical white line at origin |
800 | LLVector3 v = gAgent.getPositionAgent(); | 984 | LLVector3 v = gAgent.getPositionAgent(); |
801 | glBegin(GL_LINES); | 985 | gGL.begin(GL_LINES); |
802 | glColor3f(1.0f, 1.0f, 1.0f); | 986 | gGL.color3f(1.0f, 1.0f, 1.0f); |
803 | glVertex3f(0.0f, 0.0f, 0.0f); | 987 | gGL.vertex3f(0.0f, 0.0f, 0.0f); |
804 | glVertex3f(0.0f, 0.0f, 40.0f); | 988 | gGL.vertex3f(0.0f, 0.0f, 40.0f); |
805 | glEnd(); | 989 | gGL.end(); |
806 | // Some coordinate axes | 990 | // Some coordinate axes |
807 | glPushMatrix(); | 991 | glPushMatrix(); |
808 | glTranslatef( v.mV[VX], v.mV[VY], v.mV[VZ] ); | 992 | glTranslatef( v.mV[VX], v.mV[VY], v.mV[VZ] ); |
@@ -822,9 +1006,9 @@ void render_ui_3d() | |||
822 | // | 1006 | // |
823 | 1007 | ||
824 | // Render selections | 1008 | // Render selections |
825 | glDisableClientState(GL_COLOR_ARRAY); | 1009 | //glDisableClientState(GL_COLOR_ARRAY); |
826 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 1010 | //glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
827 | glDisableClientState(GL_NORMAL_ARRAY); | 1011 | //glDisableClientState(GL_NORMAL_ARRAY); |
828 | 1012 | ||
829 | ///////////////////////////////////////////////////////////// | 1013 | ///////////////////////////////////////////////////////////// |
830 | // | 1014 | // |
@@ -891,7 +1075,7 @@ void render_ui_2d() | |||
891 | glTranslatef((F32)half_width, (F32)half_height, 0.f); | 1075 | glTranslatef((F32)half_width, (F32)half_height, 0.f); |
892 | F32 zoom = gAgent.getAvatarObject()->mHUDCurZoom; | 1076 | F32 zoom = gAgent.getAvatarObject()->mHUDCurZoom; |
893 | glScalef(zoom,zoom,1.f); | 1077 | glScalef(zoom,zoom,1.f); |
894 | glColor4fv(LLColor4::white.mV); | 1078 | gGL.color4fv(LLColor4::white.mV); |
895 | gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE); | 1079 | gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE); |
896 | glPopMatrix(); | 1080 | glPopMatrix(); |
897 | stop_glerror(); | 1081 | stop_glerror(); |
@@ -909,6 +1093,7 @@ void render_ui_2d() | |||
909 | 1093 | ||
910 | void render_disconnected_background() | 1094 | void render_disconnected_background() |
911 | { | 1095 | { |
1096 | gGL.start(); | ||
912 | if (!gDisconnectedImagep && gDisconnected) | 1097 | if (!gDisconnectedImagep && gDisconnected) |
913 | { | 1098 | { |
914 | llinfos << "Loading last bitmap..." << llendl; | 1099 | llinfos << "Loading last bitmap..." << llendl; |
@@ -951,7 +1136,7 @@ void render_disconnected_background() | |||
951 | rawp++; | 1136 | rawp++; |
952 | } | 1137 | } |
953 | 1138 | ||
954 | 1139 | ||
955 | raw->expandToPowerOfTwo(); | 1140 | raw->expandToPowerOfTwo(); |
956 | gDisconnectedImagep->createGLTexture(0, raw); | 1141 | gDisconnectedImagep->createGLTexture(0, raw); |
957 | gStartImageGL = gDisconnectedImagep; | 1142 | gStartImageGL = gDisconnectedImagep; |
@@ -975,12 +1160,13 @@ void render_disconnected_background() | |||
975 | glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f); | 1160 | glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f); |
976 | 1161 | ||
977 | LLViewerImage::bindTexture(gDisconnectedImagep); | 1162 | LLViewerImage::bindTexture(gDisconnectedImagep); |
978 | glColor4f(1.f, 1.f, 1.f, 1.f); | 1163 | gGL.color4f(1.f, 1.f, 1.f, 1.f); |
979 | gl_rect_2d_simple_tex(width, height); | 1164 | gl_rect_2d_simple_tex(width, height); |
980 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); | 1165 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); |
981 | } | 1166 | } |
982 | glPopMatrix(); | 1167 | glPopMatrix(); |
983 | } | 1168 | } |
1169 | gGL.stop(); | ||
984 | } | 1170 | } |
985 | 1171 | ||
986 | void display_cleanup() | 1172 | void display_cleanup() |