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