Changeset 3582 for trunk/src/opengl/mesa/fog_tmp.h
- Timestamp:
- May 21, 2000, 10:57:14 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/fog_tmp.h
r2938 r3582 1 /* $Id: fog_tmp.h,v 1. 1 2000-02-29 00:48:30 sandervlExp $ */1 /* $Id: fog_tmp.h,v 1.2 2000-05-21 20:46:23 jeroen Exp $ */ 2 2 3 3 /* … … 29 29 */ 30 30 static void TAG(make_fog_coord)( struct vertex_buffer *VB, 31 32 31 const GLvector4f *eye, 32 GLubyte flag) 33 33 { 34 34 const GLcontext *ctx = VB->ctx; … … 38 38 GLuint stride = eye->stride; 39 39 GLuint n = VB->Count - VB->Start; 40 GLubyte (*out)[4]; 40 GLubyte (*out)[4]; 41 41 GLfloat d; 42 42 GLuint i; … … 52 52 switch (ctx->Fog.Mode) { 53 53 case GL_LINEAR: 54 55 56 57 58 59 60 61 54 d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); 55 for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { 56 CULLCHECK { 57 GLfloat f = (end - ABSF(v[2])) * d; 58 FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f); 59 } 60 } 61 break; 62 62 case GL_EXP: 63 64 65 66 67 68 69 70 63 d = -ctx->Fog.Density; 64 for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) { 65 CULLCHECK { 66 GLfloat f = exp( d*ABSF(v[2]) ); /* already clamped */ 67 FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f); 68 } 69 } 70 break; 71 71 case GL_EXP2: 72 73 74 75 76 77 78 79 80 72 d = -(ctx->Fog.Density*ctx->Fog.Density); 73 for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { 74 CULLCHECK { 75 GLfloat z = v[2]; 76 GLfloat f = exp( d*z*z ); /* already clamped */ 77 FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f); 78 } 79 } 80 break; 81 81 default: 82 83 82 gl_problem(ctx, "Bad fog mode in make_fog_coord"); 83 return; 84 84 } 85 85 } … … 89 89 90 90 if (ctx->Fog.Mode == GL_LINEAR) { 91 92 93 94 91 GLfloat f = ctx->Fog.End * (ctx->Fog.End - ctx->Fog.Start); 92 CLAMP_FLOAT_COLOR( f ); 93 f = 1.0 - f; 94 FLOAT_COLOR_TO_UBYTE_COLOR(r, f); 95 95 } 96 96 97 97 for (i = 0 ; i < n ; i++) 98 98 out[i][3] = r; 99 99 } 100 100 } … … 105 105 106 106 #if 0 107 /* For 3.3: use fog coordinates as intermediate step in all fog107 /* TODO : use fog coordinates as intermediate step in all fog 108 108 * calculations. 109 109 */ 110 110 111 111 static void TAG(fog_rgba_vertices)( struct vertex_buffer *VB, 112 113 112 GLuint side, 113 GLubyte flag) 114 114 { 115 115 const GLcontext *ctx = VB->ctx; … … 143 143 for ( i = 0 ; i < n ; i++, STRIDE_F(spec, sp_stride), in += in_stride) { 144 144 CULLCHECK { 145 146 147 148 149 145 GLint fc = (GLint) spec[3], ifc = 255 - fc; 146 147 out[i][0] = (fc * in[0] + ifc * rFog) >> 8; 148 out[i][1] = (fc * in[1] + ifc * gFog) >> 8; 149 out[i][2] = (fc * in[2] + ifc * bFog) >> 8; 150 150 } 151 151 } … … 155 155 156 156 static void TAG(fog_ci_vertices)( struct vertex_buffer *VB, 157 158 157 GLuint side, 158 GLubyte flag ) 159 159 { 160 160 GLcontext *ctx = VB->ctx; … … 182 182 183 183 184 /* NOTE: the extensiveuse of casts generates better/faster code for MIPS */184 /* NOTE: the use of casts generates better/faster code for MIPS */ 185 185 for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride)) 186 186 CULLCHECK { … … 200 200 201 201 static void TAG(fog_rgba_vertices)( struct vertex_buffer *VB, 202 203 202 GLuint side, 203 GLubyte flag) 204 204 { 205 205 const GLcontext *ctx = VB->ctx; … … 233 233 switch (ctx->Fog.Mode) { 234 234 case GL_LINEAR: 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 235 d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); 236 for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride), in += in_stride) { 237 CULLCHECK { 238 GLfloat f = (end - ABSF(v[2])) * d; 239 if (f >= 1.0) continue; 240 if (f < 0) { 241 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][0], rFog); 242 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][1], gFog); 243 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][2], bFog); 244 } else { 245 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[0]) + (1.0F-f)*rFog; 246 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][0], t); 247 248 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[1]) + (1.0F-f)*gFog; 249 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][1], t); 250 251 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[2]) + (1.0F-f)*bFog; 252 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][2], t); 253 254 } 255 } 256 } 257 break; 258 258 case GL_EXP: 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 259 d = -ctx->Fog.Density; 260 for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride), in += in_stride) { 261 CULLCHECK { 262 GLfloat f = exp( d*ABSF(v[2]) ); /* already clamped */ 263 264 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[0]) + (1.0F-f)*rFog; 265 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][0], t); 266 267 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[1]) + (1.0F-f)*gFog; 268 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][1], t); 269 270 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[2]) + (1.0F-f)*bFog; 271 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][2], t); 272 } 273 } 274 break; 275 275 case GL_EXP2: 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 276 d = -(ctx->Fog.Density*ctx->Fog.Density); 277 for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride), in += in_stride) { 278 CULLCHECK { 279 GLfloat z = v[2]; 280 GLfloat f = exp( d*z*z ); /* already clamped */ 281 282 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[0]) + (1.0F-f)*rFog; 283 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][0], t); 284 285 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[1]) + (1.0F-f)*gFog; 286 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][1], t); 287 288 t = f * UBYTE_COLOR_TO_FLOAT_COLOR(in[2]) + (1.0F-f)*bFog; 289 CLAMPED_FLOAT_COLOR_TO_UBYTE_COLOR(out[i][2], t); 290 } 291 } 292 break; 293 default: 294 gl_problem(ctx, "Bad fog mode in gl_fog_rgba_vertices"); 295 return; 296 296 } 297 297 } … … 312 312 313 313 for (i = 0 ; i < n ; i++) { 314 315 316 317 318 314 /* CULLCHECK */ { 315 out[i][0] = r; 316 out[i][1] = g; 317 out[i][2] = b; 318 } 319 319 } 320 320 } … … 330 330 */ 331 331 static void TAG(fog_ci_vertices)( struct vertex_buffer *VB, 332 333 332 GLuint side, 333 GLubyte flag ) 334 334 { 335 335 GLcontext *ctx = VB->ctx; … … 362 362 case GL_LINEAR: 363 363 { 364 365 366 367 368 369 370 371 372 373 374 375 376 364 GLfloat d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); 365 GLfloat fogindex = ctx->Fog.Index; 366 GLfloat fogend = ctx->Fog.End; 367 368 for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride)) 369 { 370 CULLCHECK { 371 GLfloat f = (fogend - ABSF(v[2])) * d; 372 f = CLAMP( f, 0.0, 1.0 ); 373 *out = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex); 374 } 375 } 376 break; 377 377 } 378 378 case GL_EXP: 379 379 { 380 381 382 383 384 385 386 387 388 389 380 GLfloat d = -ctx->Fog.Density; 381 GLfloat fogindex = ctx->Fog.Index; 382 for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride)) 383 { 384 CULLCHECK { 385 GLfloat f = exp( d * ABSF(v[2]) ); 386 *out = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex); 387 } 388 } 389 break; 390 390 } 391 391 case GL_EXP2: 392 392 { 393 394 395 396 397 398 399 400 401 402 403 393 GLfloat d = -(ctx->Fog.Density*ctx->Fog.Density); 394 GLfloat fogindex = ctx->Fog.Index; 395 for ( i = 0; i < n ; i++, STRIDE_F(v,stride),STRIDE_UI(in,in_stride)) 396 { 397 CULLCHECK { 398 GLfloat z = v[2]; /*ABSF(v[i][2]);*/ 399 GLfloat f = exp( d * z*z ); /* was -d ??? */ 400 out[i] = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex); 401 } 402 } 403 break; 404 404 } 405 405 default: 406 407 406 gl_problem(ctx, "Bad fog mode in gl_fog_ci_vertices"); 407 return; 408 408 } 409 409 } else if (ctx->Fog.Mode == GL_LINEAR) { … … 414 414 fogindex = (GLuint)(f * ctx->Fog.Index); 415 415 if (fogindex) { 416 417 418 419 420 421 416 for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride)) 417 { 418 CULLCHECK { 419 *out = *in + fogindex; 420 } 421 } 422 422 } 423 423 }
Note:
See TracChangeset
for help on using the changeset viewer.