aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolterrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lldrawpoolterrain.cpp')
-rw-r--r--linden/indra/newview/lldrawpoolterrain.cpp108
1 files changed, 24 insertions, 84 deletions
diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp
index 1d43698..fdb27f9 100644
--- a/linden/indra/newview/lldrawpoolterrain.cpp
+++ b/linden/indra/newview/lldrawpoolterrain.cpp
@@ -217,14 +217,6 @@ void LLDrawPoolTerrain::render(S32 pass)
217 217
218void LLDrawPoolTerrain::renderFullShader() 218void LLDrawPoolTerrain::renderFullShader()
219{ 219{
220 glEnableClientState(GL_VERTEX_ARRAY);
221 glEnableClientState(GL_NORMAL_ARRAY);
222
223 if (gPipeline.getLightingDetail() >= 2)
224 {
225 glEnableClientState(GL_COLOR_ARRAY);
226 }
227
228 // Hack! Get the region that this draw pool is rendering from! 220 // Hack! Get the region that this draw pool is rendering from!
229 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); 221 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
230 LLVLComposition *compp = regionp->getComposition(); 222 LLVLComposition *compp = regionp->getComposition();
@@ -247,10 +239,8 @@ void LLDrawPoolTerrain::renderFullShader()
247 // 239 //
248 S32 detail0 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL0); 240 S32 detail0 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL0);
249 LLViewerImage::bindTexture(detail_texture0p,detail0); 241 LLViewerImage::bindTexture(detail_texture0p,detail0);
250 glClientActiveTextureARB(GL_TEXTURE0_ARB);
251 glActiveTextureARB(GL_TEXTURE0_ARB); 242 glActiveTextureARB(GL_TEXTURE0_ARB);
252 243
253 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
254 glEnable(GL_TEXTURE_GEN_S); 244 glEnable(GL_TEXTURE_GEN_S);
255 glEnable(GL_TEXTURE_GEN_T); 245 glEnable(GL_TEXTURE_GEN_T);
256 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 246 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -269,9 +259,7 @@ void LLDrawPoolTerrain::renderFullShader()
269 LLViewerImage::bindTexture(detail_texture1p,detail1); 259 LLViewerImage::bindTexture(detail_texture1p,detail1);
270 260
271 /// ALPHA TEXTURE COORDS 0: 261 /// ALPHA TEXTURE COORDS 0:
272 glClientActiveTextureARB(GL_TEXTURE1_ARB);
273 glActiveTextureARB(GL_TEXTURE1_ARB); 262 glActiveTextureARB(GL_TEXTURE1_ARB);
274 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
275 glMatrixMode(GL_TEXTURE); 263 glMatrixMode(GL_TEXTURE);
276 glLoadIdentity(); 264 glLoadIdentity();
277 glMatrixMode(GL_MODELVIEW); 265 glMatrixMode(GL_MODELVIEW);
@@ -283,9 +271,7 @@ void LLDrawPoolTerrain::renderFullShader()
283 glEnable(GL_TEXTURE_2D); 271 glEnable(GL_TEXTURE_2D);
284 272
285 /// ALPHA TEXTURE COORDS 1: 273 /// ALPHA TEXTURE COORDS 1:
286 glClientActiveTextureARB(GL_TEXTURE2_ARB);
287 glActiveTextureARB(GL_TEXTURE2_ARB); 274 glActiveTextureARB(GL_TEXTURE2_ARB);
288 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
289 glMatrixMode(GL_TEXTURE); 275 glMatrixMode(GL_TEXTURE);
290 glLoadIdentity(); 276 glLoadIdentity();
291 glTranslatef(-2.f, 0.f, 0.f); 277 glTranslatef(-2.f, 0.f, 0.f);
@@ -298,9 +284,7 @@ void LLDrawPoolTerrain::renderFullShader()
298 LLViewerImage::bindTexture(detail_texture3p,detail3); 284 LLViewerImage::bindTexture(detail_texture3p,detail3);
299 285
300 /// ALPHA TEXTURE COORDS 2: 286 /// ALPHA TEXTURE COORDS 2:
301 glClientActiveTextureARB(GL_TEXTURE3_ARB);
302 glActiveTextureARB(GL_TEXTURE3_ARB); 287 glActiveTextureARB(GL_TEXTURE3_ARB);
303 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
304 glMatrixMode(GL_TEXTURE); 288 glMatrixMode(GL_TEXTURE);
305 glLoadIdentity(); 289 glLoadIdentity();
306 glTranslatef(-1.f, 0.f, 0.f); 290 glTranslatef(-1.f, 0.f, 0.f);
@@ -323,7 +307,6 @@ void LLDrawPoolTerrain::renderFullShader()
323 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL3); 307 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL3);
324 308
325 LLImageGL::unbindTexture(alpha_ramp, GL_TEXTURE_2D); 309 LLImageGL::unbindTexture(alpha_ramp, GL_TEXTURE_2D);
326 glClientActiveTextureARB(GL_TEXTURE4_ARB);
327 glActiveTextureARB(GL_TEXTURE4_ARB); 310 glActiveTextureARB(GL_TEXTURE4_ARB);
328 glDisable(GL_TEXTURE_2D); // Texture unit 4 311 glDisable(GL_TEXTURE_2D); // Texture unit 4
329 glDisable(GL_TEXTURE_GEN_S); 312 glDisable(GL_TEXTURE_GEN_S);
@@ -333,10 +316,8 @@ void LLDrawPoolTerrain::renderFullShader()
333 glMatrixMode(GL_MODELVIEW); 316 glMatrixMode(GL_MODELVIEW);
334 317
335 LLImageGL::unbindTexture(detail3, GL_TEXTURE_2D); 318 LLImageGL::unbindTexture(detail3, GL_TEXTURE_2D);
336 glClientActiveTextureARB(GL_TEXTURE3_ARB);
337 glActiveTextureARB(GL_TEXTURE3_ARB); 319 glActiveTextureARB(GL_TEXTURE3_ARB);
338 glDisable(GL_TEXTURE_2D); 320 glDisable(GL_TEXTURE_2D);
339 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
340 glDisable(GL_TEXTURE_GEN_S); 321 glDisable(GL_TEXTURE_GEN_S);
341 glDisable(GL_TEXTURE_GEN_T); 322 glDisable(GL_TEXTURE_GEN_T);
342 glMatrixMode(GL_TEXTURE); 323 glMatrixMode(GL_TEXTURE);
@@ -344,10 +325,8 @@ void LLDrawPoolTerrain::renderFullShader()
344 glMatrixMode(GL_MODELVIEW); 325 glMatrixMode(GL_MODELVIEW);
345 326
346 LLImageGL::unbindTexture(detail2, GL_TEXTURE_2D); 327 LLImageGL::unbindTexture(detail2, GL_TEXTURE_2D);
347 glClientActiveTextureARB(GL_TEXTURE2_ARB);
348 glActiveTextureARB(GL_TEXTURE2_ARB); 328 glActiveTextureARB(GL_TEXTURE2_ARB);
349 glDisable(GL_TEXTURE_2D); 329 glDisable(GL_TEXTURE_2D);
350 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
351 glDisable(GL_TEXTURE_GEN_S); 330 glDisable(GL_TEXTURE_GEN_S);
352 glDisable(GL_TEXTURE_GEN_T); 331 glDisable(GL_TEXTURE_GEN_T);
353 glMatrixMode(GL_TEXTURE); 332 glMatrixMode(GL_TEXTURE);
@@ -355,10 +334,8 @@ void LLDrawPoolTerrain::renderFullShader()
355 glMatrixMode(GL_MODELVIEW); 334 glMatrixMode(GL_MODELVIEW);
356 335
357 LLImageGL::unbindTexture(detail1, GL_TEXTURE_2D); 336 LLImageGL::unbindTexture(detail1, GL_TEXTURE_2D);
358 glClientActiveTextureARB(GL_TEXTURE1_ARB);
359 glActiveTextureARB(GL_TEXTURE1_ARB); 337 glActiveTextureARB(GL_TEXTURE1_ARB);
360 glDisable(GL_TEXTURE_2D); 338 glDisable(GL_TEXTURE_2D);
361 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
362 glDisable(GL_TEXTURE_GEN_S); 339 glDisable(GL_TEXTURE_GEN_S);
363 glDisable(GL_TEXTURE_GEN_T); 340 glDisable(GL_TEXTURE_GEN_T);
364 glMatrixMode(GL_TEXTURE); 341 glMatrixMode(GL_TEXTURE);
@@ -369,7 +346,6 @@ void LLDrawPoolTerrain::renderFullShader()
369 // Restore Texture Unit 0 defaults 346 // Restore Texture Unit 0 defaults
370 347
371 LLImageGL::unbindTexture(detail0, GL_TEXTURE_2D); 348 LLImageGL::unbindTexture(detail0, GL_TEXTURE_2D);
372 glClientActiveTextureARB(GL_TEXTURE0_ARB);
373 glActiveTextureARB(GL_TEXTURE0_ARB); 349 glActiveTextureARB(GL_TEXTURE0_ARB);
374 glEnable(GL_TEXTURE_2D); 350 glEnable(GL_TEXTURE_2D);
375 glDisable(GL_TEXTURE_GEN_S); 351 glDisable(GL_TEXTURE_GEN_S);
@@ -377,14 +353,11 @@ void LLDrawPoolTerrain::renderFullShader()
377 glMatrixMode(GL_TEXTURE); 353 glMatrixMode(GL_TEXTURE);
378 glLoadIdentity(); 354 glLoadIdentity();
379 glMatrixMode(GL_MODELVIEW); 355 glMatrixMode(GL_MODELVIEW);
380
381 // Restore non Texture Unit specific defaults
382 glDisableClientState(GL_NORMAL_ARRAY);
383} 356}
384 357
385void LLDrawPoolTerrain::renderFull4TU() 358void LLDrawPoolTerrain::renderFull4TU()
386{ 359{
387 glEnableClientState(GL_VERTEX_ARRAY); 360 glEnableClientState(GL_VERTEX_ARRAY);
388 glEnableClientState(GL_NORMAL_ARRAY); 361 glEnableClientState(GL_NORMAL_ARRAY);
389 362
390 // Hack! Get the region that this draw pool is rendering from! 363 // Hack! Get the region that this draw pool is rendering from!
@@ -434,9 +407,8 @@ void LLDrawPoolTerrain::renderFull4TU()
434 // 407 //
435 // Stage 1: Generate alpha ramp for detail0/detail1 transition 408 // Stage 1: Generate alpha ramp for detail0/detail1 transition
436 // 409 //
437 glActiveTextureARB(GL_TEXTURE1_ARB);
438 LLViewerImage::bindTexture(m2DAlphaRampImagep,1); 410 LLViewerImage::bindTexture(m2DAlphaRampImagep,1);
439 411 glActiveTextureARB(GL_TEXTURE1_ARB);
440 glEnable(GL_TEXTURE_2D); // Texture unit 1 412 glEnable(GL_TEXTURE_2D); // Texture unit 1
441 glClientActiveTextureARB(GL_TEXTURE1_ARB); 413 glClientActiveTextureARB(GL_TEXTURE1_ARB);
442 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 414 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -454,8 +426,8 @@ void LLDrawPoolTerrain::renderFull4TU()
454 // 426 //
455 // Stage 2: Interpolate detail1 with existing based on ramp 427 // Stage 2: Interpolate detail1 with existing based on ramp
456 // 428 //
457 glActiveTextureARB(GL_TEXTURE2_ARB);
458 LLViewerImage::bindTexture(detail_texture1p,2); 429 LLViewerImage::bindTexture(detail_texture1p,2);
430 glActiveTextureARB(GL_TEXTURE2_ARB);
459 glEnable(GL_TEXTURE_2D); // Texture unit 2 431 glEnable(GL_TEXTURE_2D); // Texture unit 2
460 glClientActiveTextureARB(GL_TEXTURE2_ARB); 432 glClientActiveTextureARB(GL_TEXTURE2_ARB);
461 433
@@ -480,8 +452,8 @@ void LLDrawPoolTerrain::renderFull4TU()
480 // 452 //
481 // Stage 3: Modulate with primary (vertex) color for lighting 453 // Stage 3: Modulate with primary (vertex) color for lighting
482 // 454 //
483 glActiveTextureARB(GL_TEXTURE3_ARB);
484 LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture 455 LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture
456 glActiveTextureARB(GL_TEXTURE3_ARB);
485 glEnable(GL_TEXTURE_2D); // Texture unit 3 457 glEnable(GL_TEXTURE_2D); // Texture unit 3
486 glClientActiveTextureARB(GL_TEXTURE3_ARB); 458 glClientActiveTextureARB(GL_TEXTURE3_ARB);
487 459
@@ -494,6 +466,7 @@ void LLDrawPoolTerrain::renderFull4TU()
494 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); 466 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
495 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); 467 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
496 468
469 glActiveTextureARB(GL_TEXTURE0_ARB);
497 // GL_BLEND disabled by default 470 // GL_BLEND disabled by default
498 drawLoop(); 471 drawLoop();
499 472
@@ -524,9 +497,8 @@ void LLDrawPoolTerrain::renderFull4TU()
524 // 497 //
525 // Stage 1: Generate alpha ramp for detail2/detail3 transition 498 // Stage 1: Generate alpha ramp for detail2/detail3 transition
526 // 499 //
527 glActiveTextureARB(GL_TEXTURE1_ARB);
528 LLViewerImage::bindTexture(m2DAlphaRampImagep,1); 500 LLViewerImage::bindTexture(m2DAlphaRampImagep,1);
529 501 glActiveTextureARB(GL_TEXTURE1_ARB);
530 glEnable(GL_TEXTURE_2D); // Texture unit 1 502 glEnable(GL_TEXTURE_2D); // Texture unit 1
531 glClientActiveTextureARB(GL_TEXTURE1_ARB); 503 glClientActiveTextureARB(GL_TEXTURE1_ARB);
532 504
@@ -551,8 +523,8 @@ void LLDrawPoolTerrain::renderFull4TU()
551 // 523 //
552 // Stage 2: Interpolate detail2 with existing based on ramp 524 // Stage 2: Interpolate detail2 with existing based on ramp
553 // 525 //
554 glActiveTextureARB(GL_TEXTURE2_ARB);
555 LLViewerImage::bindTexture(detail_texture2p,2); 526 LLViewerImage::bindTexture(detail_texture2p,2);
527 glActiveTextureARB(GL_TEXTURE2_ARB);
556 glEnable(GL_TEXTURE_2D); // Texture unit 2 528 glEnable(GL_TEXTURE_2D); // Texture unit 2
557 glClientActiveTextureARB(GL_TEXTURE2_ARB); 529 glClientActiveTextureARB(GL_TEXTURE2_ARB);
558 530
@@ -578,9 +550,9 @@ void LLDrawPoolTerrain::renderFull4TU()
578 // 550 //
579 // Stage 3: Generate alpha ramp for detail1/detail2 transition 551 // Stage 3: Generate alpha ramp for detail1/detail2 transition
580 // 552 //
581 glActiveTextureARB(GL_TEXTURE3_ARB);
582 LLViewerImage::bindTexture(m2DAlphaRampImagep,3); 553 LLViewerImage::bindTexture(m2DAlphaRampImagep,3);
583 554 glActiveTextureARB(GL_TEXTURE3_ARB);
555
584 glEnable(GL_TEXTURE_2D); // Texture unit 3 556 glEnable(GL_TEXTURE_2D); // Texture unit 3
585 glClientActiveTextureARB(GL_TEXTURE3_ARB); 557 glClientActiveTextureARB(GL_TEXTURE3_ARB);
586 558
@@ -603,7 +575,7 @@ void LLDrawPoolTerrain::renderFull4TU()
603 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); 575 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
604 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); 576 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
605 577
606 578 glActiveTextureARB(GL_TEXTURE0_ARB);
607 { 579 {
608 LLGLEnable blend(GL_BLEND); 580 LLGLEnable blend(GL_BLEND);
609 drawLoop(); 581 drawLoop();
@@ -611,6 +583,7 @@ void LLDrawPoolTerrain::renderFull4TU()
611 583
612 // Disable multitexture 584 // Disable multitexture
613 LLImageGL::unbindTexture(3, GL_TEXTURE_2D); 585 LLImageGL::unbindTexture(3, GL_TEXTURE_2D);
586 glActiveTextureARB(GL_TEXTURE3_ARB);
614 glClientActiveTextureARB(GL_TEXTURE3_ARB); 587 glClientActiveTextureARB(GL_TEXTURE3_ARB);
615 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 588 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
616 glDisable(GL_TEXTURE_2D); // Texture unit 3 589 glDisable(GL_TEXTURE_2D); // Texture unit 3
@@ -619,6 +592,7 @@ void LLDrawPoolTerrain::renderFull4TU()
619 glMatrixMode(GL_MODELVIEW); 592 glMatrixMode(GL_MODELVIEW);
620 593
621 LLImageGL::unbindTexture(2, GL_TEXTURE_2D); 594 LLImageGL::unbindTexture(2, GL_TEXTURE_2D);
595 glActiveTextureARB(GL_TEXTURE2_ARB);
622 glClientActiveTextureARB(GL_TEXTURE2_ARB); 596 glClientActiveTextureARB(GL_TEXTURE2_ARB);
623 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 597 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
624 glDisable(GL_TEXTURE_2D); // Texture unit 2 598 glDisable(GL_TEXTURE_2D); // Texture unit 2
@@ -629,6 +603,7 @@ void LLDrawPoolTerrain::renderFull4TU()
629 glMatrixMode(GL_MODELVIEW); 603 glMatrixMode(GL_MODELVIEW);
630 604
631 LLImageGL::unbindTexture(1, GL_TEXTURE_2D); 605 LLImageGL::unbindTexture(1, GL_TEXTURE_2D);
606 glActiveTextureARB(GL_TEXTURE1_ARB);
632 glClientActiveTextureARB(GL_TEXTURE1_ARB); 607 glClientActiveTextureARB(GL_TEXTURE1_ARB);
633 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 608 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
634 glDisable(GL_TEXTURE_2D); // Texture unit 1 609 glDisable(GL_TEXTURE_2D); // Texture unit 1
@@ -642,6 +617,7 @@ void LLDrawPoolTerrain::renderFull4TU()
642 //---------------------------------------------------------------------------- 617 //----------------------------------------------------------------------------
643 // Restore Texture Unit 0 defaults 618 // Restore Texture Unit 0 defaults
644 619
620 glActiveTextureARB(GL_TEXTURE0_ARB);
645 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 621 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
646 glClientActiveTextureARB(GL_TEXTURE0_ARB); 622 glClientActiveTextureARB(GL_TEXTURE0_ARB);
647 glActiveTextureARB(GL_TEXTURE0_ARB); 623 glActiveTextureARB(GL_TEXTURE0_ARB);
@@ -658,9 +634,6 @@ void LLDrawPoolTerrain::renderFull4TU()
658 634
659void LLDrawPoolTerrain::renderFull2TU() 635void LLDrawPoolTerrain::renderFull2TU()
660{ 636{
661 glEnableClientState(GL_VERTEX_ARRAY);
662 glEnableClientState(GL_NORMAL_ARRAY);
663
664 // Hack! Get the region that this draw pool is rendering from! 637 // Hack! Get the region that this draw pool is rendering from!
665 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); 638 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
666 LLVLComposition *compp = regionp->getComposition(); 639 LLVLComposition *compp = regionp->getComposition();
@@ -687,9 +660,6 @@ void LLDrawPoolTerrain::renderFull2TU()
687 // Stage 0: Render detail 0 into base 660 // Stage 0: Render detail 0 into base
688 // 661 //
689 LLViewerImage::bindTexture(detail_texture0p,0); 662 LLViewerImage::bindTexture(detail_texture0p,0);
690 glClientActiveTextureARB(GL_TEXTURE0_ARB);
691
692 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
693 glEnable(GL_TEXTURE_GEN_S); 663 glEnable(GL_TEXTURE_GEN_S);
694 glEnable(GL_TEXTURE_GEN_T); 664 glEnable(GL_TEXTURE_GEN_T);
695 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 665 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -715,12 +685,10 @@ void LLDrawPoolTerrain::renderFull2TU()
715 // Stage 0: Generate alpha ramp for detail0/detail1 transition 685 // Stage 0: Generate alpha ramp for detail0/detail1 transition
716 // 686 //
717 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 687 LLViewerImage::bindTexture(m2DAlphaRampImagep,0);
718 glClientActiveTextureARB(GL_TEXTURE0_ARB); 688
719
720 glDisable(GL_TEXTURE_GEN_S); 689 glDisable(GL_TEXTURE_GEN_S);
721 glDisable(GL_TEXTURE_GEN_T); 690 glDisable(GL_TEXTURE_GEN_T);
722 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 691
723
724 // Care about alpha only 692 // Care about alpha only
725 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 693 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
726 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); 694 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
@@ -736,10 +704,8 @@ void LLDrawPoolTerrain::renderFull2TU()
736 // Stage 1: Write detail1 704 // Stage 1: Write detail1
737 // 705 //
738 LLViewerImage::bindTexture(detail_texture1p,1); // Texture unit 1 706 LLViewerImage::bindTexture(detail_texture1p,1); // Texture unit 1
707 glActiveTextureARB(GL_TEXTURE1_ARB);
739 glEnable(GL_TEXTURE_2D); // Texture unit 1 708 glEnable(GL_TEXTURE_2D); // Texture unit 1
740 glClientActiveTextureARB(GL_TEXTURE1_ARB);
741
742 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
743 glEnable(GL_TEXTURE_GEN_S); 709 glEnable(GL_TEXTURE_GEN_S);
744 glEnable(GL_TEXTURE_GEN_T); 710 glEnable(GL_TEXTURE_GEN_T);
745 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 711 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -758,6 +724,7 @@ void LLDrawPoolTerrain::renderFull2TU()
758 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS); 724 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
759 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); 725 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
760 726
727 glActiveTextureARB(GL_TEXTURE0_ARB);
761 { 728 {
762 LLGLEnable blend(GL_BLEND); 729 LLGLEnable blend(GL_BLEND);
763 drawLoop(); 730 drawLoop();
@@ -769,14 +736,11 @@ void LLDrawPoolTerrain::renderFull2TU()
769 // Stage 0: Generate alpha ramp for detail1/detail2 transition 736 // Stage 0: Generate alpha ramp for detail1/detail2 transition
770 // 737 //
771 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 738 LLViewerImage::bindTexture(m2DAlphaRampImagep,0);
772 glClientActiveTextureARB(GL_TEXTURE0_ARB);
773 // Set the texture matrix 739 // Set the texture matrix
774 glMatrixMode(GL_TEXTURE); 740 glMatrixMode(GL_TEXTURE);
775 glLoadIdentity(); 741 glLoadIdentity();
776 glTranslatef(-1.f, 0.f, 0.f); 742 glTranslatef(-1.f, 0.f, 0.f);
777 743
778 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
779
780 // Care about alpha only 744 // Care about alpha only
781 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 745 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
782 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); 746 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
@@ -793,9 +757,7 @@ void LLDrawPoolTerrain::renderFull2TU()
793 757
794 LLViewerImage::bindTexture(detail_texture2p,1); 758 LLViewerImage::bindTexture(detail_texture2p,1);
795 glEnable(GL_TEXTURE_2D); // Texture unit 1 759 glEnable(GL_TEXTURE_2D); // Texture unit 1
796 glClientActiveTextureARB(GL_TEXTURE1_ARB); 760
797
798 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
799 glEnable(GL_TEXTURE_GEN_S); 761 glEnable(GL_TEXTURE_GEN_S);
800 glEnable(GL_TEXTURE_GEN_T); 762 glEnable(GL_TEXTURE_GEN_T);
801 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 763 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -826,14 +788,11 @@ void LLDrawPoolTerrain::renderFull2TU()
826 // Stage 0: Generate alpha ramp for detail2/detail3 transition 788 // Stage 0: Generate alpha ramp for detail2/detail3 transition
827 // 789 //
828 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 790 LLViewerImage::bindTexture(m2DAlphaRampImagep,0);
829 glClientActiveTextureARB(GL_TEXTURE0_ARB);
830 // Set the texture matrix 791 // Set the texture matrix
831 glMatrixMode(GL_TEXTURE); 792 glMatrixMode(GL_TEXTURE);
832 glLoadIdentity(); 793 glLoadIdentity();
833 glTranslatef(-2.f, 0.f, 0.f); 794 glTranslatef(-2.f, 0.f, 0.f);
834 795
835 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
836
837 // Care about alpha only 796 // Care about alpha only
838 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 797 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
839 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); 798 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
@@ -847,10 +806,8 @@ void LLDrawPoolTerrain::renderFull2TU()
847 // Stage 1: Write detail3 806 // Stage 1: Write detail3
848 807
849 LLViewerImage::bindTexture(detail_texture3p,1); 808 LLViewerImage::bindTexture(detail_texture3p,1);
809 glActiveTextureARB(GL_TEXTURE1_ARB);
850 glEnable(GL_TEXTURE_2D); // Texture unit 1 810 glEnable(GL_TEXTURE_2D); // Texture unit 1
851 glClientActiveTextureARB(GL_TEXTURE1_ARB);
852
853 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
854 glEnable(GL_TEXTURE_GEN_S); 811 glEnable(GL_TEXTURE_GEN_S);
855 glEnable(GL_TEXTURE_GEN_T); 812 glEnable(GL_TEXTURE_GEN_T);
856 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 813 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -869,6 +826,7 @@ void LLDrawPoolTerrain::renderFull2TU()
869 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS); 826 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
870 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); 827 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
871 828
829 glActiveTextureARB(GL_TEXTURE0_ARB);
872 { 830 {
873 LLGLEnable blend(GL_BLEND); 831 LLGLEnable blend(GL_BLEND);
874 drawLoop(); 832 drawLoop();
@@ -879,8 +837,7 @@ void LLDrawPoolTerrain::renderFull2TU()
879 837
880 // Disable multitexture 838 // Disable multitexture
881 LLImageGL::unbindTexture(1, GL_TEXTURE_2D); 839 LLImageGL::unbindTexture(1, GL_TEXTURE_2D);
882 glClientActiveTextureARB(GL_TEXTURE1_ARB); 840 glActiveTextureARB(GL_TEXTURE1_ARB);
883 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
884 glDisable(GL_TEXTURE_2D); // Texture unit 1 841 glDisable(GL_TEXTURE_2D); // Texture unit 1
885 glDisable(GL_TEXTURE_GEN_S); 842 glDisable(GL_TEXTURE_GEN_S);
886 glDisable(GL_TEXTURE_GEN_T); 843 glDisable(GL_TEXTURE_GEN_T);
@@ -891,9 +848,9 @@ void LLDrawPoolTerrain::renderFull2TU()
891 //---------------------------------------------------------------------------- 848 //----------------------------------------------------------------------------
892 // Restore Texture Unit 0 defaults 849 // Restore Texture Unit 0 defaults
893 850
851 glActiveTextureARB(GL_TEXTURE0_ARB);
894 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 852 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
895 853
896 glClientActiveTextureARB(GL_TEXTURE0_ARB);
897 glActiveTextureARB(GL_TEXTURE0_ARB); 854 glActiveTextureARB(GL_TEXTURE0_ARB);
898 glDisable(GL_TEXTURE_GEN_S); 855 glDisable(GL_TEXTURE_GEN_S);
899 glDisable(GL_TEXTURE_GEN_T); 856 glDisable(GL_TEXTURE_GEN_T);
@@ -902,16 +859,12 @@ void LLDrawPoolTerrain::renderFull2TU()
902 glMatrixMode(GL_MODELVIEW); 859 glMatrixMode(GL_MODELVIEW);
903 860
904 // Restore non Texture Unit specific defaults 861 // Restore non Texture Unit specific defaults
905 glDisableClientState(GL_NORMAL_ARRAY);
906 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 862 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
907} 863}
908 864
909 865
910void LLDrawPoolTerrain::renderSimple() 866void LLDrawPoolTerrain::renderSimple()
911{ 867{
912 glEnableClientState(GL_VERTEX_ARRAY);
913 glEnableClientState(GL_NORMAL_ARRAY);
914
915 LLVector4 tp0, tp1; 868 LLVector4 tp0, tp1;
916 869
917 //---------------------------------------------------------------------------- 870 //----------------------------------------------------------------------------
@@ -923,14 +876,12 @@ void LLDrawPoolTerrain::renderSimple()
923 876
924 glActiveTextureARB(GL_TEXTURE0_ARB); 877 glActiveTextureARB(GL_TEXTURE0_ARB);
925 glEnable(GL_TEXTURE_2D); // Texture unit 2 878 glEnable(GL_TEXTURE_2D); // Texture unit 2
926 glClientActiveTextureARB(GL_TEXTURE0_ARB); 879
927
928 LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent(); 880 LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent();
929 F32 tscale = 1.f/256.f; 881 F32 tscale = 1.f/256.f;
930 tp0.setVec(tscale, 0.f, 0.0f, -1.f*(origin_agent.mV[0]/256.f)); 882 tp0.setVec(tscale, 0.f, 0.0f, -1.f*(origin_agent.mV[0]/256.f));
931 tp1.setVec(0.f, tscale, 0.0f, -1.f*(origin_agent.mV[1]/256.f)); 883 tp1.setVec(0.f, tscale, 0.0f, -1.f*(origin_agent.mV[1]/256.f));
932 884
933 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
934 glEnable(GL_TEXTURE_GEN_S); 885 glEnable(GL_TEXTURE_GEN_S);
935 glEnable(GL_TEXTURE_GEN_T); 886 glEnable(GL_TEXTURE_GEN_T);
936 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 887 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -952,7 +903,6 @@ void LLDrawPoolTerrain::renderSimple()
952 // Restore Texture Unit 0 defaults 903 // Restore Texture Unit 0 defaults
953 904
954 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 905 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
955 glClientActiveTextureARB(GL_TEXTURE0_ARB);
956 glActiveTextureARB(GL_TEXTURE0_ARB); 906 glActiveTextureARB(GL_TEXTURE0_ARB);
957 glDisable(GL_TEXTURE_GEN_S); 907 glDisable(GL_TEXTURE_GEN_S);
958 glDisable(GL_TEXTURE_GEN_T); 908 glDisable(GL_TEXTURE_GEN_T);
@@ -961,7 +911,6 @@ void LLDrawPoolTerrain::renderSimple()
961 glMatrixMode(GL_MODELVIEW); 911 glMatrixMode(GL_MODELVIEW);
962 912
963 // Restore non Texture Unit specific defaults 913 // Restore non Texture Unit specific defaults
964 glDisableClientState(GL_NORMAL_ARRAY);
965 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 914 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
966} 915}
967 916
@@ -986,14 +935,8 @@ void LLDrawPoolTerrain::renderOwnership()
986 LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay(); 935 LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay();
987 LLImageGL *texturep = overlayp->getTexture(); 936 LLImageGL *texturep = overlayp->getTexture();
988 937
989 glEnableClientState(GL_VERTEX_ARRAY);
990 glDisableClientState(GL_NORMAL_ARRAY);
991
992 LLViewerImage::bindTexture(texturep); 938 LLViewerImage::bindTexture(texturep);
993 939
994 glClientActiveTextureARB(GL_TEXTURE0_ARB);
995 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
996
997 // *NOTE: Because the region is 256 meters wide, but has 257 pixels, the 940 // *NOTE: Because the region is 256 meters wide, but has 257 pixels, the
998 // texture coordinates for pixel 256x256 is not 1,1. This makes the 941 // texture coordinates for pixel 256x256 is not 1,1. This makes the
999 // ownership map not line up with the selection. We address this with 942 // ownership map not line up with the selection. We address this with
@@ -1014,9 +957,6 @@ void LLDrawPoolTerrain::renderOwnership()
1014 glMatrixMode(GL_TEXTURE); 957 glMatrixMode(GL_TEXTURE);
1015 glPopMatrix(); 958 glPopMatrix();
1016 glMatrixMode(GL_MODELVIEW); 959 glMatrixMode(GL_MODELVIEW);
1017
1018 // Restore non Texture Unit specific defaults
1019 glDisableClientState(GL_NORMAL_ARRAY);
1020} 960}
1021 961
1022 962