1 /* $Id: s_points.c,v 1.7 2000/11/19 23:10:26 brianp 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.
34 #include "s_context.h"
35 #include "s_feedback.h"
41 /**********************************************************************/
42 /***** Rasterization *****/
43 /**********************************************************************/
47 * There are 3 pairs (RGBA, CI) of point rendering functions:
48 * 1. simple: size=1 and no special rasterization functions (fastest)
49 * 2. size1: size=1 and any rasterization functions
50 * 3. general: any size and rasterization functions (slowest)
59 * CI points with size == 1.0
62 size1_ci_point( GLcontext
*ctx
, const SWvertex
*vert
)
64 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
65 GLint
*pbx
= PB
->x
, *pby
= PB
->y
;
67 GLfixed
*pbfog
= PB
->fog
;
68 GLuint
*pbi
= PB
->index
;
69 GLuint pbcount
= PB
->count
;
71 pbx
[pbcount
] = (GLint
) vert
->win
[0];
72 pby
[pbcount
] = (GLint
) vert
->win
[1];
73 pbz
[pbcount
] = (GLint
) vert
->win
[2];
74 pbfog
[pbcount
] = FloatToFixed(vert
->fog
);
75 pbi
[pbcount
] = vert
->index
;
78 PB_CHECK_FLUSH(ctx
, PB
);
84 * RGBA points with size == 1.0
87 size1_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
89 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
91 GLint x
= (GLint
) vert
->win
[0];
92 GLint y
= (GLint
) vert
->win
[1];
93 GLint z
= (GLint
) (vert
->win
[2]);
94 GLfixed fog
= FloatToFixed( vert
->fog
);
95 GLubyte red
= vert
->color
[0];
96 GLubyte green
= vert
->color
[1];
97 GLubyte blue
= vert
->color
[2];
98 GLubyte alpha
= vert
->color
[3];
100 PB_WRITE_RGBA_PIXEL( PB
, x
, y
, z
, fog
, red
, green
, blue
, alpha
);
101 PB_CHECK_FLUSH(ctx
, PB
);
110 general_ci_point( GLcontext
*ctx
, const SWvertex
*vert
)
112 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
113 const GLint isize
= (GLint
) (ctx
->Point
._Size
+ 0.5F
);
114 GLint radius
= isize
>> 1;
116 GLint x0
, x1
, y0
, y1
;
119 GLint x
= (GLint
) vert
->win
[0];
120 GLint y
= (GLint
) vert
->win
[1];
121 GLint z
= (GLint
) (vert
->win
[2]);
123 GLfixed fog
= FloatToFixed( vert
->fog
);
134 x0
= (GLint
) (x
+ 1.5F
) - radius
;
136 y0
= (GLint
) (y
+ 1.5F
) - radius
;
140 PB_SET_INDEX( PB
, vert
->index
);
142 for (iy
= y0
; iy
<= y1
; iy
++) {
143 for (ix
= x0
; ix
<= x1
; ix
++) {
144 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
147 PB_CHECK_FLUSH(ctx
,PB
);
152 * General RGBA points.
155 general_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
157 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
158 GLint isize
= (GLint
) (ctx
->Point
._Size
+ 0.5F
);
159 GLint radius
= isize
>> 1;
161 GLint x0
, x1
, y0
, y1
;
164 GLint x
= (GLint
) vert
->win
[0];
165 GLint y
= (GLint
) vert
->win
[1];
166 GLint z
= (GLint
) (vert
->win
[2]);
168 GLfixed fog
= FloatToFixed( vert
->fog
);
179 x0
= (GLint
) (x
+ 1.5F
) - radius
;
181 y0
= (GLint
) (y
+ 1.5F
) - radius
;
191 for (iy
= y0
; iy
<= y1
; iy
++) {
192 for (ix
= x0
; ix
<= x1
; ix
++) {
193 PB_WRITE_PIXEL( PB
, ix
, iy
, z
, fog
);
196 PB_CHECK_FLUSH(ctx
,PB
);
203 * Textured RGBA points.
206 textured_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
208 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
210 GLint x0
, x1
, y0
, y1
;
211 GLint ix
, iy
, radius
;
212 GLint red
, green
, blue
, alpha
;
215 GLint x
= (GLint
) vert
->win
[0];
216 GLint y
= (GLint
) vert
->win
[1];
217 GLint z
= (GLint
) (vert
->win
[2]);
218 GLint isize
= (GLint
) (ctx
->Point
._Size
+ 0.5F
);
220 GLfixed fog
= FloatToFixed( vert
->fog
);
236 x0
= (GLint
) (x
+ 1.5F
) - radius
;
238 y0
= (GLint
) (y
+ 1.5F
) - radius
;
242 red
= vert
->color
[0];
243 green
= vert
->color
[1];
244 blue
= vert
->color
[2];
245 alpha
= vert
->color
[3];
247 if (vert
->texcoord
[0][3] != 1.0) {
248 s
= vert
->texcoord
[0][0]/vert
->texcoord
[0][3];
249 t
= vert
->texcoord
[0][1]/vert
->texcoord
[0][3];
250 u
= vert
->texcoord
[0][2]/vert
->texcoord
[0][3];
252 s
= vert
->texcoord
[0][0];
253 t
= vert
->texcoord
[0][1];
254 u
= vert
->texcoord
[0][2];
257 for (iy
= y0
; iy
<= y1
; iy
++) {
258 for (ix
= x0
; ix
<= x1
; ix
++) {
259 PB_WRITE_TEX_PIXEL( PB
, ix
, iy
, z
, fog
, red
, green
, blue
, alpha
,
264 PB_CHECK_FLUSH(ctx
, PB
);
270 * Multitextured RGBA points.
273 multitextured_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
275 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
277 const GLint red
= vert
->color
[0];
278 const GLint green
= vert
->color
[1];
279 const GLint blue
= vert
->color
[2];
280 const GLint alpha
= vert
->color
[3];
281 const GLint sRed
= vert
->specular
[0];
282 const GLint sGreen
= vert
->specular
[1];
283 const GLint sBlue
= vert
->specular
[2];
284 const GLint x
= (GLint
) vert
->win
[0];
285 const GLint y
= (GLint
) vert
->win
[1];
286 const GLint z
= (GLint
) (vert
->win
[2]);
287 GLint x0
, x1
, y0
, y1
;
289 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
291 GLint isize
= (GLint
) (ctx
->Point
._Size
+ 0.5F
);
293 GLfixed fog
= FloatToFixed( vert
->fog
);
309 x0
= (GLint
) (x
+ 1.5F
) - radius
;
311 y0
= (GLint
) (y
+ 1.5F
) - radius
;
315 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
316 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
317 if (vert
->texcoord
[u
][3] != 1.0) {
318 texcoord
[u
][0] = vert
->texcoord
[u
][0] /
319 vert
->texcoord
[u
][3];
320 texcoord
[u
][1] = vert
->texcoord
[u
][1] /
321 vert
->texcoord
[u
][3];
322 texcoord
[u
][2] = vert
->texcoord
[u
][2] /
323 vert
->texcoord
[u
][3];
326 texcoord
[u
][0] = vert
->texcoord
[u
][0];
327 texcoord
[u
][1] = vert
->texcoord
[u
][1];
328 texcoord
[u
][2] = vert
->texcoord
[u
][2];
333 for (iy
= y0
; iy
<= y1
; iy
++) {
334 for (ix
= x0
; ix
<= x1
; ix
++) {
335 PB_WRITE_MULTITEX_SPEC_PIXEL( PB
, ix
, iy
, z
, fog
,
336 red
, green
, blue
, alpha
,
341 PB_CHECK_FLUSH(ctx
, PB
);
346 * NOTES on aa point rasterization:
348 * Let d = distance of fragment center from vertex.
350 * fragment has 100% coverage
351 * else if d > rmax2 then
352 * fragment has 0% coverage
354 * fragement has % coverage = (d - rmin2) / (rmax2 - rmin2)
359 * Antialiased points with or without texture mapping.
362 antialiased_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
364 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
365 struct pixel_buffer
*PB
= swrast
->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 (swrast
->_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
, const 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
, const 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
, const SWvertex
*vert
)
617 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
618 struct pixel_buffer
*PB
= swrast
->PB
;
619 const GLfloat psize
= ctx
->Point
._Size
;
620 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
622 const GLint x
= (GLint
) vert
->win
[0];
623 const GLint y
= (GLint
) vert
->win
[1];
624 const GLint z
= (GLint
) (vert
->win
[2]);
625 const GLint red
= vert
->color
[0];
626 const GLint green
= vert
->color
[1];
627 const GLint blue
= vert
->color
[2];
628 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
629 GLint x0
, x1
, y0
, y1
;
630 GLint ix
, iy
, alpha
, u
;
632 GLfloat dsize
= psize
*dist
;
634 GLfixed fog
= FloatToFixed( vert
->fog
);
636 /* compute point size and alpha */
637 if (dsize
>= ctx
->Point
.Threshold
) {
638 isize
= (GLint
) (MIN2(dsize
, ctx
->Point
.MaxSize
) + 0.5F
);
639 alpha
= vert
->color
[3];
642 isize
= (GLint
) (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) + 0.5F
);
643 dsize
/= ctx
->Point
.Threshold
;
644 alpha
= (GLint
) (vert
->color
[3] * (dsize
* dsize
));
660 x0
= (GLint
) (x
+ 1.5F
) - radius
;
662 y0
= (GLint
) (y
+ 1.5F
) - radius
;
666 /* get texture coordinates */
667 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
668 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
669 if (texcoord
[u
][3] != 1.0) {
670 texcoord
[u
][0] = vert
->texcoord
[u
][0] /
671 vert
->texcoord
[u
][3];
672 texcoord
[u
][1] = vert
->texcoord
[u
][1] /
673 vert
->texcoord
[u
][3];
674 texcoord
[u
][2] = vert
->texcoord
[u
][2] /
675 vert
->texcoord
[u
][3];
678 texcoord
[u
][0] = vert
->texcoord
[u
][0];
679 texcoord
[u
][1] = vert
->texcoord
[u
][1];
680 texcoord
[u
][2] = vert
->texcoord
[u
][2];
685 for (iy
= y0
; iy
<= y1
; iy
++) {
686 for (ix
= x0
; ix
<= x1
; ix
++) {
687 if (swrast
->_MultiTextureEnabled
) {
688 PB_WRITE_MULTITEX_PIXEL( PB
, ix
, iy
, z
, fog
,
689 red
, green
, blue
, alpha
,
693 PB_WRITE_TEX_PIXEL( PB
, ix
, iy
, z
, fog
,
694 red
, green
, blue
, alpha
,
701 PB_CHECK_FLUSH(ctx
,PB
);
705 * Distance Attenuated Antialiased points with or without texture mapping.
708 dist_atten_antialiased_rgba_point( GLcontext
*ctx
, const SWvertex
*vert
)
710 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
711 struct pixel_buffer
*PB
= swrast
->PB
;
712 const GLfloat psize
= ctx
->Point
._Size
;
713 GLfloat dist
= attenuation_distance( ctx
, vert
->eye
);
715 if (ctx
->Texture
._ReallyEnabled
) {
716 GLfloat radius
, rmin
, rmax
, rmin2
, rmax2
, cscale
, alphaf
;
717 GLint xmin
, ymin
, xmax
, ymax
;
719 GLint red
, green
, blue
, alpha
;
720 GLfloat texcoord
[MAX_TEXTURE_UNITS
][4];
721 GLfloat dsize
= psize
* dist
;
724 GLfixed fog
= FloatToFixed( vert
->fog
);
726 if (dsize
>= ctx
->Point
.Threshold
) {
727 radius
= MIN2(dsize
, ctx
->Point
.MaxSize
) * 0.5F
;
731 radius
= (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) * 0.5F
);
732 dsize
/= ctx
->Point
.Threshold
;
733 alphaf
= (dsize
*dsize
);
735 rmin
= radius
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
736 rmax
= radius
+ 0.7071F
;
737 rmin2
= MAX2(0.0, rmin
* rmin
);
739 cscale
= 256.0F
/ (rmax2
- rmin2
);
741 xmin
= (GLint
) (vert
->win
[0] - radius
);
742 xmax
= (GLint
) (vert
->win
[0] + radius
);
743 ymin
= (GLint
) (vert
->win
[1] - radius
);
744 ymax
= (GLint
) (vert
->win
[1] + radius
);
745 z
= (GLint
) (vert
->win
[2]);
747 red
= vert
->color
[0];
748 green
= vert
->color
[1];
749 blue
= vert
->color
[2];
751 /* get texture coordinates */
752 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
753 if (ctx
->Texture
.Unit
[u
]._ReallyEnabled
) {
754 if (vert
->texcoord
[u
][3] != 1.0 && vert
->texcoord
[u
][3] != 0.0) {
755 texcoord
[u
][0] = vert
->texcoord
[u
][0] / vert
->texcoord
[u
][3];
756 texcoord
[u
][1] = vert
->texcoord
[u
][1] / vert
->texcoord
[u
][3];
757 texcoord
[u
][2] = vert
->texcoord
[u
][2] / vert
->texcoord
[u
][3];
760 texcoord
[u
][0] = vert
->texcoord
[u
][0];
761 texcoord
[u
][1] = vert
->texcoord
[u
][1];
762 texcoord
[u
][2] = vert
->texcoord
[u
][2];
767 for (y
= ymin
; y
<= ymax
; y
++) {
768 for (x
= xmin
; x
<= xmax
; x
++) {
769 const GLfloat dx
= x
+ 0.5F
- vert
->win
[0];
770 const GLfloat dy
= y
+ 0.5F
- vert
->win
[1];
771 const GLfloat dist2
= dx
*dx
+ dy
*dy
;
773 alpha
= vert
->color
[3];
774 if (dist2
>= rmin2
) {
775 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
776 /* coverage is in [0,256] */
777 alpha
= (alpha
* coverage
) >> 8;
779 alpha
= (GLint
) (alpha
* alphaf
);
780 if (swrast
->_MultiTextureEnabled
) {
781 PB_WRITE_MULTITEX_PIXEL( PB
, x
, y
, z
, fog
,
782 red
, green
, blue
, alpha
,
786 PB_WRITE_TEX_PIXEL( PB
, x
,y
,z
, fog
,
787 red
, green
, blue
, alpha
,
795 PB_CHECK_FLUSH(ctx
,PB
);
798 /* Not texture mapped */
799 GLfloat radius
, rmin
, rmax
, rmin2
, rmax2
, cscale
, alphaf
;
800 GLint xmin
, ymin
, xmax
, ymax
;
803 GLint red
, green
, blue
, alpha
;
804 GLfloat dsize
= psize
* dist
;
806 if (dsize
>= ctx
->Point
.Threshold
) {
807 radius
= MIN2(dsize
, ctx
->Point
.MaxSize
) * 0.5F
;
811 radius
= (MAX2(ctx
->Point
.Threshold
, ctx
->Point
.MinSize
) * 0.5F
);
812 dsize
/= ctx
->Point
.Threshold
;
813 alphaf
= dsize
* dsize
;
815 rmin
= radius
- 0.7071F
; /* 0.7071 = sqrt(2)/2 */
816 rmax
= radius
+ 0.7071F
;
817 rmin2
= MAX2(0.0, rmin
* rmin
);
819 cscale
= 256.0F
/ (rmax2
- rmin2
);
821 xmin
= (GLint
) (vert
->win
[0] - radius
);
822 xmax
= (GLint
) (vert
->win
[0] + radius
);
823 ymin
= (GLint
) (vert
->win
[1] - radius
);
824 ymax
= (GLint
) (vert
->win
[1] + radius
);
825 z
= (GLint
) (vert
->win
[2]);
827 fog
= FloatToFixed( vert
->fog
);
829 red
= vert
->color
[0];
830 green
= vert
->color
[1];
831 blue
= vert
->color
[2];
833 for (y
= ymin
; y
<= ymax
; y
++) {
834 for (x
= xmin
; x
<= xmax
; x
++) {
835 const GLfloat dx
= x
+ 0.5F
- vert
->win
[0];
836 const GLfloat dy
= y
+ 0.5F
- vert
->win
[1];
837 const GLfloat dist2
= dx
* dx
+ dy
* dy
;
839 alpha
= vert
->color
[3];
840 if (dist2
>= rmin2
) {
841 GLint coverage
= (GLint
) (256.0F
- (dist2
- rmin2
) * cscale
);
842 /* coverage is in [0,256] */
843 alpha
= (alpha
* coverage
) >> 8;
845 alpha
= (GLint
) (alpha
* alphaf
);
846 PB_WRITE_RGBA_PIXEL(PB
, x
, y
, z
, fog
,
847 red
, green
, blue
, alpha
);
851 PB_CHECK_FLUSH(ctx
,PB
);
858 _mesa_print_point_function(GLcontext
*ctx
); /* silence compiler warning */
860 _mesa_print_point_function(GLcontext
*ctx
)
862 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
864 printf("Point Func == ");
865 if (swrast
->Point
== size1_ci_point
)
866 printf("size1_ci_point\n");
867 else if (swrast
->Point
== size1_rgba_point
)
868 printf("size1_rgba_point\n");
869 else if (swrast
->Point
== general_ci_point
)
870 printf("general_ci_point\n");
871 else if (swrast
->Point
== general_rgba_point
)
872 printf("general_rgba_point\n");
873 else if (swrast
->Point
== textured_rgba_point
)
874 printf("textured_rgba_point\n");
875 else if (swrast
->Point
== multitextured_rgba_point
)
876 printf("multitextured_rgba_point\n");
877 else if (swrast
->Point
== antialiased_rgba_point
)
878 printf("antialiased_rgba_point\n");
879 else if (swrast
->Point
== dist_atten_general_ci_point
)
880 printf("dist_atten_general_ci_point\n");
881 else if (swrast
->Point
== dist_atten_general_rgba_point
)
882 printf("dist_atten_general_rgba_point\n");
883 else if (swrast
->Point
== dist_atten_textured_rgba_point
)
884 printf("dist_atten_textured_rgba_point\n");
885 else if (swrast
->Point
== dist_atten_antialiased_rgba_point
)
886 printf("dist_atten_antialiased_rgba_point\n");
887 else if (!swrast
->Point
)
890 printf("Driver func %p\n", swrast
->Point
);
896 * Examine the current context to determine which point drawing function
900 _swrast_choose_point( GLcontext
*ctx
)
902 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
903 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
905 if (ctx
->RenderMode
==GL_RENDER
) {
906 if (!ctx
->Point
._Attenuated
) {
907 if (ctx
->Point
.SmoothFlag
&& rgbmode
) {
908 swrast
->Point
= antialiased_rgba_point
;
910 else if (ctx
->Texture
._ReallyEnabled
) {
911 if (swrast
->_MultiTextureEnabled
||
912 ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
||
913 ctx
->Fog
.ColorSumEnabled
) {
914 swrast
->Point
= multitextured_rgba_point
;
917 swrast
->Point
= textured_rgba_point
;
920 else if (ctx
->Point
._Size
== 1.0) {
921 /* size=1, any raster ops */
923 swrast
->Point
= size1_rgba_point
;
925 swrast
->Point
= size1_ci_point
;
928 /* every other kind of point rendering */
930 swrast
->Point
= general_rgba_point
;
932 swrast
->Point
= general_ci_point
;
935 else if(ctx
->Point
.SmoothFlag
&& rgbmode
) {
936 swrast
->Point
= dist_atten_antialiased_rgba_point
;
938 else if (ctx
->Texture
._ReallyEnabled
) {
939 swrast
->Point
= dist_atten_textured_rgba_point
;
942 /* every other kind of point rendering */
944 swrast
->Point
= dist_atten_general_rgba_point
;
946 swrast
->Point
= dist_atten_general_ci_point
;
949 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
950 swrast
->Point
= gl_feedback_point
;
954 swrast
->Point
= gl_select_point
;
957 /*_mesa_print_points_function(ctx);*/