1 /* $Id: s_points.c,v 1.14 2001/03/03 20:33:30 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
34 #include "s_context.h"
35 #include "s_feedback.h"
48 #define ATTENUATE 0x20
53 * CI points with size == 1.0
56 #define NAME size1_ci_point
57 #include "s_pointtemp.h"
63 #define FLAGS (INDEX | LARGE)
64 #define NAME general_ci_point
65 #include "s_pointtemp.h"
69 * Antialiased CI points.
71 #define FLAGS (INDEX | SMOOTH)
72 #define NAME antialiased_ci_point
73 #include "s_pointtemp.h"
77 * Distance attenuated, general CI points.
79 #define FLAGS (INDEX | ATTENUATE)
80 #define NAME atten_general_ci_point
81 #include "s_pointtemp.h"
85 * RGBA points with size == 1.0
88 #define NAME size1_rgba_point
89 #include "s_pointtemp.h"
93 * General RGBA points.
95 #define FLAGS (RGBA | LARGE)
96 #define NAME general_rgba_point
97 #include "s_pointtemp.h"
101 * Antialiased RGBA points.
103 #define FLAGS (RGBA | SMOOTH)
104 #define NAME antialiased_rgba_point
105 #include "s_pointtemp.h"
109 * Textured RGBA points.
111 #define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
112 #define NAME textured_rgba_point
113 #include "s_pointtemp.h"
117 * Antialiased points with texture mapping.
119 #define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
120 #define NAME antialiased_tex_rgba_point
121 #include "s_pointtemp.h"
125 * Distance attenuated, general RGBA points.
127 #define FLAGS (RGBA | ATTENUATE)
128 #define NAME atten_general_rgba_point
129 #include "s_pointtemp.h"
133 * Distance attenuated, textured RGBA points.
135 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
136 #define NAME atten_textured_rgba_point
137 #include "s_pointtemp.h"
141 * Distance attenuated, antialiased points with or without texture mapping.
143 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
144 #define NAME atten_antialiased_rgba_point
145 #include "s_pointtemp.h"
149 * Sprite (textured point)
151 #define FLAGS (RGBA | TEXTURE | SPRITE)
152 #define NAME sprite_point
153 #include "s_pointtemp.h"
156 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPRITE)
157 #define NAME atten_sprite_point
158 #include "s_pointtemp.h"
162 void _swrast_add_spec_terms_point( GLcontext
*ctx
,
165 SWvertex
*ncv0
= (SWvertex
*)v0
;
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] );
175 /* record the current point function name */
178 static const char *pntFuncName
= NULL
;
180 #define USE(pntFunc) \
182 pntFuncName = #pntFunc; \
183 /*printf("%s\n", pntFuncName);*/ \
184 swrast->Point = pntFunc; \
189 #define USE(pntFunc) swrast->Point = pntFunc
195 * Examine the current context to determine which point drawing function
199 _swrast_choose_point( GLcontext
*ctx
)
201 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
202 GLboolean rgbMode
= ctx
->Visual
.rgbMode
;
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
);
212 else if (ctx
->Point
.SmoothFlag
) {
215 if (ctx
->Point
._Attenuated
) {
216 USE(atten_antialiased_rgba_point
);
218 else if (ctx
->Texture
._ReallyEnabled
) {
219 USE(antialiased_tex_rgba_point
);
222 USE(antialiased_rgba_point
);
226 USE(antialiased_ci_point
);
229 else if (ctx
->Point
._Attenuated
) {
231 if (ctx
->Texture
._ReallyEnabled
) {
232 if (ctx
->Point
.SmoothFlag
) {
233 USE(atten_antialiased_rgba_point
);
236 USE(atten_textured_rgba_point
);
240 USE(atten_general_rgba_point
);
245 USE(atten_general_ci_point
);
248 else if (ctx
->Texture
._ReallyEnabled
&& rgbMode
) {
250 USE(textured_rgba_point
);
252 else if (ctx
->Point
.Size
!= 1.0) {
255 USE(general_rgba_point
);
258 USE(general_ci_point
);
262 /* single pixel points */
264 USE(size1_rgba_point
);
271 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
272 USE(_mesa_feedback_point
);
276 USE(_mesa_select_point
);