aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolterrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lldrawpoolterrain.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp
index ccfbd2d..e99fc91 100644
--- a/linden/indra/newview/lldrawpoolterrain.cpp
+++ b/linden/indra/newview/lldrawpoolterrain.cpp
@@ -72,19 +72,19 @@ LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) :
72 TRUE, TRUE, GL_ALPHA8, GL_ALPHA, 72 TRUE, TRUE, GL_ALPHA8, GL_ALPHA,
73 LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); 73 LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb"));
74 74
75 mAlphaRampImagep->bind(0); 75 gGL.getTexUnit(0)->bind(mAlphaRampImagep.get());
76 mAlphaRampImagep->setClamp(TRUE, TRUE); 76 mAlphaRampImagep->setClamp(TRUE, TRUE);
77 77
78 m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", 78 m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c",
79 TRUE, TRUE, GL_ALPHA8, GL_ALPHA, 79 TRUE, TRUE, GL_ALPHA8, GL_ALPHA,
80 LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); 80 LLUUID("38b86f85-2575-52a9-a531-23108d8da837"));
81 81
82 m2DAlphaRampImagep->bind(0); 82 gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get());
83 m2DAlphaRampImagep->setClamp(TRUE, TRUE); 83 m2DAlphaRampImagep->setClamp(TRUE, TRUE);
84 84
85 mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN); 85 mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN);
86 86
87 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 87 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
88} 88}
89 89
90LLDrawPoolTerrain::~LLDrawPoolTerrain() 90LLDrawPoolTerrain::~LLDrawPoolTerrain()
@@ -240,7 +240,7 @@ void LLDrawPoolTerrain::renderFullShader()
240 // detail texture 0 240 // detail texture 0
241 // 241 //
242 S32 detail0 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL0); 242 S32 detail0 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL0);
243 LLViewerImage::bindTexture(detail_texture0p,detail0); 243 gGL.getTexUnit(detail0)->bind(detail_texture0p);
244 gGL.getTexUnit(0)->activate(); 244 gGL.getTexUnit(0)->activate();
245 245
246 glEnable(GL_TEXTURE_GEN_S); 246 glEnable(GL_TEXTURE_GEN_S);
@@ -258,7 +258,7 @@ void LLDrawPoolTerrain::renderFullShader()
258 // detail texture 1 258 // detail texture 1
259 // 259 //
260 S32 detail1 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL1); 260 S32 detail1 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL1);
261 LLViewerImage::bindTexture(detail_texture1p,detail1); 261 gGL.getTexUnit(detail1)->bind(detail_texture1p);
262 262
263 /// ALPHA TEXTURE COORDS 0: 263 /// ALPHA TEXTURE COORDS 0:
264 gGL.getTexUnit(1)->activate(); 264 gGL.getTexUnit(1)->activate();
@@ -269,11 +269,11 @@ void LLDrawPoolTerrain::renderFullShader()
269 // detail texture 2 269 // detail texture 2
270 // 270 //
271 S32 detail2 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2); 271 S32 detail2 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2);
272 LLViewerImage::bindTexture(detail_texture2p,detail2); 272 gGL.getTexUnit(detail2)->bind(detail_texture2p);
273 glEnable(GL_TEXTURE_2D); 273
274 gGL.getTexUnit(2)->activate();
274 275
275 /// ALPHA TEXTURE COORDS 1: 276 /// ALPHA TEXTURE COORDS 1:
276 gGL.getTexUnit(2)->activate();
277 glMatrixMode(GL_TEXTURE); 277 glMatrixMode(GL_TEXTURE);
278 glLoadIdentity(); 278 glLoadIdentity();
279 glTranslatef(-2.f, 0.f, 0.f); 279 glTranslatef(-2.f, 0.f, 0.f);
@@ -283,7 +283,7 @@ void LLDrawPoolTerrain::renderFullShader()
283 // detail texture 3 283 // detail texture 3
284 // 284 //
285 S32 detail3 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3); 285 S32 detail3 = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3);
286 LLViewerImage::bindTexture(detail_texture3p,detail3); 286 gGL.getTexUnit(detail3)->bind(detail_texture3p);
287 287
288 /// ALPHA TEXTURE COORDS 2: 288 /// ALPHA TEXTURE COORDS 2:
289 gGL.getTexUnit(3)->activate(); 289 gGL.getTexUnit(3)->activate();
@@ -296,7 +296,7 @@ void LLDrawPoolTerrain::renderFullShader()
296 // Alpha Ramp 296 // Alpha Ramp
297 // 297 //
298 S32 alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); 298 S32 alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP);
299 LLViewerImage::bindTexture(m2DAlphaRampImagep,alpha_ramp); 299 gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep.get());
300 300
301 // GL_BLEND disabled by default 301 // GL_BLEND disabled by default
302 drawLoop(); 302 drawLoop();
@@ -308,36 +308,36 @@ void LLDrawPoolTerrain::renderFullShader()
308 sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2); 308 sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL2);
309 sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3); 309 sShader->disableTexture(LLViewerShaderMgr::TERRAIN_DETAIL3);
310 310
311 LLImageGL::unbindTexture(alpha_ramp, GL_TEXTURE_2D); 311 gGL.getTexUnit(alpha_ramp)->unbind(LLTexUnit::TT_TEXTURE);
312 gGL.getTexUnit(4)->disable();
312 gGL.getTexUnit(4)->activate(); 313 gGL.getTexUnit(4)->activate();
313 glDisable(GL_TEXTURE_2D); // Texture unit 4
314 glDisable(GL_TEXTURE_GEN_S); 314 glDisable(GL_TEXTURE_GEN_S);
315 glDisable(GL_TEXTURE_GEN_T); 315 glDisable(GL_TEXTURE_GEN_T);
316 glMatrixMode(GL_TEXTURE); 316 glMatrixMode(GL_TEXTURE);
317 glLoadIdentity(); 317 glLoadIdentity();
318 glMatrixMode(GL_MODELVIEW); 318 glMatrixMode(GL_MODELVIEW);
319 319
320 LLImageGL::unbindTexture(detail3, GL_TEXTURE_2D); 320 gGL.getTexUnit(detail3)->unbind(LLTexUnit::TT_TEXTURE);
321 gGL.getTexUnit(3)->disable();
321 gGL.getTexUnit(3)->activate(); 322 gGL.getTexUnit(3)->activate();
322 glDisable(GL_TEXTURE_2D);
323 glDisable(GL_TEXTURE_GEN_S); 323 glDisable(GL_TEXTURE_GEN_S);
324 glDisable(GL_TEXTURE_GEN_T); 324 glDisable(GL_TEXTURE_GEN_T);
325 glMatrixMode(GL_TEXTURE); 325 glMatrixMode(GL_TEXTURE);
326 glLoadIdentity(); 326 glLoadIdentity();
327 glMatrixMode(GL_MODELVIEW); 327 glMatrixMode(GL_MODELVIEW);
328 328
329 LLImageGL::unbindTexture(detail2, GL_TEXTURE_2D); 329 gGL.getTexUnit(detail2)->unbind(LLTexUnit::TT_TEXTURE);
330 gGL.getTexUnit(2)->disable();
330 gGL.getTexUnit(2)->activate(); 331 gGL.getTexUnit(2)->activate();
331 glDisable(GL_TEXTURE_2D);
332 glDisable(GL_TEXTURE_GEN_S); 332 glDisable(GL_TEXTURE_GEN_S);
333 glDisable(GL_TEXTURE_GEN_T); 333 glDisable(GL_TEXTURE_GEN_T);
334 glMatrixMode(GL_TEXTURE); 334 glMatrixMode(GL_TEXTURE);
335 glLoadIdentity(); 335 glLoadIdentity();
336 glMatrixMode(GL_MODELVIEW); 336 glMatrixMode(GL_MODELVIEW);
337 337
338 LLImageGL::unbindTexture(detail1, GL_TEXTURE_2D); 338 gGL.getTexUnit(detail1)->unbind(LLTexUnit::TT_TEXTURE);
339 gGL.getTexUnit(1)->disable();
339 gGL.getTexUnit(1)->activate(); 340 gGL.getTexUnit(1)->activate();
340 glDisable(GL_TEXTURE_2D);
341 glDisable(GL_TEXTURE_GEN_S); 341 glDisable(GL_TEXTURE_GEN_S);
342 glDisable(GL_TEXTURE_GEN_T); 342 glDisable(GL_TEXTURE_GEN_T);
343 glMatrixMode(GL_TEXTURE); 343 glMatrixMode(GL_TEXTURE);
@@ -347,9 +347,9 @@ void LLDrawPoolTerrain::renderFullShader()
347 //---------------------------------------------------------------------------- 347 //----------------------------------------------------------------------------
348 // Restore Texture Unit 0 defaults 348 // Restore Texture Unit 0 defaults
349 349
350 LLImageGL::unbindTexture(detail0, GL_TEXTURE_2D); 350 gGL.getTexUnit(detail0)->unbind(LLTexUnit::TT_TEXTURE);
351 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
351 gGL.getTexUnit(0)->activate(); 352 gGL.getTexUnit(0)->activate();
352 glEnable(GL_TEXTURE_2D);
353 glDisable(GL_TEXTURE_GEN_S); 353 glDisable(GL_TEXTURE_GEN_S);
354 glDisable(GL_TEXTURE_GEN_T); 354 glDisable(GL_TEXTURE_GEN_T);
355 glMatrixMode(GL_TEXTURE); 355 glMatrixMode(GL_TEXTURE);
@@ -388,7 +388,7 @@ void LLDrawPoolTerrain::renderFull4TU()
388 // Stage 0: detail texture 0 388 // Stage 0: detail texture 0
389 // 389 //
390 gGL.getTexUnit(0)->activate(); 390 gGL.getTexUnit(0)->activate();
391 LLViewerImage::bindTexture(detail_texture0p,0); 391 gGL.getTexUnit(0)->bind(detail_texture0p);
392 glClientActiveTextureARB(GL_TEXTURE0_ARB); 392 glClientActiveTextureARB(GL_TEXTURE0_ARB);
393 393
394 glEnable(GL_TEXTURE_GEN_S); 394 glEnable(GL_TEXTURE_GEN_S);
@@ -405,9 +405,9 @@ void LLDrawPoolTerrain::renderFull4TU()
405 // Stage 1: Generate alpha ramp for detail0/detail1 transition 405 // Stage 1: Generate alpha ramp for detail0/detail1 transition
406 // 406 //
407 407
408 LLViewerImage::bindTexture(m2DAlphaRampImagep,1); 408 gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get());
409 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
409 gGL.getTexUnit(1)->activate(); 410 gGL.getTexUnit(1)->activate();
410 glEnable(GL_TEXTURE_2D); // Texture unit 1
411 glClientActiveTextureARB(GL_TEXTURE1_ARB); 411 glClientActiveTextureARB(GL_TEXTURE1_ARB);
412 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 412 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
413 413
@@ -418,12 +418,13 @@ void LLDrawPoolTerrain::renderFull4TU()
418 // 418 //
419 // Stage 2: Interpolate detail1 with existing based on ramp 419 // Stage 2: Interpolate detail1 with existing based on ramp
420 // 420 //
421 LLViewerImage::bindTexture(detail_texture1p,2); 421 gGL.getTexUnit(2)->bind(detail_texture1p);
422 gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE);
422 gGL.getTexUnit(2)->activate(); 423 gGL.getTexUnit(2)->activate();
423 glEnable(GL_TEXTURE_2D); // Texture unit 2
424 glClientActiveTextureARB(GL_TEXTURE2_ARB);
425 424
425 glClientActiveTextureARB(GL_TEXTURE2_ARB);
426 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 426 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
427
427 glEnable(GL_TEXTURE_GEN_S); 428 glEnable(GL_TEXTURE_GEN_S);
428 glEnable(GL_TEXTURE_GEN_T); 429 glEnable(GL_TEXTURE_GEN_T);
429 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 430 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -436,9 +437,9 @@ void LLDrawPoolTerrain::renderFull4TU()
436 // 437 //
437 // Stage 3: Modulate with primary (vertex) color for lighting 438 // Stage 3: Modulate with primary (vertex) color for lighting
438 // 439 //
439 LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture 440 gGL.getTexUnit(3)->bind(detail_texture1p);
441 gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE);
440 gGL.getTexUnit(3)->activate(); 442 gGL.getTexUnit(3)->activate();
441 glEnable(GL_TEXTURE_2D); // Texture unit 3
442 glClientActiveTextureARB(GL_TEXTURE3_ARB); 443 glClientActiveTextureARB(GL_TEXTURE3_ARB);
443 444
444 // Set alpha texture and do lighting modulation 445 // Set alpha texture and do lighting modulation
@@ -456,7 +457,7 @@ void LLDrawPoolTerrain::renderFull4TU()
456 // Stage 0: Write detail3 into base 457 // Stage 0: Write detail3 into base
457 // 458 //
458 gGL.getTexUnit(0)->activate(); 459 gGL.getTexUnit(0)->activate();
459 LLViewerImage::bindTexture(detail_texture3p,0); 460 gGL.getTexUnit(0)->bind(detail_texture3p);
460 glClientActiveTextureARB(GL_TEXTURE0_ARB); 461 glClientActiveTextureARB(GL_TEXTURE0_ARB);
461 462
462 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 463 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -472,9 +473,9 @@ void LLDrawPoolTerrain::renderFull4TU()
472 // 473 //
473 // Stage 1: Generate alpha ramp for detail2/detail3 transition 474 // Stage 1: Generate alpha ramp for detail2/detail3 transition
474 // 475 //
475 LLViewerImage::bindTexture(m2DAlphaRampImagep,1); 476 gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get());
477 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
476 gGL.getTexUnit(1)->activate(); 478 gGL.getTexUnit(1)->activate();
477 glEnable(GL_TEXTURE_2D); // Texture unit 1
478 glClientActiveTextureARB(GL_TEXTURE1_ARB); 479 glClientActiveTextureARB(GL_TEXTURE1_ARB);
479 480
480 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 481 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -492,9 +493,9 @@ void LLDrawPoolTerrain::renderFull4TU()
492 // 493 //
493 // Stage 2: Interpolate detail2 with existing based on ramp 494 // Stage 2: Interpolate detail2 with existing based on ramp
494 // 495 //
495 LLViewerImage::bindTexture(detail_texture2p,2); 496 gGL.getTexUnit(2)->bind(detail_texture2p);
497 gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE);
496 gGL.getTexUnit(2)->activate(); 498 gGL.getTexUnit(2)->activate();
497 glEnable(GL_TEXTURE_2D); // Texture unit 2
498 499
499 glClientActiveTextureARB(GL_TEXTURE2_ARB); 500 glClientActiveTextureARB(GL_TEXTURE2_ARB);
500 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 501 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -511,9 +512,9 @@ void LLDrawPoolTerrain::renderFull4TU()
511 // 512 //
512 // Stage 3: Generate alpha ramp for detail1/detail2 transition 513 // Stage 3: Generate alpha ramp for detail1/detail2 transition
513 // 514 //
514 LLViewerImage::bindTexture(m2DAlphaRampImagep,3); 515 gGL.getTexUnit(3)->bind(m2DAlphaRampImagep.get());
516 gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE);
515 gGL.getTexUnit(3)->activate(); 517 gGL.getTexUnit(3)->activate();
516 glEnable(GL_TEXTURE_2D); // Texture unit 3
517 518
518 glClientActiveTextureARB(GL_TEXTURE3_ARB); 519 glClientActiveTextureARB(GL_TEXTURE3_ARB);
519 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 520 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -536,21 +537,21 @@ void LLDrawPoolTerrain::renderFull4TU()
536 537
537 LLVertexBuffer::unbind(); 538 LLVertexBuffer::unbind();
538 // Disable multitexture 539 // Disable multitexture
539 LLImageGL::unbindTexture(3, GL_TEXTURE_2D); 540 gGL.getTexUnit(3)->unbind(LLTexUnit::TT_TEXTURE);
541 gGL.getTexUnit(3)->disable();
540 gGL.getTexUnit(3)->activate(); 542 gGL.getTexUnit(3)->activate();
541 glClientActiveTextureARB(GL_TEXTURE3_ARB); 543 glClientActiveTextureARB(GL_TEXTURE3_ARB);
542 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 544 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
543 glDisable(GL_TEXTURE_2D); // Texture unit 3
544 545
545 glMatrixMode(GL_TEXTURE); 546 glMatrixMode(GL_TEXTURE);
546 glLoadIdentity(); 547 glLoadIdentity();
547 glMatrixMode(GL_MODELVIEW); 548 glMatrixMode(GL_MODELVIEW);
548 549
549 LLImageGL::unbindTexture(2, GL_TEXTURE_2D); 550 gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
551 gGL.getTexUnit(2)->disable();
550 gGL.getTexUnit(2)->activate(); 552 gGL.getTexUnit(2)->activate();
551 glClientActiveTextureARB(GL_TEXTURE2_ARB); 553 glClientActiveTextureARB(GL_TEXTURE2_ARB);
552 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 554 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
553 glDisable(GL_TEXTURE_2D); // Texture unit 2
554 555
555 glDisable(GL_TEXTURE_GEN_S); 556 glDisable(GL_TEXTURE_GEN_S);
556 glDisable(GL_TEXTURE_GEN_T); 557 glDisable(GL_TEXTURE_GEN_T);
@@ -558,11 +559,11 @@ void LLDrawPoolTerrain::renderFull4TU()
558 glLoadIdentity(); 559 glLoadIdentity();
559 glMatrixMode(GL_MODELVIEW); 560 glMatrixMode(GL_MODELVIEW);
560 561
561 LLImageGL::unbindTexture(1, GL_TEXTURE_2D); 562 gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
563 gGL.getTexUnit(1)->disable();
562 gGL.getTexUnit(1)->activate(); 564 gGL.getTexUnit(1)->activate();
563 glClientActiveTextureARB(GL_TEXTURE1_ARB); 565 glClientActiveTextureARB(GL_TEXTURE1_ARB);
564 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 566 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
565 glDisable(GL_TEXTURE_2D); // Texture unit 1
566 567
567 glMatrixMode(GL_TEXTURE); 568 glMatrixMode(GL_TEXTURE);
568 glLoadIdentity(); 569 glLoadIdentity();
@@ -575,9 +576,9 @@ void LLDrawPoolTerrain::renderFull4TU()
575 // Restore Texture Unit 0 defaults 576 // Restore Texture Unit 0 defaults
576 577
577 gGL.getTexUnit(0)->activate(); 578 gGL.getTexUnit(0)->activate();
578 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 579 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
580
579 glClientActiveTextureARB(GL_TEXTURE0_ARB); 581 glClientActiveTextureARB(GL_TEXTURE0_ARB);
580 gGL.getTexUnit(0)->activate();
581 glDisableClientState(GL_NORMAL_ARRAY); 582 glDisableClientState(GL_NORMAL_ARRAY);
582 583
583 glDisable(GL_TEXTURE_GEN_S); 584 glDisable(GL_TEXTURE_GEN_S);
@@ -616,7 +617,7 @@ void LLDrawPoolTerrain::renderFull2TU()
616 // 617 //
617 // Stage 0: Render detail 0 into base 618 // Stage 0: Render detail 0 into base
618 // 619 //
619 LLViewerImage::bindTexture(detail_texture0p,0); 620 gGL.getTexUnit(0)->bind(detail_texture0p);
620 glEnable(GL_TEXTURE_GEN_S); 621 glEnable(GL_TEXTURE_GEN_S);
621 glEnable(GL_TEXTURE_GEN_T); 622 glEnable(GL_TEXTURE_GEN_T);
622 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 623 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
@@ -635,7 +636,7 @@ void LLDrawPoolTerrain::renderFull2TU()
635 // 636 //
636 // Stage 0: Generate alpha ramp for detail0/detail1 transition 637 // Stage 0: Generate alpha ramp for detail0/detail1 transition
637 // 638 //
638 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 639 gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get());
639 640
640 glDisable(GL_TEXTURE_GEN_S); 641 glDisable(GL_TEXTURE_GEN_S);
641 glDisable(GL_TEXTURE_GEN_T); 642 glDisable(GL_TEXTURE_GEN_T);
@@ -648,9 +649,9 @@ void LLDrawPoolTerrain::renderFull2TU()
648 // 649 //
649 // Stage 1: Write detail1 650 // Stage 1: Write detail1
650 // 651 //
651 LLViewerImage::bindTexture(detail_texture1p,1); // Texture unit 1 652 gGL.getTexUnit(1)->bind(detail_texture1p);
653 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
652 gGL.getTexUnit(1)->activate(); 654 gGL.getTexUnit(1)->activate();
653 glEnable(GL_TEXTURE_2D); // Texture unit 1
654 655
655 glEnable(GL_TEXTURE_GEN_S); 656 glEnable(GL_TEXTURE_GEN_S);
656 glEnable(GL_TEXTURE_GEN_T); 657 glEnable(GL_TEXTURE_GEN_T);
@@ -673,7 +674,7 @@ void LLDrawPoolTerrain::renderFull2TU()
673 // 674 //
674 // Stage 0: Generate alpha ramp for detail1/detail2 transition 675 // Stage 0: Generate alpha ramp for detail1/detail2 transition
675 // 676 //
676 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 677 gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get());
677 678
678 // Set the texture matrix 679 // Set the texture matrix
679 glMatrixMode(GL_TEXTURE); 680 glMatrixMode(GL_TEXTURE);
@@ -687,9 +688,9 @@ void LLDrawPoolTerrain::renderFull2TU()
687 // 688 //
688 // Stage 1: Write detail2 689 // Stage 1: Write detail2
689 // 690 //
690 LLViewerImage::bindTexture(detail_texture2p,1); 691 gGL.getTexUnit(1)->bind(detail_texture2p);
692 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
691 gGL.getTexUnit(1)->activate(); 693 gGL.getTexUnit(1)->activate();
692 glEnable(GL_TEXTURE_2D); // Texture unit 1
693 694
694 glEnable(GL_TEXTURE_GEN_S); 695 glEnable(GL_TEXTURE_GEN_S);
695 glEnable(GL_TEXTURE_GEN_T); 696 glEnable(GL_TEXTURE_GEN_T);
@@ -713,7 +714,7 @@ void LLDrawPoolTerrain::renderFull2TU()
713 // Stage 0: Generate alpha ramp for detail2/detail3 transition 714 // Stage 0: Generate alpha ramp for detail2/detail3 transition
714 // 715 //
715 gGL.getTexUnit(0)->activate(); 716 gGL.getTexUnit(0)->activate();
716 LLViewerImage::bindTexture(m2DAlphaRampImagep,0); 717 gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get());
717 // Set the texture matrix 718 // Set the texture matrix
718 glMatrixMode(GL_TEXTURE); 719 glMatrixMode(GL_TEXTURE);
719 glLoadIdentity(); 720 glLoadIdentity();
@@ -724,9 +725,9 @@ void LLDrawPoolTerrain::renderFull2TU()
724 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); 725 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA);
725 726
726 // Stage 1: Write detail3 727 // Stage 1: Write detail3
727 LLViewerImage::bindTexture(detail_texture3p,1); 728 gGL.getTexUnit(1)->bind(detail_texture3p);
729 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
728 gGL.getTexUnit(1)->activate(); 730 gGL.getTexUnit(1)->activate();
729 glEnable(GL_TEXTURE_2D); // Texture unit 1
730 731
731 glEnable(GL_TEXTURE_GEN_S); 732 glEnable(GL_TEXTURE_GEN_S);
732 glEnable(GL_TEXTURE_GEN_T); 733 glEnable(GL_TEXTURE_GEN_T);
@@ -749,9 +750,9 @@ void LLDrawPoolTerrain::renderFull2TU()
749 750
750 // Disable multitexture 751 // Disable multitexture
751 752
752 LLImageGL::unbindTexture(1, GL_TEXTURE_2D); 753 gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
754 gGL.getTexUnit(1)->disable();
753 gGL.getTexUnit(1)->activate(); 755 gGL.getTexUnit(1)->activate();
754 glDisable(GL_TEXTURE_2D); // Texture unit 1
755 756
756 glDisable(GL_TEXTURE_GEN_S); 757 glDisable(GL_TEXTURE_GEN_S);
757 glDisable(GL_TEXTURE_GEN_T); 758 glDisable(GL_TEXTURE_GEN_T);
@@ -763,9 +764,8 @@ void LLDrawPoolTerrain::renderFull2TU()
763 // Restore Texture Unit 0 defaults 764 // Restore Texture Unit 0 defaults
764 765
765 gGL.getTexUnit(0)->activate(); 766 gGL.getTexUnit(0)->activate();
766 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 767 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
767 768
768 gGL.getTexUnit(0)->activate();
769 glDisable(GL_TEXTURE_GEN_S); 769 glDisable(GL_TEXTURE_GEN_S);
770 glDisable(GL_TEXTURE_GEN_T); 770 glDisable(GL_TEXTURE_GEN_T);
771 glMatrixMode(GL_TEXTURE); 771 glMatrixMode(GL_TEXTURE);
@@ -784,10 +784,10 @@ void LLDrawPoolTerrain::renderSimple()
784 784
785 // Stage 0: Base terrain texture pass 785 // Stage 0: Base terrain texture pass
786 mTexturep->addTextureStats(1024.f*1024.f); 786 mTexturep->addTextureStats(1024.f*1024.f);
787 mTexturep->bind(0);
788 787
789 gGL.getTexUnit(0)->activate(); 788 gGL.getTexUnit(0)->activate();
790 glEnable(GL_TEXTURE_2D); // Texture unit 2 789 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
790 gGL.getTexUnit(0)->bind(mTexturep.get());
791 791
792 LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent(); 792 LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent();
793 F32 tscale = 1.f/256.f; 793 F32 tscale = 1.f/256.f;
@@ -808,8 +808,8 @@ void LLDrawPoolTerrain::renderSimple()
808 //---------------------------------------------------------------------------- 808 //----------------------------------------------------------------------------
809 // Restore Texture Unit 0 defaults 809 // Restore Texture Unit 0 defaults
810 810
811 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
812 gGL.getTexUnit(0)->activate(); 811 gGL.getTexUnit(0)->activate();
812 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
813 glDisable(GL_TEXTURE_GEN_S); 813 glDisable(GL_TEXTURE_GEN_S);
814 glDisable(GL_TEXTURE_GEN_T); 814 glDisable(GL_TEXTURE_GEN_T);
815 glMatrixMode(GL_TEXTURE); 815 glMatrixMode(GL_TEXTURE);
@@ -839,7 +839,7 @@ void LLDrawPoolTerrain::renderOwnership()
839 LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay(); 839 LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay();
840 LLImageGL *texturep = overlayp->getTexture(); 840 LLImageGL *texturep = overlayp->getTexture();
841 841
842 LLViewerImage::bindTexture(texturep); 842 gGL.getTexUnit(0)->bind(texturep);
843 843
844 // *NOTE: Because the region is 256 meters wide, but has 257 pixels, the 844 // *NOTE: Because the region is 256 meters wide, but has 257 pixels, the
845 // texture coordinates for pixel 256x256 is not 1,1. This makes the 845 // texture coordinates for pixel 256x256 is not 1,1. This makes the
@@ -872,7 +872,7 @@ void LLDrawPoolTerrain::renderForSelect()
872 } 872 }
873 873
874 874
875 LLImageGL::unbindTexture(0); 875 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
876 876
877 for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); 877 for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
878 iter != mDrawFace.end(); iter++) 878 iter != mDrawFace.end(); iter++)