Changeset 3598 for trunk/src/opengl/mesa/clip.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/clip.c
r2962 r3598 1 /* $Id: clip.c,v 1. 2 2000-03-01 18:49:24jeroen Exp $ */1 /* $Id: clip.c,v 1.3 2000-05-23 20:40:25 jeroen Exp $ */ 2 2 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 32 32 #include "all.h" 33 33 #else 34 #ifndef XFree86Server 35 #include <string.h> 36 #include <stdlib.h> 37 #include <stdio.h> 38 #else 39 #include "GL/xf86glx.h" 40 #endif 34 #include "glheader.h" 41 35 #include "clip.h" 42 36 #include "types.h" … … 66 60 67 61 68 #define INTERP_SZ( t, vec, to, a, b, sz ) 69 do { 70 switch (sz) { 71 case 4: vec[to][3] = LINTERP( t, vec[a][3], vec[b][3] ); 72 case 3: vec[to][2] = LINTERP( t, vec[a][2], vec[b][2] ); 73 case 2: vec[to][1] = LINTERP( t, vec[a][1], vec[b][1] ); 74 case 1: vec[to][0] = LINTERP( t, vec[a][0], vec[b][0] ); 75 } 62 #define INTERP_SZ( t, vec, to, a, b, sz ) \ 63 do { \ 64 switch (sz) { \ 65 case 4: vec[to][3] = LINTERP( t, vec[a][3], vec[b][3] ); \ 66 case 3: vec[to][2] = LINTERP( t, vec[a][2], vec[b][2] ); \ 67 case 2: vec[to][1] = LINTERP( t, vec[a][1], vec[b][1] ); \ 68 case 1: vec[to][0] = LINTERP( t, vec[a][0], vec[b][0] ); \ 69 } \ 76 70 } while(0) 77 71 … … 176 170 177 171 178 void gl_ClipPlane( GLcontext* ctx, GLenum plane, const GLfloat *equation ) 179 { 172 void 173 _mesa_ClipPlane( GLenum plane, const GLdouble *eq ) 174 { 175 GET_CURRENT_CONTEXT(ctx); 180 176 GLint p; 177 GLfloat equation[4]; 178 179 equation[0] = eq[0]; 180 equation[1] = eq[1]; 181 equation[2] = eq[2]; 182 equation[3] = eq[3]; 181 183 182 184 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClipPlane"); … … 200 202 } 201 203 gl_transform_vector( ctx->Transform.EyeUserPlane[p], equation, 202 204 ctx->ModelView.inv ); 203 205 204 206 … … 207 209 208 210 if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) { 209 211 gl_matrix_analyze( &ctx->ProjectionMatrix ); 210 212 } 211 213 gl_transform_vector( ctx->Transform.ClipUserPlane[p], 212 213 214 ctx->Transform.EyeUserPlane[p], 215 ctx->ProjectionMatrix.inv ); 214 216 } 215 217 } … … 222 224 for (p = 0 ; p < MAX_CLIP_PLANES ; p++) { 223 225 if (ctx->Transform.ClipEnabled[p]) { 224 225 226 226 gl_transform_vector( ctx->Transform.ClipUserPlane[p], 227 ctx->Transform.EyeUserPlane[p], 228 ctx->ProjectionMatrix.inv ); 227 229 } 228 230 } 229 231 } 230 232 231 void gl_GetClipPlane( GLcontext* ctx, GLenum plane, GLdouble *equation ) 232 { 233 void 234 _mesa_GetClipPlane( GLenum plane, GLdouble *equation ) 235 { 236 GET_CURRENT_CONTEXT(ctx); 233 237 GLint p; 234 238 … … 286 290 for (p=0;p<MAX_CLIP_PLANES;p++) { 287 291 if (ctx->Transform.ClipEnabled[p]) { 288 289 290 291 292 GLfloat dot = v[0] * ctx->Transform.ClipUserPlane[p][0] 293 + v[1] * ctx->Transform.ClipUserPlane[p][1] 294 + v[2] * ctx->Transform.ClipUserPlane[p][2] 295 + v[3] * ctx->Transform.ClipUserPlane[p][3]; 292 296 if (dot < 0.0F) { 293 297 return 0; … … 377 381 if (ctx->Light.ShadeModel==GL_SMOOTH) 378 382 { 379 380 381 382 383 mask |= CLIP_RGBA0; 384 385 if (ctx->TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR)) 386 mask |= CLIP_RGBA1; 383 387 } 384 388 385 389 if (ctx->Texture.ReallyEnabled & 0xf0) 386 390 mask |= CLIP_TEX1|CLIP_TEX0; 387 391 388 392 if (ctx->Texture.ReallyEnabled & 0xf) 389 393 mask |= CLIP_TEX0; 390 394 } 391 395 else if (ctx->Light.ShadeModel==GL_SMOOTH) … … 394 398 395 399 if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) 396 400 mask |= CLIP_INDEX1; 397 401 } 398 402 … … 411 415 412 416 413 #define USER_CLIPTEST(NAME, SZ) 414 static void NAME( struct vertex_buffer *VB ) 415 { 416 GLcontext *ctx = VB->ctx; 417 GLubyte *clipMask = VB->ClipMask; 418 GLubyte *userClipMask = VB->UserClipMask; 419 GLuint start = VB->Start; 420 GLuint count = VB->Count; 421 GLuint p, i; 422 GLubyte bit; 423 424 425 for (bit = 1, p = 0; p < MAX_CLIP_PLANES ; p++, bit *=2) 426 if (ctx->Transform.ClipEnabled[p]) { 427 GLuint nr = 0;\428 const GLfloat a = ctx->Transform.ClipUserPlane[p][0];\429 const GLfloat b = ctx->Transform.ClipUserPlane[p][1];\430 const GLfloat c = ctx->Transform.ClipUserPlane[p][2];\431 const GLfloat d = ctx->Transform.ClipUserPlane[p][3];\432 GLfloat *coord = VB->ClipPtr->start; 433 GLuint stride = VB->ClipPtr->stride; 434 435 for (i = start ; i < count ; i++, STRIDE_F(coord, stride)) {\436 GLfloat dp = coord[0] * a + coord[1] * b;\437 if (SZ > 2) dp += coord[2] * c;\438 if (SZ > 3) dp += coord[3] * d; else dp += d;\439 440 if (dp < 0) {\441 clipMask[i] |= CLIP_USER_BIT;\442 userClipMask[i] |= bit;\443 nr++;\444 }\445 }\446 447 if (nr > 0) {\448 VB->ClipOrMask |= CLIP_USER_BIT;\449 VB->CullMode |= CLIP_MASK_ACTIVE;\450 if (nr == count - start) {\451 VB->ClipAndMask |= CLIP_USER_BIT;\452 VB->Culled = 1;\453 return;\454 }\455 }\456 } 457 } 458 459 460 USER_CLIPTEST(userclip2, 2) 461 USER_CLIPTEST(userclip3, 3) 462 USER_CLIPTEST(userclip4, 4) 417 #define USER_CLIPTEST(NAME, SZ) \ 418 static void NAME( struct vertex_buffer *VB ) \ 419 { \ 420 GLcontext *ctx = VB->ctx; \ 421 GLubyte *clipMask = VB->ClipMask; \ 422 GLubyte *userClipMask = VB->UserClipMask; \ 423 GLuint start = VB->Start; \ 424 GLuint count = VB->Count; \ 425 GLuint p, i; \ 426 GLubyte bit; \ 427 \ 428 \ 429 for (bit = 1, p = 0; p < MAX_CLIP_PLANES ; p++, bit *=2) \ 430 if (ctx->Transform.ClipEnabled[p]) { \ 431 GLuint nr = 0; \ 432 const GLfloat a = ctx->Transform.ClipUserPlane[p][0]; \ 433 const GLfloat b = ctx->Transform.ClipUserPlane[p][1]; \ 434 const GLfloat c = ctx->Transform.ClipUserPlane[p][2]; \ 435 const GLfloat d = ctx->Transform.ClipUserPlane[p][3]; \ 436 GLfloat *coord = VB->ClipPtr->start; \ 437 GLuint stride = VB->ClipPtr->stride; \ 438 \ 439 for (i = start ; i < count ; i++, STRIDE_F(coord, stride)) { \ 440 GLfloat dp = coord[0] * a + coord[1] * b; \ 441 if (SZ > 2) dp += coord[2] * c; \ 442 if (SZ > 3) dp += coord[3] * d; else dp += d; \ 443 \ 444 if (dp < 0) { \ 445 clipMask[i] |= CLIP_USER_BIT; \ 446 userClipMask[i] |= bit; \ 447 nr++; \ 448 } \ 449 } \ 450 \ 451 if (nr > 0) { \ 452 VB->ClipOrMask |= CLIP_USER_BIT; \ 453 VB->CullMode |= CLIP_MASK_ACTIVE; \ 454 if (nr == count - start) { \ 455 VB->ClipAndMask |= CLIP_USER_BIT; \ 456 VB->Culled = 1; \ 457 return; \ 458 } \ 459 } \ 460 } \ 461 } 462 463 464 USER_CLIPTEST(userclip2, 2) 465 USER_CLIPTEST(userclip3, 3) 466 USER_CLIPTEST(userclip4, 4) 463 467 464 468 static void (*(usercliptab[5]))( struct vertex_buffer * ) = {
Note:
See TracChangeset
for help on using the changeset viewer.