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/3dfx/fxtritmp.h

    r2938 r3598  
    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.
     
    4949   struct vertex_buffer *VB=ctx->VB;
    5050   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    51    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     51   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    5252   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    5353   GrVertex *v3 = (GrVertex *)gWin[e3].f;
     
    5555   (void) fxMesa;
    5656
    57    if (IND & (FX_TWOSIDE|FX_OFFSET)) 
     57   if (IND & (FX_TWOSIDE|FX_OFFSET))
    5858   {
    5959      GLfloat ex = v1->x - v3->x;
     
    6262      GLfloat fy = v2->y - v3->y;
    6363      GLfloat c = ex*fy-ey*fx;
    64          
     64
    6565      if (IND & FX_TWOSIDE) {
    66         GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
    67         GLubyte (*color)[4] = VB->Color[facing]->data;
    68         if (IND & FX_FLAT) {
    69             FX_VB_COLOR(fxMesa, color[pv]);
    70         } else {
    71             GOURAUD2(v1,color[e1]);
    72             GOURAUD2(v2,color[e2]);
    73             GOURAUD2(v3,color[e3]);
    74         }
    75       }
    76      
     66        GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
     67        GLubyte (*color)[4] = VB->Color[facing]->data;
     68        if (IND & FX_FLAT) {
     69            FX_VB_COLOR(fxMesa, color[pv]);
     70        } else {
     71            GOURAUD2(v1,color[e1]);
     72            GOURAUD2(v2,color[e2]);
     73            GOURAUD2(v3,color[e3]);
     74        }
     75      }
     76
    7777      /* Should apply a factor to ac to compensate for different x/y
    7878       * scaling introduced in the Viewport matrix.
     
    8181       */
    8282      if (IND & FX_OFFSET) {
    83         GLfloat offset = ctx->Polygon.OffsetUnits;
    84 
    85         if (c * c > 1e-16) {
    86             GLfloat factor = ctx->Polygon.OffsetFactor;
    87             GLfloat ez = v1->ooz - v3->ooz;
    88             GLfloat fz = v2->ooz - v3->ooz;
    89             GLfloat a = ey*fz-ez*fy;
    90             GLfloat b = ez*fx-ex*fz;
    91             GLfloat ic = 1.0 / c;
    92             GLfloat ac = a * ic;
    93             GLfloat bc = b * ic;
    94             if (ac<0.0F)  ac = -ac;
    95             if (bc<0.0F)  bc = -bc;
    96             offset += MAX2( ac, bc ) * factor;
    97         }
    98         /* Probably a lot quicker just to nudge the z values and put
    99           * them back afterwards.
    100           */
    101         FX_grDepthBiasLevel((int)offset);
     83        GLfloat offset = ctx->Polygon.OffsetUnits;
     84
     85        if (c * c > 1e-16) {
     86            GLfloat factor = ctx->Polygon.OffsetFactor;
     87            GLfloat ez = v1->ooz - v3->ooz;
     88            GLfloat fz = v2->ooz - v3->ooz;
     89            GLfloat a = ey*fz-ez*fy;
     90            GLfloat b = ez*fx-ex*fz;
     91            GLfloat ic = 1.0 / c;
     92            GLfloat ac = a * ic;
     93            GLfloat bc = b * ic;
     94            if (ac<0.0F)  ac = -ac;
     95            if (bc<0.0F)  bc = -bc;
     96            offset += MAX2( ac, bc ) * factor;
     97        }
     98        /* Probably a lot quicker just to nudge the z values and put
     99          * them back afterwards.
     100          */
     101        FX_grDepthBiasLevel((int)offset);
    102102      }
    103103   }
     
    109109   if (IND & FX_FRONT_BACK) {
    110110      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    111                   ctx->Color.ColorMask[GCOMP] ||
    112                   ctx->Color.ColorMask[BCOMP],
    113                   FXFALSE);
     111                  ctx->Color.ColorMask[GCOMP] ||
     112                  ctx->Color.ColorMask[BCOMP],
     113                  FXFALSE);
    114114
    115115      FX_grDepthMask(FXFALSE);
     
    117117   }
    118118
    119    if (IND & FX_ANTIALIAS) 
     119   if (IND & FX_ANTIALIAS)
    120120      FX_grAADrawTriangle(v1, v2, v3, FXTRUE, FXTRUE, FXTRUE);
    121    else 
     121   else
    122122      FX_grDrawTriangle(v1, v2, v3);
    123123
     
    126126   if (IND & FX_FRONT_BACK) {
    127127      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    128                   ctx->Color.ColorMask[GCOMP] ||
    129                   ctx->Color.ColorMask[BCOMP],
    130                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     128                  ctx->Color.ColorMask[GCOMP] ||
     129                  ctx->Color.ColorMask[BCOMP],
     130                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    131131
    132132      if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
     
    135135
    136136      if (IND & FX_ANTIALIAS)
    137         FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE);
     137        FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE);
    138138      else
    139         FX_grDrawTriangle(v1, v2, v3);
    140    }   
     139        FX_grDrawTriangle(v1, v2, v3);
     140   }
    141141}
    142142
     
    145145 */
    146146static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3,
    147                         GLuint e4, GLuint pv)
     147                        GLuint e4, GLuint pv)
    148148{
    149149   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
    150150   struct vertex_buffer *VB=ctx->VB;
    151151   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    152    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     152   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    153153   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    154154   GrVertex *v3 = (GrVertex *)gWin[e3].f;
     
    157157   (void) fxMesa;
    158158
    159    if (IND & (FX_TWOSIDE|FX_OFFSET)) 
     159   if (IND & (FX_TWOSIDE|FX_OFFSET))
    160160   {
    161161      GLfloat ex = v3->x - v1->x;
     
    164164      GLfloat fy = v4->y - v2->y;
    165165      GLfloat c = ex*fy-ey*fx;
    166          
     166
    167167      if (IND & FX_TWOSIDE) {
    168         GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
    169         GLubyte (*color)[4] = VB->Color[facing]->data;
    170         if (IND & FX_FLAT) {
    171             FX_VB_COLOR(fxMesa, color[pv]);
    172         } else {
    173             GOURAUD2(v1,color[e1]);
    174             GOURAUD2(v2,color[e2]);
    175             GOURAUD2(v3,color[e3]);
    176             GOURAUD2(v4,color[e4]);
    177         }
    178       }
    179      
     168        GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
     169        GLubyte (*color)[4] = VB->Color[facing]->data;
     170        if (IND & FX_FLAT) {
     171            FX_VB_COLOR(fxMesa, color[pv]);
     172        } else {
     173            GOURAUD2(v1,color[e1]);
     174            GOURAUD2(v2,color[e2]);
     175            GOURAUD2(v3,color[e3]);
     176            GOURAUD2(v4,color[e4]);
     177        }
     178      }
     179
    180180      /* Should apply a factor to ac to compensate for different x/y
    181181       * scaling introduced in the Viewport matrix.
     
    184184       */
    185185      if (IND & FX_OFFSET) {
    186         GLfloat offset = ctx->Polygon.OffsetUnits;
    187 
    188         if (c * c > 1e-16) {
    189             GLfloat factor = ctx->Polygon.OffsetFactor;
    190             GLfloat ez = v3->ooz - v1->ooz;
    191             GLfloat fz = v4->ooz - v2->ooz;
    192             GLfloat a = ey*fz-ez*fy;
    193             GLfloat b = ez*fx-ex*fz;
    194             GLfloat ic = 1.0 / c;
    195             GLfloat ac = a * ic;
    196             GLfloat bc = b * ic;
    197             if (ac<0.0F)  ac = -ac;
    198             if (bc<0.0F)  bc = -bc;
    199             offset += MAX2( ac, bc ) * factor;
    200         }
    201         /* Probably a lot quicker just to nudge the z values and put
    202           * them back afterwards.
    203           */
    204         FX_grDepthBiasLevel((int)offset);
     186        GLfloat offset = ctx->Polygon.OffsetUnits;
     187
     188        if (c * c > 1e-16) {
     189            GLfloat factor = ctx->Polygon.OffsetFactor;
     190            GLfloat ez = v3->ooz - v1->ooz;
     191            GLfloat fz = v4->ooz - v2->ooz;
     192            GLfloat a = ey*fz-ez*fy;
     193            GLfloat b = ez*fx-ex*fz;
     194            GLfloat ic = 1.0 / c;
     195            GLfloat ac = a * ic;
     196            GLfloat bc = b * ic;
     197            if (ac<0.0F)  ac = -ac;
     198            if (bc<0.0F)  bc = -bc;
     199            offset += MAX2( ac, bc ) * factor;
     200        }
     201        /* Probably a lot quicker just to nudge the z values and put
     202          * them back afterwards.
     203          */
     204        FX_grDepthBiasLevel((int)offset);
    205205      }
    206206   }
     
    212212   if (IND & FX_FRONT_BACK) {
    213213      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    214                   ctx->Color.ColorMask[GCOMP] ||
    215                   ctx->Color.ColorMask[BCOMP],
    216                   FXFALSE);
     214                  ctx->Color.ColorMask[GCOMP] ||
     215                  ctx->Color.ColorMask[BCOMP],
     216                  FXFALSE);
    217217
    218218      FX_grDepthMask(FXFALSE);
     
    232232   if (IND & FX_FRONT_BACK) {
    233233      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    234                   ctx->Color.ColorMask[GCOMP] ||
    235                   ctx->Color.ColorMask[BCOMP],
    236                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     234                  ctx->Color.ColorMask[GCOMP] ||
     235                  ctx->Color.ColorMask[BCOMP],
     236                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    237237
    238238      if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
     
    241241
    242242      if (IND & FX_ANTIALIAS) {
    243         FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
    244         FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
     243        FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
     244        FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
    245245      } else {
    246         FX_grDrawTriangle(v1, v2, v4);
    247         FX_grDrawTriangle(v2, v3, v4);
    248       }
    249    }   
     246        FX_grDrawTriangle(v1, v2, v4);
     247        FX_grDrawTriangle(v2, v3, v4);
     248      }
     249   }
    250250}
    251251
    252 
    253 
     252#define DRAW_LINE(tmp0, tmp1, width)    \
     253  do {                                  \
     254    GrVertex verts[4];                  \
     255    float dx, dy, wx, wy;               \
     256                                        \
     257    dx = tmp0->x - tmp1->x;             \
     258    dy = tmp0->y - tmp1->y;             \
     259                                        \
     260    if (dx * dx > dy * dy) {            \
     261      wx = 0;                           \
     262      wy = width;                       \
     263    } else {                            \
     264      wx = width;                       \
     265      wy = 0;                           \
     266    }                                   \
     267                                        \
     268   verts[0] = *tmp0;                    \
     269   verts[1] = *tmp0;                    \
     270   verts[2] = *tmp1;                    \
     271   verts[3] = *tmp1;                    \
     272                                        \
     273   verts[0].x = tmp0->x - wx;           \
     274   verts[0].y = tmp0->y - wy;           \
     275                                        \
     276   verts[1].x = tmp0->x + wx;           \
     277   verts[1].y = tmp0->y + wy;           \
     278                                        \
     279   verts[2].x = tmp1->x + wx;           \
     280   verts[2].y = tmp1->y + wy;           \
     281                                        \
     282   verts[3].x = tmp1->x - wx;           \
     283   verts[3].y = tmp1->y - wy;           \
     284                                        \
     285   FX_grDrawPolygonVertexList(4, verts); \
     286  } while (0)
    254287
    255288#if (IND & FX_OFFSET) == 0
     
    260293   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
    261294   GLubyte (* const color)[4] = VB->Color[0]->data;
    262    GrVertex *v1 = (GrVertex *)gWin[e1].f; 
     295   GrVertex *v1 = (GrVertex *)gWin[e1].f;
    263296   GrVertex *v2 = (GrVertex *)gWin[e2].f;
    264 
    265    if (IND & FX_FLAT)
     297   GLfloat w = ctx->Line.Width*.5;
     298
     299   if (IND & FX_FLAT)
    266300   {
    267301      FX_VB_COLOR(fxMesa, color[pv]);
     
    271305        GLuint v1argb = v1->argb;
    272306        GLuint v2argb = v2->argb;
    273         v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF);
    274         v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF);
     307        v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF);
     308        v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF);
    275309      }
    276310#else
    277         v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
    278 #endif 
    279    } 
    280    else if (IND & FX_TWOSIDE) 
     311        v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
     312#endif
     313   }
     314   else if (IND & FX_TWOSIDE)
    281315   {
    282       GOURAUD2(v1,color[e1]); 
    283       GOURAUD2(v2,color[e2]); 
    284    }
    285 
    286    if (IND & FX_FRONT_BACK) {
    287       FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    288                   ctx->Color.ColorMask[GCOMP] ||
    289                   ctx->Color.ColorMask[BCOMP],
    290                   FXFALSE);
     316      GOURAUD2(v1,color[e1]);
     317      GOURAUD2(v2,color[e2]);
     318   }
     319
     320   if (IND & FX_FRONT_BACK) {
     321      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
     322                  ctx->Color.ColorMask[GCOMP] ||
     323                  ctx->Color.ColorMask[BCOMP],
     324                  FXFALSE);
    291325      FX_grDepthMask(FXFALSE);
    292326      FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
     
    296330      FX_grAADrawLine(v1,v2);
    297331   else
    298       FX_grDrawLine(v1,v2);
    299 
    300    if (IND & FX_FRONT_BACK) 
     332      DRAW_LINE(v1,v2,w);
     333
     334   if (IND & FX_FRONT_BACK)
    301335   {
    302336      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    303                   ctx->Color.ColorMask[GCOMP] ||
    304                   ctx->Color.ColorMask[BCOMP],
    305                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     337                  ctx->Color.ColorMask[GCOMP] ||
     338                  ctx->Color.ColorMask[BCOMP],
     339                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    306340
    307341      if(ctx->Depth.Mask)
    308         FX_grDepthMask(FXTRUE);
     342        FX_grDepthMask(FXTRUE);
    309343
    310344      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    311345
    312346      if (IND & FX_ANTIALIAS)
    313         FX_grAADrawLine(v1,v2);
     347        FX_grAADrawLine(v1,v2);
    314348      else
    315          FX_grDrawLine(v1,v2);
     349         DRAW_LINE(v1,v2,w);
    316350   }
    317351}
     
    336370#endif
    337371
    338 #if IND & FX_ANTIALIAS
    339 #define DRAW_POINT(i) FX_grAADrawPoint((GrVertex *)gWin[i].f);
    340 #else
    341 #define DRAW_POINT(i) FX_grDrawPoint((GrVertex *)gWin[i].f);
    342 #endif
    343 
     372
     373#define DRAW_POINT(i, sz)                       \
     374  do {                                          \
     375    GrVertex verts[4], *tmp;                    \
     376                                                \
     377    tmp = (GrVertex*)gWin[i].f;                 \
     378    verts[0] = *tmp;                            \
     379    verts[1] = *tmp;                            \
     380    verts[2] = *tmp;                            \
     381    verts[3] = *tmp;                            \
     382    verts[0].x = verts[3].x = tmp->x + sz;      \
     383    verts[0].y = verts[1].y = tmp->y + sz;      \
     384    verts[2].x = verts[1].x = tmp->x - sz;      \
     385    verts[2].y = verts[3].y = tmp->y - sz;      \
     386                                                \
     387    FX_grDrawPolygonVertexList(4, verts);       \
     388  } while (0)
    344389
    345390static void TAG(fx_points)(GLcontext *ctx, GLuint first, GLuint last)
     
    350395   GLubyte (*color)[4] = VB->ColorPtr->data;
    351396   GLuint i;
     397   GLfloat sz = ctx->Point.Size * .5;
    352398
    353399   (void) color; (void) fxMesa;
     
    355401   if (IND & FX_FRONT_BACK) {
    356402      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    357                   ctx->Color.ColorMask[GCOMP] ||
    358                   ctx->Color.ColorMask[BCOMP],
    359                   FXFALSE);
     403                  ctx->Color.ColorMask[GCOMP] ||
     404                  ctx->Color.ColorMask[BCOMP],
     405                  FXFALSE);
    360406
    361407      FX_grDepthMask(FXFALSE);
     
    365411   if(!VB->ClipOrMask) {
    366412      for(i=first;i<=last;i++) {
    367         FLAT_COLOR(fxMesa, color[i]);
    368          DRAW_POINT(i);
     413        FLAT_COLOR(fxMesa, color[i]);
     414         DRAW_POINT(i, sz);
    369415      }
    370416   } else {
    371417      for(i=first;i<=last;i++) {
    372         if(VB->ClipMask[i]==0) {
    373             FLAT_COLOR(fxMesa, color[i]);
    374             DRAW_POINT(i);
    375         }
    376       }
    377    }
    378 
    379    if (IND & FX_FRONT_BACK) {
    380       FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
    381                   ctx->Color.ColorMask[GCOMP] ||
    382                   ctx->Color.ColorMask[BCOMP],
    383                   ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
     418        if(VB->ClipMask[i]==0) {
     419            FLAT_COLOR(fxMesa, color[i]);
     420            DRAW_POINT(i, sz);
     421        }
     422      }
     423   }
     424
     425   if (IND & FX_FRONT_BACK) {
     426      FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
     427                  ctx->Color.ColorMask[GCOMP] ||
     428                  ctx->Color.ColorMask[BCOMP],
     429                  ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
    384430      if(ctx->Depth.Mask)
    385         FX_grDepthMask(FXTRUE);
     431        FX_grDepthMask(FXTRUE);
    386432      FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
    387433
    388434
    389435      if(!VB->ClipOrMask) {
    390         for(i=first;i<=last;i++) {
    391             FLAT_COLOR(fxMesa, color[i]);
    392             DRAW_POINT(i);
    393         }
     436        for(i=first;i<=last;i++) {
     437            FLAT_COLOR(fxMesa, color[i]);
     438            DRAW_POINT(i, sz);
     439        }
    394440      } else {
    395         for(i=first;i<=last;i++) {
    396             if(VB->ClipMask[i]==0) {
    397                FLAT_COLOR(fxMesa, color[i]);
    398                DRAW_POINT(i);
    399             }
    400         }
     441        for(i=first;i<=last;i++) {
     442            if(VB->ClipMask[i]==0) {
     443               FLAT_COLOR(fxMesa, color[i]);
     444               DRAW_POINT(i, sz);
     445            }
     446        }
    401447      }
    402448   }
     
    412458   quad_tab[IND] = TAG(fx_quad);
    413459
    414 #if ((IND & FX_OFFSET) == 0) 
     460#if ((IND & FX_OFFSET) == 0)
    415461      line_tab[IND] = TAG(fx_line);
    416462      points_tab[IND] = TAG(fx_points);
    417 #else 
     463#else
    418464      line_tab[IND] = line_tab[IND & ~FX_OFFSET];
    419465      points_tab[IND] = points_tab[IND & ~FX_OFFSET];
Note: See TracChangeset for help on using the changeset viewer.