ss_tritmp.h revision 565cd49b5fc7a5bd1e533542888bf322b83b8e56
17c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell/*
27c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Mesa 3-D graphics library
37c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul * Version:  6.1
422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
57c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
77c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
87c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * copy of this software and associated documentation files (the "Software"),
97c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * to deal in the Software without restriction, including without limitation
107c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the
127c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Software is furnished to do so, subject to the following conditions:
1322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
147c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * The above copyright notice and this permission notice shall be included
157c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * in all copies or substantial portions of the Software.
1622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
177c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
187c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
197c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
207c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
217c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
227c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell *
247c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Authors:
2505a4b37707d2c598ea68c05d07a3d65bcbf5a076Brian Paul *    Keith Whitwell <keith@tungstengraphics.com>
267c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell */
277c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
287c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2958e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwellstatic void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
307c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{
31cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
32cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
337c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   SWvertex *v[3];
347c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   GLfloat z[3];
3558e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell   GLfloat offset;
367c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   GLenum mode = GL_FILL;
3721709b354b45ad6aa4669d9ef028df9c902d3552Brian Paul   GLuint facing = 0;
38326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell   GLchan saved_color[3][4];
39326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell   GLchan saved_spec[3][4];
40bdd15b5749b45929fa642c3e47997f52eb07fbe5Brian Paul   GLfloat saved_index[3];
417c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
427c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   v[0] = &verts[e0];
437c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   v[1] = &verts[e1];
447c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   v[2] = &verts[e2];
457c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
467c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
477c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
487c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   {
497c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      GLfloat ex = v[0]->win[0] - v[2]->win[0];
507c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      GLfloat ey = v[0]->win[1] - v[2]->win[1];
517c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      GLfloat fx = v[1]->win[0] - v[2]->win[0];
527c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      GLfloat fy = v[1]->win[1] - v[2]->win[1];
537c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      GLfloat cc  = ex*fy - ey*fx;
547c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
557c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
567c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      {
5758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell	 facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
5810b5895597d5e069183cb647d17eb412effceb4fBrian Paul         ctx->_Facing = facing;
5922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
607c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 if (IND & SS_UNFILLED_BIT)
617c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	    mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
6222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
6358e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell	 if (facing == 1) {
6458e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell	    if (IND & SS_TWOSIDE_BIT) {
65cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	       if (IND & SS_RGBA_BIT) {
66565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                  if (VB->ColorPtr[1]) {
67565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
68565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao
69565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     COPY_CHAN4(saved_color[0], v[0]->color);
70565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     COPY_CHAN4(saved_color[1], v[1]->color);
71565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     COPY_CHAN4(saved_color[2], v[2]->color);
72565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao
73565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     if (VB->ColorPtr[1]->stride) {
74565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[0]->color, vbcolor[e0]);
75565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[1]->color, vbcolor[e1]);
76565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[2]->color, vbcolor[e2]);
77565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     }
78565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     else {
79565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[0]->color, vbcolor[0]);
80565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[1]->color, vbcolor[0]);
81565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                        SS_COLOR(v[2]->color, vbcolor[0]);
82565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                     }
83565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao                  }
84326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell
851182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell		  if (VB->SecondaryColorPtr[1]) {
86ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell		     GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
87326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell
88326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		     COPY_CHAN4(saved_spec[0], v[0]->specular);
89326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		     COPY_CHAN4(saved_spec[1], v[1]->specular);
90326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		     COPY_CHAN4(saved_spec[2], v[2]->specular);
91326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell
92a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell		     if (VB->SecondaryColorPtr[1]->stride) {
93a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[0]->specular, vbspec[e0]);
94a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[1]->specular, vbspec[e1]);
95a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[2]->specular, vbspec[e2]);
96a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell		     }
97a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell		     else {
98a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[0]->specular, vbspec[0]);
99a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[1]->specular, vbspec[0]);
100a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell			SS_SPEC(v[2]->specular, vbspec[0]);
101a5820159056fb9c3f5da6b3ae4570cd97b95835dKeith Whitwell		     }
1021182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell		  }
103cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	       } else {
104ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell		  GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
105326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		  saved_index[0] = v[0]->index;
106326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		  saved_index[1] = v[1]->index;
107326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell		  saved_index[2] = v[2]->index;
108326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell
1098236a534b7c31b5d3b688323de05cfa5e446f70dBrian Paul		  SS_IND(v[0]->index, (GLuint) vbindex[e0]);
1108236a534b7c31b5d3b688323de05cfa5e446f70dBrian Paul		  SS_IND(v[1]->index, (GLuint) vbindex[e1]);
1118236a534b7c31b5d3b688323de05cfa5e446f70dBrian Paul		  SS_IND(v[2]->index, (GLuint) vbindex[e2]);
1121e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell	       }
1137c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	    }
11422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes	 }
1157c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      }
1167c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
1177c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      if (IND & SS_OFFSET_BIT)
1187c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      {
119e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul	 offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
1207c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 z[0] = v[0]->win[2];
1217c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 z[1] = v[1]->win[2];
1227c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 z[2] = v[2]->win[2];
1237c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 if (cc * cc > 1e-16) {
1247c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    const GLfloat ez = z[0] - z[2];
1257c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    const GLfloat fz = z[1] - z[2];
1267c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    const GLfloat oneOverArea = 1.0F / cc;
1277c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
1287c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
1297c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul	    offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
1307c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul            /* Unfortunately, we need to clamp to prevent negative Zs below.
1317c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul             * Technically, we should do the clamping per-fragment.
1327c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul             */
1337c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul            offset = MAX2(offset, -v[0]->win[2]);
1347c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul            offset = MAX2(offset, -v[1]->win[2]);
1357c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul            offset = MAX2(offset, -v[2]->win[2]);
1367c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 }
1377c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      }
1387c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   }
1397c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
1407c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   if (mode == GL_POINT) {
1417c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
1427c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[0]->win[2] += offset;
1437c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[1]->win[2] += offset;
1447c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[2]->win[2] += offset;
1457c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      }
14646b3f976542190dd3c217a46653159f77552764aBrian Paul      _swsetup_render_point_tri( ctx, e0, e1, e2, facing );
1477c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   } else if (mode == GL_LINE) {
1487c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
1497c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[0]->win[2] += offset;
1507c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[1]->win[2] += offset;
1517c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[2]->win[2] += offset;
1527c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      }
15346b3f976542190dd3c217a46653159f77552764aBrian Paul      _swsetup_render_line_tri( ctx, e0, e1, e2, facing );
1547c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   } else {
1557c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
1567c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[0]->win[2] += offset;
1577c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[1]->win[2] += offset;
1587c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell	 v[2]->win[2] += offset;
1597c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      }
16022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes      _swrast_Triangle( ctx, v[0], v[1], v[2] );
1617c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   }
1627c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
1637c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   if (IND & SS_OFFSET_BIT) {
1647c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      v[0]->win[2] = z[0];
1657c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      v[1]->win[2] = z[1];
1667c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell      v[2]->win[2] = z[2];
1677c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   }
1687c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
16922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes   if (IND & SS_TWOSIDE_BIT) {
17058e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      if (facing == 1) {
17158e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell	 if (IND & SS_RGBA_BIT) {
172565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao            if (VB->ColorPtr[1]) {
173565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao               COPY_CHAN4(v[0]->color, saved_color[0]);
174565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao               COPY_CHAN4(v[1]->color, saved_color[1]);
175565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao               COPY_CHAN4(v[2]->color, saved_color[2]);
176565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao            }
177565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao
178326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	    if (VB->SecondaryColorPtr[1]) {
179326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	       COPY_CHAN4(v[0]->specular, saved_spec[0]);
180326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	       COPY_CHAN4(v[1]->specular, saved_spec[1]);
181326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	       COPY_CHAN4(v[2]->specular, saved_spec[2]);
1821182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell	    }
18358e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell	 } else {
184326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	    v[0]->index = saved_index[0];
185326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	    v[1]->index = saved_index[1];
186326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell	    v[2]->index = saved_index[2];
1871e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell	 }
1881e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell      }
18922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes   }
1907c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell}
1917c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
1927c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
1937c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
194709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell/* Need to fixup edgeflags when decomposing to triangles:
1957c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell */
1966f3178a3bed43b49407f0bde92c2e6d85c40d190Sven M. Hallbergstatic void TAG(quadfunc)( GLcontext *ctx, GLuint v0,
19758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell		       GLuint v1, GLuint v2, GLuint v3 )
1987c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{
199cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (IND & SS_UNFILLED_BIT) {
200cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
20158e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      GLubyte ef1 = VB->EdgeFlag[v1];
20258e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      GLubyte ef3 = VB->EdgeFlag[v3];
20322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes      VB->EdgeFlag[v1] = 0;
20458e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      TAG(triangle)( ctx, v0, v1, v3 );
20558e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      VB->EdgeFlag[v1] = ef1;
20622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes      VB->EdgeFlag[v3] = 0;
20722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes      TAG(triangle)( ctx, v1, v2, v3 );
20822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes      VB->EdgeFlag[v3] = ef3;
209cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   } else {
21058e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      TAG(triangle)( ctx, v0, v1, v3 );
21158e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell      TAG(triangle)( ctx, v1, v2, v3 );
212cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
2137c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell}
2147c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2157c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2167c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2177c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2187c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwellstatic void TAG(init)( void )
2197c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{
2207c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell   tri_tab[IND] = TAG(triangle);
2216f3178a3bed43b49407f0bde92c2e6d85c40d190Sven M. Hallberg   quad_tab[IND] = TAG(quadfunc);
2227c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell}
2237c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2247c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell
2257c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell#undef IND
2267c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell#undef TAG
227