fix GL_BACK color material bug
[mesa.git] / src / mesa / main / points.c
1 /* $Id: points.c,v 1.9 2000/05/10 22:36:05 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 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 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "context.h"
33 #include "feedback.h"
34 #include "macros.h"
35 #include "mmath.h"
36 #include "pb.h"
37 #include "points.h"
38 #include "span.h"
39 #include "texstate.h"
40 #include "types.h"
41 #include "vb.h"
42 #endif
43
44
45
46 void
47 _mesa_PointSize( GLfloat size )
48 {
49 GET_CURRENT_CONTEXT(ctx);
50 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
51
52 if (size <= 0.0) {
53 gl_error( ctx, GL_INVALID_VALUE, "glPointSize" );
54 return;
55 }
56
57 if (ctx->Point.UserSize != size) {
58 ctx->Point.UserSize = size;
59 ctx->Point.Size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
60 ctx->TriangleCaps &= ~DD_POINT_SIZE;
61 if (size != 1.0)
62 ctx->TriangleCaps |= DD_POINT_SIZE;
63 ctx->NewState |= NEW_RASTER_OPS;
64 }
65 }
66
67
68
69 void
70 _mesa_PointParameterfEXT( GLenum pname, GLfloat param)
71 {
72 _mesa_PointParameterfvEXT(pname, &param);
73 }
74
75
76 void
77 _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
78 {
79 GET_CURRENT_CONTEXT(ctx);
80 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointParameterfvEXT");
81
82 switch (pname) {
83 case GL_DISTANCE_ATTENUATION_EXT:
84 {
85 const GLboolean tmp = ctx->Point.Attenuated;
86 COPY_3V(ctx->Point.Params, params);
87 ctx->Point.Attenuated = (params[0] != 1.0 ||
88 params[1] != 0.0 ||
89 params[2] != 0.0);
90
91 if (tmp != ctx->Point.Attenuated) {
92 ctx->Enabled ^= ENABLE_POINT_ATTEN;
93 ctx->TriangleCaps ^= DD_POINT_ATTEN;
94 ctx->NewState |= NEW_RASTER_OPS;
95 }
96 }
97 break;
98 case GL_POINT_SIZE_MIN_EXT:
99 if (*params < 0.0F) {
100 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
101 return;
102 }
103 ctx->Point.MinSize = *params;
104 break;
105 case GL_POINT_SIZE_MAX_EXT:
106 if (*params < 0.0F) {
107 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
108 return;
109 }
110 ctx->Point.MaxSize = *params;
111 break;
112 case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
113 if (*params < 0.0F) {
114 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
115 return;
116 }
117 ctx->Point.Threshold = *params;
118 break;
119 default:
120 gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
121 return;
122 }
123
124 ctx->NewState |= NEW_RASTER_OPS;
125 }
126
127
128 /**********************************************************************/
129 /***** Rasterization *****/
130 /**********************************************************************/
131
132
133 /*
134 * There are 3 pairs (RGBA, CI) of point rendering functions:
135 * 1. simple: size=1 and no special rasterization functions (fastest)
136 * 2. size1: size=1 and any rasterization functions
137 * 3. general: any size and rasterization functions (slowest)
138 *
139 * All point rendering functions take the same two arguments: first and
140 * last which specify that the points specified by VB[first] through
141 * VB[last] are to be rendered.
142 */
143
144
145
146
147
148 /*
149 * CI points with size == 1.0
150 */
151 static void
152 size1_ci_points( GLcontext *ctx, GLuint first, GLuint last )
153 {
154 struct vertex_buffer *VB = ctx->VB;
155 struct pixel_buffer *PB = ctx->PB;
156 GLfloat *win;
157 GLint *pbx = PB->x, *pby = PB->y;
158 GLdepth *pbz = PB->z;
159 GLuint *pbi = PB->index;
160 GLuint pbcount = PB->count;
161 GLuint i;
162
163 win = &VB->Win.data[first][0];
164 for (i = first; i <= last; i++) {
165 if (VB->ClipMask[i] == 0) {
166 pbx[pbcount] = (GLint) win[0];
167 pby[pbcount] = (GLint) win[1];
168 pbz[pbcount] = (GLint) (win[2] + ctx->PointZoffset);
169 pbi[pbcount] = VB->IndexPtr->data[i];
170 pbcount++;
171 }
172 win += 3;
173 }
174 PB->count = pbcount;
175 PB_CHECK_FLUSH(ctx, PB);
176 }
177
178
179
180 /*
181 * RGBA points with size == 1.0
182 */
183 static void
184 size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
185 {
186 struct vertex_buffer *VB = ctx->VB;
187 struct pixel_buffer *PB = ctx->PB;
188 GLuint i;
189
190 for (i = first; i <= last; i++) {
191 if (VB->ClipMask[i] == 0) {
192 GLint x, y, z;
193 GLint red, green, blue, alpha;
194
195 x = (GLint) VB->Win.data[i][0];
196 y = (GLint) VB->Win.data[i][1];
197 z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
198
199 red = VB->ColorPtr->data[i][0];
200 green = VB->ColorPtr->data[i][1];
201 blue = VB->ColorPtr->data[i][2];
202 alpha = VB->ColorPtr->data[i][3];
203
204 PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue, alpha );
205 }
206 }
207 PB_CHECK_FLUSH(ctx, PB);
208 }
209
210
211
212 /*
213 * General CI points.
214 */
215 static void
216 general_ci_points( GLcontext *ctx, GLuint first, GLuint last )
217 {
218 struct vertex_buffer *VB = ctx->VB;
219 struct pixel_buffer *PB = ctx->PB;
220 const GLint isize = (GLint) (ctx->Point.Size + 0.5F);
221 GLint radius = isize >> 1;
222 GLuint i;
223
224 for (i = first; i <= last; i++) {
225 if (VB->ClipMask[i] == 0) {
226 GLint x0, x1, y0, y1;
227 GLint ix, iy;
228
229 GLint x = (GLint) VB->Win.data[i][0];
230 GLint y = (GLint) VB->Win.data[i][1];
231 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
232
233 if (isize & 1) {
234 /* odd size */
235 x0 = x - radius;
236 x1 = x + radius;
237 y0 = y - radius;
238 y1 = y + radius;
239 }
240 else {
241 /* even size */
242 x0 = (GLint) (x + 1.5F) - radius;
243 x1 = x0 + isize - 1;
244 y0 = (GLint) (y + 1.5F) - radius;
245 y1 = y0 + isize - 1;
246 }
247
248 PB_SET_INDEX( PB, VB->IndexPtr->data[i] );
249
250 for (iy = y0; iy <= y1; iy++) {
251 for (ix = x0; ix <= x1; ix++) {
252 PB_WRITE_PIXEL( PB, ix, iy, z );
253 }
254 }
255 PB_CHECK_FLUSH(ctx,PB);
256 }
257 }
258 }
259
260
261 /*
262 * General RGBA points.
263 */
264 static void
265 general_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
266 {
267 struct vertex_buffer *VB = ctx->VB;
268 struct pixel_buffer *PB = ctx->PB;
269 GLint isize = (GLint) (ctx->Point.Size + 0.5F);
270 GLint radius = isize >> 1;
271 GLuint i;
272
273 for (i = first; i <= last; i++) {
274 if (VB->ClipMask[i] == 0) {
275 GLint x0, x1, y0, y1;
276 GLint ix, iy;
277
278 GLint x = (GLint) VB->Win.data[i][0];
279 GLint y = (GLint) VB->Win.data[i][1];
280 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
281
282 if (isize & 1) {
283 /* odd size */
284 x0 = x - radius;
285 x1 = x + radius;
286 y0 = y - radius;
287 y1 = y + radius;
288 }
289 else {
290 /* even size */
291 x0 = (GLint) (x + 1.5F) - radius;
292 x1 = x0 + isize - 1;
293 y0 = (GLint) (y + 1.5F) - radius;
294 y1 = y0 + isize - 1;
295 }
296
297 PB_SET_COLOR( PB,
298 VB->ColorPtr->data[i][0],
299 VB->ColorPtr->data[i][1],
300 VB->ColorPtr->data[i][2],
301 VB->ColorPtr->data[i][3] );
302
303 for (iy = y0; iy <= y1; iy++) {
304 for (ix = x0; ix <= x1; ix++) {
305 PB_WRITE_PIXEL( PB, ix, iy, z );
306 }
307 }
308 PB_CHECK_FLUSH(ctx,PB);
309 }
310 }
311 }
312
313
314
315
316 /*
317 * Textured RGBA points.
318 */
319 static void
320 textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
321 {
322 struct vertex_buffer *VB = ctx->VB;
323 struct pixel_buffer *PB = ctx->PB;
324 GLuint i;
325
326 for (i = first; i <= last; i++) {
327 if (VB->ClipMask[i] == 0) {
328 GLint x0, x1, y0, y1;
329 GLint ix, iy, radius;
330 GLint red, green, blue, alpha;
331 GLfloat s, t, u;
332
333 GLint x = (GLint) VB->Win.data[i][0];
334 GLint y = (GLint) VB->Win.data[i][1];
335 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
336 GLint isize = (GLint) (ctx->Point.Size + 0.5F);
337
338 if (isize < 1) {
339 isize = 1;
340 }
341 radius = isize >> 1;
342
343 if (isize & 1) {
344 /* odd size */
345 x0 = x - radius;
346 x1 = x + radius;
347 y0 = y - radius;
348 y1 = y + radius;
349 }
350 else {
351 /* even size */
352 x0 = (GLint) (x + 1.5F) - radius;
353 x1 = x0 + isize - 1;
354 y0 = (GLint) (y + 1.5F) - radius;
355 y1 = y0 + isize - 1;
356 }
357
358 red = VB->ColorPtr->data[i][0];
359 green = VB->ColorPtr->data[i][1];
360 blue = VB->ColorPtr->data[i][2];
361 alpha = VB->ColorPtr->data[i][3];
362
363 switch (VB->TexCoordPtr[0]->size) {
364 case 4:
365 s = VB->TexCoordPtr[0]->data[i][0]/VB->TexCoordPtr[0]->data[i][3];
366 t = VB->TexCoordPtr[0]->data[i][1]/VB->TexCoordPtr[0]->data[i][3];
367 u = VB->TexCoordPtr[0]->data[i][2]/VB->TexCoordPtr[0]->data[i][3];
368 break;
369 case 3:
370 s = VB->TexCoordPtr[0]->data[i][0];
371 t = VB->TexCoordPtr[0]->data[i][1];
372 u = VB->TexCoordPtr[0]->data[i][2];
373 break;
374 case 2:
375 s = VB->TexCoordPtr[0]->data[i][0];
376 t = VB->TexCoordPtr[0]->data[i][1];
377 u = 0.0;
378 break;
379 case 1:
380 s = VB->TexCoordPtr[0]->data[i][0];
381 t = 0.0;
382 u = 0.0;
383 break;
384 default:
385 /* should never get here */
386 s = t = u = 0.0;
387 gl_problem(ctx, "unexpected texcoord size in textured_rgba_points()");
388 }
389
390 /* don't think this is needed
391 PB_SET_COLOR( red, green, blue, alpha );
392 */
393
394 for (iy = y0; iy <= y1; iy++) {
395 for (ix = x0; ix <= x1; ix++) {
396 PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u );
397 }
398 }
399 PB_CHECK_FLUSH(ctx, PB);
400 }
401 }
402 }
403
404
405 /*
406 * Multitextured RGBA points.
407 */
408 static void
409 multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
410 {
411 struct vertex_buffer *VB = ctx->VB;
412 struct pixel_buffer *PB = ctx->PB;
413 GLuint i;
414
415 for (i = first; i <= last; i++) {
416 if (VB->ClipMask[i] == 0) {
417 GLint x0, x1, y0, y1;
418 GLint ix, iy;
419 GLint radius;
420 GLint red, green, blue, alpha;
421 GLfloat s, t, u;
422 GLfloat s1, t1, u1;
423
424 GLint x = (GLint) VB->Win.data[i][0];
425 GLint y = (GLint) VB->Win.data[i][1];
426 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
427 GLint isize = (GLint) (ctx->Point.Size + 0.5F);
428
429 if (isize < 1) {
430 isize = 1;
431 }
432 radius = isize >> 1;
433
434 if (isize & 1) {
435 /* odd size */
436 x0 = x - radius;
437 x1 = x + radius;
438 y0 = y - radius;
439 y1 = y + radius;
440 }
441 else {
442 /* even size */
443 x0 = (GLint) (x + 1.5F) - radius;
444 x1 = x0 + isize - 1;
445 y0 = (GLint) (y + 1.5F) - radius;
446 y1 = y0 + isize - 1;
447 }
448
449 red = VB->ColorPtr->data[i][0];
450 green = VB->ColorPtr->data[i][1];
451 blue = VB->ColorPtr->data[i][2];
452 alpha = VB->ColorPtr->data[i][3];
453
454 switch (VB->TexCoordPtr[0]->size) {
455 case 4:
456 s = VB->TexCoordPtr[0]->data[i][0]/VB->TexCoordPtr[0]->data[i][3];
457 t = VB->TexCoordPtr[0]->data[i][1]/VB->TexCoordPtr[0]->data[i][3];
458 u = VB->TexCoordPtr[0]->data[i][2]/VB->TexCoordPtr[0]->data[i][3];
459 break;
460 case 3:
461 s = VB->TexCoordPtr[0]->data[i][0];
462 t = VB->TexCoordPtr[0]->data[i][1];
463 u = VB->TexCoordPtr[0]->data[i][2];
464 break;
465 case 2:
466 s = VB->TexCoordPtr[0]->data[i][0];
467 t = VB->TexCoordPtr[0]->data[i][1];
468 u = 0.0;
469 break;
470 case 1:
471 s = VB->TexCoordPtr[0]->data[i][0];
472 t = 0.0;
473 u = 0.0;
474 break;
475 default:
476 /* should never get here */
477 s = t = u = 0.0;
478 gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
479 }
480
481 switch (VB->TexCoordPtr[1]->size) {
482 case 4:
483 s1 = VB->TexCoordPtr[1]->data[i][0]/VB->TexCoordPtr[1]->data[i][3];
484 t1 = VB->TexCoordPtr[1]->data[i][1]/VB->TexCoordPtr[1]->data[i][3];
485 u1 = VB->TexCoordPtr[1]->data[i][2]/VB->TexCoordPtr[1]->data[i][3];
486 break;
487 case 3:
488 s1 = VB->TexCoordPtr[1]->data[i][0];
489 t1 = VB->TexCoordPtr[1]->data[i][1];
490 u1 = VB->TexCoordPtr[1]->data[i][2];
491 break;
492 case 2:
493 s1 = VB->TexCoordPtr[1]->data[i][0];
494 t1 = VB->TexCoordPtr[1]->data[i][1];
495 u1 = 0.0;
496 break;
497 case 1:
498 s1 = VB->TexCoordPtr[1]->data[i][0];
499 t1 = 0.0;
500 u1 = 0.0;
501 break;
502 default:
503 /* should never get here */
504 s1 = t1 = u1 = 0.0;
505 gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
506 }
507
508 for (iy=y0;iy<=y1;iy++) {
509 for (ix=x0;ix<=x1;ix++) {
510 PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha,
511 s, t, u, s1, t1, u1 );
512 }
513 }
514 PB_CHECK_FLUSH(ctx, PB);
515 }
516 }
517 }
518
519
520
521
522 /*
523 * Antialiased points with or without texture mapping.
524 */
525 static void
526 antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
527 {
528 struct vertex_buffer *VB = ctx->VB;
529 struct pixel_buffer *PB = ctx->PB;
530 const GLfloat radius = ctx->Point.Size * 0.5F;
531 const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
532 const GLfloat rmax = radius + 0.7071F;
533 const GLfloat rmin2 = rmin * rmin;
534 const GLfloat rmax2 = rmax * rmax;
535 const GLfloat cscale = 256.0F / (rmax2 - rmin2);
536 GLuint i;
537
538 if (ctx->Texture.ReallyEnabled) {
539 for (i = first; i <= last; i++) {
540 if (VB->ClipMask[i] == 0) {
541 GLint x, y;
542 GLint red, green, blue, alpha;
543 GLfloat s, t, u;
544 GLfloat s1, t1, u1;
545
546 GLint xmin = (GLint) (VB->Win.data[i][0] - radius);
547 GLint xmax = (GLint) (VB->Win.data[i][0] + radius);
548 GLint ymin = (GLint) (VB->Win.data[i][1] - radius);
549 GLint ymax = (GLint) (VB->Win.data[i][1] + radius);
550 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
551
552 red = VB->ColorPtr->data[i][0];
553 green = VB->ColorPtr->data[i][1];
554 blue = VB->ColorPtr->data[i][2];
555
556 switch (VB->TexCoordPtr[0]->size) {
557 case 4:
558 s = (VB->TexCoordPtr[0]->data[i][0]/
559 VB->TexCoordPtr[0]->data[i][3]);
560 t = (VB->TexCoordPtr[0]->data[i][1]/
561 VB->TexCoordPtr[0]->data[i][3]);
562 u = (VB->TexCoordPtr[0]->data[i][2]/
563 VB->TexCoordPtr[0]->data[i][3]);
564 break;
565 case 3:
566 s = VB->TexCoordPtr[0]->data[i][0];
567 t = VB->TexCoordPtr[0]->data[i][1];
568 u = VB->TexCoordPtr[0]->data[i][2];
569 break;
570 case 2:
571 s = VB->TexCoordPtr[0]->data[i][0];
572 t = VB->TexCoordPtr[0]->data[i][1];
573 u = 0.0;
574 break;
575 case 1:
576 s = VB->TexCoordPtr[0]->data[i][0];
577 t = 0.0;
578 u = 0.0;
579 break;
580 default:
581 /* should never get here */
582 s = t = u = 0.0;
583 gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
584 }
585
586 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
587 /* Multitextured! This is probably a slow enough path that
588 there's no reason to specialize the multitexture case. */
589 switch (VB->TexCoordPtr[1]->size) {
590 case 4:
591 s1 = ( VB->TexCoordPtr[1]->data[i][0] /
592 VB->TexCoordPtr[1]->data[i][3]);
593 t1 = ( VB->TexCoordPtr[1]->data[i][1] /
594 VB->TexCoordPtr[1]->data[i][3]);
595 u1 = ( VB->TexCoordPtr[1]->data[i][2] /
596 VB->TexCoordPtr[1]->data[i][3]);
597 break;
598 case 3:
599 s1 = VB->TexCoordPtr[1]->data[i][0];
600 t1 = VB->TexCoordPtr[1]->data[i][1];
601 u1 = VB->TexCoordPtr[1]->data[i][2];
602 break;
603 case 2:
604 s1 = VB->TexCoordPtr[1]->data[i][0];
605 t1 = VB->TexCoordPtr[1]->data[i][1];
606 u1 = 0.0;
607 break;
608 case 1:
609 s1 = VB->TexCoordPtr[1]->data[i][0];
610 t1 = 0.0;
611 u1 = 0.0;
612 break;
613 default:
614 /* should never get here */
615 s1 = t1 = u1 = 0.0;
616 gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
617 }
618 }
619
620 for (y=ymin;y<=ymax;y++) {
621 for (x=xmin;x<=xmax;x++) {
622 GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
623 GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
624 GLfloat dist2 = dx*dx + dy*dy;
625 if (dist2<rmax2) {
626 alpha = VB->ColorPtr->data[i][3];
627 if (dist2>=rmin2) {
628 GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale);
629 /* coverage is in [0,256] */
630 alpha = (alpha * coverage) >> 8;
631 }
632 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
633 PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, red, green, blue,
634 alpha, s, t, u, s1, t1, u1 );
635 } else {
636 PB_WRITE_TEX_PIXEL( PB, x,y,z, red, green, blue,
637 alpha, s, t, u );
638 }
639 }
640 }
641 }
642
643 PB_CHECK_FLUSH(ctx,PB);
644 }
645 }
646 }
647 else {
648 /* Not texture mapped */
649 for (i=first;i<=last;i++) {
650 if (VB->ClipMask[i]==0) {
651 GLint xmin, ymin, xmax, ymax;
652 GLint x, y, z;
653 GLint red, green, blue, alpha;
654
655 xmin = (GLint) (VB->Win.data[i][0] - radius);
656 xmax = (GLint) (VB->Win.data[i][0] + radius);
657 ymin = (GLint) (VB->Win.data[i][1] - radius);
658 ymax = (GLint) (VB->Win.data[i][1] + radius);
659 z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
660
661 red = VB->ColorPtr->data[i][0];
662 green = VB->ColorPtr->data[i][1];
663 blue = VB->ColorPtr->data[i][2];
664
665 for (y=ymin;y<=ymax;y++) {
666 for (x=xmin;x<=xmax;x++) {
667 GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
668 GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
669 GLfloat dist2 = dx*dx + dy*dy;
670 if (dist2<rmax2) {
671 alpha = VB->ColorPtr->data[i][3];
672 if (dist2>=rmin2) {
673 GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale);
674 /* coverage is in [0,256] */
675 alpha = (alpha * coverage) >> 8;
676 }
677 PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue,
678 alpha );
679 }
680 }
681 }
682 PB_CHECK_FLUSH(ctx,PB);
683 }
684 }
685 }
686 }
687
688
689
690 /*
691 * Null rasterizer for measuring transformation speed.
692 */
693 static void
694 null_points( GLcontext *ctx, GLuint first, GLuint last )
695 {
696 (void) ctx;
697 (void) first;
698 (void) last;
699 }
700
701
702
703 /* Definition of the functions for GL_EXT_point_parameters */
704
705 /* Calculates the distance attenuation formula of a vector of points in
706 * eye space coordinates
707 */
708 static void
709 dist3(GLfloat *out, GLuint first, GLuint last,
710 const GLcontext *ctx, const GLvector4f *v)
711 {
712 GLuint stride = v->stride;
713 const GLfloat *p = VEC_ELT(v, GLfloat, first);
714 GLuint i;
715
716 for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
717 GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
718 out[i] = 1.0F / (ctx->Point.Params[0] +
719 dist * (ctx->Point.Params[1] +
720 dist * ctx->Point.Params[2]));
721 }
722 }
723
724
725 static void
726 dist2(GLfloat *out, GLuint first, GLuint last,
727 const GLcontext *ctx, const GLvector4f *v)
728 {
729 GLuint stride = v->stride;
730 const GLfloat *p = VEC_ELT(v, GLfloat, first);
731 GLuint i;
732
733 for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
734 GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]);
735 out[i] = 1.0F / (ctx->Point.Params[0] +
736 dist * (ctx->Point.Params[1] +
737 dist * ctx->Point.Params[2]));
738 }
739 }
740
741
742 typedef void (*dist_func)(GLfloat *out, GLuint first, GLuint last,
743 const GLcontext *ctx, const GLvector4f *v);
744
745
746 static dist_func eye_dist_tab[5] = {
747 0,
748 0,
749 dist2,
750 dist3,
751 dist3
752 };
753
754
755 static void
756 clip_dist(GLfloat *out, GLuint first, GLuint last,
757 const GLcontext *ctx, GLvector4f *clip)
758 {
759 /* this is never called */
760 gl_problem(NULL, "clip_dist() called - dead code!\n");
761
762 (void) out;
763 (void) first;
764 (void) last;
765 (void) ctx;
766 (void) clip;
767
768 #if 0
769 GLuint i;
770 const GLfloat *from = (GLfloat *)clip_vec->start;
771 const GLuint stride = clip_vec->stride;
772
773 for (i = first ; i <= last ; i++ )
774 {
775 GLfloat dist = win[i][2];
776 out[i] = 1/(ctx->Point.Params[0]+
777 dist * (ctx->Point.Params[1] +
778 dist * ctx->Point.Params[2]));
779 }
780 #endif
781 }
782
783
784
785 /*
786 * Distance Attenuated General CI points.
787 */
788 static void
789 dist_atten_general_ci_points( GLcontext *ctx, GLuint first, GLuint last )
790 {
791 struct vertex_buffer *VB = ctx->VB;
792 struct pixel_buffer *PB = ctx->PB;
793 GLfloat dist[VB_SIZE];
794 const GLfloat psize = ctx->Point.Size;
795 GLuint i;
796
797 if (ctx->NeedEyeCoords)
798 (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr );
799 else
800 clip_dist( dist, first, last, ctx, VB->ClipPtr );
801
802 for (i=first;i<=last;i++) {
803 if (VB->ClipMask[i]==0) {
804 GLint x0, x1, y0, y1;
805 GLint ix, iy;
806 GLint isize, radius;
807 GLint x = (GLint) VB->Win.data[i][0];
808 GLint y = (GLint) VB->Win.data[i][1];
809 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
810 GLfloat dsize = psize * dist[i];
811
812 if (dsize >= ctx->Point.Threshold) {
813 isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F);
814 }
815 else {
816 isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F);
817 }
818 radius = isize >> 1;
819
820 if (isize & 1) {
821 /* odd size */
822 x0 = x - radius;
823 x1 = x + radius;
824 y0 = y - radius;
825 y1 = y + radius;
826 }
827 else {
828 /* even size */
829 x0 = (GLint) (x + 1.5F) - radius;
830 x1 = x0 + isize - 1;
831 y0 = (GLint) (y + 1.5F) - radius;
832 y1 = y0 + isize - 1;
833 }
834
835 PB_SET_INDEX( PB, VB->IndexPtr->data[i] );
836
837 for (iy=y0;iy<=y1;iy++) {
838 for (ix=x0;ix<=x1;ix++) {
839 PB_WRITE_PIXEL( PB, ix, iy, z );
840 }
841 }
842 PB_CHECK_FLUSH(ctx,PB);
843 }
844 }
845 }
846
847 /*
848 * Distance Attenuated General RGBA points.
849 */
850 static void
851 dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
852 {
853 struct vertex_buffer *VB = ctx->VB;
854 struct pixel_buffer *PB = ctx->PB;
855 GLfloat dist[VB_SIZE];
856 const GLfloat psize = ctx->Point.Size;
857 GLuint i;
858
859 if (ctx->NeedEyeCoords)
860 (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr );
861 else
862 clip_dist( dist, first, last, ctx, VB->ClipPtr );
863
864 for (i=first;i<=last;i++) {
865 if (VB->ClipMask[i]==0) {
866 GLint x0, x1, y0, y1;
867 GLint ix, iy;
868 GLint isize, radius;
869 GLint x = (GLint) VB->Win.data[i][0];
870 GLint y = (GLint) VB->Win.data[i][1];
871 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
872 GLfloat dsize=psize*dist[i];
873 GLubyte alpha;
874
875 if (dsize >= ctx->Point.Threshold) {
876 isize = (GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F);
877 alpha = VB->ColorPtr->data[i][3];
878 }
879 else {
880 isize = (GLint) (MAX2(ctx->Point.Threshold,ctx->Point.MinSize)+0.5F);
881 dsize /= ctx->Point.Threshold;
882 alpha = (GLint) (VB->ColorPtr->data[i][3]* (dsize*dsize));
883 }
884 radius = isize >> 1;
885
886 if (isize & 1) {
887 /* odd size */
888 x0 = x - radius;
889 x1 = x + radius;
890 y0 = y - radius;
891 y1 = y + radius;
892 }
893 else {
894 /* even size */
895 x0 = (GLint) (x + 1.5F) - radius;
896 x1 = x0 + isize - 1;
897 y0 = (GLint) (y + 1.5F) - radius;
898 y1 = y0 + isize - 1;
899 }
900
901 PB_SET_COLOR( PB,
902 VB->ColorPtr->data[i][0],
903 VB->ColorPtr->data[i][1],
904 VB->ColorPtr->data[i][2],
905 alpha );
906
907 for (iy=y0;iy<=y1;iy++) {
908 for (ix=x0;ix<=x1;ix++) {
909 PB_WRITE_PIXEL( PB, ix, iy, z );
910 }
911 }
912 PB_CHECK_FLUSH(ctx,PB);
913 }
914 }
915 }
916
917 /*
918 * Distance Attenuated Textured RGBA points.
919 */
920 static void
921 dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
922 {
923 struct vertex_buffer *VB = ctx->VB;
924 struct pixel_buffer *PB = ctx->PB;
925 GLfloat dist[VB_SIZE];
926 const GLfloat psize = ctx->Point.Size;
927 GLuint i;
928
929 if (ctx->NeedEyeCoords)
930 (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr );
931 else
932 clip_dist( dist, first, last, ctx, VB->ClipPtr );
933
934 for (i=first;i<=last;i++) {
935 if (VB->ClipMask[i]==0) {
936 GLint x0, x1, y0, y1;
937 GLint ix, iy;
938 GLint isize, radius;
939 GLint red, green, blue, alpha;
940 GLfloat s, t, u;
941 GLfloat s1, t1, u1;
942
943 GLint x = (GLint) VB->Win.data[i][0];
944 GLint y = (GLint) VB->Win.data[i][1];
945 GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
946
947 GLfloat dsize = psize*dist[i];
948 if(dsize >= ctx->Point.Threshold) {
949 isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F);
950 alpha = VB->ColorPtr->data[i][3];
951 }
952 else {
953 isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F);
954 dsize /= ctx->Point.Threshold;
955 alpha = (GLint) (VB->ColorPtr->data[i][3] * (dsize * dsize));
956 }
957
958 if (isize < 1) {
959 isize = 1;
960 }
961 radius = isize >> 1;
962
963 if (isize & 1) {
964 /* odd size */
965 x0 = x - radius;
966 x1 = x + radius;
967 y0 = y - radius;
968 y1 = y + radius;
969 }
970 else {
971 /* even size */
972 x0 = (GLint) (x + 1.5F) - radius;
973 x1 = x0 + isize - 1;
974 y0 = (GLint) (y + 1.5F) - radius;
975 y1 = y0 + isize - 1;
976 }
977
978 red = VB->ColorPtr->data[i][0];
979 green = VB->ColorPtr->data[i][1];
980 blue = VB->ColorPtr->data[i][2];
981
982 switch (VB->TexCoordPtr[0]->size) {
983 case 4:
984 s = (VB->TexCoordPtr[0]->data[i][0]/
985 VB->TexCoordPtr[0]->data[i][3]);
986 t = (VB->TexCoordPtr[0]->data[i][1]/
987 VB->TexCoordPtr[0]->data[i][3]);
988 u = (VB->TexCoordPtr[0]->data[i][2]/
989 VB->TexCoordPtr[0]->data[i][3]);
990 break;
991 case 3:
992 s = VB->TexCoordPtr[0]->data[i][0];
993 t = VB->TexCoordPtr[0]->data[i][1];
994 u = VB->TexCoordPtr[0]->data[i][2];
995 break;
996 case 2:
997 s = VB->TexCoordPtr[0]->data[i][0];
998 t = VB->TexCoordPtr[0]->data[i][1];
999 u = 0.0;
1000 break;
1001 case 1:
1002 s = VB->TexCoordPtr[0]->data[i][0];
1003 t = 0.0;
1004 u = 0.0;
1005 break;
1006 default:
1007 /* should never get here */
1008 s = t = u = 0.0;
1009 gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
1010 }
1011
1012 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
1013 /* Multitextured! This is probably a slow enough path that
1014 there's no reason to specialize the multitexture case. */
1015 switch (VB->TexCoordPtr[1]->size) {
1016 case 4:
1017 s1 = ( VB->TexCoordPtr[1]->data[i][0] /
1018 VB->TexCoordPtr[1]->data[i][3] );
1019 t1 = ( VB->TexCoordPtr[1]->data[i][1] /
1020 VB->TexCoordPtr[1]->data[i][3] );
1021 u1 = ( VB->TexCoordPtr[1]->data[i][2] /
1022 VB->TexCoordPtr[1]->data[i][3] );
1023 break;
1024 case 3:
1025 s1 = VB->TexCoordPtr[1]->data[i][0];
1026 t1 = VB->TexCoordPtr[1]->data[i][1];
1027 u1 = VB->TexCoordPtr[1]->data[i][2];
1028 break;
1029 case 2:
1030 s1 = VB->TexCoordPtr[1]->data[i][0];
1031 t1 = VB->TexCoordPtr[1]->data[i][1];
1032 u1 = 0.0;
1033 break;
1034 case 1:
1035 s1 = VB->TexCoordPtr[1]->data[i][0];
1036 t1 = 0.0;
1037 u1 = 0.0;
1038 break;
1039 default:
1040 /* should never get here */
1041 s1 = t1 = u1 = 0.0;
1042 gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
1043 }
1044 }
1045
1046 /* don't think this is needed
1047 PB_SET_COLOR( red, green, blue, alpha );
1048 */
1049
1050 for (iy=y0;iy<=y1;iy++) {
1051 for (ix=x0;ix<=x1;ix++) {
1052 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
1053 PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u, s1, t1, u1 );
1054 } else {
1055 PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u );
1056 }
1057 }
1058 }
1059 PB_CHECK_FLUSH(ctx,PB);
1060 }
1061 }
1062 }
1063
1064 /*
1065 * Distance Attenuated Antialiased points with or without texture mapping.
1066 */
1067 static void
1068 dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
1069 {
1070 struct vertex_buffer *VB = ctx->VB;
1071 struct pixel_buffer *PB = ctx->PB;
1072 GLfloat dist[VB_SIZE];
1073 const GLfloat psize = ctx->Point.Size;
1074 GLuint i;
1075
1076 if (ctx->NeedEyeCoords)
1077 (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr );
1078 else
1079 clip_dist( dist, first, last, ctx, VB->ClipPtr );
1080
1081 if (ctx->Texture.ReallyEnabled) {
1082 for (i=first;i<=last;i++) {
1083 if (VB->ClipMask[i]==0) {
1084 GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf;
1085 GLint xmin, ymin, xmax, ymax;
1086 GLint x, y, z;
1087 GLint red, green, blue, alpha;
1088 GLfloat s, t, u;
1089 GLfloat s1, t1, u1;
1090 GLfloat dsize = psize * dist[i];
1091
1092 if (dsize >= ctx->Point.Threshold) {
1093 radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F;
1094 alphaf = 1.0F;
1095 }
1096 else {
1097 radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F);
1098 dsize /= ctx->Point.Threshold;
1099 alphaf = (dsize*dsize);
1100 }
1101 rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
1102 rmax = radius + 0.7071F;
1103 rmin2 = rmin*rmin;
1104 rmax2 = rmax*rmax;
1105 cscale = 256.0F / (rmax2-rmin2);
1106
1107 xmin = (GLint) (VB->Win.data[i][0] - radius);
1108 xmax = (GLint) (VB->Win.data[i][0] + radius);
1109 ymin = (GLint) (VB->Win.data[i][1] - radius);
1110 ymax = (GLint) (VB->Win.data[i][1] + radius);
1111 z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
1112
1113 red = VB->ColorPtr->data[i][0];
1114 green = VB->ColorPtr->data[i][1];
1115 blue = VB->ColorPtr->data[i][2];
1116
1117 switch (VB->TexCoordPtr[0]->size) {
1118 case 4:
1119 s = (VB->TexCoordPtr[0]->data[i][0]/
1120 VB->TexCoordPtr[0]->data[i][3]);
1121 t = (VB->TexCoordPtr[0]->data[i][1]/
1122 VB->TexCoordPtr[0]->data[i][3]);
1123 u = (VB->TexCoordPtr[0]->data[i][2]/
1124 VB->TexCoordPtr[0]->data[i][3]);
1125 break;
1126 case 3:
1127 s = VB->TexCoordPtr[0]->data[i][0];
1128 t = VB->TexCoordPtr[0]->data[i][1];
1129 u = VB->TexCoordPtr[0]->data[i][2];
1130 break;
1131 case 2:
1132 s = VB->TexCoordPtr[0]->data[i][0];
1133 t = VB->TexCoordPtr[0]->data[i][1];
1134 u = 0.0;
1135 break;
1136 case 1:
1137 s = VB->TexCoordPtr[0]->data[i][0];
1138 t = 0.0;
1139 u = 0.0;
1140 break;
1141 default:
1142 /* should never get here */
1143 s = t = u = 0.0;
1144 gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
1145 }
1146
1147 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
1148 /* Multitextured! This is probably a slow enough path that
1149 there's no reason to specialize the multitexture case. */
1150 switch (VB->TexCoordPtr[1]->size) {
1151 case 4:
1152 s1 = ( VB->TexCoordPtr[1]->data[i][0] /
1153 VB->TexCoordPtr[1]->data[i][3] );
1154 t1 = ( VB->TexCoordPtr[1]->data[i][1] /
1155 VB->TexCoordPtr[1]->data[i][3] );
1156 u1 = ( VB->TexCoordPtr[1]->data[i][2] /
1157 VB->TexCoordPtr[1]->data[i][3] );
1158 break;
1159 case 3:
1160 s1 = VB->TexCoordPtr[1]->data[i][0];
1161 t1 = VB->TexCoordPtr[1]->data[i][1];
1162 u1 = VB->TexCoordPtr[1]->data[i][2];
1163 break;
1164 case 2:
1165 s1 = VB->TexCoordPtr[1]->data[i][0];
1166 t1 = VB->TexCoordPtr[1]->data[i][1];
1167 u1 = 0.0;
1168 break;
1169 case 1:
1170 s1 = VB->TexCoordPtr[1]->data[i][0];
1171 t1 = 0.0;
1172 u1 = 0.0;
1173 break;
1174 default:
1175 /* should never get here */
1176 s = t = u = 0.0;
1177 gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
1178 }
1179 }
1180
1181 for (y = ymin; y <= ymax; y++) {
1182 for (x = xmin; x <= xmax; x++) {
1183 GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
1184 GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
1185 GLfloat dist2 = dx*dx + dy*dy;
1186 if (dist2 < rmax2) {
1187 alpha = VB->ColorPtr->data[i][3];
1188 if (dist2 >= rmin2) {
1189 GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
1190 /* coverage is in [0,256] */
1191 alpha = (alpha * coverage) >> 8;
1192 }
1193 alpha = (GLint) (alpha * alphaf);
1194 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
1195 PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, red, green, blue,
1196 alpha, s, t, u, s1, t1, u1 );
1197 } else {
1198 PB_WRITE_TEX_PIXEL( PB, x,y,z, red, green, blue, alpha,
1199 s, t, u );
1200 }
1201 }
1202 }
1203 }
1204 PB_CHECK_FLUSH(ctx,PB);
1205 }
1206 }
1207 }
1208 else {
1209 /* Not texture mapped */
1210 for (i = first; i <= last; i++) {
1211 if (VB->ClipMask[i] == 0) {
1212 GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf;
1213 GLint xmin, ymin, xmax, ymax;
1214 GLint x, y, z;
1215 GLint red, green, blue, alpha;
1216 GLfloat dsize = psize * dist[i];
1217
1218 if (dsize >= ctx->Point.Threshold) {
1219 radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F;
1220 alphaf = 1.0F;
1221 }
1222 else {
1223 radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F);
1224 dsize /= ctx->Point.Threshold;
1225 alphaf = dsize * dsize;
1226 }
1227 rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
1228 rmax = radius + 0.7071F;
1229 rmin2 = rmin * rmin;
1230 rmax2 = rmax * rmax;
1231 cscale = 256.0F / (rmax2 - rmin2);
1232
1233 xmin = (GLint) (VB->Win.data[i][0] - radius);
1234 xmax = (GLint) (VB->Win.data[i][0] + radius);
1235 ymin = (GLint) (VB->Win.data[i][1] - radius);
1236 ymax = (GLint) (VB->Win.data[i][1] + radius);
1237 z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
1238
1239 red = VB->ColorPtr->data[i][0];
1240 green = VB->ColorPtr->data[i][1];
1241 blue = VB->ColorPtr->data[i][2];
1242
1243 for (y = ymin; y <= ymax; y++) {
1244 for (x = xmin; x <= xmax; x++) {
1245 GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
1246 GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
1247 GLfloat dist2 = dx * dx + dy * dy;
1248 if (dist2 < rmax2) {
1249 alpha = VB->ColorPtr->data[i][3];
1250 if (dist2 >= rmin2) {
1251 GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
1252 /* coverage is in [0,256] */
1253 alpha = (alpha * coverage) >> 8;
1254 }
1255 alpha = (GLint) (alpha * alphaf);
1256 PB_WRITE_RGBA_PIXEL(PB, x, y, z, red, green, blue, alpha);
1257 }
1258 }
1259 }
1260 PB_CHECK_FLUSH(ctx,PB);
1261 }
1262 }
1263 }
1264 }
1265
1266
1267 #ifdef DEBUG
1268 void
1269 _mesa_print_points_function(GLcontext *ctx)
1270 {
1271 printf("Point Func == ");
1272 if (ctx->Driver.PointsFunc == size1_ci_points)
1273 printf("size1_ci_points\n");
1274 else if (ctx->Driver.PointsFunc == size1_rgba_points)
1275 printf("size1_rgba_points\n");
1276 else if (ctx->Driver.PointsFunc == general_ci_points)
1277 printf("general_ci_points\n");
1278 else if (ctx->Driver.PointsFunc == general_rgba_points)
1279 printf("general_rgba_points\n");
1280 else if (ctx->Driver.PointsFunc == textured_rgba_points)
1281 printf("textured_rgba_points\n");
1282 else if (ctx->Driver.PointsFunc == multitextured_rgba_points)
1283 printf("multitextured_rgba_points\n");
1284 else if (ctx->Driver.PointsFunc == antialiased_rgba_points)
1285 printf("antialiased_rgba_points\n");
1286 else if (ctx->Driver.PointsFunc == null_points)
1287 printf("null_points\n");
1288 else if (ctx->Driver.PointsFunc == dist_atten_general_ci_points)
1289 printf("dist_atten_general_ci_points\n");
1290 else if (ctx->Driver.PointsFunc == dist_atten_general_rgba_points)
1291 printf("dist_atten_general_rgba_points\n");
1292 else if (ctx->Driver.PointsFunc == dist_atten_textured_rgba_points)
1293 printf("dist_atten_textured_rgba_points\n");
1294 else if (ctx->Driver.PointsFunc == dist_atten_antialiased_rgba_points)
1295 printf("dist_atten_antialiased_rgba_points\n");
1296 else if (!ctx->Driver.PointsFunc)
1297 printf("NULL\n");
1298 else
1299 printf("Driver func %p\n", ctx->Driver.PointsFunc);
1300 }
1301 #endif
1302
1303
1304 /*
1305 * Examine the current context to determine which point drawing function
1306 * should be used.
1307 */
1308 void gl_set_point_function( GLcontext *ctx )
1309 {
1310 GLboolean rgbmode = ctx->Visual->RGBAflag;
1311
1312 if (ctx->RenderMode==GL_RENDER) {
1313 if (ctx->NoRaster) {
1314 ctx->Driver.PointsFunc = null_points;
1315 return;
1316 }
1317 if (ctx->Driver.PointsFunc) {
1318 /* Device driver will draw points. */
1319 ctx->IndirectTriangles &= ~DD_POINT_SW_RASTERIZE;
1320 return;
1321 }
1322
1323 if (!ctx->Point.Attenuated) {
1324 if (ctx->Point.SmoothFlag && rgbmode) {
1325 ctx->Driver.PointsFunc = antialiased_rgba_points;
1326 }
1327 else if (ctx->Texture.ReallyEnabled) {
1328 if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
1329 ctx->Driver.PointsFunc = multitextured_rgba_points;
1330 }
1331 else {
1332 ctx->Driver.PointsFunc = textured_rgba_points;
1333 }
1334 }
1335 else if (ctx->Point.Size==1.0) {
1336 /* size=1, any raster ops */
1337 if (rgbmode)
1338 ctx->Driver.PointsFunc = size1_rgba_points;
1339 else
1340 ctx->Driver.PointsFunc = size1_ci_points;
1341 }
1342 else {
1343 /* every other kind of point rendering */
1344 if (rgbmode)
1345 ctx->Driver.PointsFunc = general_rgba_points;
1346 else
1347 ctx->Driver.PointsFunc = general_ci_points;
1348 }
1349 }
1350 else if(ctx->Point.SmoothFlag && rgbmode) {
1351 ctx->Driver.PointsFunc = dist_atten_antialiased_rgba_points;
1352 }
1353 else if (ctx->Texture.ReallyEnabled) {
1354 ctx->Driver.PointsFunc = dist_atten_textured_rgba_points;
1355 }
1356 else {
1357 /* every other kind of point rendering */
1358 if (rgbmode)
1359 ctx->Driver.PointsFunc = dist_atten_general_rgba_points;
1360 else
1361 ctx->Driver.PointsFunc = dist_atten_general_ci_points;
1362 }
1363 }
1364 else if (ctx->RenderMode==GL_FEEDBACK) {
1365 ctx->Driver.PointsFunc = gl_feedback_points;
1366 }
1367 else {
1368 /* GL_SELECT mode */
1369 ctx->Driver.PointsFunc = gl_select_points;
1370 }
1371
1372 /*_mesa_print_points_function(ctx);*/
1373 }
1374