lots of gl_*() to _mesa_*() namespace clean-up
[mesa.git] / src / mesa / swrast / s_points.c
1 /* $Id: s_points.c,v 1.14 2001/03/03 20:33:30 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 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 #include "glheader.h"
29 #include "colormac.h"
30 #include "context.h"
31 #include "macros.h"
32 #include "mmath.h"
33 #include "texstate.h"
34 #include "s_context.h"
35 #include "s_feedback.h"
36 #include "s_pb.h"
37 #include "s_points.h"
38 #include "s_span.h"
39
40
41
42 #define INDEX 0x0
43 #define RGBA 0x1
44 #define SMOOTH 0x2
45 #define TEXTURE 0x4
46 #define SPECULAR 0x8
47 #define LARGE 0x10
48 #define ATTENUATE 0x20
49 #define SPRITE 0x40
50
51
52 /*
53 * CI points with size == 1.0
54 */
55 #define FLAGS (INDEX)
56 #define NAME size1_ci_point
57 #include "s_pointtemp.h"
58
59
60 /*
61 * General CI points.
62 */
63 #define FLAGS (INDEX | LARGE)
64 #define NAME general_ci_point
65 #include "s_pointtemp.h"
66
67
68 /*
69 * Antialiased CI points.
70 */
71 #define FLAGS (INDEX | SMOOTH)
72 #define NAME antialiased_ci_point
73 #include "s_pointtemp.h"
74
75
76 /*
77 * Distance attenuated, general CI points.
78 */
79 #define FLAGS (INDEX | ATTENUATE)
80 #define NAME atten_general_ci_point
81 #include "s_pointtemp.h"
82
83
84 /*
85 * RGBA points with size == 1.0
86 */
87 #define FLAGS (RGBA)
88 #define NAME size1_rgba_point
89 #include "s_pointtemp.h"
90
91
92 /*
93 * General RGBA points.
94 */
95 #define FLAGS (RGBA | LARGE)
96 #define NAME general_rgba_point
97 #include "s_pointtemp.h"
98
99
100 /*
101 * Antialiased RGBA points.
102 */
103 #define FLAGS (RGBA | SMOOTH)
104 #define NAME antialiased_rgba_point
105 #include "s_pointtemp.h"
106
107
108 /*
109 * Textured RGBA points.
110 */
111 #define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
112 #define NAME textured_rgba_point
113 #include "s_pointtemp.h"
114
115
116 /*
117 * Antialiased points with texture mapping.
118 */
119 #define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
120 #define NAME antialiased_tex_rgba_point
121 #include "s_pointtemp.h"
122
123
124 /*
125 * Distance attenuated, general RGBA points.
126 */
127 #define FLAGS (RGBA | ATTENUATE)
128 #define NAME atten_general_rgba_point
129 #include "s_pointtemp.h"
130
131
132 /*
133 * Distance attenuated, textured RGBA points.
134 */
135 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
136 #define NAME atten_textured_rgba_point
137 #include "s_pointtemp.h"
138
139
140 /*
141 * Distance attenuated, antialiased points with or without texture mapping.
142 */
143 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
144 #define NAME atten_antialiased_rgba_point
145 #include "s_pointtemp.h"
146
147
148 /*
149 * Sprite (textured point)
150 */
151 #define FLAGS (RGBA | TEXTURE | SPRITE)
152 #define NAME sprite_point
153 #include "s_pointtemp.h"
154
155
156 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPRITE)
157 #define NAME atten_sprite_point
158 #include "s_pointtemp.h"
159
160
161
162 void _swrast_add_spec_terms_point( GLcontext *ctx,
163 const SWvertex *v0 )
164 {
165 SWvertex *ncv0 = (SWvertex *)v0;
166 GLchan c[1][4];
167 COPY_CHAN4( c[0], ncv0->color );
168 ACC_3V( ncv0->color, ncv0->specular );
169 SWRAST_CONTEXT(ctx)->SpecPoint( ctx, ncv0 );
170 COPY_CHAN4( ncv0->color, c[0] );
171 }
172
173
174
175 /* record the current point function name */
176 #ifdef DEBUG
177
178 static const char *pntFuncName = NULL;
179
180 #define USE(pntFunc) \
181 do { \
182 pntFuncName = #pntFunc; \
183 /*printf("%s\n", pntFuncName);*/ \
184 swrast->Point = pntFunc; \
185 } while (0)
186
187 #else
188
189 #define USE(pntFunc) swrast->Point = pntFunc
190
191 #endif
192
193
194 /*
195 * Examine the current context to determine which point drawing function
196 * should be used.
197 */
198 void
199 _swrast_choose_point( GLcontext *ctx )
200 {
201 SWcontext *swrast = SWRAST_CONTEXT(ctx);
202 GLboolean rgbMode = ctx->Visual.rgbMode;
203
204 if (ctx->RenderMode==GL_RENDER) {
205 if (ctx->Point.SpriteMode) {
206 /* XXX this might not be good enough */
207 if (ctx->Point._Attenuated)
208 USE(atten_sprite_point);
209 else
210 USE(sprite_point);
211 }
212 else if (ctx->Point.SmoothFlag) {
213 /* Smooth points */
214 if (rgbMode) {
215 if (ctx->Point._Attenuated) {
216 USE(atten_antialiased_rgba_point);
217 }
218 else if (ctx->Texture._ReallyEnabled) {
219 USE(antialiased_tex_rgba_point);
220 }
221 else {
222 USE(antialiased_rgba_point);
223 }
224 }
225 else {
226 USE(antialiased_ci_point);
227 }
228 }
229 else if (ctx->Point._Attenuated) {
230 if (rgbMode) {
231 if (ctx->Texture._ReallyEnabled) {
232 if (ctx->Point.SmoothFlag) {
233 USE(atten_antialiased_rgba_point);
234 }
235 else {
236 USE(atten_textured_rgba_point);
237 }
238 }
239 else {
240 USE(atten_general_rgba_point);
241 }
242 }
243 else {
244 /* ci, atten */
245 USE(atten_general_ci_point);
246 }
247 }
248 else if (ctx->Texture._ReallyEnabled && rgbMode) {
249 /* textured */
250 USE(textured_rgba_point);
251 }
252 else if (ctx->Point.Size != 1.0) {
253 /* large points */
254 if (rgbMode) {
255 USE(general_rgba_point);
256 }
257 else {
258 USE(general_ci_point);
259 }
260 }
261 else {
262 /* single pixel points */
263 if (rgbMode) {
264 USE(size1_rgba_point);
265 }
266 else {
267 USE(size1_ci_point);
268 }
269 }
270 }
271 else if (ctx->RenderMode==GL_FEEDBACK) {
272 USE(_mesa_feedback_point);
273 }
274 else {
275 /* GL_SELECT mode */
276 USE(_mesa_select_point);
277 }
278 }
279