| 1 | /* $Id: render_tmp.h,v 1.2 2000-05-23 20:34:55 jeroen Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.1
|
|---|
| 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 | /*
|
|---|
| 28 | * New (3.1) transformation code written by Keith Whitwell.
|
|---|
| 29 | */
|
|---|
| 30 |
|
|---|
| 31 | #ifndef POSTFIX
|
|---|
| 32 | #define POSTFIX
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | #ifndef INIT
|
|---|
| 36 | #define INIT(x)
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | #ifndef NEED_EDGEFLAG_SETUP
|
|---|
| 40 | #define NEED_EDGEFLAG_SETUP 0
|
|---|
| 41 | #define EDGEFLAG_TRI(a,b,c,d,e)
|
|---|
| 42 | #define EDGEFLAG_POLY_TRI_PRE(a,b,c,d)
|
|---|
| 43 | #define EDGEFLAG_POLY_TRI_POST(a,b,c,d)
|
|---|
| 44 | #define EDGEFLAG_QUAD(a,b,c,d,e)
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | #ifndef RESET_STIPPLE
|
|---|
| 48 | #define RESET_STIPPLE
|
|---|
| 49 | #endif
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | static void TAG(render_vb_points)( struct vertex_buffer *VB,
|
|---|
| 53 | GLuint start,
|
|---|
| 54 | GLuint count,
|
|---|
| 55 | GLuint parity )
|
|---|
| 56 | {
|
|---|
| 57 | LOCAL_VARS;
|
|---|
| 58 | (void) parity;
|
|---|
| 59 | INIT(GL_POINTS);
|
|---|
| 60 | RENDER_POINTS( start, count );
|
|---|
| 61 | POSTFIX;
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | static void TAG(render_vb_lines)( struct vertex_buffer *VB,
|
|---|
| 65 | GLuint start,
|
|---|
| 66 | GLuint count,
|
|---|
| 67 | GLuint parity )
|
|---|
| 68 | {
|
|---|
| 69 | GLuint j;
|
|---|
| 70 | LOCAL_VARS;
|
|---|
| 71 | (void) parity;
|
|---|
| 72 |
|
|---|
| 73 | INIT(GL_LINES);
|
|---|
| 74 | for (j=start+1; j<count; j+=2 ) {
|
|---|
| 75 | RENDER_LINE( j-1, j );
|
|---|
| 76 | RESET_STIPPLE;
|
|---|
| 77 | }
|
|---|
| 78 | POSTFIX;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | static void TAG(render_vb_line_strip)( struct vertex_buffer *VB,
|
|---|
| 83 | GLuint start,
|
|---|
| 84 | GLuint count,
|
|---|
| 85 | GLuint parity )
|
|---|
| 86 | {
|
|---|
| 87 | GLuint j;
|
|---|
| 88 | LOCAL_VARS;
|
|---|
| 89 | (void) parity;
|
|---|
| 90 |
|
|---|
| 91 | INIT(GL_LINES);
|
|---|
| 92 | for (j=start+1; j<count; j++ ) {
|
|---|
| 93 | RENDER_LINE( j-1, j );
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | if (VB->Flag[count] & VERT_END) {
|
|---|
| 97 | RESET_STIPPLE;
|
|---|
| 98 | }
|
|---|
| 99 | POSTFIX;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | static void TAG(render_vb_line_loop)( struct vertex_buffer *VB,
|
|---|
| 104 | GLuint start,
|
|---|
| 105 | GLuint count,
|
|---|
| 106 | GLuint parity )
|
|---|
| 107 | {
|
|---|
| 108 | GLuint i = start < VB->Start ? VB->Start : start + 1;
|
|---|
| 109 | LOCAL_VARS;
|
|---|
| 110 | (void) parity;
|
|---|
| 111 |
|
|---|
| 112 | INIT(GL_LINES);
|
|---|
| 113 | for ( ; i < count ; i++) {
|
|---|
| 114 | RENDER_LINE( i-1, i );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | if (VB->Flag[count] & VERT_END) {
|
|---|
| 118 | RENDER_LINE( i-1, start );
|
|---|
| 119 | RESET_STIPPLE;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | POSTFIX;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 | static void TAG(render_vb_triangles)( struct vertex_buffer *VB,
|
|---|
| 127 | GLuint start,
|
|---|
| 128 | GLuint count,
|
|---|
| 129 | GLuint parity )
|
|---|
| 130 | {
|
|---|
| 131 | GLuint j;
|
|---|
| 132 | LOCAL_VARS;
|
|---|
| 133 | (void) parity;
|
|---|
| 134 |
|
|---|
| 135 | INIT(GL_POLYGON);
|
|---|
| 136 | for (j=start+2; j<count; j+=3) {
|
|---|
| 137 | RENDER_TRI( j-2, j-1, j, j, 0 );
|
|---|
| 138 | RESET_STIPPLE;
|
|---|
| 139 | }
|
|---|
| 140 | POSTFIX;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | static void TAG(render_vb_tri_strip)( struct vertex_buffer *VB,
|
|---|
| 146 | GLuint start,
|
|---|
| 147 | GLuint count,
|
|---|
| 148 | GLuint parity )
|
|---|
| 149 | {
|
|---|
| 150 | GLuint j;
|
|---|
| 151 | LOCAL_VARS;
|
|---|
| 152 | (void) parity;
|
|---|
| 153 | INIT(GL_POLYGON);
|
|---|
| 154 | if (NEED_EDGEFLAG_SETUP) {
|
|---|
| 155 | for (j=start+2;j<count;j++,parity^=1) {
|
|---|
| 156 | EDGEFLAG_TRI( j-2, j-1, j, j, parity );
|
|---|
| 157 | RENDER_TRI( j-2, j-1, j, j, parity );
|
|---|
| 158 | RESET_STIPPLE;
|
|---|
| 159 | }
|
|---|
| 160 | } else {
|
|---|
| 161 | for (j=start+2;j<count;j++,parity^=1) {
|
|---|
| 162 | RENDER_TRI( j-2, j-1, j, j, parity );
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 | POSTFIX;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | static void TAG(render_vb_tri_fan)( struct vertex_buffer *VB,
|
|---|
| 170 | GLuint start,
|
|---|
| 171 | GLuint count,
|
|---|
| 172 | GLuint parity )
|
|---|
| 173 | {
|
|---|
| 174 | GLuint j;
|
|---|
| 175 | LOCAL_VARS;
|
|---|
| 176 | (void) parity;
|
|---|
| 177 | INIT(GL_POLYGON);
|
|---|
| 178 | if (NEED_EDGEFLAG_SETUP) {
|
|---|
| 179 | for (j=start+2;j<count;j++) {
|
|---|
| 180 | EDGEFLAG_TRI( start, j-1, j, j, 0 );
|
|---|
| 181 | RENDER_TRI( start, j-1, j, j, 0 );
|
|---|
| 182 | RESET_STIPPLE;
|
|---|
| 183 | }
|
|---|
| 184 | } else {
|
|---|
| 185 | for (j=start+2;j<count;j++) {
|
|---|
| 186 | RENDER_TRI( start, j-1, j, j, 0 );
|
|---|
| 187 | }
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | POSTFIX;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 | static void TAG(render_vb_poly)( struct vertex_buffer *VB,
|
|---|
| 195 | GLuint start,
|
|---|
| 196 | GLuint count,
|
|---|
| 197 | GLuint parity )
|
|---|
| 198 | {
|
|---|
| 199 | GLuint j;
|
|---|
| 200 | LOCAL_VARS;
|
|---|
| 201 | (void) parity;
|
|---|
| 202 | INIT(GL_POLYGON);
|
|---|
| 203 | if (NEED_EDGEFLAG_SETUP) {
|
|---|
| 204 | for (j=start+2;j<count;j++) {
|
|---|
| 205 | EDGEFLAG_POLY_TRI_PRE( start, j-1, j, start );
|
|---|
| 206 | RENDER_TRI( start, j-1, j, start, 0 );
|
|---|
| 207 | EDGEFLAG_POLY_TRI_POST( start, j-1, j, start );
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 | else {
|
|---|
| 211 | for (j=start+2;j<count;j++) {
|
|---|
| 212 | RENDER_TRI( start, j-1, j, start, 0 );
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 | RESET_STIPPLE;
|
|---|
| 216 | POSTFIX;
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | static void TAG(render_vb_quads)( struct vertex_buffer *VB,
|
|---|
| 221 | GLuint start,
|
|---|
| 222 | GLuint count,
|
|---|
| 223 | GLuint parity )
|
|---|
| 224 | {
|
|---|
| 225 | GLuint j;
|
|---|
| 226 | LOCAL_VARS;
|
|---|
| 227 | (void) parity;
|
|---|
| 228 | INIT(GL_POLYGON);
|
|---|
| 229 | for (j=start+3; j<count; j+=4) {
|
|---|
| 230 | RENDER_QUAD( j-3, j-2, j-1, j, j );
|
|---|
| 231 | RESET_STIPPLE;
|
|---|
| 232 | }
|
|---|
| 233 | POSTFIX;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | static void TAG(render_vb_quad_strip)( struct vertex_buffer *VB,
|
|---|
| 237 | GLuint start,
|
|---|
| 238 | GLuint count,
|
|---|
| 239 | GLuint parity )
|
|---|
| 240 | {
|
|---|
| 241 | GLuint j;
|
|---|
| 242 | LOCAL_VARS;
|
|---|
| 243 | (void) parity;
|
|---|
| 244 | INIT(GL_POLYGON);
|
|---|
| 245 | if (NEED_EDGEFLAG_SETUP) {
|
|---|
| 246 | for (j=start+3;j<count;j+=2) {
|
|---|
| 247 | EDGEFLAG_QUAD( j-3, j-2, j, j-1, j );
|
|---|
| 248 | RENDER_QUAD( j-3, j-2, j, j-1, j );
|
|---|
| 249 | RESET_STIPPLE;
|
|---|
| 250 | }
|
|---|
| 251 | } else {
|
|---|
| 252 | for (j=start+3;j<count;j+=2) {
|
|---|
| 253 | RENDER_QUAD( j-3, j-2, j, j-1, j );
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | POSTFIX;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | static void TAG(render_vb_noop)( struct vertex_buffer *VB,
|
|---|
| 260 | GLuint start,
|
|---|
| 261 | GLuint count,
|
|---|
| 262 | GLuint parity )
|
|---|
| 263 | {
|
|---|
| 264 | (void) VB;
|
|---|
| 265 | (void) start;
|
|---|
| 266 | (void) count;
|
|---|
| 267 | (void) parity;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 | static render_func TAG(render_tab)[GL_POLYGON+2] = {
|
|---|
| 273 | TAG(render_vb_points),
|
|---|
| 274 | TAG(render_vb_lines),
|
|---|
| 275 | TAG(render_vb_line_loop),
|
|---|
| 276 | TAG(render_vb_line_strip),
|
|---|
| 277 | TAG(render_vb_triangles),
|
|---|
| 278 | TAG(render_vb_tri_strip),
|
|---|
| 279 | TAG(render_vb_tri_fan),
|
|---|
| 280 | TAG(render_vb_quads),
|
|---|
| 281 | TAG(render_vb_quad_strip),
|
|---|
| 282 | TAG(render_vb_poly),
|
|---|
| 283 | TAG(render_vb_noop)
|
|---|
| 284 | };
|
|---|
| 285 |
|
|---|
| 286 | static void TAG(render_init)( void )
|
|---|
| 287 | {
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 | #ifndef PRESERVE_VB_DEFS
|
|---|
| 292 | #undef RENDER_TRI
|
|---|
| 293 | #undef RENDER_QUAD
|
|---|
| 294 | #undef RENDER_LINE
|
|---|
| 295 | #undef RENDER_POINTS
|
|---|
| 296 | #undef LOCAL_VARS
|
|---|
| 297 | #undef INIT
|
|---|
| 298 | #undef POSTFIX
|
|---|
| 299 | #undef RESET_STIPPLE
|
|---|
| 300 | #endif
|
|---|
| 301 |
|
|---|
| 302 | #ifndef PRESERVE_TAG
|
|---|
| 303 | #undef TAG
|
|---|
| 304 | #endif
|
|---|
| 305 |
|
|---|
| 306 | #undef PRESERVE_VB_DEFS
|
|---|
| 307 | #undef PRESERVE_TAG
|
|---|
| 308 |
|
|---|