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