| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727 |
-
- /*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Author:
- * Keith Whitwell <keithw@valinux.com>
- */
-
-
- /* Template for building functions to plug into the driver interface
- * of t_vb_render.c:
- * ctx->Driver.QuadFunc
- * ctx->Driver.TriangleFunc
- * ctx->Driver.LineFunc
- * ctx->Driver.PointsFunc
- *
- * DO_TWOSIDE: Plug back-color values from the VB into backfacing triangles,
- * and restore vertices afterwards.
- * DO_OFFSET: Calculate offset for triangles and adjust vertices. Restore
- * vertices after rendering.
- * DO_FLAT: For hardware without native flatshading, copy provoking colors
- * into the other vertices. Restore after rendering.
- * DO_UNFILLED: Decompose triangles to lines and points where appropriate.
- *
- * HAVE_RGBA: Vertices have rgba values (otherwise index values).
- * HAVE_SPEC: Vertices have secondary rgba values.
- *
- * VERT_X(v): Alias for vertex x value.
- * VERT_Y(v): Alias for vertex x value.
- * VERT_Z(v): Alias for vertex x value.
- * DEPTH_SCALE: Scale for offset.
- *
- * VERTEX: Hardware vertex type.
- * GET_VERTEX(n): Retreive vertex with index n.
- * AREA_IS_CCW(a): Return true if triangle with signed area a is ccw.
- *
- * VERT_SET_RGBA: Assign vertex rgba from VB color.
- * VERT_COPY_RGBA: Copy vertex rgba another vertex.
- * VERT_SAVE_RGBA: Save vertex rgba to a local variable.
- * VERT_RESTORE_RGBA: Restore vertex rgba from a local variable.
- * --> Similar for IND and SPEC.
- *
- * LOCAL_VARS(n): (At least) define local vars for save/restore rgba.
- *
- */
-
- #if HAVE_RGBA
- #define VERT_SET_IND( v, c ) (void) c
- #define VERT_COPY_IND( v0, v1 )
- #define VERT_SAVE_IND( idx )
- #define VERT_RESTORE_IND( idx )
- #if HAVE_BACK_COLORS
- #define VERT_SET_RGBA( v, c )
- #endif
- #else
- #define VERT_SET_RGBA( v, c ) (void) c
- #define VERT_COPY_RGBA( v0, v1 )
- #define VERT_SAVE_RGBA( idx )
- #define VERT_RESTORE_RGBA( idx )
- #if HAVE_BACK_COLORS
- #define VERT_SET_IND( v, c )
- #endif
- #endif
-
- #if !HAVE_SPEC
- #define VERT_SET_SPEC( v, c ) (void) c
- #define VERT_COPY_SPEC( v0, v1 )
- #define VERT_SAVE_SPEC( idx )
- #define VERT_RESTORE_SPEC( idx )
- #if HAVE_BACK_COLORS
- #define VERT_COPY_SPEC1( v )
- #endif
- #else
- #if HAVE_BACK_COLORS
- #define VERT_SET_SPEC( v, c )
- #endif
- #endif
-
- #if !HAVE_BACK_COLORS
- #define VERT_COPY_SPEC1( v )
- #define VERT_COPY_IND1( v )
- #define VERT_COPY_RGBA1( v )
- #endif
-
- #ifndef INSANE_VERTICES
- #define VERT_SET_Z(v,val) VERT_Z(v) = val
- #define VERT_Z_ADD(v,val) VERT_Z(v) += val
- #endif
-
- #if DO_TRI
- static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
- {
- struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
- VERTEX *v[3];
- GLfloat offset;
- GLfloat z[3];
- GLenum mode = GL_FILL;
- GLuint facing;
- LOCAL_VARS(3);
-
- /* fprintf(stderr, "%s\n", __FUNCTION__); */
-
- v[0] = (VERTEX *)GET_VERTEX(e0);
- v[1] = (VERTEX *)GET_VERTEX(e1);
- v[2] = (VERTEX *)GET_VERTEX(e2);
-
- if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED)
- {
- GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
- GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
- GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]);
- GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
- GLfloat cc = ex*fy - ey*fx;
-
- if (DO_TWOSIDE || DO_UNFILLED)
- {
- facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
-
- if (DO_UNFILLED) {
- if (facing) {
- mode = ctx->Polygon.BackMode;
- if (ctx->Polygon.CullFlag &&
- ctx->Polygon.CullFaceMode != GL_FRONT) {
- return;
- }
- } else {
- mode = ctx->Polygon.FrontMode;
- if (ctx->Polygon.CullFlag &&
- ctx->Polygon.CullFaceMode != GL_BACK) {
- return;
- }
- }
- }
-
- if (DO_TWOSIDE && facing == 1)
- {
- if (HAVE_RGBA) {
- if (HAVE_BACK_COLORS) {
- if (!DO_FLAT) {
- VERT_SAVE_RGBA( 0 );
- VERT_SAVE_RGBA( 1 );
- VERT_COPY_RGBA1( v[0] );
- VERT_COPY_RGBA1( v[1] );
- }
- VERT_SAVE_RGBA( 2 );
- VERT_COPY_RGBA1( v[2] );
- if (HAVE_SPEC) {
- if (!DO_FLAT) {
- VERT_SAVE_SPEC( 0 );
- VERT_SAVE_SPEC( 1 );
- VERT_COPY_SPEC1( v[0] );
- VERT_COPY_SPEC1( v[1] );
- }
- VERT_SAVE_SPEC( 2 );
- VERT_COPY_SPEC1( v[2] );
- }
- }
- else {
- GLchan (*vbcolor)[4] = VB->ColorPtr[1]->data;
- ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLchan));
- (void) vbcolor;
-
- if (!DO_FLAT) {
- VERT_SET_RGBA( v[0], vbcolor[e0] );
- VERT_SET_RGBA( v[1], vbcolor[e1] );
- }
- VERT_SET_RGBA( v[2], vbcolor[e2] );
-
- if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
- GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
-
- if (!DO_FLAT) {
- VERT_SET_SPEC( v[0], vbspec[e0] );
- VERT_SET_SPEC( v[1], vbspec[e1] );
- }
- VERT_SET_SPEC( v[2], vbspec[e2] );
- }
- }
- }
- else {
- GLuint *vbindex = VB->IndexPtr[1]->data;
- if (!DO_FLAT) {
- VERT_SET_IND( v[0], vbindex[e0] );
- VERT_SET_IND( v[1], vbindex[e1] );
- }
- VERT_SET_IND( v[2], vbindex[e2] );
- }
- }
- }
-
-
- if (DO_OFFSET)
- {
- offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
- z[0] = VERT_Z(v[0]);
- z[1] = VERT_Z(v[1]);
- z[2] = VERT_Z(v[2]);
- if (cc * cc > 1e-16) {
- GLfloat ic = 1.0 / cc;
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- offset *= ctx->MRD;
- }
- }
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_SAVE_RGBA( 0 );
- VERT_SAVE_RGBA( 1 );
- VERT_COPY_RGBA( v[0], v[2] );
- VERT_COPY_RGBA( v[1], v[2] );
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_SAVE_SPEC( 0 );
- VERT_SAVE_SPEC( 1 );
- VERT_COPY_SPEC( v[0], v[2] );
- VERT_COPY_SPEC( v[1], v[2] );
- }
- }
- else {
- VERT_SAVE_IND( 0 );
- VERT_SAVE_IND( 1 );
- VERT_COPY_IND( v[0], v[2] );
- VERT_COPY_IND( v[1], v[2] );
- }
- }
-
- if (mode == GL_POINT) {
- if (DO_OFFSET && ctx->Polygon.OffsetPoint) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- }
- UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
- } else if (mode == GL_LINE) {
- if (DO_OFFSET && ctx->Polygon.OffsetLine) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- }
- UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
- } else {
- if (DO_OFFSET && ctx->Polygon.OffsetFill) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- }
- if (DO_UNFILLED)
- RASTERIZE( GL_TRIANGLES );
- TRI( v[0], v[1], v[2] );
- }
-
- if (DO_OFFSET)
- {
- VERT_SET_Z(v[0], z[0]);
- VERT_SET_Z(v[1], z[1]);
- VERT_SET_Z(v[2], z[2]);
- }
-
- if (DO_TWOSIDE && facing == 1)
- {
- if (HAVE_RGBA) {
- if (HAVE_BACK_COLORS) {
- VERT_RESTORE_RGBA( 0 );
- VERT_RESTORE_RGBA( 1 );
- VERT_RESTORE_RGBA( 2 );
- if (HAVE_SPEC) {
- VERT_RESTORE_SPEC( 0 );
- VERT_RESTORE_SPEC( 1 );
- VERT_RESTORE_SPEC( 2 );
- }
- }
- else {
- GLchan (*vbcolor)[4] = VB->ColorPtr[0]->data;
- ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLchan));
- (void) vbcolor;
-
- if (!DO_FLAT) {
- VERT_SET_RGBA( v[0], vbcolor[e0] );
- VERT_SET_RGBA( v[1], vbcolor[e1] );
- }
- VERT_SET_RGBA( v[2], vbcolor[e2] );
-
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- GLchan (*vbspec)[4] = VB->SecondaryColorPtr[0]->data;
- ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLchan));
-
- if (!DO_FLAT) {
- VERT_SET_SPEC( v[0], vbspec[e0] );
- VERT_SET_SPEC( v[1], vbspec[e1] );
- }
- VERT_SET_SPEC( v[2], vbspec[e2] );
- }
- }
- }
- else {
- GLuint *vbindex = VB->IndexPtr[0]->data;
- if (!DO_FLAT) {
- VERT_SET_IND( v[0], vbindex[e0] );
- VERT_SET_IND( v[1], vbindex[e1] );
- }
- VERT_SET_IND( v[2], vbindex[e2] );
- }
- }
-
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_RESTORE_RGBA( 0 );
- VERT_RESTORE_RGBA( 1 );
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_RESTORE_SPEC( 0 );
- VERT_RESTORE_SPEC( 1 );
- }
- }
- else {
- VERT_RESTORE_IND( 0 );
- VERT_RESTORE_IND( 1 );
- }
- }
- }
- #endif
-
- #if DO_QUAD
- #if DO_FULL_QUAD
- static void TAG(quad)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
- {
- struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
- VERTEX *v[4];
- GLfloat offset;
- GLfloat z[4];
- GLenum mode = GL_FILL;
- GLuint facing;
- LOCAL_VARS(4);
-
- v[0] = (VERTEX *)GET_VERTEX(e0);
- v[1] = (VERTEX *)GET_VERTEX(e1);
- v[2] = (VERTEX *)GET_VERTEX(e2);
- v[3] = (VERTEX *)GET_VERTEX(e3);
-
- if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED)
- {
- GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
- GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
- GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]);
- GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
- GLfloat cc = ex*fy - ey*fx;
-
- if (DO_TWOSIDE || DO_UNFILLED)
- {
- facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
-
- if (DO_UNFILLED) {
- if (facing) {
- mode = ctx->Polygon.BackMode;
- if (ctx->Polygon.CullFlag &&
- ctx->Polygon.CullFaceMode != GL_FRONT) {
- return;
- }
- } else {
- mode = ctx->Polygon.FrontMode;
- if (ctx->Polygon.CullFlag &&
- ctx->Polygon.CullFaceMode != GL_BACK) {
- return;
- }
- }
- }
-
- if (DO_TWOSIDE && facing == 1)
- {
- if (HAVE_RGBA) {
- GLchan (*vbcolor)[4] = VB->ColorPtr[1]->data;
- (void)vbcolor;
-
- if (!DO_FLAT) {
- VERT_SET_RGBA( v[0], vbcolor[e0] );
- VERT_SET_RGBA( v[1], vbcolor[e1] );
- VERT_SET_RGBA( v[2], vbcolor[e2] );
- }
- VERT_SET_RGBA( v[3], vbcolor[e3] );
-
- if (HAVE_SPEC && VB->SecondaryColorPtr[facing]) {
- GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
- ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLchan));
-
- if (!DO_FLAT) {
- VERT_SET_SPEC( v[0], vbspec[e0] );
- VERT_SET_SPEC( v[1], vbspec[e1] );
- VERT_SET_SPEC( v[2], vbspec[e2] );
- }
- VERT_SET_SPEC( v[3], vbspec[e3] );
- }
- }
- else {
- GLuint *vbindex = VB->IndexPtr[1]->data;
- if (!DO_FLAT) {
- VERT_SET_IND( v[0], vbindex[e0] );
- VERT_SET_IND( v[1], vbindex[e1] );
- VERT_SET_IND( v[2], vbindex[e2] );
- }
- VERT_SET_IND( v[3], vbindex[e3] );
- }
- }
- }
-
-
- if (DO_OFFSET)
- {
- offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
- z[0] = VERT_Z(v[0]);
- z[1] = VERT_Z(v[1]);
- z[2] = VERT_Z(v[2]);
- z[3] = VERT_Z(v[3]);
- if (cc * cc > 1e-16) {
- GLfloat ez = z[2] - z[0];
- GLfloat fz = z[3] - z[1];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- offset *= ctx->MRD;
- }
- }
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_SAVE_RGBA( 0 );
- VERT_SAVE_RGBA( 1 );
- VERT_SAVE_RGBA( 2 );
- VERT_COPY_RGBA( v[0], v[3] );
- VERT_COPY_RGBA( v[1], v[3] );
- VERT_COPY_RGBA( v[2], v[3] );
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_SAVE_SPEC( 0 );
- VERT_SAVE_SPEC( 1 );
- VERT_SAVE_SPEC( 2 );
- VERT_COPY_SPEC( v[0], v[3] );
- VERT_COPY_SPEC( v[1], v[3] );
- VERT_COPY_SPEC( v[2], v[3] );
- }
- }
- else {
- VERT_SAVE_IND( 0 );
- VERT_SAVE_IND( 1 );
- VERT_SAVE_IND( 2 );
- VERT_COPY_IND( v[0], v[3] );
- VERT_COPY_IND( v[1], v[3] );
- VERT_COPY_IND( v[2], v[3] );
- }
- }
-
- if (mode == GL_POINT) {
- if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- VERT_Z_ADD(v[3], offset);
- }
- UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );
- } else if (mode == GL_LINE) {
- if (DO_OFFSET && ctx->Polygon.OffsetLine) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- VERT_Z_ADD(v[3], offset);
- }
- UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );
- } else {
- if (DO_OFFSET && ctx->Polygon.OffsetFill) {
- VERT_Z_ADD(v[0], offset);
- VERT_Z_ADD(v[1], offset);
- VERT_Z_ADD(v[2], offset);
- VERT_Z_ADD(v[3], offset);
- }
- RASTERIZE( GL_TRIANGLES );
- QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );
- }
-
- if (DO_OFFSET)
- {
- VERT_SET_Z(v[0], z[0]);
- VERT_SET_Z(v[1], z[1]);
- VERT_SET_Z(v[2], z[2]);
- VERT_SET_Z(v[3], z[3]);
- }
-
- if (DO_TWOSIDE && facing == 1)
- {
- if (HAVE_RGBA) {
- GLchan (*vbcolor)[4] = VB->ColorPtr[0]->data;
- ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLchan));
- (void) vbcolor;
-
- if (!DO_FLAT) {
- VERT_SET_RGBA( v[0], vbcolor[e0] );
- VERT_SET_RGBA( v[1], vbcolor[e1] );
- VERT_SET_RGBA( v[2], vbcolor[e2] );
- }
- VERT_SET_RGBA( v[3], vbcolor[e3] );
-
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- GLchan (*vbspec)[4] = VB->SecondaryColorPtr[0]->data;
- ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLchan));
-
- if (!DO_FLAT) {
- VERT_SET_SPEC( v[0], vbspec[e0] );
- VERT_SET_SPEC( v[1], vbspec[e1] );
- VERT_SET_SPEC( v[2], vbspec[e2] );
- }
- VERT_SET_SPEC( v[3], vbspec[e3] );
- }
- }
- else {
- GLuint *vbindex = VB->IndexPtr[0]->data;
- if (!DO_FLAT) {
- VERT_SET_IND( v[0], vbindex[e0] );
- VERT_SET_IND( v[1], vbindex[e1] );
- VERT_SET_IND( v[2], vbindex[e2] );
- }
- VERT_SET_IND( v[3], vbindex[e3] );
- }
- }
-
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_RESTORE_RGBA( 0 );
- VERT_RESTORE_RGBA( 1 );
- VERT_RESTORE_RGBA( 2 );
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_RESTORE_SPEC( 0 );
- VERT_RESTORE_SPEC( 1 );
- VERT_RESTORE_SPEC( 2 );
- }
- }
- else {
- VERT_RESTORE_IND( 0 );
- VERT_RESTORE_IND( 1 );
- VERT_RESTORE_IND( 2 );
- }
- }
- }
- #else
- static void TAG(quad)( GLcontext *ctx, GLuint e0,
- GLuint e1, GLuint e2, GLuint e3 )
- {
- if (DO_UNFILLED) {
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLubyte ef1 = VB->EdgeFlag[e1];
- GLubyte ef3 = VB->EdgeFlag[e3];
- VB->EdgeFlag[e1] = 0;
- TAG(triangle)( ctx, e0, e1, e3 );
- VB->EdgeFlag[e1] = ef1;
- VB->EdgeFlag[e3] = 0;
- TAG(triangle)( ctx, e1, e2, e3 );
- VB->EdgeFlag[e3] = ef3;
- } else {
- TAG(triangle)( ctx, e0, e1, e3 );
- TAG(triangle)( ctx, e1, e2, e3 );
- }
- }
- #endif
- #endif
-
- #if DO_LINE
- static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
- {
- TNLvertexbuffer *VB = &TNL_CONTEXT(ctx)->vb;
- VERTEX *v[2];
- LOCAL_VARS(2);
-
- v[0] = (VERTEX *)GET_VERTEX(e0);
- v[1] = (VERTEX *)GET_VERTEX(e1);
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_SAVE_RGBA( 0 );
- VERT_COPY_RGBA( v[0], v[1] );
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_SAVE_SPEC( 0 );
- VERT_COPY_SPEC( v[0], v[1] );
- }
- }
- else {
- VERT_SAVE_IND( 0 );
- VERT_COPY_IND( v[0], v[1] );
- }
- }
-
- LINE( v[0], v[1] );
-
- if (DO_FLAT) {
- if (HAVE_RGBA) {
- VERT_RESTORE_RGBA( 0 );
-
- if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
- VERT_RESTORE_SPEC( 0 );
- }
- }
- else {
- VERT_RESTORE_IND( 0 );
- }
- }
- }
- #endif
-
- #if DO_POINT
- static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
- {
- struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
- int i;
- LOCAL_VARS(1);
-
- if (VB->Elts == 0) {
- for ( i = first ; i < last ; i++ ) {
- if ( VB->ClipMask[i] == 0 ) {
- VERTEX *v = (VERTEX *)GET_VERTEX(i);
- POINT( v );
- }
- }
- } else {
- for ( i = first ; i < last ; i++ ) {
- GLuint e = VB->Elts[i];
- if ( VB->ClipMask[e] == 0 ) {
- VERTEX *v = (VERTEX *)GET_VERTEX(e);
- POINT( v );
- }
- }
- }
- }
- #endif
-
- static void TAG(init)( void )
- {
- #if DO_QUAD
- TAB[IND].quad = TAG(quad);
- #endif
- #if DO_TRI
- TAB[IND].triangle = TAG(triangle);
- #endif
- #if DO_LINE
- TAB[IND].line = TAG(line);
- #endif
- #if DO_POINT
- TAB[IND].points = TAG(points);
- #endif
- }
-
- #undef IND
- #undef TAG
-
- #if HAVE_RGBA
- #undef VERT_SET_IND
- #undef VERT_COPY_IND
- #undef VERT_SAVE_IND
- #undef VERT_RESTORE_IND
- #if HAVE_BACK_COLORS
- #undef VERT_SET_RGBA
- #endif
- #else
- #undef VERT_SET_RGBA
- #undef VERT_COPY_RGBA
- #undef VERT_SAVE_RGBA
- #undef VERT_RESTORE_RGBA
- #if HAVE_BACK_COLORS
- #undef VERT_SET_IND
- #endif
- #endif
-
- #if !HAVE_SPEC
- #undef VERT_SET_SPEC
- #undef VERT_COPY_SPEC
- #undef VERT_SAVE_SPEC
- #undef VERT_RESTORE_SPEC
- #if HAVE_BACK_COLORS
- #undef VERT_COPY_SPEC1
- #endif
- #else
- #if HAVE_BACK_COLORS
- #undef VERT_SET_SPEC
- #endif
- #endif
-
- #if !HAVE_BACK_COLORS
- #undef VERT_COPY_SPEC1
- #undef VERT_COPY_IND1
- #undef VERT_COPY_RGBA1
- #endif
-
- #ifndef INSANE_VERTICES
- #undef VERT_SET_Z
- #undef VERT_Z_ADD
- #endif
|