-/* $Id: points.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: points.c,v 1.7 2000/03/02 18:34:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
-
-
-
#ifdef PC_HEADER
#include "all.h"
#else
+#include "glheader.h"
#include "context.h"
#include "feedback.h"
#include "macros.h"
+#include "mmath.h"
#include "pb.h"
+#include "points.h"
#include "span.h"
#include "texstate.h"
#include "types.h"
#include "vb.h"
-#include "mmath.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
#endif
-void gl_PointSize( GLcontext *ctx, GLfloat size )
+void
+_mesa_PointSize( GLfloat size )
{
- if (size<=0.0) {
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
+
+ if (size <= 0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glPointSize" );
return;
}
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
if (ctx->Point.Size != size) {
ctx->Point.Size = size;
- ctx->TriangleCaps &= DD_POINT_SIZE;
+ ctx->TriangleCaps &= ~DD_POINT_SIZE;
if (size != 1.0) ctx->TriangleCaps |= DD_POINT_SIZE;
ctx->NewState |= NEW_RASTER_OPS;
}
-void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
- const GLfloat *params)
+void
+_mesa_PointParameterfEXT( GLenum pname, GLfloat param)
{
+ _mesa_PointParameterfvEXT(pname, ¶m);
+}
+
+
+void
+_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointParameterfvEXT");
- if(pname==GL_DISTANCE_ATTENUATION_EXT) {
- GLboolean tmp = ctx->Point.Attenuated;
- COPY_3V(ctx->Point.Params,params);
- ctx->Point.Attenuated = (params[0] != 1.0 ||
- params[1] != 0.0 ||
- params[2] != 0.0);
-
- if (tmp != ctx->Point.Attenuated) {
- ctx->Enabled ^= ENABLE_POINT_ATTEN;
- ctx->TriangleCaps ^= DD_POINT_ATTEN;
- ctx->NewState |= NEW_RASTER_OPS;
- }
- } else {
- if (*params<0.0 ) {
+
+ switch (pname) {
+ case GL_DISTANCE_ATTENUATION_EXT:
+ {
+ const GLboolean tmp = ctx->Point.Attenuated;
+ COPY_3V(ctx->Point.Params, params);
+ ctx->Point.Attenuated = (params[0] != 1.0 ||
+ params[1] != 0.0 ||
+ params[2] != 0.0);
+
+ if (tmp != ctx->Point.Attenuated) {
+ ctx->Enabled ^= ENABLE_POINT_ATTEN;
+ ctx->TriangleCaps ^= DD_POINT_ATTEN;
+ ctx->NewState |= NEW_RASTER_OPS;
+ }
+ }
+ break;
+ case GL_POINT_SIZE_MIN_EXT:
+ if (*params < 0.0F) {
gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
return;
- }
- switch (pname) {
- case GL_POINT_SIZE_MIN_EXT:
- ctx->Point.MinSize=*params;
- break;
- case GL_POINT_SIZE_MAX_EXT:
- ctx->Point.MaxSize=*params;
- break;
- case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
- ctx->Point.Threshold=*params;
- break;
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
- return;
- }
+ }
+ ctx->Point.MinSize = *params;
+ break;
+ case GL_POINT_SIZE_MAX_EXT:
+ if (*params < 0.0F) {
+ gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
+ return;
+ }
+ ctx->Point.MaxSize = *params;
+ break;
+ case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+ if (*params < 0.0F) {
+ gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
+ return;
+ }
+ ctx->Point.Threshold = *params;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
+ return;
}
+
ctx->NewState |= NEW_RASTER_OPS;
}
-/*
- * Put points in feedback buffer.
- */
-static void feedback_points( GLcontext *ctx, GLuint first, GLuint last )
-{
- struct vertex_buffer *VB = ctx->VB;
- GLuint texUnit = ctx->Texture.CurrentTransformUnit;
- GLuint tsize = VB->TexCoordPtr[texUnit]->size;
- GLuint i;
- GLfloat texcoord[4];
-
- ASSIGN_4V(texcoord, 0,0,0,1);
-
- for (i=first;i<=last;i++) {
- if (VB->ClipMask[i]==0) {
- GLfloat x, y, z, w, invq;
- GLfloat color[4];
- x = VB->Win.data[i][0];
- y = VB->Win.data[i][1];
- z = VB->Win.data[i][2] / DEPTH_SCALE;
- w = VB->ClipPtr->data[i][3];
-
- if (tsize == 4) {
- invq = 1.0F / VB->TexCoordPtr[texUnit]->data[i][3];
- texcoord[0] = VB->TexCoordPtr[texUnit]->data[i][0] * invq;
- texcoord[1] = VB->TexCoordPtr[texUnit]->data[i][1] * invq;
- texcoord[2] = VB->TexCoordPtr[texUnit]->data[i][2] * invq;
- texcoord[3] = VB->TexCoordPtr[texUnit]->data[i][3];
- } else {
- COPY_SZ_4V(texcoord, tsize, VB->TexCoordPtr[texUnit]->data[i]);
- }
-
- FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN );
-
- UBYTE_RGBA_TO_FLOAT_RGBA( color, VB->ColorPtr->data[i] );
-
- gl_feedback_vertex( ctx, x, y, z, w, color,
- (GLfloat) VB->IndexPtr->data[i], texcoord
-);
- }
- }
-}
-
-
-
-/*
- * Put points in selection buffer.
- */
-static void select_points( GLcontext *ctx, GLuint first, GLuint last )
-{
- struct vertex_buffer *VB = ctx->VB;
- GLuint i;
-
- for (i=first;i<=last;i++) {
- if (VB->ClipMask[i]==0) {
- gl_update_hitflag( ctx, VB->Win.data[i][2] / DEPTH_SCALE );
- }
- }
-}
/*
* CI points with size == 1.0
*/
-void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last )
+static void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last )
{
struct vertex_buffer *VB = ctx->VB;
struct pixel_buffer *PB = ctx->PB;
t = 0.0;
u = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in textured_rgba_points()");
}
-
-
-
/* don't think this is needed
PB_SET_COLOR( red, green, blue, alpha );
*/
t = 0.0;
u = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
}
switch (VB->TexCoordPtr[1]->size) {
t1 = 0.0;
u1 = 0.0;
break;
+ default:
+ /* should never get here */
+ s1 = t1 = u1 = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
}
for (iy=y0;iy<=y1;iy++) {
t = 0.0;
u = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
}
if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
t1 = 0.0;
u1 = 0.0;
break;
+ default:
+ /* should never get here */
+ s1 = t1 = u1 = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
}
}
const GLcontext *ctx, const GLvector4f *v)
{
GLuint stride = v->stride;
- GLfloat *p = VEC_ELT(v, GLfloat, first);
+ const GLfloat *p = VEC_ELT(v, GLfloat, first);
GLuint i;
- for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
- {
+ for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
- out[i] = 1/(ctx->Point.Params[0]+
- dist * (ctx->Point.Params[1] +
- dist * ctx->Point.Params[2]));
+ out[i] = 1.0F / (ctx->Point.Params[0] +
+ dist * (ctx->Point.Params[1] +
+ dist * ctx->Point.Params[2]));
}
}
const GLcontext *ctx, const GLvector4f *v)
{
GLuint stride = v->stride;
- GLfloat *p = VEC_ELT(v, GLfloat, first);
+ const GLfloat *p = VEC_ELT(v, GLfloat, first);
GLuint i;
- for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
- {
+ for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]);
- out[i] = 1/(ctx->Point.Params[0]+
- dist * (ctx->Point.Params[1] +
- dist * ctx->Point.Params[2]));
+ out[i] = 1.0F / (ctx->Point.Params[0] +
+ dist * (ctx->Point.Params[1] +
+ dist * ctx->Point.Params[2]));
}
}
t = 0.0;
u = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
}
if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
t1 = 0.0;
u1 = 0.0;
break;
+ default:
+ /* should never get here */
+ s1 = t1 = u1 = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
}
}
t = 0.0;
u = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
}
if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
t1 = 0.0;
u1 = 0.0;
break;
+ default:
+ /* should never get here */
+ s = t = u = 0.0;
+ gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
}
}
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
- ctx->Driver.PointsFunc = feedback_points;
+ ctx->Driver.PointsFunc = gl_feedback_points;
}
else {
/* GL_SELECT mode */
- ctx->Driver.PointsFunc = select_points;
+ ctx->Driver.PointsFunc = gl_select_points;
}
}