1 /* $Id: s_points.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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.
35 #include "s_context.h"
36 #include "s_feedback.h"
42 /**********************************************************************/
43 /***** Rasterization *****/
44 /**********************************************************************/
48 * There are 3 pairs (RGBA, CI) of point rendering functions:
49 * 1. simple: size=1 and no special rasterization functions (fastest)
50 * 2. size1: size=1 and any rasterization functions
51 * 3. general: any size and rasterization functions (slowest)
60 * CI points with size == 1.0
63 size1_ci_point( GLcontext
*ctx
, SWvertex
*vert
)
65 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
66 GLint
*pbx
= PB
->x
, *pby
= PB
->y
;
68 GLfixed
*pbfog
= PB
->fog
;
69 GLuint
*pbi
= PB
->index
;
70 GLuint pbcount
= PB
->count
;
72 pbx
[pbcount
] = (GLint
) vert
->win
[0];
73 pby
[pbcount
] = (GLint
) vert
->win
[1];
74 pbz
[pbcount
] = (GLint
) vert
->win
[2];
75 pbfog
[pbcount
] = FloatToFixed(vert
->fog
);
76 pbi
[pbcount
] = vert
->index
;
79 PB_CHECK_FLUSH(ctx
, PB
);
85 * RGBA points with size == 1.0
88 size1_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
90 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
92 GLint x
= (GLint
) vert
->win
[0];
93 GLint y
= (GLint
) vert
->win
[1];
94 GLint z
= (GLint
) (vert
->win
[2]);
95 GLfixed fog
= FloatToFixed( vert
->fog
);
96 GLubyte red
= vert
->color
[0];
97 GLubyte green
= vert
->color
[1];
98 GLubyte blue
= vert
->color
[2];
99 GLubyte alpha
= vert
->color
[3];
101 PB_WRITE_RGBA_PIXEL( PB
, x
, y
, z
, fog
, red
, green
, blue
, alpha
);
102 PB_CHECK_FLUSH(ctx
, PB
);
111 general_ci_point( GLcontext
*ctx
, SWvertex
*vert
)
113 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
114 const GLint isize
= (GLint
) (ctx
->Point
.Size
+ 0.5F
);
115 GLint radius
= isize
>> 1;
117 GLint x0
, x1
, y0
, y1
;
120 GLint x
= (GLint
) vert
->win
[0];
121 GLint y
= (GLint
) vert
->win
[1];
122 GLint z
= (GLint
) (vert
->win
[2]);
124 GLfixed fog
= FloatToFixed( vert
->fog
);
135 x0
= (GLint
) (x
+ 1.5F
) - radius
;
137 y0
= (GLint
) (y
+ 1.5F
) - radius
;
141 PB_SET_INDEX( PB
, vert
->index
);
143 for (iy
= y0
; iy
<= y1
; iy
++) {
144 for (ix
= x0
; ix
<= x1
; ix
++) {
145 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
148 PB_CHECK_FLUSH(ctx
,PB
);
153 * General RGBA points.
156 general_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
158 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
159 GLint isize
= (GLint
) (ctx
->Point
.Size
+ 0.5F
);
160 GLint radius
= isize
>> 1;
162 GLint x0
, x1
, y0
, y1
;
165 GLint x
= (GLint
) vert
->win
[0];
166 GLint y
= (GLint
) vert
->win
[1];
167 GLint z
= (GLint
) (vert
->win
[2]);
169 GLfixed fog
= FloatToFixed( vert
->fog
);
180 x0
= (GLint
) (x
+ 1.5F
) - radius
;
182 y0
= (GLint
) (y
+ 1.5F
) - radius
;
192 for (iy
= y0
; iy
<= y1
; iy
++) {
193 for (ix
= x0
; ix
<= x1
; ix
++) {
194 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
197 PB_CHECK_FLUSH(ctx
,PB
);
204 * Textured RGBA points.
207 textured_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
209 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
211 GLint x0
, x1
, y0
, y1
;
212 GLint ix
, iy
, radius
;
213 GLint red
, green
, blue
, alpha
;
216 GLint x
= (GLint
) vert
->win
[0];
217 GLint y
= (GLint
) vert
->win
[1];
218 GLint z
= (GLint
) (vert
->win
[2]);
219 GLint isize
= (GLint
) (ctx
->Point
.Size
+ 0.5F
);
221 GLfixed fog
= FloatToFixed( vert
->fog
);
237 x0
= (GLint
) (x
+ 1.5F
) - radius
;
239 y0
= (GLint
) (y
+ 1.5F
) - radius
;
243 red
= vert
->color
[0];
244 green
= vert
->color
[1];
245 blue
= vert
->color
[2];
246 alpha
= vert
->color
[3];
248 if (vert
->texcoord
[0][3] != 1.0) {
249 s
= vert
->texcoord
[0][0]/vert
->texcoord
[0][3];
250 t
= vert
->texcoord
[0][1]/vert
->texcoord
[0][3];
251 u
= vert
->texcoord
[0][2]/vert
->texcoord
[0][3];
253 s
= vert
->texcoord
[0][0];
254 t
= vert
->texcoord
[0][1];
255 u
= vert
->texcoord
[0][2];
258 for (iy
= y0
; iy
<= y1
; iy
++) {
259 for (ix
= x0
; ix
<= x1
; ix
++) {
260 PB_WRITE_TEX_PIXEL( PB
, ix
, iy
, z
, fog
, red
, green
, blue
, alpha
,
265 PB_CHECK_FLUSH(ctx
, PB
);
271 * Multitextured RGBA points.
274 multitextured_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
276 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
278 const GLint red
= vert
->color
[0];
279 const GLint green
= vert
->color
[1];
280 const GLint blue
= vert
->color
[2];
281 const GLint alpha
= vert
->color
[3];
282 const GLint sRed
= vert
->specular
[0];
283 const GLint sGreen
= vert
->specular
[1];
284 const GLint sBlue
= vert
->specular
[2];
285 const GLint x
= (GLint
) vert
->win
[0];
286 const GLint y
= (GLint
) vert
->win
[1];
287 const GLint z
= (GLint
) (vert
->win
[2]);
288 GLint x0
, x1
, y0
, y1
;
290 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
292 GLint isize
= (GLint
) (ctx
->Point
.Size
+ 0.5F
);
294 GLfixed fog
= FloatToFixed( vert
->fog
);
310 x0
= (GLint
) (x
+ 1.5F
) - radius
;
312 y0
= (GLint
) (y
+ 1.5F
) - radius
;
316 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
317 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
318 if (vert
->texcoord
[u
][3] != 1.0) {
319 texcoord
[u
][0] = vert
->texcoord
[u
][0] /
320 vert
->texcoord
[u
][3];
321 texcoord
[u
][1] = vert
->texcoord
[u
][1] /
322 vert
->texcoord
[u
][3];
323 texcoord
[u
][2] = vert
->texcoord
[u
][2] /
324 vert
->texcoord
[u
][3];
327 texcoord
[u
][0] = vert
->texcoord
[u
][0];
328 texcoord
[u
][1] = vert
->texcoord
[u
][1];
329 texcoord
[u
][2] = vert
->texcoord
[u
][2];
334 for (iy
= y0
; iy
<= y1
; iy
++) {
335 for (ix
= x0
; ix
<= x1
; ix
++) {
336 PB_WRITE_MULTITEX_SPEC_PIXEL( PB
, ix
, iy
, z
, fog
,
337 red
, green
, blue
, alpha
,
342 PB_CHECK_FLUSH(ctx
, PB
);
347 * NOTES on aa point rasterization:
349 * Let d = distance of fragment center from vertex.
351 * fragment has 100% coverage
352 * else if d > rmax2 then
353 * fragment has 0% coverage
355 * fragement has % coverage = (d - rmin2) / (rmax2 - rmin2)
360 * Antialiased points with or without texture mapping.
363 antialiased_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
365 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
366 const GLfloat radius
= ctx
->Point
.Size
* 0.5F
;
367 const GLfloat rmin
= radius
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
368 const GLfloat rmax
= radius
+ 0.7071F
;
369 const GLfloat rmin2
= MAX2(0.0, rmin
* rmin
);
370 const GLfloat rmax2
= rmax
* rmax
;
371 const GLfloat cscale
= 256.0F
/ (rmax2
- rmin2
);
373 if (ctx
->Texture
._ReallyEnabled
) {
375 GLfloat vx
= vert
->win
[0];
376 GLfloat vy
= vert
->win
[1];
377 const GLint xmin
= (GLint
) (vx
- radius
);
378 const GLint xmax
= (GLint
) (vx
+ radius
);
379 const GLint ymin
= (GLint
) (vy
- radius
);
380 const GLint ymax
= (GLint
) (vy
+ radius
);
381 const GLint z
= (GLint
) (vert
->win
[2]);
382 const GLint red
= vert
->color
[0];
383 const GLint green
= vert
->color
[1];
384 const GLint blue
= vert
->color
[2];
385 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
388 GLfixed fog
= FloatToFixed( vert
->fog
);
390 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
391 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
392 if (texcoord
[u
][3] != 1.0) {
393 texcoord
[u
][0] = (vert
->texcoord
[u
][0] /
394 vert
->texcoord
[u
][3]);
395 texcoord
[u
][1] = (vert
->texcoord
[u
][1] /
396 vert
->texcoord
[u
][3]);
397 texcoord
[u
][2] = (vert
->texcoord
[u
][2] /
398 vert
->texcoord
[u
][3]);
401 texcoord
[u
][0] = vert
->texcoord
[u
][0];
402 texcoord
[u
][1] = vert
->texcoord
[u
][1];
403 texcoord
[u
][2] = vert
->texcoord
[u
][2];
408 /* translate by a half pixel to simplify math below */
412 for (y
= ymin
; y
<= ymax
; y
++) {
413 for (x
= xmin
; x
<= xmax
; x
++) {
414 const GLfloat dx
= x
- vx
;
415 const GLfloat dy
= y
- vy
;
416 const GLfloat dist2
= dx
*dx
+ dy
*dy
;
418 alpha
= vert
->color
[3];
419 if (dist2
>= rmin2
) {
420 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
421 /* coverage is in [0,256] */
422 alpha
= (alpha
* coverage
) >> 8;
424 if (ctx
->Texture
._MultiTextureEnabled
) {
425 PB_WRITE_MULTITEX_PIXEL( PB
, x
,y
,z
, fog
,
430 PB_WRITE_TEX_PIXEL( PB
, x
,y
,z
, fog
,
431 red
, green
, blue
, alpha
,
440 PB_CHECK_FLUSH(ctx
,PB
);
443 /* Not texture mapped */
444 const GLint xmin
= (GLint
) (vert
->win
[0] - 0.0 - radius
);
445 const GLint xmax
= (GLint
) (vert
->win
[0] - 0.0 + radius
);
446 const GLint ymin
= (GLint
) (vert
->win
[1] - 0.0 - radius
);
447 const GLint ymax
= (GLint
) (vert
->win
[1] - 0.0 + radius
);
448 const GLint red
= vert
->color
[0];
449 const GLint green
= vert
->color
[1];
450 const GLint blue
= vert
->color
[2];
451 const GLint z
= (GLint
) (vert
->win
[2]);
454 GLfixed fog
= FloatToFixed( vert
->fog
);
457 printf("point %g, %g\n", vert->win[0], vert->win[1]);
458 printf("%d..%d X %d..%d\n", xmin, xmax, ymin, ymax);
460 for (y
= ymin
; y
<= ymax
; y
++) {
461 for (x
= xmin
; x
<= xmax
; x
++) {
462 const GLfloat dx
= x
+ 0.5F
- vert
->win
[0];
463 const GLfloat dy
= y
+ 0.5F
- vert
->win
[1];
464 const GLfloat dist2
= dx
*dx
+ dy
*dy
;
466 GLint alpha
= vert
->color
[3];
467 if (dist2
>= rmin2
) {
468 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
469 /* coverage is in [0,256] */
470 alpha
= (alpha
* coverage
) >> 8;
472 PB_WRITE_RGBA_PIXEL(PB
, x
, y
, z
, fog
,
473 red
, green
, blue
, alpha
);
477 PB_CHECK_FLUSH(ctx
,PB
);
483 /* Definition of the functions for GL_EXT_point_parameters */
485 /* Calculates the distance attenuation formula of a vector of points in
486 * eye space coordinates
488 static GLfloat
attenuation_distance(const GLcontext
*ctx
, const GLfloat
*pos
)
490 GLfloat dist
= GL_SQRT(pos
[0]*pos
[0]+pos
[1]*pos
[1]+pos
[2]*pos
[2]);
491 return 1.0F
/ (ctx
->Point
.Params
[0] +
492 dist
* (ctx
->Point
.Params
[1] +
493 dist
* ctx
->Point
.Params
[2]));
501 * Distance Attenuated General CI points.
504 dist_atten_general_ci_point( GLcontext
*ctx
, SWvertex
*vert
)
506 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
507 const GLfloat psize
= ctx
->Point
.Size
;
508 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
509 GLint x0
, x1
, y0
, y1
;
512 GLint x
= (GLint
) vert
->win
[0];
513 GLint y
= (GLint
) vert
->win
[1];
514 GLint z
= (GLint
) (vert
->win
[2]);
515 GLfloat dsize
= psize
* dist
;
517 GLfixed fog
= FloatToFixed( vert
->fog
);
519 if (dsize
>= ctx
->Point
.Threshold
) {
520 isize
= (GLint
) (MIN2(dsize
, ctx
->Point
.MaxSize
) + 0.5F
);
523 isize
= (GLint
) (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) + 0.5F
);
536 x0
= (GLint
) (x
+ 1.5F
) - radius
;
538 y0
= (GLint
) (y
+ 1.5F
) - radius
;
542 PB_SET_INDEX( PB
, vert
->index
);
544 for (iy
=y0
;iy
<=y1
;iy
++) {
545 for (ix
=x0
;ix
<=x1
;ix
++) {
546 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
549 PB_CHECK_FLUSH(ctx
,PB
);
553 * Distance Attenuated General RGBA points.
556 dist_atten_general_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
558 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
559 const GLfloat psize
= ctx
->Point
.Size
;
560 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
561 GLint x0
, x1
, y0
, y1
;
564 GLint x
= (GLint
) vert
->win
[0];
565 GLint y
= (GLint
) vert
->win
[1];
566 GLint z
= (GLint
) (vert
->win
[2]);
567 GLfloat dsize
=psize
*dist
;
569 GLfixed fog
= FloatToFixed( vert
->fog
);
571 if (dsize
>= ctx
->Point
.Threshold
) {
572 isize
= (GLint
) (MIN2(dsize
,ctx
->Point
.MaxSize
)+0.5F
);
573 alpha
= vert
->color
[3];
576 isize
= (GLint
) (MAX2(ctx
->Point
.Threshold
,ctx
->Point
.MinSize
)+0.5F
);
577 dsize
/= ctx
->Point
.Threshold
;
578 alpha
= (GLint
) (vert
->color
[3]* (dsize
*dsize
));
591 x0
= (GLint
) (x
+ 1.5F
) - radius
;
593 y0
= (GLint
) (y
+ 1.5F
) - radius
;
603 for (iy
= y0
; iy
<= y1
; iy
++) {
604 for (ix
= x0
; ix
<= x1
; ix
++) {
605 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
608 PB_CHECK_FLUSH(ctx
,PB
);
612 * Distance Attenuated Textured RGBA points.
615 dist_atten_textured_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
617 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
618 const GLfloat psize
= ctx
->Point
.Size
;
619 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
621 const GLint x
= (GLint
) vert
->win
[0];
622 const GLint y
= (GLint
) vert
->win
[1];
623 const GLint z
= (GLint
) (vert
->win
[2]);
624 const GLint red
= vert
->color
[0];
625 const GLint green
= vert
->color
[1];
626 const GLint blue
= vert
->color
[2];
627 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
628 GLint x0
, x1
, y0
, y1
;
629 GLint ix
, iy
, alpha
, u
;
631 GLfloat dsize
= psize
*dist
;
633 GLfixed fog
= FloatToFixed( vert
->fog
);
635 /* compute point size and alpha */
636 if (dsize
>= ctx
->Point
.Threshold
) {
637 isize
= (GLint
) (MIN2(dsize
, ctx
->Point
.MaxSize
) + 0.5F
);
638 alpha
= vert
->color
[3];
641 isize
= (GLint
) (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) + 0.5F
);
642 dsize
/= ctx
->Point
.Threshold
;
643 alpha
= (GLint
) (vert
->color
[3] * (dsize
* dsize
));
659 x0
= (GLint
) (x
+ 1.5F
) - radius
;
661 y0
= (GLint
) (y
+ 1.5F
) - radius
;
665 /* get texture coordinates */
666 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
667 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
668 if (texcoord
[u
][3] != 1.0) {
669 texcoord
[u
][0] = vert
->texcoord
[u
][0] /
670 vert
->texcoord
[u
][3];
671 texcoord
[u
][1] = vert
->texcoord
[u
][1] /
672 vert
->texcoord
[u
][3];
673 texcoord
[u
][2] = vert
->texcoord
[u
][2] /
674 vert
->texcoord
[u
][3];
677 texcoord
[u
][0] = vert
->texcoord
[u
][0];
678 texcoord
[u
][1] = vert
->texcoord
[u
][1];
679 texcoord
[u
][2] = vert
->texcoord
[u
][2];
684 for (iy
= y0
; iy
<= y1
; iy
++) {
685 for (ix
= x0
; ix
<= x1
; ix
++) {
686 if (ctx
->Texture
._MultiTextureEnabled
) {
687 PB_WRITE_MULTITEX_PIXEL( PB
, ix
, iy
, z
, fog
,
688 red
, green
, blue
, alpha
,
692 PB_WRITE_TEX_PIXEL( PB
, ix
, iy
, z
, fog
,
693 red
, green
, blue
, alpha
,
700 PB_CHECK_FLUSH(ctx
,PB
);
704 * Distance Attenuated Antialiased points with or without texture mapping.
707 dist_atten_antialiased_rgba_point( GLcontext
*ctx
, SWvertex
*vert
)
709 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
710 const GLfloat psize
= ctx
->Point
.Size
;
711 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
713 if (ctx
->Texture
._ReallyEnabled
) {
714 GLfloat radius
, rmin
, rmax
, rmin2
, rmax2
, cscale
, alphaf
;
715 GLint xmin
, ymin
, xmax
, ymax
;
717 GLint red
, green
, blue
, alpha
;
718 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
719 GLfloat dsize
= psize
* dist
;
722 GLfixed fog
= FloatToFixed( vert
->fog
);
724 if (dsize
>= ctx
->Point
.Threshold
) {
725 radius
= MIN2(dsize
, ctx
->Point
.MaxSize
) * 0.5F
;
729 radius
= (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) * 0.5F
);
730 dsize
/= ctx
->Point
.Threshold
;
731 alphaf
= (dsize
*dsize
);
733 rmin
= radius
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
734 rmax
= radius
+ 0.7071F
;
735 rmin2
= MAX2(0.0, rmin
* rmin
);
737 cscale
= 256.0F
/ (rmax2
- rmin2
);
739 xmin
= (GLint
) (vert
->win
[0] - radius
);
740 xmax
= (GLint
) (vert
->win
[0] + radius
);
741 ymin
= (GLint
) (vert
->win
[1] - radius
);
742 ymax
= (GLint
) (vert
->win
[1] + radius
);
743 z
= (GLint
) (vert
->win
[2]);
745 red
= vert
->color
[0];
746 green
= vert
->color
[1];
747 blue
= vert
->color
[2];
749 /* get texture coordinates */
750 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
751 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
752 if (vert
->texcoord
[u
][3] != 1.0 && vert
->texcoord
[u
][3] != 0.0) {
753 texcoord
[u
][0] = vert
->texcoord
[u
][0] / vert
->texcoord
[u
][3];
754 texcoord
[u
][1] = vert
->texcoord
[u
][1] / vert
->texcoord
[u
][3];
755 texcoord
[u
][2] = vert
->texcoord
[u
][2] / vert
->texcoord
[u
][3];
758 texcoord
[u
][0] = vert
->texcoord
[u
][0];
759 texcoord
[u
][1] = vert
->texcoord
[u
][1];
760 texcoord
[u
][2] = vert
->texcoord
[u
][2];
765 for (y
= ymin
; y
<= ymax
; y
++) {
766 for (x
= xmin
; x
<= xmax
; x
++) {
767 const GLfloat dx
= x
+ 0.5F
- vert
->win
[0];
768 const GLfloat dy
= y
+ 0.5F
- vert
->win
[1];
769 const GLfloat dist2
= dx
*dx
+ dy
*dy
;
771 alpha
= vert
->color
[3];
772 if (dist2
>= rmin2
) {
773 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
774 /* coverage is in [0,256] */
775 alpha
= (alpha
* coverage
) >> 8;
777 alpha
= (GLint
) (alpha
* alphaf
);
778 if (ctx
->Texture
._MultiTextureEnabled
) {
779 PB_WRITE_MULTITEX_PIXEL( PB
, x
, y
, z
, fog
,
780 red
, green
, blue
, alpha
,
784 PB_WRITE_TEX_PIXEL( PB
, x
,y
,z
, fog
,
785 red
, green
, blue
, alpha
,
793 PB_CHECK_FLUSH(ctx
,PB
);
796 /* Not texture mapped */
797 GLfloat radius
, rmin
, rmax
, rmin2
, rmax2
, cscale
, alphaf
;
798 GLint xmin
, ymin
, xmax
, ymax
;
801 GLint red
, green
, blue
, alpha
;
802 GLfloat dsize
= psize
* dist
;
804 if (dsize
>= ctx
->Point
.Threshold
) {
805 radius
= MIN2(dsize
, ctx
->Point
.MaxSize
) * 0.5F
;
809 radius
= (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) * 0.5F
);
810 dsize
/= ctx
->Point
.Threshold
;
811 alphaf
= dsize
* dsize
;
813 rmin
= radius
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
814 rmax
= radius
+ 0.7071F
;
815 rmin2
= MAX2(0.0, rmin
* rmin
);
817 cscale
= 256.0F
/ (rmax2
- rmin2
);
819 xmin
= (GLint
) (vert
->win
[0] - radius
);
820 xmax
= (GLint
) (vert
->win
[0] + radius
);
821 ymin
= (GLint
) (vert
->win
[1] - radius
);
822 ymax
= (GLint
) (vert
->win
[1] + radius
);
823 z
= (GLint
) (vert
->win
[2]);
825 fog
= FloatToFixed( vert
->fog
);
827 red
= vert
->color
[0];
828 green
= vert
->color
[1];
829 blue
= vert
->color
[2];
831 for (y
= ymin
; y
<= ymax
; y
++) {
832 for (x
= xmin
; x
<= xmax
; x
++) {
833 const GLfloat dx
= x
+ 0.5F
- vert
->win
[0];
834 const GLfloat dy
= y
+ 0.5F
- vert
->win
[1];
835 const GLfloat dist2
= dx
* dx
+ dy
* dy
;
837 alpha
= vert
->color
[3];
838 if (dist2
>= rmin2
) {
839 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
840 /* coverage is in [0,256] */
841 alpha
= (alpha
* coverage
) >> 8;
843 alpha
= (GLint
) (alpha
* alphaf
);
844 PB_WRITE_RGBA_PIXEL(PB
, x
, y
, z
, fog
,
845 red
, green
, blue
, alpha
);
849 PB_CHECK_FLUSH(ctx
,PB
);
856 _mesa_print_point_function(GLcontext
*ctx
)
858 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
860 printf("Point Func == ");
861 if (swrast
->Point
== size1_ci_point
)
862 printf("size1_ci_point\n");
863 else if (swrast
->Point
== size1_rgba_point
)
864 printf("size1_rgba_point\n");
865 else if (swrast
->Point
== general_ci_point
)
866 printf("general_ci_point\n");
867 else if (swrast
->Point
== general_rgba_point
)
868 printf("general_rgba_point\n");
869 else if (swrast
->Point
== textured_rgba_point
)
870 printf("textured_rgba_point\n");
871 else if (swrast
->Point
== multitextured_rgba_point
)
872 printf("multitextured_rgba_point\n");
873 else if (swrast
->Point
== antialiased_rgba_point
)
874 printf("antialiased_rgba_point\n");
875 else if (swrast
->Point
== dist_atten_general_ci_point
)
876 printf("dist_atten_general_ci_point\n");
877 else if (swrast
->Point
== dist_atten_general_rgba_point
)
878 printf("dist_atten_general_rgba_point\n");
879 else if (swrast
->Point
== dist_atten_textured_rgba_point
)
880 printf("dist_atten_textured_rgba_point\n");
881 else if (swrast
->Point
== dist_atten_antialiased_rgba_point
)
882 printf("dist_atten_antialiased_rgba_point\n");
883 else if (!swrast
->Point
)
886 printf("Driver func %p\n", swrast
->Point
);
892 * Examine the current context to determine which point drawing function
896 _swrast_choose_point( GLcontext
*ctx
)
898 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
899 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
901 if (ctx
->RenderMode
==GL_RENDER
) {
902 if (!ctx
->Point
._Attenuated
) {
903 if (ctx
->Point
.SmoothFlag
&& rgbmode
) {
904 swrast
->Point
= antialiased_rgba_point
;
906 else if (ctx
->Texture
._ReallyEnabled
) {
907 if (ctx
->Texture
._MultiTextureEnabled
||
908 ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
||
909 ctx
->Fog
.ColorSumEnabled
) {
910 swrast
->Point
= multitextured_rgba_point
;
913 swrast
->Point
= textured_rgba_point
;
916 else if (ctx
->Point
.Size
==1.0) {
917 /* size=1, any raster ops */
919 swrast
->Point
= size1_rgba_point
;
921 swrast
->Point
= size1_ci_point
;
924 /* every other kind of point rendering */
926 swrast
->Point
= general_rgba_point
;
928 swrast
->Point
= general_ci_point
;
931 else if(ctx
->Point
.SmoothFlag
&& rgbmode
) {
932 swrast
->Point
= dist_atten_antialiased_rgba_point
;
934 else if (ctx
->Texture
._ReallyEnabled
) {
935 swrast
->Point
= dist_atten_textured_rgba_point
;
938 /* every other kind of point rendering */
940 swrast
->Point
= dist_atten_general_rgba_point
;
942 swrast
->Point
= dist_atten_general_ci_point
;
945 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
946 swrast
->Point
= gl_feedback_point
;
950 swrast
->Point
= gl_select_point
;
953 /*_mesa_print_points_function(ctx);*/