Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

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:24 jeroen Exp $ */
     1/* $Id: clip.c,v 1.3 2000-05-23 20:40:25 jeroen Exp $ */
    22
    33/*
    44 * Mesa 3-D graphics library
    5  * Version:  3.1
     5 * Version:  3.3
    66 *
    77 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
     
    3232#include "all.h"
    3333#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"
    4135#include "clip.h"
    4236#include "types.h"
     
    6660
    6761
    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 )                       \
     63do {                                                            \
     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   }                                                            \
    7670} while(0)
    7771
     
    176170
    177171
    178 void gl_ClipPlane( GLcontext* ctx, GLenum plane, const GLfloat *equation )
    179 {
     172void
     173_mesa_ClipPlane( GLenum plane, const GLdouble *eq )
     174{
     175   GET_CURRENT_CONTEXT(ctx);
    180176   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];
    181183
    182184   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClipPlane");
     
    200202   }
    201203   gl_transform_vector( ctx->Transform.EyeUserPlane[p], equation,
    202                         ctx->ModelView.inv );
     204                        ctx->ModelView.inv );
    203205
    204206
     
    207209
    208210      if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
    209         gl_matrix_analyze( &ctx->ProjectionMatrix );
     211        gl_matrix_analyze( &ctx->ProjectionMatrix );
    210212      }
    211213      gl_transform_vector( ctx->Transform.ClipUserPlane[p],
    212                            ctx->Transform.EyeUserPlane[p],
    213                            ctx->ProjectionMatrix.inv );
     214                           ctx->Transform.EyeUserPlane[p],
     215                           ctx->ProjectionMatrix.inv );
    214216   }
    215217}
     
    222224   for (p = 0 ; p < MAX_CLIP_PLANES ; p++) {
    223225      if (ctx->Transform.ClipEnabled[p]) {
    224         gl_transform_vector( ctx->Transform.ClipUserPlane[p],
    225                               ctx->Transform.EyeUserPlane[p],
    226                               ctx->ProjectionMatrix.inv );
     226        gl_transform_vector( ctx->Transform.ClipUserPlane[p],
     227                              ctx->Transform.EyeUserPlane[p],
     228                              ctx->ProjectionMatrix.inv );
    227229      }
    228230   }
    229231}
    230232
    231 void gl_GetClipPlane( GLcontext* ctx, GLenum plane, GLdouble *equation )
    232 {
     233void
     234_mesa_GetClipPlane( GLenum plane, GLdouble *equation )
     235{
     236   GET_CURRENT_CONTEXT(ctx);
    233237   GLint p;
    234238
     
    286290   for (p=0;p<MAX_CLIP_PLANES;p++) {
    287291      if (ctx->Transform.ClipEnabled[p]) {
    288         GLfloat dot = v[0] * ctx->Transform.ClipUserPlane[p][0]
    289                      + v[1] * ctx->Transform.ClipUserPlane[p][1]
    290                      + v[2] * ctx->Transform.ClipUserPlane[p][2]
    291                      + v[3] * ctx->Transform.ClipUserPlane[p][3];
     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];
    292296         if (dot < 0.0F) {
    293297            return 0;
     
    377381      if (ctx->Light.ShadeModel==GL_SMOOTH)
    378382      {
    379         mask |= CLIP_RGBA0;
    380 
    381         if (ctx->TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR))
    382             mask |= CLIP_RGBA1;
     383        mask |= CLIP_RGBA0;
     384
     385        if (ctx->TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR))
     386            mask |= CLIP_RGBA1;
    383387      }
    384388
    385389      if (ctx->Texture.ReallyEnabled & 0xf0)
    386         mask |= CLIP_TEX1|CLIP_TEX0;
     390        mask |= CLIP_TEX1|CLIP_TEX0;
    387391
    388392      if (ctx->Texture.ReallyEnabled & 0xf)
    389         mask |= CLIP_TEX0;
     393        mask |= CLIP_TEX0;
    390394   }
    391395   else if (ctx->Light.ShadeModel==GL_SMOOTH)
     
    394398
    395399      if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
    396         mask |= CLIP_INDEX1;
     400        mask |= CLIP_INDEX1;
    397401   }
    398402
     
    411415
    412416
    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)                                         \
     418static 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
     464USER_CLIPTEST(userclip2, 2)
     465USER_CLIPTEST(userclip3, 3)
     466USER_CLIPTEST(userclip4, 4)
    463467
    464468static void (*(usercliptab[5]))( struct vertex_buffer * ) = {
Note: See TracChangeset for help on using the changeset viewer.