1 /* $Id: s_points.c,v 1.20 2003/03/01 01:50:26 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.
33 #include "s_context.h"
34 #include "s_feedback.h"
46 #define ATTENUATE 0x40
51 * CI points with size == 1.0
54 #define NAME size1_ci_point
55 #include "s_pointtemp.h"
61 #define FLAGS (INDEX | LARGE)
62 #define NAME general_ci_point
63 #include "s_pointtemp.h"
67 * Antialiased CI points.
69 #define FLAGS (INDEX | SMOOTH)
70 #define NAME antialiased_ci_point
71 #include "s_pointtemp.h"
75 * Distance attenuated, general CI points.
77 #define FLAGS (INDEX | ATTENUATE)
78 #define NAME atten_general_ci_point
79 #include "s_pointtemp.h"
83 * RGBA points with size == 1.0
86 #define NAME size1_rgba_point
87 #include "s_pointtemp.h"
91 * General RGBA points.
93 #define FLAGS (RGBA | LARGE)
94 #define NAME general_rgba_point
95 #include "s_pointtemp.h"
99 * Antialiased RGBA points.
101 #define FLAGS (RGBA | SMOOTH)
102 #define NAME antialiased_rgba_point
103 #include "s_pointtemp.h"
107 * Textured RGBA points.
109 #define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
110 #define NAME textured_rgba_point
111 #include "s_pointtemp.h"
115 * Antialiased points with texture mapping.
117 #define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
118 #define NAME antialiased_tex_rgba_point
119 #include "s_pointtemp.h"
123 * Distance attenuated, general RGBA points.
125 #define FLAGS (RGBA | ATTENUATE)
126 #define NAME atten_general_rgba_point
127 #include "s_pointtemp.h"
131 * Distance attenuated, textured RGBA points.
133 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
134 #define NAME atten_textured_rgba_point
135 #include "s_pointtemp.h"
139 * Distance attenuated, antialiased points with or without texture mapping.
141 #define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
142 #define NAME atten_antialiased_rgba_point
143 #include "s_pointtemp.h"
147 * Sprite (textured point)
149 #define FLAGS (RGBA | SPRITE)
150 #define NAME sprite_point
151 #include "s_pointtemp.h"
154 #define FLAGS (RGBA | ATTENUATE | SPRITE)
155 #define NAME atten_sprite_point
156 #include "s_pointtemp.h"
160 void _swrast_add_spec_terms_point( GLcontext
*ctx
,
163 SWvertex
*ncv0
= (SWvertex
*)v0
;
165 COPY_CHAN4( c
[0], ncv0
->color
);
166 ACC_3V( ncv0
->color
, ncv0
->specular
);
167 SWRAST_CONTEXT(ctx
)->SpecPoint( ctx
, ncv0
);
168 COPY_CHAN4( ncv0
->color
, c
[0] );
173 /* record the current point function name */
176 static const char *pntFuncName
= NULL
;
178 #define USE(pntFunc) \
180 pntFuncName = #pntFunc; \
181 /*printf("%s\n", pntFuncName);*/ \
182 swrast->Point = pntFunc; \
187 #define USE(pntFunc) swrast->Point = pntFunc
193 * Examine the current context to determine which point drawing function
197 _swrast_choose_point( GLcontext
*ctx
)
199 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
200 GLboolean rgbMode
= ctx
->Visual
.rgbMode
;
202 if (ctx
->RenderMode
==GL_RENDER
) {
203 if (ctx
->Point
.PointSprite
) {
204 /* GL_NV_point_sprite */
205 /* XXX this might not be good enough */
206 if (ctx
->Point
._Attenuated
)
207 USE(atten_sprite_point
);
211 else if (ctx
->Point
.SmoothFlag
) {
214 if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
215 USE(atten_antialiased_rgba_point
);
217 else if (ctx
->Texture
._EnabledUnits
) {
218 USE(antialiased_tex_rgba_point
);
221 USE(antialiased_rgba_point
);
225 USE(antialiased_ci_point
);
228 else if (ctx
->Point
._Attenuated
|| ctx
->VertexProgram
.PointSizeEnabled
) {
230 if (ctx
->Texture
._EnabledUnits
) {
231 if (ctx
->Point
.SmoothFlag
) {
232 USE(atten_antialiased_rgba_point
);
235 USE(atten_textured_rgba_point
);
239 USE(atten_general_rgba_point
);
244 USE(atten_general_ci_point
);
247 else if (ctx
->Texture
._EnabledUnits
&& rgbMode
) {
249 USE(textured_rgba_point
);
251 else if (ctx
->Point
.Size
!= 1.0) {
254 USE(general_rgba_point
);
257 USE(general_ci_point
);
261 /* single pixel points */
263 USE(size1_rgba_point
);
270 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
271 USE(_mesa_feedback_point
);
275 USE(_mesa_select_point
);