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"
44 #define ATTENUATE 0x40
49 * CI points with size == 1.0
52 #define NAME size1_ci_point
53 #include "s_pointtemp.h"
59 #define FLAGS (INDEX | LARGE)
60 #define NAME general_ci_point
61 #include "s_pointtemp.h"
65 * Antialiased CI points.
67 #define FLAGS (INDEX | SMOOTH)
68 #define NAME antialiased_ci_point
69 #include "s_pointtemp.h"
73 * Distance attenuated, general CI points.
75 #define FLAGS (INDEX | ATTENUATE)
76 #define NAME atten_general_ci_point
77 #include "s_pointtemp.h"
81 * RGBA points with size == 1.0
84 #define NAME size1_rgba_point
85 #include "s_pointtemp.h"
89 * General RGBA points.
91 #define FLAGS (RGBA | LARGE)
92 #define NAME general_rgba_point
93 #include "s_pointtemp.h"
97 * Antialiased RGBA points.
99 #define FLAGS (RGBA | SMOOTH)
100 #define NAME antialiased_rgba_point
101 #include "s_pointtemp.h"
105 * Textured RGBA points.
107 #define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
108 #define NAME textured_rgba_point
109 #include "s_pointtemp.h"
113 * Antialiased points with texture mapping.
115 #define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
116 #define NAME antialiased_tex_rgba_point
117 #include "s_pointtemp.h"
121 * Distance attenuated, general RGBA points.
123 #define FLAGS (RGBA | ATTENUATE)
124 #define NAME atten_general_rgba_point
125 #include "s_pointtemp.h"
129 * Distance attenuated, textured RGBA points.
131 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
132 #define NAME atten_textured_rgba_point
133 #include "s_pointtemp.h"
137 * Distance attenuated, antialiased points with or without texture mapping.
139 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
140 #define NAME atten_antialiased_rgba_point
141 #include "s_pointtemp.h"
145 * Sprite (textured point)
147 #define FLAGS (RGBA | SPRITE | SPECULAR)
148 #define NAME sprite_point
149 #include "s_pointtemp.h"
152 #define FLAGS (RGBA | SPRITE | SPECULAR | ATTENUATE)
153 #define NAME atten_sprite_point
154 #include "s_pointtemp.h"
158 void _swrast_add_spec_terms_point( GLcontext
*ctx
,
161 SWvertex
*ncv0
= (SWvertex
*)v0
;
163 COPY_CHAN4( c
[0], ncv0
->color
);
164 ACC_3V( ncv0
->color
, ncv0
->specular
);
165 SWRAST_CONTEXT(ctx
)->SpecPoint( ctx
, ncv0
);
166 COPY_CHAN4( ncv0
->color
, c
[0] );
171 /* record the current point function name */
174 static const char *pntFuncName
= NULL
;
176 #define USE(pntFunc) \
178 pntFuncName = #pntFunc; \
179 /*printf("%s\n", pntFuncName);*/ \
180 swrast->Point = pntFunc; \
185 #define USE(pntFunc) swrast->Point = pntFunc
191 * Examine the current context to determine which point drawing function
195 _swrast_choose_point( GLcontext
*ctx
)
197 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
198 GLboolean rgbMode
= ctx
->Visual
.rgbMode
;
200 if (ctx
->RenderMode
==GL_RENDER
) {
201 if (ctx
->Point
.PointSprite
) {
202 /* GL_ARB_point_sprite / GL_NV_point_sprite */
203 /* XXX this might not be good enough */
204 if (ctx
->Point
._Attenuated
)
205 USE(atten_sprite_point
);
209 else if (ctx
->Point
.SmoothFlag
) {
212 if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
213 USE(atten_antialiased_rgba_point
);
215 else if (ctx
->Texture
._EnabledCoordUnits
) {
216 USE(antialiased_tex_rgba_point
);
219 USE(antialiased_rgba_point
);
223 USE(antialiased_ci_point
);
226 else if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
228 if (ctx
->Texture
._EnabledCoordUnits
) {
229 if (ctx
->Point
.SmoothFlag
) {
230 USE(atten_antialiased_rgba_point
);
233 USE(atten_textured_rgba_point
);
237 USE(atten_general_rgba_point
);
242 USE(atten_general_ci_point
);
245 else if (ctx
->Texture
._EnabledCoordUnits
&& rgbMode
) {
247 USE(textured_rgba_point
);
249 else if (ctx
->Point
._Size
!= 1.0) {
252 USE(general_rgba_point
);
255 USE(general_ci_point
);
259 /* single pixel points */
261 USE(size1_rgba_point
);
268 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
269 USE(_swrast_feedback_point
);
273 USE(_swrast_select_point
);