1 | /* $Id: cull_tmp.h,v 1.1 2000-02-29 00:48:28 sandervl 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 |
|
---|
32 | static GLuint TAG(gl_cull_triangles)( struct vertex_buffer *VB,
|
---|
33 | GLuint start,
|
---|
34 | GLuint count,
|
---|
35 | GLuint parity,
|
---|
36 | CONST GLfloat (*proj)[4])
|
---|
37 | {
|
---|
38 | const GLcontext *ctx = VB->ctx;
|
---|
39 | const GLubyte face_bit = ctx->Polygon.FrontBit;
|
---|
40 | const GLubyte cull_faces = ctx->Polygon.CullBits;
|
---|
41 | GLubyte *cullmask = VB->CullMask;
|
---|
42 | GLint i,cullcount = 0;
|
---|
43 | GLint last = count - 3;
|
---|
44 |
|
---|
45 | (void) parity;
|
---|
46 | for (i=start; i <= last ; i+=3 ) {
|
---|
47 | CULL_TRI(DO_CLIP, DO_AREA, i, i+1, i+2, face_bit, 3);
|
---|
48 | }
|
---|
49 |
|
---|
50 | if (i != count)
|
---|
51 | cullcount += count - i;
|
---|
52 |
|
---|
53 | return cullcount;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | static GLuint TAG(gl_cull_triangle_fan)( struct vertex_buffer *VB,
|
---|
62 | GLuint start,
|
---|
63 | GLuint count,
|
---|
64 | GLuint parity,
|
---|
65 | CONST GLfloat (*proj)[4])
|
---|
66 | {
|
---|
67 | const GLcontext *ctx = VB->ctx;
|
---|
68 | const GLubyte face_bit = ctx->Polygon.FrontBit;
|
---|
69 | const GLubyte cull_faces = ctx->Polygon.CullBits;
|
---|
70 | GLubyte *cullmask = VB->CullMask;
|
---|
71 | GLint cullcount = 0;
|
---|
72 | GLint i;
|
---|
73 | GLint last = count - 3;
|
---|
74 | GLint nr = 3;
|
---|
75 |
|
---|
76 | (void) parity;
|
---|
77 | for (i=start; i <= last ; i++, nr = 1) {
|
---|
78 | CULL_TRI(DO_CLIP, DO_AREA, start, i+1, i+2, face_bit, nr);
|
---|
79 | }
|
---|
80 |
|
---|
81 | if (i != last + 1)
|
---|
82 | cullcount += count - i;
|
---|
83 |
|
---|
84 | return cullcount;
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 | static GLuint TAG(gl_cull_triangle_strip)( struct vertex_buffer *VB,
|
---|
90 | GLuint start,
|
---|
91 | GLuint count,
|
---|
92 | GLuint parity,
|
---|
93 | CONST GLfloat (*proj)[4])
|
---|
94 | {
|
---|
95 | const GLcontext *ctx = VB->ctx;
|
---|
96 | const GLubyte face_bit = ctx->Polygon.FrontBit;
|
---|
97 | const GLubyte cull_faces = ctx->Polygon.CullBits;
|
---|
98 | GLubyte *cullmask = VB->CullMask;
|
---|
99 | GLint i;
|
---|
100 | GLint cullcount = 0;
|
---|
101 | GLint last = count - 3;
|
---|
102 | GLint nr = 2;
|
---|
103 |
|
---|
104 | parity ^= face_bit;
|
---|
105 |
|
---|
106 | for (i = start; i <= last ; i++, parity ^= 1, nr = 1 ) {
|
---|
107 | CULL_TRI(DO_CLIP, DO_AREA, i, i+1, i+2, parity, nr);
|
---|
108 | }
|
---|
109 |
|
---|
110 | if (i != last + 1)
|
---|
111 | cullcount += count - i;
|
---|
112 |
|
---|
113 | return cullcount;
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 | static GLuint TAG(gl_cull_quads)( struct vertex_buffer *VB,
|
---|
121 | GLuint start,
|
---|
122 | GLuint count,
|
---|
123 | GLuint parity,
|
---|
124 | CONST GLfloat (*proj)[4])
|
---|
125 | {
|
---|
126 | const GLcontext *ctx = VB->ctx;
|
---|
127 | const GLubyte face_bit = ctx->Polygon.FrontBit;
|
---|
128 | const GLubyte cull_faces = ctx->Polygon.CullBits;
|
---|
129 | GLubyte *cullmask = VB->CullMask;
|
---|
130 | GLint i,cullcount = 0;
|
---|
131 | GLint last = count - 4;
|
---|
132 |
|
---|
133 | (void) parity;
|
---|
134 |
|
---|
135 | for (i = start; i <= last ; i += 4) {
|
---|
136 | CULL_QUAD(DO_CLIP, DO_AREA, i, i+1, i+2, i+3, 4);
|
---|
137 | }
|
---|
138 |
|
---|
139 | if (i != count)
|
---|
140 | cullcount += count - i;
|
---|
141 |
|
---|
142 | return cullcount;
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | static GLuint TAG(gl_cull_quad_strip)( struct vertex_buffer *VB,
|
---|
147 | GLuint start,
|
---|
148 | GLuint count,
|
---|
149 | GLuint parity,
|
---|
150 | CONST GLfloat (*proj)[4])
|
---|
151 | {
|
---|
152 | const GLcontext *ctx = VB->ctx;
|
---|
153 | const GLubyte face_bit = ctx->Polygon.FrontBit;
|
---|
154 | const GLubyte cull_faces = ctx->Polygon.CullBits;
|
---|
155 | GLubyte *cullmask = VB->CullMask;
|
---|
156 | GLint i,cullcount = 0;
|
---|
157 | GLint last = count - 4;
|
---|
158 | GLint nr = 4;
|
---|
159 |
|
---|
160 | (void) parity;
|
---|
161 |
|
---|
162 | for (i = start ; i <= last ; i += 2, nr = 2) {
|
---|
163 | CULL_QUAD(DO_CLIP, DO_AREA, i, i+1, i+3, i+2, nr);
|
---|
164 | }
|
---|
165 |
|
---|
166 | if (i != last + 2)
|
---|
167 | cullcount += count - i;
|
---|
168 |
|
---|
169 | return cullcount;
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 |
|
---|
174 |
|
---|
175 | #undef DO_CLIP
|
---|
176 | #undef DO_AREA
|
---|
177 | #undef TAG
|
---|