1 /* $Id: s_points.c,v 1.19 2002/06/15 03:03:11 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 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"
47 #define ATTENUATE 0x40
52 * CI points with size == 1.0
55 #define NAME size1_ci_point
56 #include "s_pointtemp.h"
62 #define FLAGS (INDEX | LARGE)
63 #define NAME general_ci_point
64 #include "s_pointtemp.h"
68 * Antialiased CI points.
70 #define FLAGS (INDEX | SMOOTH)
71 #define NAME antialiased_ci_point
72 #include "s_pointtemp.h"
76 * Distance attenuated, general CI points.
78 #define FLAGS (INDEX | ATTENUATE)
79 #define NAME atten_general_ci_point
80 #include "s_pointtemp.h"
84 * RGBA points with size == 1.0
87 #define NAME size1_rgba_point
88 #include "s_pointtemp.h"
92 * General RGBA points.
94 #define FLAGS (RGBA | LARGE)
95 #define NAME general_rgba_point
96 #include "s_pointtemp.h"
100 * Antialiased RGBA points.
102 #define FLAGS (RGBA | SMOOTH)
103 #define NAME antialiased_rgba_point
104 #include "s_pointtemp.h"
108 * Textured RGBA points.
110 #define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
111 #define NAME textured_rgba_point
112 #include "s_pointtemp.h"
116 * Antialiased points with texture mapping.
118 #define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
119 #define NAME antialiased_tex_rgba_point
120 #include "s_pointtemp.h"
124 * Distance attenuated, general RGBA points.
126 #define FLAGS (RGBA | ATTENUATE)
127 #define NAME atten_general_rgba_point
128 #include "s_pointtemp.h"
132 * Distance attenuated, textured RGBA points.
134 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
135 #define NAME atten_textured_rgba_point
136 #include "s_pointtemp.h"
140 * Distance attenuated, antialiased points with or without texture mapping.
142 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
143 #define NAME atten_antialiased_rgba_point
144 #include "s_pointtemp.h"
148 * Sprite (textured point)
150 #define FLAGS (RGBA | SPRITE)
151 #define NAME sprite_point
152 #include "s_pointtemp.h"
155 #define FLAGS (RGBA | ATTENUATE | SPRITE)
156 #define NAME atten_sprite_point
157 #include "s_pointtemp.h"
161 void _swrast_add_spec_terms_point( GLcontext
*ctx
,
164 SWvertex
*ncv0
= (SWvertex
*)v0
;
166 COPY_CHAN4( c
[0], ncv0
->color
);
167 ACC_3V( ncv0
->color
, ncv0
->specular
);
168 SWRAST_CONTEXT(ctx
)->SpecPoint( ctx
, ncv0
);
169 COPY_CHAN4( ncv0
->color
, c
[0] );
174 /* record the current point function name */
177 static const char *pntFuncName
= NULL
;
179 #define USE(pntFunc) \
181 pntFuncName = #pntFunc; \
182 /*printf("%s\n", pntFuncName);*/ \
183 swrast->Point = pntFunc; \
188 #define USE(pntFunc) swrast->Point = pntFunc
194 * Examine the current context to determine which point drawing function
198 _swrast_choose_point( GLcontext
*ctx
)
200 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
201 GLboolean rgbMode
= ctx
->Visual
.rgbMode
;
203 if (ctx
->RenderMode
==GL_RENDER
) {
204 if (ctx
->Point
.PointSprite
) {
205 /* GL_NV_point_sprite */
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
|| ctx
->VertexProgram
.PointSizeEnabled
) {
216 USE(atten_antialiased_rgba_point
);
218 else if (ctx
->Texture
._EnabledUnits
) {
219 USE(antialiased_tex_rgba_point
);
222 USE(antialiased_rgba_point
);
226 USE(antialiased_ci_point
);
229 else if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
231 if (ctx
->Texture
._EnabledUnits
) {
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
._EnabledUnits
&& 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
);