1 /* $Id: points.c,v 1.33 2002/05/27 17:04:53 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 * Added by GL_NV_point_sprite
77 _mesa_PointParameteriNV( GLenum pname
, GLint param
)
79 const GLfloat value
= (GLfloat
) param
;
80 _mesa_PointParameterfvEXT(pname
, &value
);
85 * Added by GL_NV_point_sprite
88 _mesa_PointParameterivNV( GLenum pname
, const GLint
*params
)
90 const GLfloat value
= (GLfloat
) params
[0];
91 _mesa_PointParameterfvEXT(pname
, &value
);
97 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
100 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
102 _mesa_PointParameterfvEXT(pname
, ¶m
);
108 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
111 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
113 GET_CURRENT_CONTEXT(ctx
);
114 ASSERT_OUTSIDE_BEGIN_END(ctx
);
117 case GL_DISTANCE_ATTENUATION_EXT
:
118 if (ctx
->Extensions
.EXT_point_parameters
) {
119 const GLboolean tmp
= ctx
->Point
._Attenuated
;
120 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
123 FLUSH_VERTICES(ctx
, _NEW_POINT
);
124 COPY_3V(ctx
->Point
.Params
, params
);
126 /* Update several derived values now. This likely to be
127 * more efficient than trying to catch this statechange in
130 ctx
->Point
._Attenuated
= (params
[0] != 1.0 ||
134 if (tmp
!= ctx
->Point
._Attenuated
) {
135 ctx
->_TriangleCaps
^= DD_POINT_ATTEN
;
136 ctx
->_NeedEyeCoords
^= NEED_EYE_POINT_ATTEN
;
140 _mesa_error(ctx
, GL_INVALID_ENUM
,
141 "glPointParameterf[v]{EXT,ARB}(pname)");
145 case GL_POINT_SIZE_MIN_EXT
:
146 if (ctx
->Extensions
.EXT_point_parameters
) {
147 if (params
[0] < 0.0F
) {
148 _mesa_error( ctx
, GL_INVALID_VALUE
,
149 "glPointParameterf[v]{EXT,ARB}(param)" );
152 if (ctx
->Point
.MinSize
== params
[0])
154 FLUSH_VERTICES(ctx
, _NEW_POINT
);
155 ctx
->Point
.MinSize
= params
[0];
158 _mesa_error(ctx
, GL_INVALID_ENUM
,
159 "glPointParameterf[v]{EXT,ARB}(pname)");
163 case GL_POINT_SIZE_MAX_EXT
:
164 if (ctx
->Extensions
.EXT_point_parameters
) {
165 if (params
[0] < 0.0F
) {
166 _mesa_error( ctx
, GL_INVALID_VALUE
,
167 "glPointParameterf[v]{EXT,ARB}(param)" );
170 if (ctx
->Point
.MaxSize
== params
[0])
172 FLUSH_VERTICES(ctx
, _NEW_POINT
);
173 ctx
->Point
.MaxSize
= params
[0];
176 _mesa_error(ctx
, GL_INVALID_ENUM
,
177 "glPointParameterf[v]{EXT,ARB}(pname)");
181 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
182 if (ctx
->Extensions
.EXT_point_parameters
) {
183 if (params
[0] < 0.0F
) {
184 _mesa_error( ctx
, GL_INVALID_VALUE
,
185 "glPointParameterf[v]{EXT,ARB}(param)" );
188 if (ctx
->Point
.Threshold
== params
[0])
190 FLUSH_VERTICES(ctx
, _NEW_POINT
);
191 ctx
->Point
.Threshold
= params
[0];
194 _mesa_error(ctx
, GL_INVALID_ENUM
,
195 "glPointParameterf[v]{EXT,ARB}(pname)");
199 case GL_POINT_SPRITE_R_MODE_NV
:
200 if (ctx
->Extensions
.NV_point_sprite
) {
201 GLenum value
= (GLenum
) params
[0];
202 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
203 _mesa_error(ctx
, GL_INVALID_VALUE
,
204 "glPointParameterf[v]{EXT,ARB}(param)");
207 if (ctx
->Point
.SpriteRMode
== value
)
209 FLUSH_VERTICES(ctx
, _NEW_POINT
);
210 ctx
->Point
.SpriteRMode
= value
;
213 _mesa_error(ctx
, GL_INVALID_ENUM
,
214 "glPointParameterf[v]{EXT,ARB}(pname)");
219 _mesa_error( ctx
, GL_INVALID_ENUM
,
220 "glPointParameterf[v]{EXT,ARB}(pname)" );
224 if (ctx
->Driver
.PointParameterfv
)
225 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);