1 /* $Id: points.c,v 1.32 2002/04/02 16:15:16 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 _mesa_PointSize( GLfloat size
)
45 GET_CURRENT_CONTEXT(ctx
);
46 ASSERT_OUTSIDE_BEGIN_END(ctx
);
49 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
53 if (ctx
->Point
.Size
== size
)
56 FLUSH_VERTICES(ctx
, _NEW_POINT
);
57 ctx
->Point
.Size
= size
;
58 ctx
->Point
._Size
= CLAMP(size
,
59 ctx
->Const
.MinPointSize
,
60 ctx
->Const
.MaxPointSize
);
62 if (ctx
->Point
._Size
== 1.0F
)
63 ctx
->_TriangleCaps
&= ~DD_POINT_SIZE
;
65 ctx
->_TriangleCaps
|= DD_POINT_SIZE
;
67 if (ctx
->Driver
.PointSize
)
68 (*ctx
->Driver
.PointSize
)(ctx
, size
);
74 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
77 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
79 _mesa_PointParameterfvEXT(pname
, ¶m
);
85 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
88 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
90 GET_CURRENT_CONTEXT(ctx
);
91 ASSERT_OUTSIDE_BEGIN_END(ctx
);
93 if (!ctx
->Extensions
.EXT_point_parameters
) {
94 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPointParameterf[v]{EXT,ARB}(pname)");
99 case GL_DISTANCE_ATTENUATION_EXT
:
101 const GLboolean tmp
= ctx
->Point
._Attenuated
;
102 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
105 FLUSH_VERTICES(ctx
, _NEW_POINT
);
106 COPY_3V(ctx
->Point
.Params
, params
);
108 /* Update several derived values now. This likely to be
109 * more efficient than trying to catch this statechange in
112 ctx
->Point
._Attenuated
= (params
[0] != 1.0 ||
116 if (tmp
!= ctx
->Point
._Attenuated
) {
117 ctx
->_TriangleCaps
^= DD_POINT_ATTEN
;
118 ctx
->_NeedEyeCoords
^= NEED_EYE_POINT_ATTEN
;
122 case GL_POINT_SIZE_MIN_EXT
:
123 if (*params
< 0.0F
) {
124 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointParameterf[v]{EXT,ARB}(param)" );
127 if (ctx
->Point
.MinSize
== *params
)
129 FLUSH_VERTICES(ctx
, _NEW_POINT
);
130 ctx
->Point
.MinSize
= *params
;
132 case GL_POINT_SIZE_MAX_EXT
:
133 if (*params
< 0.0F
) {
134 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointParameterf[v]{EXT,ARB}(param)" );
137 if (ctx
->Point
.MaxSize
== *params
)
139 FLUSH_VERTICES(ctx
, _NEW_POINT
);
140 ctx
->Point
.MaxSize
= *params
;
142 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
143 if (*params
< 0.0F
) {
144 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointParameterf[v]{EXT,ARB}(param)" );
147 if (ctx
->Point
.Threshold
== *params
)
149 FLUSH_VERTICES(ctx
, _NEW_POINT
);
150 ctx
->Point
.Threshold
= *params
;
153 _mesa_error( ctx
, GL_INVALID_ENUM
, "glPointParameterf[v]{EXT,ARB}(pname)" );
157 if (ctx
->Driver
.PointParameterfv
)
158 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);