aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolterrain.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/lldrawpoolterrain.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/lldrawpoolterrain.cpp274
1 files changed, 127 insertions, 147 deletions
diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp
index e315259..82fcd59 100644
--- a/linden/indra/newview/lldrawpoolterrain.cpp
+++ b/linden/indra/newview/lldrawpoolterrain.cpp
@@ -52,12 +52,14 @@
52#include "llworld.h" 52#include "llworld.h"
53#include "pipeline.h" 53#include "pipeline.h"
54#include "llglslshader.h" 54#include "llglslshader.h"
55#include "llglimmediate.h"
55 56
56const F32 DETAIL_SCALE = 1.f/16.f; 57const F32 DETAIL_SCALE = 1.f/16.f;
57int DebugDetailMap = 0; 58int DebugDetailMap = 0;
58 59
59S32 LLDrawPoolTerrain::sDetailMode = 1; 60S32 LLDrawPoolTerrain::sDetailMode = 1;
60F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE; 61F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE;
62static LLGLSLShader* sShader = NULL;
61 63
62LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) : 64LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) :
63 LLFacePool(POOL_TERRAIN), 65 LLFacePool(POOL_TERRAIN),
@@ -95,10 +97,40 @@ LLDrawPool *LLDrawPoolTerrain::instancePool()
95 97
96void LLDrawPoolTerrain::prerender() 98void LLDrawPoolTerrain::prerender()
97{ 99{
98#if 0 // 1.9.2 100 mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT);
99 mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT); 101 if (mVertexShaderLevel > 0)
100#endif 102 {
101 sDetailMode = gSavedSettings.getS32("RenderTerrainDetail"); 103 sDetailMode = 1;
104 }
105 else
106 {
107 sDetailMode = gSavedSettings.getS32("RenderTerrainDetail");
108 }
109}
110
111void LLDrawPoolTerrain::beginRenderPass( S32 pass )
112{
113 LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN);
114 LLFacePool::beginRenderPass(pass);
115
116 sShader = LLPipeline::sUnderWaterRender ?
117 &gTerrainWaterProgram :
118 &gTerrainProgram;
119
120 if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0)
121 {
122 sShader->bind();
123 }
124}
125
126void LLDrawPoolTerrain::endRenderPass( S32 pass )
127{
128 LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN);
129 LLFacePool::endRenderPass(pass);
130
131 if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) {
132 sShader->unbind();
133 }
102} 134}
103 135
104//static 136//static
@@ -127,7 +159,7 @@ void LLDrawPoolTerrain::render(S32 pass)
127 159
128 if (!gGLManager.mHasMultitexture) 160 if (!gGLManager.mHasMultitexture)
129 { 161 {
130 // No mulititexture, render simple land. 162 // No multitexture, render simple land.
131 renderSimple(); // Render without multitexture 163 renderSimple(); // Render without multitexture
132 return; 164 return;
133 } 165 }
@@ -141,52 +173,47 @@ void LLDrawPoolTerrain::render(S32 pass)
141 LLGLSPipeline gls; 173 LLGLSPipeline gls;
142 LLOverrideFaceColor override(this, 1.f, 1.f, 1.f, 1.f); 174 LLOverrideFaceColor override(this, 1.f, 1.f, 1.f, 1.f);
143 175
144 if (mVertexShaderLevel > 0) 176 if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0)
145 { 177 {
146 gPipeline.enableLightsDynamic(1.f); 178 gPipeline.enableLightsDynamic();
147 renderFull4TUShader(); 179 renderFullShader();
148 } 180 }
149 else 181 else
150 { 182 {
151 gPipeline.enableLightsStatic(1.f); 183 gPipeline.enableLightsStatic();
152 switch (sDetailMode) 184
153 { 185 if (sDetailMode == 0){
154 case 0:
155 renderSimple(); 186 renderSimple();
156 break; 187 } else if (gGLManager.mNumTextureUnits < 4){
157 default: 188 renderFull2TU();
158 if (gGLManager.mNumTextureUnits < 4) 189 } else {
159 { 190 renderFull4TU();
160 renderFull2TU();
161 }
162 else
163 {
164 renderFull4TU();
165 }
166 break;
167 } 191 }
168 } 192 }
169 193
170 // Special-case for land ownership feedback 194 // Special-case for land ownership feedback
171 if (gSavedSettings.getBOOL("ShowParcelOwners")) 195 if (gSavedSettings.getBOOL("ShowParcelOwners"))
172 { 196 {
173 gPipeline.disableLights(); 197 if (mVertexShaderLevel > 1)
174 if ((mVertexShaderLevel > 0)) 198 { //use fullbright shader for highlighting
175 { 199 LLGLSLShader* old_shader = sShader;
176 gHighlightProgram.bind(); 200 sShader->unbind();
177 gHighlightProgram.vertexAttrib4f(LLShaderMgr::MATERIAL_COLOR,1,1,1,1); 201 sShader = &gObjectFullbrightProgram;
202 sShader->bind();
178 renderOwnership(); 203 renderOwnership();
179 gTerrainProgram.bind(); 204 sShader = old_shader;
205 sShader->bind();
180 } 206 }
181 else 207 else
182 { 208 {
209 gPipeline.disableLights();
183 renderOwnership(); 210 renderOwnership();
184 } 211 }
185 } 212 }
186} 213}
187 214
188 215
189void LLDrawPoolTerrain::renderFull4TUShader() 216void LLDrawPoolTerrain::renderFullShader()
190{ 217{
191 glEnableClientState(GL_VERTEX_ARRAY); 218 glEnableClientState(GL_VERTEX_ARRAY);
192 glEnableClientState(GL_NORMAL_ARRAY); 219 glEnableClientState(GL_NORMAL_ARRAY);
@@ -195,9 +222,7 @@ void LLDrawPoolTerrain::renderFull4TUShader()
195 { 222 {
196 glEnableClientState(GL_COLOR_ARRAY); 223 glEnableClientState(GL_COLOR_ARRAY);
197 } 224 }
198 225
199 glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
200
201 // Hack! Get the region that this draw pool is rendering from! 226 // Hack! Get the region that this draw pool is rendering from!
202 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); 227 LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
203 LLVLComposition *compp = regionp->getComposition(); 228 LLVLComposition *compp = regionp->getComposition();
@@ -206,12 +231,7 @@ void LLDrawPoolTerrain::renderFull4TUShader()
206 LLViewerImage *detail_texture2p = compp->mDetailTextures[2]; 231 LLViewerImage *detail_texture2p = compp->mDetailTextures[2];
207 LLViewerImage *detail_texture3p = compp->mDetailTextures[3]; 232 LLViewerImage *detail_texture3p = compp->mDetailTextures[3];
208 233
209 static F32 dp = 0.f;
210 static LLFrameTimer timer;
211 dp += timer.getElapsedTimeAndResetF32();
212
213 LLVector3d region_origin_global = gAgent.getRegion()->getOriginGlobal(); 234 LLVector3d region_origin_global = gAgent.getRegion()->getOriginGlobal();
214
215 F32 offset_x = (F32)fmod(region_origin_global.mdV[VX], 1.0/(F64)sDetailScale)*sDetailScale; 235 F32 offset_x = (F32)fmod(region_origin_global.mdV[VX], 1.0/(F64)sDetailScale)*sDetailScale;
216 F32 offset_y = (F32)fmod(region_origin_global.mdV[VY], 1.0/(F64)sDetailScale)*sDetailScale; 236 F32 offset_y = (F32)fmod(region_origin_global.mdV[VY], 1.0/(F64)sDetailScale)*sDetailScale;
217 237
@@ -220,145 +240,111 @@ void LLDrawPoolTerrain::renderFull4TUShader()
220 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x); 240 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x);
221 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y); 241 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y);
222 242
223 //----------------------------------------------------------------------------
224 // Pass 1/1
225
226 // 243 //
227 // Stage 0: detail texture 0 244 // detail texture 0
228 // 245 //
229 246 S32 detail0 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL0);
230 S32 detailTex0 = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_DETAIL0); 247 LLViewerImage::bindTexture(detail_texture0p,detail0);
231 S32 detailTex1 = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_DETAIL1);
232 S32 rampTex = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_ALPHARAMP);
233
234 LLViewerImage::bindTexture(detail_texture0p,detailTex0);
235
236 glClientActiveTextureARB(GL_TEXTURE0_ARB); 248 glClientActiveTextureARB(GL_TEXTURE0_ARB);
237 glActiveTextureARB(GL_TEXTURE0_ARB); 249 glActiveTextureARB(GL_TEXTURE0_ARB);
238 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
239 glEnable(GL_TEXTURE_GEN_S);
240 glEnable(GL_TEXTURE_GEN_T);
241 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
242 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
243
244 glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
245 glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
246 250
247 //
248 // Stage 1: Generate alpha ramp for detail0/detail1 transition
249 //
250 LLViewerImage::bindTexture(m2DAlphaRampImagep,rampTex);
251
252 glClientActiveTextureARB(GL_TEXTURE1_ARB);
253 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
254
255 //
256 // Stage 2: Interpolate detail1 with existing based on ramp
257 //
258 LLViewerImage::bindTexture(detail_texture1p,detailTex1);
259
260 glClientActiveTextureARB(GL_TEXTURE2_ARB);
261 glActiveTextureARB(GL_TEXTURE2_ARB);
262 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 251 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
263 glEnable(GL_TEXTURE_GEN_S); 252 glEnable(GL_TEXTURE_GEN_S);
264 glEnable(GL_TEXTURE_GEN_T); 253 glEnable(GL_TEXTURE_GEN_T);
265 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 254 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
266 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 255 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
267 glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
268 glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
269 256
270 //
271 // Stage 3: Modulate with primary color for lighting
272 //
273 //LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture
274 //glEnable(GL_TEXTURE_2D); // Texture unit 3
275 glClientActiveTextureARB(GL_TEXTURE3_ARB);
276 glActiveTextureARB(GL_TEXTURE3_ARB);
277 // GL_BLEND disabled by default
278 drawLoop();
279
280 //----------------------------------------------------------------------------
281 // Second pass
282
283 //
284 // Stage 0: Write detail3 into base
285 //
286 LLViewerImage::bindTexture(detail_texture2p,detailTex0);
287
288 glClientActiveTextureARB(GL_TEXTURE0_ARB);
289 glActiveTextureARB(GL_TEXTURE0_ARB);
290 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
291 glEnable(GL_TEXTURE_GEN_S);
292 glEnable(GL_TEXTURE_GEN_T);
293 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
294 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
295 glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV); 257 glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
296 glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV); 258 glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
259 glMatrixMode(GL_TEXTURE);
260 glLoadIdentity();
261 glMatrixMode(GL_MODELVIEW);
297 262
298 // 263 //
299 // Stage 1: Generate alpha ramp for detail2/detail3 transition 264 // detail texture 1
300 // 265 //
301 LLViewerImage::bindTexture(m2DAlphaRampImagep,rampTex); 266 S32 detail1 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL1);
267 LLViewerImage::bindTexture(detail_texture1p,detail1);
302 268
269 /// ALPHA TEXTURE COORDS 0:
303 glClientActiveTextureARB(GL_TEXTURE1_ARB); 270 glClientActiveTextureARB(GL_TEXTURE1_ARB);
304 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
305 glActiveTextureARB(GL_TEXTURE1_ARB); 271 glActiveTextureARB(GL_TEXTURE1_ARB);
306 272 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
307 // Set the texture matrix
308 glMatrixMode(GL_TEXTURE); 273 glMatrixMode(GL_TEXTURE);
309 glLoadIdentity(); 274 glLoadIdentity();
310 glTranslatef(-2.f, 0.f, 0.f); 275 glMatrixMode(GL_MODELVIEW);
311 276
312 // 277 // detail texture 2
313 // Stage 2: Interpolate detail2 with existing based on ramp
314 // 278 //
315 LLViewerImage::bindTexture(detail_texture3p,detailTex1); 279 S32 detail2 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL2);
280 LLViewerImage::bindTexture(detail_texture2p,detail2);
281 glEnable(GL_TEXTURE_2D);
316 282
283 /// ALPHA TEXTURE COORDS 1:
317 glClientActiveTextureARB(GL_TEXTURE2_ARB); 284 glClientActiveTextureARB(GL_TEXTURE2_ARB);
318 glActiveTextureARB(GL_TEXTURE2_ARB); 285 glActiveTextureARB(GL_TEXTURE2_ARB);
319 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 286 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
320 glEnable(GL_TEXTURE_GEN_S); 287 glMatrixMode(GL_TEXTURE);
321 glEnable(GL_TEXTURE_GEN_T); 288 glLoadIdentity();
322 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 289 glTranslatef(-2.f, 0.f, 0.f);
323 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 290 glMatrixMode(GL_MODELVIEW);
324 glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
325 glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
326 291
327 // 292 //
328 // Stage 3: Generate alpha ramp for detail1/detail2 transition 293 // detail texture 3
329 // 294 //
330 //LLViewerImage::bindTexture(m2DAlphaRampImagep,3); 295 S32 detail3 = sShader->enableTexture(LLShaderMgr::TERRAIN_DETAIL3);
331 296 LLViewerImage::bindTexture(detail_texture3p,detail3);
332 //glEnable(GL_TEXTURE_2D); // Texture unit 3
333 297
298 /// ALPHA TEXTURE COORDS 2:
334 glClientActiveTextureARB(GL_TEXTURE3_ARB); 299 glClientActiveTextureARB(GL_TEXTURE3_ARB);
335 glActiveTextureARB(GL_TEXTURE3_ARB); 300 glActiveTextureARB(GL_TEXTURE3_ARB);
336 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 301 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
337
338 // Set the texture matrix
339 glMatrixMode(GL_TEXTURE); 302 glMatrixMode(GL_TEXTURE);
340 glLoadIdentity(); 303 glLoadIdentity();
341 glTranslatef(-1.f, 0.f, 0.f); 304 glTranslatef(-1.f, 0.f, 0.f);
305 glMatrixMode(GL_MODELVIEW);
342 306
343 { 307 //
344 LLGLEnable blend(GL_BLEND); 308 // Alpha Ramp
345 drawLoop(); 309 //
346 } 310 S32 alpha_ramp = sShader->enableTexture(LLShaderMgr::TERRAIN_ALPHARAMP);
311 LLViewerImage::bindTexture(m2DAlphaRampImagep,alpha_ramp);
312
313 // GL_BLEND disabled by default
314 drawLoop();
347 315
348 // Disable multitexture 316 // Disable multitexture
349 gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_ALPHARAMP); 317 sShader->disableTexture(LLShaderMgr::TERRAIN_ALPHARAMP);
350 gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_DETAIL0); 318 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL0);
351 gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_DETAIL1); 319 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL1);
352 320 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL2);
321 sShader->disableTexture(LLShaderMgr::TERRAIN_DETAIL3);
322
323 LLImageGL::unbindTexture(alpha_ramp, GL_TEXTURE_2D);
324 glClientActiveTextureARB(GL_TEXTURE4_ARB);
325 glActiveTextureARB(GL_TEXTURE4_ARB);
326 glDisable(GL_TEXTURE_2D); // Texture unit 4
327 glDisable(GL_TEXTURE_GEN_S);
328 glDisable(GL_TEXTURE_GEN_T);
329 glMatrixMode(GL_TEXTURE);
330 glLoadIdentity();
331 glMatrixMode(GL_MODELVIEW);
332
333 LLImageGL::unbindTexture(detail3, GL_TEXTURE_2D);
353 glClientActiveTextureARB(GL_TEXTURE3_ARB); 334 glClientActiveTextureARB(GL_TEXTURE3_ARB);
354 glActiveTextureARB(GL_TEXTURE3_ARB); 335 glActiveTextureARB(GL_TEXTURE3_ARB);
336 glDisable(GL_TEXTURE_2D);
355 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 337 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
338 glDisable(GL_TEXTURE_GEN_S);
339 glDisable(GL_TEXTURE_GEN_T);
356 glMatrixMode(GL_TEXTURE); 340 glMatrixMode(GL_TEXTURE);
357 glLoadIdentity(); 341 glLoadIdentity();
358 glMatrixMode(GL_MODELVIEW); 342 glMatrixMode(GL_MODELVIEW);
359 343
344 LLImageGL::unbindTexture(detail2, GL_TEXTURE_2D);
360 glClientActiveTextureARB(GL_TEXTURE2_ARB); 345 glClientActiveTextureARB(GL_TEXTURE2_ARB);
361 glActiveTextureARB(GL_TEXTURE2_ARB); 346 glActiveTextureARB(GL_TEXTURE2_ARB);
347 glDisable(GL_TEXTURE_2D);
362 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 348 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
363 glDisable(GL_TEXTURE_GEN_S); 349 glDisable(GL_TEXTURE_GEN_S);
364 glDisable(GL_TEXTURE_GEN_T); 350 glDisable(GL_TEXTURE_GEN_T);
@@ -366,32 +352,32 @@ void LLDrawPoolTerrain::renderFull4TUShader()
366 glLoadIdentity(); 352 glLoadIdentity();
367 glMatrixMode(GL_MODELVIEW); 353 glMatrixMode(GL_MODELVIEW);
368 354
355 LLImageGL::unbindTexture(detail1, GL_TEXTURE_2D);
369 glClientActiveTextureARB(GL_TEXTURE1_ARB); 356 glClientActiveTextureARB(GL_TEXTURE1_ARB);
370 glActiveTextureARB(GL_TEXTURE1_ARB); 357 glActiveTextureARB(GL_TEXTURE1_ARB);
371 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 358 glDisable(GL_TEXTURE_2D);
359 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
360 glDisable(GL_TEXTURE_GEN_S);
361 glDisable(GL_TEXTURE_GEN_T);
372 glMatrixMode(GL_TEXTURE); 362 glMatrixMode(GL_TEXTURE);
373 glLoadIdentity(); 363 glLoadIdentity();
374 glMatrixMode(GL_MODELVIEW); 364 glMatrixMode(GL_MODELVIEW);
375
376 // Restore blend state
377 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
378 365
379 //---------------------------------------------------------------------------- 366 //----------------------------------------------------------------------------
380 // Restore Texture Unit 0 defaults 367 // Restore Texture Unit 0 defaults
381 368
369 LLImageGL::unbindTexture(detail0, GL_TEXTURE_2D);
382 glClientActiveTextureARB(GL_TEXTURE0_ARB); 370 glClientActiveTextureARB(GL_TEXTURE0_ARB);
383 glActiveTextureARB(GL_TEXTURE0_ARB); 371 glActiveTextureARB(GL_TEXTURE0_ARB);
372 glEnable(GL_TEXTURE_2D);
384 glDisable(GL_TEXTURE_GEN_S); 373 glDisable(GL_TEXTURE_GEN_S);
385 glDisable(GL_TEXTURE_GEN_T); 374 glDisable(GL_TEXTURE_GEN_T);
386 glEnable(GL_TEXTURE_2D);
387 glMatrixMode(GL_TEXTURE); 375 glMatrixMode(GL_TEXTURE);
388 glLoadIdentity(); 376 glLoadIdentity();
389 glMatrixMode(GL_MODELVIEW); 377 glMatrixMode(GL_MODELVIEW);
390 378
391 // Restore non Texture Unit specific defaults 379 // Restore non Texture Unit specific defaults
392 glDisableClientState(GL_NORMAL_ARRAY); 380 glDisableClientState(GL_NORMAL_ARRAY);
393 glDisableClientState(GL_COLOR_ARRAY);
394 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
395} 381}
396 382
397void LLDrawPoolTerrain::renderFull4TU() 383void LLDrawPoolTerrain::renderFull4TU()
@@ -416,7 +402,7 @@ void LLDrawPoolTerrain::renderFull4TU()
416 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x); 402 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x);
417 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y); 403 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y);
418 404
419 glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); 405 gGL.blendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
420 406
421 //---------------------------------------------------------------------------- 407 //----------------------------------------------------------------------------
422 // Pass 1/1 408 // Pass 1/1
@@ -649,7 +635,7 @@ void LLDrawPoolTerrain::renderFull4TU()
649 glMatrixMode(GL_MODELVIEW); 635 glMatrixMode(GL_MODELVIEW);
650 636
651 // Restore blend state 637 // Restore blend state
652 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 638 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
653 639
654 //---------------------------------------------------------------------------- 640 //----------------------------------------------------------------------------
655 // Restore Texture Unit 0 defaults 641 // Restore Texture Unit 0 defaults
@@ -690,7 +676,7 @@ void LLDrawPoolTerrain::renderFull2TU()
690 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x); 676 tp0.setVec(sDetailScale, 0.0f, 0.0f, offset_x);
691 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y); 677 tp1.setVec(0.0f, sDetailScale, 0.0f, offset_y);
692 678
693 glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); 679 gGL.blendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
694 680
695 //---------------------------------------------------------------------------- 681 //----------------------------------------------------------------------------
696 // Pass 1/4 682 // Pass 1/4
@@ -887,7 +873,7 @@ void LLDrawPoolTerrain::renderFull2TU()
887 } 873 }
888 874
889 // Restore blend state 875 // Restore blend state
890 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 876 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
891 877
892 // Disable multitexture 878 // Disable multitexture
893 LLImageGL::unbindTexture(1, GL_TEXTURE_2D); 879 LLImageGL::unbindTexture(1, GL_TEXTURE_2D);
@@ -1015,7 +1001,6 @@ void LLDrawPoolTerrain::renderOwnership()
1015 1001
1016 const F32 TEXTURE_FUDGE = 257.f / 256.f; 1002 const F32 TEXTURE_FUDGE = 257.f / 256.f;
1017 glScalef( TEXTURE_FUDGE, TEXTURE_FUDGE, 1.f ); 1003 glScalef( TEXTURE_FUDGE, TEXTURE_FUDGE, 1.f );
1018
1019 for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); 1004 for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
1020 iter != mDrawFace.end(); iter++) 1005 iter != mDrawFace.end(); iter++)
1021 { 1006 {
@@ -1082,8 +1067,3 @@ LLColor3 LLDrawPoolTerrain::getDebugColor() const
1082{ 1067{
1083 return LLColor3(0.f, 0.f, 1.f); 1068 return LLColor3(0.f, 0.f, 1.f);
1084} 1069}
1085
1086S32 LLDrawPoolTerrain::getMaterialAttribIndex()
1087{
1088 return gTerrainProgram.mAttribute[LLShaderMgr::MATERIAL_COLOR];
1089}