Subversion Repositories shark

Rev

Rev 57 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
57 pj 1
/* $Id: s_points.c,v 1.1 2003-02-28 11:49:42 pj Exp $ */
2
 
3
/*
4
 * Mesa 3-D graphics library
5
 * Version:  4.1
6
 *
7
 * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
8
 *
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:
15
 *
16
 * The above copyright notice and this permission notice shall be included
17
 * in all copies or substantial portions of the Software.
18
 *
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.
25
 */
26
 
27
 
28
#include "glheader.h"
29
#include "colormac.h"
30
#include "context.h"
31
#include "macros.h"
32
#include "mmath.h"
33
#include "texstate.h"
34
#include "s_context.h"
35
#include "s_feedback.h"
36
#include "s_points.h"
37
#include "s_span.h"
38
 
39
 
40
 
41
#define RGBA       0x1
42
#define INDEX      0x2
43
#define SMOOTH     0x4
44
#define TEXTURE    0x8
45
#define SPECULAR  0x10
46
#define LARGE     0x20
47
#define ATTENUATE 0x40
48
#define SPRITE    0x80
49
 
50
 
51
/*
52
 * CI points with size == 1.0
53
 */
54
#define FLAGS (INDEX)
55
#define NAME size1_ci_point
56
#include "s_pointtemp.h"
57
 
58
 
59
/*
60
 * General CI points.
61
 */
62
#define FLAGS (INDEX | LARGE)
63
#define NAME general_ci_point
64
#include "s_pointtemp.h"
65
 
66
 
67
/*
68
 * Antialiased CI points.
69
 */
70
#define FLAGS (INDEX | SMOOTH)
71
#define NAME antialiased_ci_point
72
#include "s_pointtemp.h"
73
 
74
 
75
/*
76
 * Distance attenuated, general CI points.
77
 */
78
#define FLAGS (INDEX | ATTENUATE)
79
#define NAME atten_general_ci_point
80
#include "s_pointtemp.h"
81
 
82
 
83
/*
84
 * RGBA points with size == 1.0
85
 */
86
#define FLAGS (RGBA)
87
#define NAME size1_rgba_point
88
#include "s_pointtemp.h"
89
 
90
 
91
/*
92
 * General RGBA points.
93
 */
94
#define FLAGS (RGBA | LARGE)
95
#define NAME general_rgba_point
96
#include "s_pointtemp.h"
97
 
98
 
99
/*
100
 * Antialiased RGBA points.
101
 */
102
#define FLAGS (RGBA | SMOOTH)
103
#define NAME antialiased_rgba_point
104
#include "s_pointtemp.h"
105
 
106
 
107
/*
108
 * Textured RGBA points.
109
 */
110
#define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
111
#define NAME textured_rgba_point
112
#include "s_pointtemp.h"
113
 
114
 
115
/*
116
 * Antialiased points with texture mapping.
117
 */
118
#define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
119
#define NAME antialiased_tex_rgba_point
120
#include "s_pointtemp.h"
121
 
122
 
123
/*
124
 * Distance attenuated, general RGBA points.
125
 */
126
#define FLAGS (RGBA | ATTENUATE)
127
#define NAME atten_general_rgba_point
128
#include "s_pointtemp.h"
129
 
130
 
131
/*
132
 * Distance attenuated, textured RGBA points.
133
 */
134
#define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
135
#define NAME atten_textured_rgba_point
136
#include "s_pointtemp.h"
137
 
138
 
139
/*
140
 * Distance attenuated, antialiased points with or without texture mapping.
141
 */
142
#define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
143
#define NAME atten_antialiased_rgba_point
144
#include "s_pointtemp.h"
145
 
146
 
147
/*
148
 * Sprite (textured point)
149
 */
150
#define FLAGS (RGBA | SPRITE)
151
#define NAME sprite_point
152
#include "s_pointtemp.h"
153
 
154
 
155
#define FLAGS (RGBA | ATTENUATE | SPRITE)
156
#define NAME atten_sprite_point
157
#include "s_pointtemp.h"
158
 
159
 
160
 
161
void _swrast_add_spec_terms_point( GLcontext *ctx,
162
                                   const SWvertex *v0 )
163
{
164
   SWvertex *ncv0 = (SWvertex *)v0;
165
   GLchan c[1][4];
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] );
170
}
171
 
172
 
173
 
174
/* record the current point function name */
175
#ifdef DEBUG
176
 
177
static const char *pntFuncName = NULL;
178
 
179
#define USE(pntFunc)                   \
180
do {                                   \
181
    pntFuncName = #pntFunc;            \
182
    /*printf("%s\n", pntFuncName);*/   \
183
    swrast->Point = pntFunc;           \
184
} while (0)
185
 
186
#else
187
 
188
#define USE(pntFunc)  swrast->Point = pntFunc
189
 
190
#endif
191
 
192
 
193
/*
194
 * Examine the current context to determine which point drawing function
195
 * should be used.
196
 */
197
void
198
_swrast_choose_point( GLcontext *ctx )
199
{
200
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
201
   GLboolean rgbMode = ctx->Visual.rgbMode;
202
 
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);
209
         else
210
            USE(sprite_point);
211
      }
212
      else if (ctx->Point.SmoothFlag) {
213
         /* Smooth points */
214
         if (rgbMode) {
215
            if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
216
               USE(atten_antialiased_rgba_point);
217
            }
218
            else if (ctx->Texture._EnabledUnits) {
219
               USE(antialiased_tex_rgba_point);
220
            }
221
            else {
222
               USE(antialiased_rgba_point);
223
            }
224
         }
225
         else {
226
            USE(antialiased_ci_point);
227
         }
228
      }
229
      else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
230
         if (rgbMode) {
231
            if (ctx->Texture._EnabledUnits) {
232
               if (ctx->Point.SmoothFlag) {
233
                  USE(atten_antialiased_rgba_point);
234
               }
235
               else {
236
                  USE(atten_textured_rgba_point);
237
               }
238
            }
239
            else {
240
               USE(atten_general_rgba_point);
241
            }
242
         }
243
         else {
244
            /* ci, atten */
245
            USE(atten_general_ci_point);
246
         }
247
      }
248
      else if (ctx->Texture._EnabledUnits && rgbMode) {
249
         /* textured */
250
         USE(textured_rgba_point);
251
      }
252
      else if (ctx->Point.Size != 1.0) {
253
         /* large points */
254
         if (rgbMode) {
255
            USE(general_rgba_point);
256
         }
257
         else {
258
            USE(general_ci_point);
259
         }
260
      }
261
      else {
262
         /* single pixel points */
263
         if (rgbMode) {
264
            USE(size1_rgba_point);
265
         }
266
         else {
267
            USE(size1_ci_point);
268
         }
269
      }
270
   }
271
   else if (ctx->RenderMode==GL_FEEDBACK) {
272
      USE(_mesa_feedback_point);
273
   }
274
   else {
275
      /* GL_SELECT mode */
276
      USE(_mesa_select_point);
277
   }
278
}