1 /* $Id: points.c,v 1.34 2002/10/24 23:57:21 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.
39 _mesa_PointSize( GLfloat size
)
41 GET_CURRENT_CONTEXT(ctx
);
42 ASSERT_OUTSIDE_BEGIN_END(ctx
);
45 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
49 if (ctx
->Point
.Size
== size
)
52 FLUSH_VERTICES(ctx
, _NEW_POINT
);
53 ctx
->Point
.Size
= size
;
54 ctx
->Point
._Size
= CLAMP(size
,
55 ctx
->Const
.MinPointSize
,
56 ctx
->Const
.MaxPointSize
);
58 if (ctx
->Point
._Size
== 1.0F
)
59 ctx
->_TriangleCaps
&= ~DD_POINT_SIZE
;
61 ctx
->_TriangleCaps
|= DD_POINT_SIZE
;
63 if (ctx
->Driver
.PointSize
)
64 (*ctx
->Driver
.PointSize
)(ctx
, size
);
70 * Added by GL_NV_point_sprite
73 _mesa_PointParameteriNV( GLenum pname
, GLint param
)
75 const GLfloat value
= (GLfloat
) param
;
76 _mesa_PointParameterfvEXT(pname
, &value
);
81 * Added by GL_NV_point_sprite
84 _mesa_PointParameterivNV( GLenum pname
, const GLint
*params
)
86 const GLfloat value
= (GLfloat
) params
[0];
87 _mesa_PointParameterfvEXT(pname
, &value
);
93 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
96 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
98 _mesa_PointParameterfvEXT(pname
, ¶m
);
104 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
107 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
109 GET_CURRENT_CONTEXT(ctx
);
110 ASSERT_OUTSIDE_BEGIN_END(ctx
);
113 case GL_DISTANCE_ATTENUATION_EXT
:
114 if (ctx
->Extensions
.EXT_point_parameters
) {
115 const GLboolean tmp
= ctx
->Point
._Attenuated
;
116 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
119 FLUSH_VERTICES(ctx
, _NEW_POINT
);
120 COPY_3V(ctx
->Point
.Params
, params
);
122 /* Update several derived values now. This likely to be
123 * more efficient than trying to catch this statechange in
126 ctx
->Point
._Attenuated
= (params
[0] != 1.0 ||
130 if (tmp
!= ctx
->Point
._Attenuated
) {
131 ctx
->_TriangleCaps
^= DD_POINT_ATTEN
;
132 ctx
->_NeedEyeCoords
^= NEED_EYE_POINT_ATTEN
;
136 _mesa_error(ctx
, GL_INVALID_ENUM
,
137 "glPointParameterf[v]{EXT,ARB}(pname)");
141 case GL_POINT_SIZE_MIN_EXT
:
142 if (ctx
->Extensions
.EXT_point_parameters
) {
143 if (params
[0] < 0.0F
) {
144 _mesa_error( ctx
, GL_INVALID_VALUE
,
145 "glPointParameterf[v]{EXT,ARB}(param)" );
148 if (ctx
->Point
.MinSize
== params
[0])
150 FLUSH_VERTICES(ctx
, _NEW_POINT
);
151 ctx
->Point
.MinSize
= params
[0];
154 _mesa_error(ctx
, GL_INVALID_ENUM
,
155 "glPointParameterf[v]{EXT,ARB}(pname)");
159 case GL_POINT_SIZE_MAX_EXT
:
160 if (ctx
->Extensions
.EXT_point_parameters
) {
161 if (params
[0] < 0.0F
) {
162 _mesa_error( ctx
, GL_INVALID_VALUE
,
163 "glPointParameterf[v]{EXT,ARB}(param)" );
166 if (ctx
->Point
.MaxSize
== params
[0])
168 FLUSH_VERTICES(ctx
, _NEW_POINT
);
169 ctx
->Point
.MaxSize
= params
[0];
172 _mesa_error(ctx
, GL_INVALID_ENUM
,
173 "glPointParameterf[v]{EXT,ARB}(pname)");
177 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
178 if (ctx
->Extensions
.EXT_point_parameters
) {
179 if (params
[0] < 0.0F
) {
180 _mesa_error( ctx
, GL_INVALID_VALUE
,
181 "glPointParameterf[v]{EXT,ARB}(param)" );
184 if (ctx
->Point
.Threshold
== params
[0])
186 FLUSH_VERTICES(ctx
, _NEW_POINT
);
187 ctx
->Point
.Threshold
= params
[0];
190 _mesa_error(ctx
, GL_INVALID_ENUM
,
191 "glPointParameterf[v]{EXT,ARB}(pname)");
195 case GL_POINT_SPRITE_R_MODE_NV
:
196 if (ctx
->Extensions
.NV_point_sprite
) {
197 GLenum value
= (GLenum
) params
[0];
198 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
199 _mesa_error(ctx
, GL_INVALID_VALUE
,
200 "glPointParameterf[v]{EXT,ARB}(param)");
203 if (ctx
->Point
.SpriteRMode
== value
)
205 FLUSH_VERTICES(ctx
, _NEW_POINT
);
206 ctx
->Point
.SpriteRMode
= value
;
209 _mesa_error(ctx
, GL_INVALID_ENUM
,
210 "glPointParameterf[v]{EXT,ARB}(pname)");
215 _mesa_error( ctx
, GL_INVALID_ENUM
,
216 "glPointParameterf[v]{EXT,ARB}(pname)" );
220 if (ctx
->Driver
.PointParameterfv
)
221 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);