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