Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 3 | * Version: 7.1 |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 4 | * |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 5 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 6 | * |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 13 | * |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 16 | * |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
Brian Paul | 05a4b37 | 2002-10-29 20:28:36 +0000 | [diff] [blame] | 25 | * Keith Whitwell <keith@tungstengraphics.com> |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 29 | /** |
| 30 | * This is where we handle assigning vertex colors based on front/back |
| 31 | * facing, compute polygon offset and handle glPolygonMode(). |
| 32 | */ |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 33 | static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 34 | { |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 35 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 36 | SScontext *swsetup = SWSETUP_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 37 | SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 38 | SWvertex *v[3]; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 39 | GLfloat z[3]; |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 40 | GLfloat offset, oz0, oz1, oz2; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 41 | GLenum mode = GL_FILL; |
Brian Paul | 21709b3 | 2002-11-13 15:04:29 +0000 | [diff] [blame] | 42 | GLuint facing = 0; |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 43 | GLchan saved_color[3][4]; |
Vinson Lee | 0aef54b | 2009-12-12 22:00:19 -0800 | [diff] [blame] | 44 | GLfloat saved_col0[3][4] = { { 0 } }; |
| 45 | GLfloat saved_spec[3][4] = { { 0 } }; |
| 46 | GLfloat saved_index[3] = { 0 }; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 47 | |
| 48 | v[0] = &verts[e0]; |
| 49 | v[1] = &verts[e1]; |
| 50 | v[2] = &verts[e2]; |
| 51 | |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 52 | if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) |
| 53 | { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 54 | GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0]; |
| 55 | GLfloat ey = v[0]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; |
| 56 | GLfloat fx = v[1]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0]; |
| 57 | GLfloat fy = v[1]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 58 | GLfloat cc = ex*fy - ey*fx; |
| 59 | |
| 60 | if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) |
| 61 | { |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 62 | facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 63 | |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 64 | if (IND & SS_UNFILLED_BIT) |
| 65 | mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 66 | |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 67 | if (facing == 1) { |
| 68 | if (IND & SS_TWOSIDE_BIT) { |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 69 | if (IND & SS_RGBA_BIT) { |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 70 | if (VB->BackfaceColorPtr) { |
| 71 | GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data; |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 72 | |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 73 | if (swsetup->intColors) { |
| 74 | COPY_CHAN4(saved_color[0], v[0]->color); |
| 75 | COPY_CHAN4(saved_color[1], v[1]->color); |
| 76 | COPY_CHAN4(saved_color[2], v[2]->color); |
Xiang, Haihao | 565cd49 | 2007-04-18 12:37:09 +0800 | [diff] [blame] | 77 | } |
| 78 | else { |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 79 | COPY_4V(saved_col0[0], v[0]->attrib[FRAG_ATTRIB_COL0]); |
| 80 | COPY_4V(saved_col0[1], v[1]->attrib[FRAG_ATTRIB_COL0]); |
| 81 | COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL0]); |
| 82 | } |
| 83 | |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 84 | if (VB->BackfaceColorPtr->stride) { |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 85 | if (swsetup->intColors) { |
| 86 | SS_COLOR(v[0]->color, vbcolor[e0]); |
| 87 | SS_COLOR(v[1]->color, vbcolor[e1]); |
| 88 | SS_COLOR(v[2]->color, vbcolor[e2]); |
| 89 | } |
| 90 | else { |
| 91 | COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[e0]); |
| 92 | COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[e1]); |
| 93 | COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[e2]); |
| 94 | } |
| 95 | } |
| 96 | else { |
| 97 | /* flat shade */ |
| 98 | if (swsetup->intColors) { |
| 99 | SS_COLOR(v[0]->color, vbcolor[0]); |
| 100 | SS_COLOR(v[1]->color, vbcolor[0]); |
| 101 | SS_COLOR(v[2]->color, vbcolor[0]); |
| 102 | } |
| 103 | else { |
| 104 | COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]); |
| 105 | COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]); |
| 106 | COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]); |
| 107 | } |
Xiang, Haihao | 565cd49 | 2007-04-18 12:37:09 +0800 | [diff] [blame] | 108 | } |
| 109 | } |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 110 | |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 111 | if (VB->BackfaceSecondaryColorPtr) { |
| 112 | GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data; |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 113 | |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 114 | COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]); |
| 115 | COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]); |
| 116 | COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]); |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 117 | |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 118 | if (VB->BackfaceSecondaryColorPtr->stride) { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 119 | SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]); |
| 120 | SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]); |
| 121 | SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]); |
Keith Whitwell | a582015 | 2005-05-11 10:30:13 +0000 | [diff] [blame] | 122 | } |
| 123 | else { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 124 | SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[0]); |
| 125 | SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[0]); |
| 126 | SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[0]); |
Keith Whitwell | a582015 | 2005-05-11 10:30:13 +0000 | [diff] [blame] | 127 | } |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 128 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 129 | } else { |
Eric Anholt | fc9a297 | 2009-11-17 23:38:35 -0800 | [diff] [blame] | 130 | GLfloat *vbindex = (GLfloat *)VB->BackfaceIndexPtr->data; |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 131 | saved_index[0] = v[0]->attrib[FRAG_ATTRIB_CI][0]; |
| 132 | saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0]; |
| 133 | saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0]; |
Keith Whitwell | 326bc71 | 2003-11-28 09:43:18 +0000 | [diff] [blame] | 134 | |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 135 | SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e0]); |
| 136 | SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e1]); |
| 137 | SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e2]); |
Keith Whitwell | 1e1aac0 | 2000-11-13 20:02:56 +0000 | [diff] [blame] | 138 | } |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 139 | } |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 140 | } |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 143 | if (IND & SS_OFFSET_BIT) { |
| 144 | const GLfloat max = ctx->DrawBuffer->_DepthMaxF; |
| 145 | /* save original Z values (restored later) */ |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 146 | z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2]; |
| 147 | z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2]; |
| 148 | z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2]; |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 149 | /* Note that Z values are already scaled to [0,65535] (for example) |
| 150 | * so no MRD value is used here. |
| 151 | */ |
| 152 | offset = ctx->Polygon.OffsetUnits; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 153 | if (cc * cc > 1e-16) { |
Brian Paul | 7c6a04f | 2004-03-03 15:50:28 +0000 | [diff] [blame] | 154 | const GLfloat ez = z[0] - z[2]; |
| 155 | const GLfloat fz = z[1] - z[2]; |
| 156 | const GLfloat oneOverArea = 1.0F / cc; |
| 157 | const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); |
| 158 | const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); |
| 159 | offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 160 | } |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 161 | /* new Z values */ |
| 162 | oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); |
| 163 | oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); |
| 164 | oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 165 | } |
| 166 | } |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 167 | |
| 168 | if (mode == GL_POINT) { |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 169 | if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 170 | v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; |
| 171 | v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; |
| 172 | v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 173 | } |
Michal Krol | 355e9bb | 2009-03-19 10:39:57 +0100 | [diff] [blame] | 174 | _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_point_tri); |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 175 | } else if (mode == GL_LINE) { |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 176 | if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 177 | v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; |
| 178 | v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; |
| 179 | v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 180 | } |
Michal Krol | 355e9bb | 2009-03-19 10:39:57 +0100 | [diff] [blame] | 181 | _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_line_tri); |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 182 | } else { |
| 183 | if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { |
Brian | b755a2d | 2007-07-11 16:19:51 -0600 | [diff] [blame] | 184 | v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; |
| 185 | v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; |
| 186 | v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 187 | } |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 188 | _swrast_Triangle( ctx, v[0], v[1], v[2] ); |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 191 | /* |
| 192 | * Restore original vertex colors, etc. |
| 193 | */ |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 194 | if (IND & SS_OFFSET_BIT) { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 195 | v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0]; |
| 196 | v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1]; |
| 197 | v[2]->attrib[FRAG_ATTRIB_WPOS][2] = z[2]; |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 200 | if (IND & SS_TWOSIDE_BIT) { |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 201 | if (facing == 1) { |
| 202 | if (IND & SS_RGBA_BIT) { |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 203 | if (VB->BackfaceColorPtr) { |
Brian | a700832 | 2007-05-23 15:33:46 -0600 | [diff] [blame] | 204 | if (swsetup->intColors) { |
| 205 | COPY_CHAN4(v[0]->color, saved_color[0]); |
| 206 | COPY_CHAN4(v[1]->color, saved_color[1]); |
| 207 | COPY_CHAN4(v[2]->color, saved_color[2]); |
| 208 | } |
| 209 | else { |
| 210 | COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], saved_col0[0]); |
| 211 | COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], saved_col0[1]); |
| 212 | COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], saved_col0[2]); |
| 213 | } |
Xiang, Haihao | 565cd49 | 2007-04-18 12:37:09 +0800 | [diff] [blame] | 214 | } |
| 215 | |
Eric Anholt | 0a91878 | 2009-11-18 01:38:55 -0800 | [diff] [blame] | 216 | if (VB->BackfaceSecondaryColorPtr) { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 217 | COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]); |
| 218 | COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]); |
| 219 | COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 220 | } |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 221 | } else { |
Brian | 9e8a961 | 2007-05-20 12:27:39 -0600 | [diff] [blame] | 222 | v[0]->attrib[FRAG_ATTRIB_CI][0] = saved_index[0]; |
| 223 | v[1]->attrib[FRAG_ATTRIB_CI][0] = saved_index[1]; |
| 224 | v[2]->attrib[FRAG_ATTRIB_CI][0] = saved_index[2]; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 225 | } |
| 226 | } |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 227 | } |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | |
| 231 | |
Keith Whitwell | 7098924 | 2001-03-19 02:25:35 +0000 | [diff] [blame] | 232 | /* Need to fixup edgeflags when decomposing to triangles: |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 233 | */ |
pesco | 6f3178a | 2001-03-21 17:11:32 +0000 | [diff] [blame] | 234 | static void TAG(quadfunc)( GLcontext *ctx, GLuint v0, |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 235 | GLuint v1, GLuint v2, GLuint v3 ) |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 236 | { |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 237 | if (IND & SS_UNFILLED_BIT) { |
| 238 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
Brian | c9ce3e8 | 2007-11-05 14:41:18 -0700 | [diff] [blame] | 239 | if (VB->EdgeFlag) { /* XXX this test shouldn't be needed (bug 12614) */ |
| 240 | GLubyte ef1 = VB->EdgeFlag[v1]; |
| 241 | GLubyte ef3 = VB->EdgeFlag[v3]; |
| 242 | VB->EdgeFlag[v1] = 0; |
| 243 | TAG(triangle)( ctx, v0, v1, v3 ); |
| 244 | VB->EdgeFlag[v1] = ef1; |
| 245 | VB->EdgeFlag[v3] = 0; |
| 246 | TAG(triangle)( ctx, v1, v2, v3 ); |
| 247 | VB->EdgeFlag[v3] = ef3; |
| 248 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 249 | } else { |
Keith Whitwell | 58e9917 | 2001-01-05 02:26:48 +0000 | [diff] [blame] | 250 | TAG(triangle)( ctx, v0, v1, v3 ); |
| 251 | TAG(triangle)( ctx, v1, v2, v3 ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 252 | } |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 256 | |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 257 | |
| 258 | static void TAG(init)( void ) |
| 259 | { |
| 260 | tri_tab[IND] = TAG(triangle); |
pesco | 6f3178a | 2001-03-21 17:11:32 +0000 | [diff] [blame] | 261 | quad_tab[IND] = TAG(quadfunc); |
Keith Whitwell | 7c20642 | 2000-11-05 18:20:18 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | |
| 265 | #undef IND |
| 266 | #undef TAG |