2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #include "s_context.h"
32 #include "s_feedback.h"
43 #define ATTENUATE 0x40
48 * CI points with size == 1.0
51 #define NAME size1_ci_point
52 #include "s_pointtemp.h"
58 #define FLAGS (INDEX | LARGE)
59 #define NAME general_ci_point
60 #include "s_pointtemp.h"
64 * Antialiased CI points.
66 #define FLAGS (INDEX | SMOOTH)
67 #define NAME antialiased_ci_point
68 #include "s_pointtemp.h"
72 * Distance attenuated, general CI points.
74 #define FLAGS (INDEX | ATTENUATE)
75 #define NAME atten_general_ci_point
76 #include "s_pointtemp.h"
80 * RGBA points with size == 1.0
83 #define NAME size1_rgba_point
84 #include "s_pointtemp.h"
88 * General RGBA points.
90 #define FLAGS (RGBA | LARGE)
91 #define NAME general_rgba_point
92 #include "s_pointtemp.h"
96 * Antialiased RGBA points.
98 #define FLAGS (RGBA | SMOOTH)
99 #define NAME antialiased_rgba_point
100 #include "s_pointtemp.h"
104 * Textured RGBA points.
106 #define FLAGS (RGBA | LARGE | ATTRIBS | SPECULAR)
107 #define NAME textured_rgba_point
108 #include "s_pointtemp.h"
112 * Antialiased points with texture mapping.
114 #define FLAGS (RGBA | SMOOTH | ATTRIBS | SPECULAR)
115 #define NAME antialiased_tex_rgba_point
116 #include "s_pointtemp.h"
120 * Distance attenuated, general RGBA points.
122 #define FLAGS (RGBA | ATTENUATE)
123 #define NAME atten_general_rgba_point
124 #include "s_pointtemp.h"
128 * Distance attenuated, textured RGBA points.
130 #define FLAGS (RGBA | ATTENUATE | ATTRIBS | SPECULAR)
131 #define NAME atten_textured_rgba_point
132 #include "s_pointtemp.h"
136 * Distance attenuated, antialiased points with or without texture mapping.
138 #define FLAGS (RGBA | ATTENUATE | ATTRIBS | SMOOTH)
139 #define NAME atten_antialiased_rgba_point
140 #include "s_pointtemp.h"
144 * Sprite (textured point)
146 #define FLAGS (RGBA | SPRITE | SPECULAR)
147 #define NAME sprite_point
148 #include "s_pointtemp.h"
151 #define FLAGS (RGBA | SPRITE | SPECULAR | ATTENUATE)
152 #define NAME atten_sprite_point
153 #include "s_pointtemp.h"
157 _swrast_add_spec_terms_point(GLcontext
*ctx
, const SWvertex
*v0
)
159 SWvertex
*ncv0
= (SWvertex
*) v0
;
160 GLfloat rSum
, gSum
, bSum
;
164 COPY_CHAN4( cSave
, ncv0
->color
);
166 rSum
= CHAN_TO_FLOAT(ncv0
->color
[0]) + ncv0
->attrib
[FRAG_ATTRIB_COL1
][0];
167 gSum
= CHAN_TO_FLOAT(ncv0
->color
[1]) + ncv0
->attrib
[FRAG_ATTRIB_COL1
][1];
168 bSum
= CHAN_TO_FLOAT(ncv0
->color
[2]) + ncv0
->attrib
[FRAG_ATTRIB_COL1
][2];
169 UNCLAMPED_FLOAT_TO_CHAN(ncv0
->color
[0], rSum
);
170 UNCLAMPED_FLOAT_TO_CHAN(ncv0
->color
[1], gSum
);
171 UNCLAMPED_FLOAT_TO_CHAN(ncv0
->color
[2], bSum
);
173 SWRAST_CONTEXT(ctx
)->SpecPoint(ctx
, ncv0
);
175 COPY_CHAN4(ncv0
->color
, cSave
);
180 /* record the current point function name */
183 static const char *pntFuncName
= NULL
;
185 #define USE(pntFunc) \
187 pntFuncName = #pntFunc; \
188 /*printf("%s\n", pntFuncName);*/ \
189 swrast->Point = pntFunc; \
194 #define USE(pntFunc) swrast->Point = pntFunc
200 * Examine the current context to determine which point drawing function
204 _swrast_choose_point( GLcontext
*ctx
)
206 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
207 GLboolean rgbMode
= ctx
->Visual
.rgbMode
;
208 GLboolean specular
= (ctx
->Fog
.ColorSumEnabled
||
209 (ctx
->Light
.Enabled
&&
210 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
));
212 if (ctx
->RenderMode
==GL_RENDER
) {
213 if (ctx
->Point
.PointSprite
) {
214 /* GL_ARB_point_sprite / GL_NV_point_sprite */
215 /* XXX this might not be good enough */
216 if (ctx
->Point
._Attenuated
)
217 USE(atten_sprite_point
);
221 else if (ctx
->Point
.SmoothFlag
) {
224 if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
225 USE(atten_antialiased_rgba_point
);
227 else if (ctx
->Texture
._EnabledCoordUnits
) {
228 USE(antialiased_tex_rgba_point
);
231 USE(antialiased_rgba_point
);
235 USE(antialiased_ci_point
);
238 else if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
240 if (ctx
->Texture
._EnabledCoordUnits
) {
241 if (ctx
->Point
.SmoothFlag
) {
242 USE(atten_antialiased_rgba_point
);
245 USE(atten_textured_rgba_point
);
249 USE(atten_general_rgba_point
);
254 USE(atten_general_ci_point
);
257 else if ((ctx
->Texture
._EnabledCoordUnits
259 || swrast
->_FogEnabled
) && rgbMode
) {
260 /* textured, fogged */
261 USE(textured_rgba_point
);
263 else if (ctx
->Point
._Size
!= 1.0) {
266 USE(general_rgba_point
);
269 USE(general_ci_point
);
273 /* single pixel points */
275 assert((swrast
->_ActiveAttribMask
& FRAG_BIT_COL1
) == 0);
276 USE(size1_rgba_point
);
283 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
284 USE(_swrast_feedback_point
);
288 USE(_swrast_select_point
);