| 1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.3
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
|---|
| 10 | * copy of this software and associated documentation files (the "Software"),
|
|---|
| 11 | * to deal in the Software without restriction, including without limitation
|
|---|
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|---|
| 13 | * and/or sell copies of the Software, and to permit persons to whom the
|
|---|
| 14 | * Software is furnished to do so, subject to the following conditions:
|
|---|
| 15 | *
|
|---|
| 16 | * The above copyright notice and this permission notice shall be included
|
|---|
| 17 | * in all copies or substantial portions of the Software.
|
|---|
| 18 | *
|
|---|
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|---|
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|---|
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|---|
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|---|
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 25 | *
|
|---|
| 26 | *
|
|---|
| 27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
|---|
| 28 | * terms stated above.
|
|---|
| 29 | *
|
|---|
| 30 | * Thank you for your contribution, David!
|
|---|
| 31 | *
|
|---|
| 32 | * Please make note of the above copyright/license statement. If you
|
|---|
| 33 | * contributed code or bug fixes to this code under the previous (GNU
|
|---|
| 34 | * Library) license and object to the new license, your code will be
|
|---|
| 35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
|---|
| 36 | * for more information.
|
|---|
| 37 | *
|
|---|
| 38 | * Additional Mesa/3Dfx driver developers:
|
|---|
| 39 | * Daryll Strauss <daryll@precisioninsight.com>
|
|---|
| 40 | * Keith Whitwell <keith@precisioninsight.com>
|
|---|
| 41 | *
|
|---|
| 42 | * See fxapi.h for more revision/author details.
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | /*
|
|---|
| 47 | * Notes: the folowing code works only if count is > start.
|
|---|
| 48 | * Corrently we are looking for the pattern:
|
|---|
| 49 | * v0,v1,v2 v2,v1,v3, v2,v3,v4....
|
|---|
| 50 | *
|
|---|
| 51 | * For this:
|
|---|
| 52 | * #define STRIP0 ((u1 == v1) && (u2 == v0))
|
|---|
| 53 | * #define STRIP1 ((u0 == v0) && (u2 == v1))
|
|---|
| 54 | *
|
|---|
| 55 | */
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | static void TAG(render_vb_triangles_smooth_indirect_sd)
|
|---|
| 59 | ( struct vertex_buffer *VB,
|
|---|
| 60 | GLuint start,
|
|---|
| 61 | GLuint count,
|
|---|
| 62 | GLuint parity)
|
|---|
| 63 | {
|
|---|
| 64 | GLint u0,u1,u2;
|
|---|
| 65 | GLint v0,v1,v2;
|
|---|
| 66 | GLuint *elt = VB->EltPtr->data;
|
|---|
| 67 |
|
|---|
| 68 | int i;
|
|---|
| 69 | LOCAL_VARS
|
|---|
| 70 |
|
|---|
| 71 | INIT(GL_TRIANGLES);
|
|---|
| 72 |
|
|---|
| 73 | elt = &elt[start-1];
|
|---|
| 74 | u0 = *(++elt);
|
|---|
| 75 | u1 = *(++elt);
|
|---|
| 76 | u2 = *(++elt);
|
|---|
| 77 | i = start+3;
|
|---|
| 78 | while (i < count)
|
|---|
| 79 | {
|
|---|
| 80 | v0 = *(++elt);
|
|---|
| 81 | v1 = *(++elt);
|
|---|
| 82 | v2 = *(++elt);
|
|---|
| 83 |
|
|---|
| 84 | if (CLIPPED(u0,u1,u2))
|
|---|
| 85 | {
|
|---|
| 86 | if (!CULLED(u0,u1,u2)) SENDCLIPTRI(u0,u1,u2);
|
|---|
| 87 | }
|
|---|
| 88 | else
|
|---|
| 89 | {
|
|---|
| 90 | if (STRIP0(u,v))
|
|---|
| 91 | {
|
|---|
| 92 | int is_strips = 1;
|
|---|
| 93 | int parity = 0;
|
|---|
| 94 | STRIPSLOCAL_VAR
|
|---|
| 95 |
|
|---|
| 96 | FLUSHTRI();
|
|---|
| 97 | STARTSTRIPS(u0,u1,u2);
|
|---|
| 98 | while (is_strips && i < count)
|
|---|
| 99 | {
|
|---|
| 100 | SENDSTRIPS(v2);
|
|---|
| 101 |
|
|---|
| 102 | u0 = v0; u1 = v1; u2 = v2; i+= 3;
|
|---|
| 103 | v0 = *(++elt);
|
|---|
| 104 | v1 = *(++elt);
|
|---|
| 105 | v2 = *(++elt);
|
|---|
| 106 |
|
|---|
| 107 | if (parity) {
|
|---|
| 108 | is_strips = STRIP0(u,v);
|
|---|
| 109 | parity = 0;
|
|---|
| 110 | } else {
|
|---|
| 111 | is_strips = STRIP1(u,v);
|
|---|
| 112 | parity = 1;
|
|---|
| 113 | }
|
|---|
| 114 | }
|
|---|
| 115 | FLUSHSTRIPS();
|
|---|
| 116 |
|
|---|
| 117 | if (i >= count)
|
|---|
| 118 | return;
|
|---|
| 119 | }
|
|---|
| 120 | else
|
|---|
| 121 | {
|
|---|
| 122 | SENDTRI(u0,u1,u2);
|
|---|
| 123 | }
|
|---|
| 124 | }
|
|---|
| 125 | u0 = v0; u1 = v1; u2 = v2; i+= 3;
|
|---|
| 126 | }
|
|---|
| 127 | if (CLIPPED(u0,u1,u2))
|
|---|
| 128 | {
|
|---|
| 129 | if (!CULLED(u0,u1,u2)) SENDCLIPTRI(u0,u1,u2);
|
|---|
| 130 | }
|
|---|
| 131 | else
|
|---|
| 132 | {
|
|---|
| 133 | SENDTRI(u0,u1,u2);
|
|---|
| 134 | }
|
|---|
| 135 | FLUSHTRI();
|
|---|
| 136 |
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | #ifndef PRESERVE_VB_DEFS
|
|---|
| 140 | #undef SENDTRI
|
|---|
| 141 | #undef STRIP0
|
|---|
| 142 | #undef STRIP1
|
|---|
| 143 | #undef LOCAL_VARS
|
|---|
| 144 | #undef STRIPSLOCAL_VAR
|
|---|
| 145 | #undef INIT
|
|---|
| 146 | #undef SENDTRI
|
|---|
| 147 | #undef FLUSHTRI
|
|---|
| 148 | #undef STARTSTRIPS
|
|---|
| 149 | #undef SENDSTRIPS
|
|---|
| 150 | #undef FLUSHSTRIPS
|
|---|
| 151 | #undef CLIPPED
|
|---|
| 152 | #undef CULLED
|
|---|
| 153 | #undef SENDCLIPTRI
|
|---|
| 154 | #endif
|
|---|
| 155 |
|
|---|
| 156 | #ifndef PRESERVE_TAG
|
|---|
| 157 | #undef TAG
|
|---|
| 158 | #endif
|
|---|
| 159 |
|
|---|
| 160 | #undef PRESERVE_VB_DEFS
|
|---|
| 161 | #undef PRESERVE_TAG
|
|---|