aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llglsandbox.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llglsandbox.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-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 '')
-rw-r--r--linden/indra/newview/llglsandbox.cpp443
1 files changed, 228 insertions, 215 deletions
diff --git a/linden/indra/newview/llglsandbox.cpp b/linden/indra/newview/llglsandbox.cpp
index 6c2d34a..31e1935 100644
--- a/linden/indra/newview/llglsandbox.cpp
+++ b/linden/indra/newview/llglsandbox.cpp
@@ -39,6 +39,7 @@
39#include "llviewercontrol.h" 39#include "llviewercontrol.h"
40 40
41#include "llgl.h" 41#include "llgl.h"
42#include "llglimmediate.h"
42#include "llglheaders.h" 43#include "llglheaders.h"
43#include "llparcel.h" 44#include "llparcel.h"
44#include "llui.h" 45#include "llui.h"
@@ -65,6 +66,7 @@
65#include "llpreviewtexture.h" 66#include "llpreviewtexture.h"
66#include "llresmgr.h" 67#include "llresmgr.h"
67#include "pipeline.h" 68#include "pipeline.h"
69#include "llspatialpartition.h"
68 70
69BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) 71BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
70{ 72{
@@ -137,7 +139,7 @@ void LLAgent::renderAutoPilotTarget()
137 LLVector3d target_global; 139 LLVector3d target_global;
138 140
139 glMatrixMode(GL_MODELVIEW); 141 glMatrixMode(GL_MODELVIEW);
140 glPushMatrix(); 142 gGL.pushMatrix();
141 143
142 // not textured 144 // not textured
143 LLGLSNoTexture no_texture; 145 LLGLSNoTexture no_texture;
@@ -147,31 +149,15 @@ void LLAgent::renderAutoPilotTarget()
147 149
148 target_global = mAutoPilotTargetGlobal; 150 target_global = mAutoPilotTargetGlobal;
149 151
150 glTranslatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ])); 152 gGL.translatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ]));
151 153
152 /*
153 LLVector3 offset = target_global - mCamera.getOrigin();
154 F32 range = offset.magVec();
155 if (range > 0.001f)
156 {
157 // range != zero
158 F32 fraction_of_fov = height_pixels / (F32) mCamera.getViewHeightInPixels();
159 F32 apparent_angle = fraction_of_fov * mCamera.getView();
160 height_meters = range * tan(apparent_angle);
161 }
162 else
163 {
164 // range == zero
165 height_meters = 1.0f;
166 }
167 */
168 height_meters = 1.f; 154 height_meters = 1.f;
169 155
170 glScalef(height_meters, height_meters, height_meters); 156 glScalef(height_meters, height_meters, height_meters);
171 157
172 gSphere.render(1500.f); 158 gSphere.render(1500.f);
173 159
174 glPopMatrix(); 160 gGL.popMatrix();
175 } 161 }
176} 162}
177 163
@@ -227,7 +213,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask)
227 213
228 // save drawing mode 214 // save drawing mode
229 glMatrixMode(GL_PROJECTION); 215 glMatrixMode(GL_PROJECTION);
230 glPushMatrix(); 216 gGL.pushMatrix();
231 217
232 BOOL limit_select_distance = gSavedSettings.getBOOL("LimitSelectDistance"); 218 BOOL limit_select_distance = gSavedSettings.getBOOL("LimitSelectDistance");
233 if (limit_select_distance) 219 if (limit_select_distance)
@@ -284,14 +270,18 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask)
284 if (grow_selection) 270 if (grow_selection)
285 { 271 {
286 std::vector<LLDrawable*> potentials; 272 std::vector<LLDrawable*> potentials;
287 273
288 274 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin();
289 for (U32 i = 0; i < LLPipeline::NUM_PARTITIONS-1; i++) 275 iter != gWorldp->getRegionList().end(); ++iter)
290 { 276 {
291 LLSpatialPartition* part = gPipeline.getSpatialPartition(i); 277 LLViewerRegion* region = *iter;
292 if (part) 278 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
293 { 279 {
294 part->cull(*gCamera, &potentials, TRUE); 280 LLSpatialPartition* part = region->getSpatialPartition(i);
281 if (part)
282 {
283 part->cull(*gCamera, &potentials, TRUE);
284 }
295 } 285 }
296 } 286 }
297 287
@@ -338,7 +328,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask)
338 328
339 // restore drawing mode 329 // restore drawing mode
340 glMatrixMode(GL_PROJECTION); 330 glMatrixMode(GL_PROJECTION);
341 glPopMatrix(); 331 gGL.popMatrix();
342 glMatrixMode(GL_MODELVIEW); 332 glMatrixMode(GL_MODELVIEW);
343 333
344 // restore camera 334 // restore camera
@@ -358,35 +348,35 @@ void LLCompass::draw()
358 if (!getVisible()) return; 348 if (!getVisible()) return;
359 349
360 glMatrixMode(GL_MODELVIEW); 350 glMatrixMode(GL_MODELVIEW);
361 glPushMatrix(); 351 gGL.pushMatrix();
362 352
363 S32 width = 32; 353 S32 width = 32;
364 S32 height = 32; 354 S32 height = 32;
365 355
366 LLGLSUIDefault gls_ui; 356 LLGLSUIDefault gls_ui;
367 357
368 glTranslatef( COMPASS_SIZE/2.f, COMPASS_SIZE/2.f, 0.f); 358 gGL.translatef( COMPASS_SIZE/2.f, COMPASS_SIZE/2.f, 0.f);
369 359
370 if (mBkgndTexture) 360 if (mBkgndTexture)
371 { 361 {
372 mBkgndTexture->bind(); 362 mBkgndTexture->bind();
373 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 363 gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f);
374 364
375 glBegin(GL_QUADS); 365 gGL.begin(GL_QUADS);
376 366
377 glTexCoord2f(1.f, 1.f); 367 gGL.texCoord2f(1.f, 1.f);
378 glVertex2i(width, height); 368 gGL.vertex2i(width, height);
379 369
380 glTexCoord2f(0.f, 1.f); 370 gGL.texCoord2f(0.f, 1.f);
381 glVertex2i(-width, height); 371 gGL.vertex2i(-width, height);
382 372
383 glTexCoord2f(0.f, 0.f); 373 gGL.texCoord2f(0.f, 0.f);
384 glVertex2i(-width, -height); 374 gGL.vertex2i(-width, -height);
385 375
386 glTexCoord2f(1.f, 0.f); 376 gGL.texCoord2f(1.f, 0.f);
387 glVertex2i(width, -height); 377 gGL.vertex2i(width, -height);
388 378
389 glEnd(); 379 gGL.end();
390 } 380 }
391 381
392 // rotate subsequent draws to agent rotation 382 // rotate subsequent draws to agent rotation
@@ -396,26 +386,26 @@ void LLCompass::draw()
396 if (mTexture) 386 if (mTexture)
397 { 387 {
398 mTexture->bind(); 388 mTexture->bind();
399 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 389 gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f);
400 390
401 glBegin(GL_QUADS); 391 gGL.begin(GL_QUADS);
402 392
403 glTexCoord2f(1.f, 1.f); 393 gGL.texCoord2f(1.f, 1.f);
404 glVertex2i(width, height); 394 gGL.vertex2i(width, height);
405 395
406 glTexCoord2f(0.f, 1.f); 396 gGL.texCoord2f(0.f, 1.f);
407 glVertex2i(-width, height); 397 gGL.vertex2i(-width, height);
408 398
409 glTexCoord2f(0.f, 0.f); 399 gGL.texCoord2f(0.f, 0.f);
410 glVertex2i(-width, -height); 400 gGL.vertex2i(-width, -height);
411 401
412 glTexCoord2f(1.f, 0.f); 402 gGL.texCoord2f(1.f, 0.f);
413 glVertex2i(width, -height); 403 gGL.vertex2i(width, -height);
414 404
415 glEnd(); 405 gGL.end();
416 } 406 }
417 407
418 glPopMatrix(); 408 gGL.popMatrix();
419 409
420} 410}
421 411
@@ -427,8 +417,8 @@ void LLHorizontalCompass::draw()
427 417
428 LLGLSUIDefault gls_ui; 418 LLGLSUIDefault gls_ui;
429 419
430 S32 width = mRect.getWidth(); 420 S32 width = getRect().getWidth();
431 S32 height = mRect.getHeight(); 421 S32 height = getRect().getHeight();
432 S32 half_width = width / 2; 422 S32 half_width = width / 2;
433 423
434 if( mTexture ) 424 if( mTexture )
@@ -443,28 +433,28 @@ void LLHorizontalCompass::draw()
443 F32 right = center + COMPASS_RANGE; 433 F32 right = center + COMPASS_RANGE;
444 434
445 mTexture->bind(); 435 mTexture->bind();
446 glColor4f(1.0f, 1.0f, 1.0f, 1.0f ); 436 gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f );
447 glBegin( GL_QUADS ); 437 gGL.begin( GL_QUADS );
448 438
449 glTexCoord2f(right, 1.f); 439 gGL.texCoord2f(right, 1.f);
450 glVertex2i(width, height); 440 gGL.vertex2i(width, height);
451 441
452 glTexCoord2f(left, 1.f); 442 gGL.texCoord2f(left, 1.f);
453 glVertex2i(0, height); 443 gGL.vertex2i(0, height);
454 444
455 glTexCoord2f(left, 0.f); 445 gGL.texCoord2f(left, 0.f);
456 glVertex2i(0, 0); 446 gGL.vertex2i(0, 0);
457 447
458 glTexCoord2f(right, 0.f); 448 gGL.texCoord2f(right, 0.f);
459 glVertex2i(width, 0); 449 gGL.vertex2i(width, 0);
460 450
461 glEnd(); 451 gGL.end();
462 } 452 }
463 453
464 // Draw the focus line 454 // Draw the focus line
465 { 455 {
466 LLGLSNoTexture gls_no_texture; 456 LLGLSNoTexture gls_no_texture;
467 glColor4fv( mFocusColor.mV ); 457 gGL.color4fv( mFocusColor.mV );
468 gl_line_2d( half_width, 0, half_width, height ); 458 gl_line_2d( half_width, 0, half_width, height );
469 } 459 }
470} 460}
@@ -482,31 +472,31 @@ void LLWind::renderVectors()
482 F32 region_width_meters = gWorldPointer->getRegionWidthInMeters(); 472 F32 region_width_meters = gWorldPointer->getRegionWidthInMeters();
483 473
484 LLGLSNoTexture gls_no_texture; 474 LLGLSNoTexture gls_no_texture;
485 glPushMatrix(); 475 gGL.pushMatrix();
486 LLVector3 origin_agent; 476 LLVector3 origin_agent;
487 origin_agent = gAgent.getPosAgentFromGlobal(mOriginGlobal); 477 origin_agent = gAgent.getPosAgentFromGlobal(mOriginGlobal);
488 glTranslatef(origin_agent.mV[VX], origin_agent.mV[VY], WIND_ALTITUDE); 478 gGL.translatef(origin_agent.mV[VX], origin_agent.mV[VY], WIND_ALTITUDE);
489 for (j = 0; j < mSize; j++) 479 for (j = 0; j < mSize; j++)
490 { 480 {
491 for (i = 0; i < mSize; i++) 481 for (i = 0; i < mSize; i++)
492 { 482 {
493 x = mCloudVelX[i + j*mSize] * WIND_SCALE_HACK; 483 x = mCloudVelX[i + j*mSize] * WIND_SCALE_HACK;
494 y = mCloudVelY[i + j*mSize] * WIND_SCALE_HACK; 484 y = mCloudVelY[i + j*mSize] * WIND_SCALE_HACK;
495 glPushMatrix(); 485 gGL.pushMatrix();
496 glTranslatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); 486 gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0);
497 glColor3f(0,1,0); 487 gGL.color3f(0,1,0);
498 glBegin(GL_POINTS); 488 gGL.begin(GL_POINTS);
499 glVertex3f(0,0,0); 489 gGL.vertex3f(0,0,0);
500 glEnd(); 490 gGL.end();
501 glColor3f(1,0,0); 491 gGL.color3f(1,0,0);
502 glBegin(GL_LINES); 492 gGL.begin(GL_LINES);
503 glVertex3f(x * 0.1f, y * 0.1f ,0.f); 493 gGL.vertex3f(x * 0.1f, y * 0.1f ,0.f);
504 glVertex3f(x, y, 0.f); 494 gGL.vertex3f(x, y, 0.f);
505 glEnd(); 495 gGL.end();
506 glPopMatrix(); 496 gGL.popMatrix();
507 } 497 }
508 } 498 }
509 glPopMatrix(); 499 gGL.popMatrix();
510} 500}
511 501
512 502
@@ -545,49 +535,49 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global,
545 F32 nw_top = nw_bottom + PARCEL_POST_HEIGHT; 535 F32 nw_top = nw_bottom + PARCEL_POST_HEIGHT;
546 536
547 LLUI::setLineWidth(2.f); 537 LLUI::setLineWidth(2.f);
548 glColor4f(1.f, 1.f, 0.f, 1.f); 538 gGL.color4f(1.f, 1.f, 0.f, 1.f);
549 539
550 // Cheat and give this the same pick-name as land 540 // Cheat and give this the same pick-name as land
551 glBegin(GL_LINES); 541 gGL.begin(GL_LINES);
552 542
553 glVertex3f(west, north, nw_bottom); 543 gGL.vertex3f(west, north, nw_bottom);
554 glVertex3f(west, north, nw_top); 544 gGL.vertex3f(west, north, nw_top);
555 545
556 glVertex3f(east, north, ne_bottom); 546 gGL.vertex3f(east, north, ne_bottom);
557 glVertex3f(east, north, ne_top); 547 gGL.vertex3f(east, north, ne_top);
558 548
559 glVertex3f(east, south, se_bottom); 549 gGL.vertex3f(east, south, se_bottom);
560 glVertex3f(east, south, se_top); 550 gGL.vertex3f(east, south, se_top);
561 551
562 glVertex3f(west, south, sw_bottom); 552 gGL.vertex3f(west, south, sw_bottom);
563 glVertex3f(west, south, sw_top); 553 gGL.vertex3f(west, south, sw_top);
564 554
565 glEnd(); 555 gGL.end();
566 556
567 glColor4f(1.f, 1.f, 0.f, 0.2f); 557 gGL.color4f(1.f, 1.f, 0.f, 0.2f);
568 glBegin(GL_QUADS); 558 gGL.begin(GL_QUADS);
569 559
570 glVertex3f(west, north, nw_bottom); 560 gGL.vertex3f(west, north, nw_bottom);
571 glVertex3f(west, north, nw_top); 561 gGL.vertex3f(west, north, nw_top);
572 glVertex3f(east, north, ne_top); 562 gGL.vertex3f(east, north, ne_top);
573 glVertex3f(east, north, ne_bottom); 563 gGL.vertex3f(east, north, ne_bottom);
574 564
575 glVertex3f(east, north, ne_bottom); 565 gGL.vertex3f(east, north, ne_bottom);
576 glVertex3f(east, north, ne_top); 566 gGL.vertex3f(east, north, ne_top);
577 glVertex3f(east, south, se_top); 567 gGL.vertex3f(east, south, se_top);
578 glVertex3f(east, south, se_bottom); 568 gGL.vertex3f(east, south, se_bottom);
579 569
580 glVertex3f(east, south, se_bottom); 570 gGL.vertex3f(east, south, se_bottom);
581 glVertex3f(east, south, se_top); 571 gGL.vertex3f(east, south, se_top);
582 glVertex3f(west, south, sw_top); 572 gGL.vertex3f(west, south, sw_top);
583 glVertex3f(west, south, sw_bottom); 573 gGL.vertex3f(west, south, sw_bottom);
584 574
585 glVertex3f(west, south, sw_bottom); 575 gGL.vertex3f(west, south, sw_bottom);
586 glVertex3f(west, south, sw_top); 576 gGL.vertex3f(west, south, sw_top);
587 glVertex3f(west, north, nw_top); 577 gGL.vertex3f(west, north, nw_top);
588 glVertex3f(west, north, nw_bottom); 578 gGL.vertex3f(west, north, nw_bottom);
589 579
590 glEnd(); 580 gGL.end();
591 581
592 LLUI::setLineWidth(1.f); 582 LLUI::setLineWidth(1.f);
593} 583}
@@ -629,49 +619,49 @@ void LLViewerParcelMgr::renderParcel(LLParcel* parcel )
629 LLGLDepthTest gls_depth(GL_TRUE); 619 LLGLDepthTest gls_depth(GL_TRUE);
630 620
631 LLUI::setLineWidth(2.f); 621 LLUI::setLineWidth(2.f);
632 glColor4f(0.f, 1.f, 1.f, 1.f); 622 gGL.color4f(0.f, 1.f, 1.f, 1.f);
633 623
634 // Cheat and give this the same pick-name as land 624 // Cheat and give this the same pick-name as land
635 glBegin(GL_LINES); 625 gGL.begin(GL_LINES);
636 626
637 glVertex3f(west, north, nw_bottom); 627 gGL.vertex3f(west, north, nw_bottom);
638 glVertex3f(west, north, nw_top); 628 gGL.vertex3f(west, north, nw_top);
639 629
640 glVertex3f(east, north, ne_bottom); 630 gGL.vertex3f(east, north, ne_bottom);
641 glVertex3f(east, north, ne_top); 631 gGL.vertex3f(east, north, ne_top);
642 632
643 glVertex3f(east, south, se_bottom); 633 gGL.vertex3f(east, south, se_bottom);
644 glVertex3f(east, south, se_top); 634 gGL.vertex3f(east, south, se_top);
645 635
646 glVertex3f(west, south, sw_bottom); 636 gGL.vertex3f(west, south, sw_bottom);
647 glVertex3f(west, south, sw_top); 637 gGL.vertex3f(west, south, sw_top);
648 638
649 glEnd(); 639 gGL.end();
650 640
651 glColor4f(0.f, 1.f, 1.f, 0.2f); 641 gGL.color4f(0.f, 1.f, 1.f, 0.2f);
652 glBegin(GL_QUADS); 642 gGL.begin(GL_QUADS);
653 643
654 glVertex3f(west, north, nw_bottom); 644 gGL.vertex3f(west, north, nw_bottom);
655 glVertex3f(west, north, nw_top); 645 gGL.vertex3f(west, north, nw_top);
656 glVertex3f(east, north, ne_top); 646 gGL.vertex3f(east, north, ne_top);
657 glVertex3f(east, north, ne_bottom); 647 gGL.vertex3f(east, north, ne_bottom);
658 648
659 glVertex3f(east, north, ne_bottom); 649 gGL.vertex3f(east, north, ne_bottom);
660 glVertex3f(east, north, ne_top); 650 gGL.vertex3f(east, north, ne_top);
661 glVertex3f(east, south, se_top); 651 gGL.vertex3f(east, south, se_top);
662 glVertex3f(east, south, se_bottom); 652 gGL.vertex3f(east, south, se_bottom);
663 653
664 glVertex3f(east, south, se_bottom); 654 gGL.vertex3f(east, south, se_bottom);
665 glVertex3f(east, south, se_top); 655 gGL.vertex3f(east, south, se_top);
666 glVertex3f(west, south, sw_top); 656 gGL.vertex3f(west, south, sw_top);
667 glVertex3f(west, south, sw_bottom); 657 gGL.vertex3f(west, south, sw_bottom);
668 658
669 glVertex3f(west, south, sw_bottom); 659 gGL.vertex3f(west, south, sw_bottom);
670 glVertex3f(west, south, sw_top); 660 gGL.vertex3f(west, south, sw_top);
671 glVertex3f(west, north, nw_top); 661 gGL.vertex3f(west, north, nw_top);
672 glVertex3f(west, north, nw_bottom); 662 gGL.vertex3f(west, north, nw_bottom);
673 663
674 glEnd(); 664 gGL.end();
675 665
676 LLUI::setLineWidth(1.f); 666 LLUI::setLineWidth(1.f);
677 } 667 }
@@ -714,14 +704,14 @@ void LLViewerParcelMgr::renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 hei
714 if (height < 1.f) 704 if (height < 1.f)
715 { 705 {
716 z = z1+height; 706 z = z1+height;
717 glVertex3f(x1, y1, z); 707 gGL.vertex3f(x1, y1, z);
718 708
719 glVertex3f(x1, y1, z1); 709 gGL.vertex3f(x1, y1, z1);
720 710
721 glVertex3f(x2, y2, z2); 711 gGL.vertex3f(x2, y2, z2);
722 712
723 z = z2+height; 713 z = z2+height;
724 glVertex3f(x2, y2, z); 714 gGL.vertex3f(x2, y2, z);
725 } 715 }
726 else 716 else
727 { 717 {
@@ -750,19 +740,19 @@ void LLViewerParcelMgr::renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 hei
750 } 740 }
751 741
752 742
753 glTexCoord2f(tex_coord1*0.5f+0.5f, z1*0.5f); 743 gGL.texCoord2f(tex_coord1*0.5f+0.5f, z1*0.5f);
754 glVertex3f(x1, y1, z1); 744 gGL.vertex3f(x1, y1, z1);
755 745
756 glTexCoord2f(tex_coord2*0.5f+0.5f, z2*0.5f); 746 gGL.texCoord2f(tex_coord2*0.5f+0.5f, z2*0.5f);
757 glVertex3f(x2, y2, z2); 747 gGL.vertex3f(x2, y2, z2);
758 748
759 // top edge stairsteps 749 // top edge stairsteps
760 z = llmax(z2+height, z1+height); 750 z = llmax(z2+height, z1+height);
761 glTexCoord2f(tex_coord2*0.5f+0.5f, z*0.5f); 751 gGL.texCoord2f(tex_coord2*0.5f+0.5f, z*0.5f);
762 glVertex3f(x2, y2, z); 752 gGL.vertex3f(x2, y2, z);
763 753
764 glTexCoord2f(tex_coord1*0.5f+0.5f, z*0.5f); 754 gGL.texCoord2f(tex_coord1*0.5f+0.5f, z*0.5f);
765 glVertex3f(x1, y1, z); 755 gGL.vertex3f(x1, y1, z);
766 } 756 }
767} 757}
768 758
@@ -772,17 +762,19 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi
772 S32 x, y; 762 S32 x, y;
773 F32 x1, y1; // start point 763 F32 x1, y1; // start point
774 F32 x2, y2; // end point 764 F32 x2, y2; // end point
765 bool has_segments = false;
775 766
776 LLGLSUIDefault gls_ui; 767 LLGLSUIDefault gls_ui;
777 LLGLSNoTexture gls_no_texture; 768 LLGLSNoTexture gls_no_texture;
778 LLGLDepthTest gls_depth(GL_TRUE); 769 LLGLDepthTest gls_depth(GL_TRUE);
779 770
780 glColor4f(1.f, 1.f, 0.f, 0.2f); 771 gGL.color4f(1.f, 1.f, 0.f, 0.2f);
781
782 // Cheat and give this the same pick-name as land
783 glBegin(GL_QUADS);
784 772
785 const S32 STRIDE = (mParcelsPerEdge+1); 773 const S32 STRIDE = (mParcelsPerEdge+1);
774
775 // Cheat and give this the same pick-name as land
776
777
786 for (y = 0; y < STRIDE; y++) 778 for (y = 0; y < STRIDE; y++)
787 { 779 {
788 for (x = 0; x < STRIDE; x++) 780 for (x = 0; x < STRIDE; x++)
@@ -796,7 +788,12 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi
796 788
797 x2 = x1 + PARCEL_GRID_STEP_METERS; 789 x2 = x1 + PARCEL_GRID_STEP_METERS;
798 y2 = y1; 790 y2 = y1;
799 791
792 if (!has_segments)
793 {
794 has_segments = true;
795 gGL.begin(GL_QUADS);
796 }
800 renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp); 797 renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp);
801 } 798 }
802 799
@@ -808,12 +805,20 @@ void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegi
808 x2 = x1; 805 x2 = x1;
809 y2 = y1 + PARCEL_GRID_STEP_METERS; 806 y2 = y1 + PARCEL_GRID_STEP_METERS;
810 807
808 if (!has_segments)
809 {
810 has_segments = true;
811 gGL.begin(GL_QUADS);
812 }
811 renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp); 813 renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp);
812 } 814 }
813 } 815 }
814 } 816 }
815 817
816 glEnd(); 818 if (has_segments)
819 {
820 gGL.end();
821 }
817} 822}
818 823
819 824
@@ -851,14 +856,14 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
851 856
852 if (use_pass && (mCollisionBanned == BA_NOT_ON_LIST)) 857 if (use_pass && (mCollisionBanned == BA_NOT_ON_LIST))
853 { 858 {
854 LLViewerImage::bindTexture(mPassImage); 859 LLViewerImage::bindTexture( getPassImage() );
855 } 860 }
856 else 861 else
857 { 862 {
858 LLViewerImage::bindTexture(mBlockedImage); 863 LLViewerImage::bindTexture( getBlockedImage() );
859 } 864 }
860 865
861 glBegin(GL_QUADS); 866 gGL.begin(GL_QUADS);
862 867
863 for (y = 0; y < STRIDE; y++) 868 for (y = 0; y < STRIDE; y++)
864 { 869 {
@@ -882,7 +887,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
882 if (gRenderForSelect) 887 if (gRenderForSelect)
883 { 888 {
884 LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); 889 LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL);
885 glColor4ubv(color.mV); 890 gGL.color4ubv(color.mV);
886 } 891 }
887 else 892 else
888 { 893 {
@@ -906,7 +911,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
906 911
907 alpha = llclamp(alpha, 0.0f, MAX_ALPHA); 912 alpha = llclamp(alpha, 0.0f, MAX_ALPHA);
908 913
909 glColor4f(1.f, 1.f, 1.f, alpha); 914 gGL.color4f(1.f, 1.f, 1.f, alpha);
910 } 915 }
911 916
912 if ((pos_y - y1) < 0) direction = SOUTH_MASK; 917 if ((pos_y - y1) < 0) direction = SOUTH_MASK;
@@ -928,7 +933,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
928 if (gRenderForSelect) 933 if (gRenderForSelect)
929 { 934 {
930 LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); 935 LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL);
931 glColor4ubv(color.mV); 936 gGL.color4ubv(color.mV);
932 } 937 }
933 else 938 else
934 { 939 {
@@ -952,7 +957,7 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
952 957
953 alpha = llclamp(alpha, 0.0f, MAX_ALPHA); 958 alpha = llclamp(alpha, 0.0f, MAX_ALPHA);
954 959
955 glColor4f(1.f, 1.f, 1.f, alpha); 960 gGL.color4f(1.f, 1.f, 1.f, alpha);
956 } 961 }
957 962
958 if ((pos_x - x1) > 0) direction = WEST_MASK; 963 if ((pos_x - x1) > 0) direction = WEST_MASK;
@@ -965,43 +970,48 @@ void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLV
965 } 970 }
966 } 971 }
967 972
968 glEnd(); 973 gGL.end();
969} 974}
970 975
971void draw_line_cube(F32 width, const LLVector3& center) 976void draw_line_cube(F32 width, const LLVector3& center)
972{ 977{
973 width = 0.5f * width; 978 width = 0.5f * width;
974 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); 979 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width);
975 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); 980 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width);
976 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); 981 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width);
977 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); 982 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width);
978 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); 983 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width);
979 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); 984 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width);
980 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); 985 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width);
981 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); 986 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width);
982 987
983 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); 988 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width);
984 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); 989 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width);
985 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); 990 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width);
986 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); 991 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width);
987 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); 992 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width);
988 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); 993 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width);
989 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); 994 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width);
990 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); 995 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width);
991 996
992 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); 997 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width);
993 glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); 998 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width);
994 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); 999 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width);
995 glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); 1000 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width);
996 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); 1001 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width);
997 glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); 1002 gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width);
998 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); 1003 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width);
999 glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); 1004 gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width);
1000} 1005}
1001 1006
1002 1007
1003void LLViewerObjectList::renderObjectBeacons() 1008void LLViewerObjectList::renderObjectBeacons()
1004{ 1009{
1010 if (mDebugBeacons.empty())
1011 {
1012 return;
1013 }
1014
1005 S32 i; 1015 S32 i;
1006 //const LLFontGL *font = gResMgr->getRes(LLFONT_SANSSERIF); 1016 //const LLFontGL *font = gResMgr->getRes(LLFONT_SANSSERIF);
1007 1017
@@ -1011,7 +1021,7 @@ void LLViewerObjectList::renderObjectBeacons()
1011 1021
1012 { 1022 {
1013 LLGLSNoTexture gls_ui_no_texture; 1023 LLGLSNoTexture gls_ui_no_texture;
1014 glBegin(GL_LINES); 1024 gGL.begin(GL_LINES);
1015 for (i = 0; i < mDebugBeacons.count(); i++) 1025 for (i = 0; i < mDebugBeacons.count(); i++)
1016 { 1026 {
1017 const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; 1027 const LLDebugBeacon &debug_beacon = mDebugBeacons[i];
@@ -1020,31 +1030,32 @@ void LLViewerObjectList::renderObjectBeacons()
1020 S32 line_width = debug_beacon.mLineWidth; 1030 S32 line_width = debug_beacon.mLineWidth;
1021 if (line_width != last_line_width) 1031 if (line_width != last_line_width)
1022 { 1032 {
1023 glEnd(); 1033 gGL.end();
1034 gGL.flush();
1024 glLineWidth( (F32)line_width ); 1035 glLineWidth( (F32)line_width );
1025 last_line_width = line_width; 1036 last_line_width = line_width;
1026 glBegin(GL_LINES); 1037 gGL.begin(GL_LINES);
1027 } 1038 }
1028 1039
1029 const LLVector3 &thisline = debug_beacon.mPositionAgent; 1040 const LLVector3 &thisline = debug_beacon.mPositionAgent;
1030 glColor4fv(color.mV); 1041 gGL.color4fv(color.mV);
1031 glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f); 1042 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f);
1032 glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f); 1043 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f);
1033 glVertex3f(thisline.mV[VX] - 2.f,thisline.mV[VY],thisline.mV[VZ]); 1044 gGL.vertex3f(thisline.mV[VX] - 2.f,thisline.mV[VY],thisline.mV[VZ]);
1034 glVertex3f(thisline.mV[VX] + 2.f,thisline.mV[VY],thisline.mV[VZ]); 1045 gGL.vertex3f(thisline.mV[VX] + 2.f,thisline.mV[VY],thisline.mV[VZ]);
1035 glVertex3f(thisline.mV[VX],thisline.mV[VY] - 2.f,thisline.mV[VZ]); 1046 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 2.f,thisline.mV[VZ]);
1036 glVertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]); 1047 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]);
1037 1048
1038 draw_line_cube(0.10f, thisline); 1049 draw_line_cube(0.10f, thisline);
1039 } 1050 }
1040 glEnd(); 1051 gGL.end();
1041 } 1052 }
1042 1053
1043 { 1054 {
1044 LLGLSNoTexture gls_ui_no_texture; 1055 LLGLSNoTexture gls_ui_no_texture;
1045 LLGLDepthTest gls_depth(GL_TRUE); 1056 LLGLDepthTest gls_depth(GL_TRUE);
1046 1057
1047 glBegin(GL_LINES); 1058 gGL.begin(GL_LINES);
1048 last_line_width = -1; 1059 last_line_width = -1;
1049 for (i = 0; i < mDebugBeacons.count(); i++) 1060 for (i = 0; i < mDebugBeacons.count(); i++)
1050 { 1061 {
@@ -1053,25 +1064,27 @@ void LLViewerObjectList::renderObjectBeacons()
1053 S32 line_width = debug_beacon.mLineWidth; 1064 S32 line_width = debug_beacon.mLineWidth;
1054 if (line_width != last_line_width) 1065 if (line_width != last_line_width)
1055 { 1066 {
1056 glEnd(); 1067 gGL.end();
1068 gGL.flush();
1057 glLineWidth( (F32)line_width ); 1069 glLineWidth( (F32)line_width );
1058 last_line_width = line_width; 1070 last_line_width = line_width;
1059 glBegin(GL_LINES); 1071 gGL.begin(GL_LINES);
1060 } 1072 }
1061 1073
1062 const LLVector3 &thisline = debug_beacon.mPositionAgent; 1074 const LLVector3 &thisline = debug_beacon.mPositionAgent;
1063 glColor4fv(debug_beacon.mColor.mV); 1075 gGL.color4fv(debug_beacon.mColor.mV);
1064 glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f); 1076 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f);
1065 glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f); 1077 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f);
1066 glVertex3f(thisline.mV[VX] - 0.5f,thisline.mV[VY],thisline.mV[VZ]); 1078 gGL.vertex3f(thisline.mV[VX] - 0.5f,thisline.mV[VY],thisline.mV[VZ]);
1067 glVertex3f(thisline.mV[VX] + 0.5f,thisline.mV[VY],thisline.mV[VZ]); 1079 gGL.vertex3f(thisline.mV[VX] + 0.5f,thisline.mV[VY],thisline.mV[VZ]);
1068 glVertex3f(thisline.mV[VX],thisline.mV[VY] - 0.5f,thisline.mV[VZ]); 1080 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 0.5f,thisline.mV[VZ]);
1069 glVertex3f(thisline.mV[VX],thisline.mV[VY] + 0.5f,thisline.mV[VZ]); 1081 gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 0.5f,thisline.mV[VZ]);
1070 1082
1071 draw_line_cube(0.10f, thisline); 1083 draw_line_cube(0.10f, thisline);
1072 } 1084 }
1073 glEnd(); 1085 gGL.end();
1074 1086
1087 gGL.flush();
1075 glLineWidth(1.f); 1088 glLineWidth(1.f);
1076 1089
1077 for (i = 0; i < mDebugBeacons.count(); i++) 1090 for (i = 0; i < mDebugBeacons.count(); i++)