7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 * \param size pointer diameter.
46 * Verifies the parameter and updates gl_point_attrib::Size. On a change,
47 * flushes the vertices, updates the clamped point size and marks the
48 * DD_POINT_SIZE flag in __GLcontextRec::_TriangleCaps for the drivers if the
49 * size is different from one. Notifies the driver via
50 * the dd_function_table::PointSize callback.
53 _mesa_PointSize( GLfloat size
)
55 GET_CURRENT_CONTEXT(ctx
);
56 ASSERT_OUTSIDE_BEGIN_END(ctx
);
59 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
63 if (ctx
->Point
.Size
== size
)
66 FLUSH_VERTICES(ctx
, _NEW_POINT
);
67 ctx
->Point
.Size
= size
;
68 ctx
->Point
._Size
= CLAMP(size
,
69 ctx
->Const
.MinPointSize
,
70 ctx
->Const
.MaxPointSize
);
72 if (ctx
->Point
._Size
== 1.0F
)
73 ctx
->_TriangleCaps
&= ~DD_POINT_SIZE
;
75 ctx
->_TriangleCaps
|= DD_POINT_SIZE
;
77 if (ctx
->Driver
.PointSize
)
78 (*ctx
->Driver
.PointSize
)(ctx
, size
);
85 * Added by GL_NV_point_sprite
88 _mesa_PointParameteriNV( GLenum pname
, GLint param
)
90 const GLfloat value
= (GLfloat
) param
;
91 _mesa_PointParameterfvEXT(pname
, &value
);
96 * Added by GL_NV_point_sprite
99 _mesa_PointParameterivNV( GLenum pname
, const GLint
*params
)
101 const GLfloat value
= (GLfloat
) params
[0];
102 _mesa_PointParameterfvEXT(pname
, &value
);
108 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
111 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
113 _mesa_PointParameterfvEXT(pname
, ¶m
);
119 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
122 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
124 GET_CURRENT_CONTEXT(ctx
);
125 ASSERT_OUTSIDE_BEGIN_END(ctx
);
128 case GL_DISTANCE_ATTENUATION_EXT
:
129 if (ctx
->Extensions
.EXT_point_parameters
) {
130 const GLboolean tmp
= ctx
->Point
._Attenuated
;
131 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
134 FLUSH_VERTICES(ctx
, _NEW_POINT
);
135 COPY_3V(ctx
->Point
.Params
, params
);
137 /* Update several derived values now. This likely to be
138 * more efficient than trying to catch this statechange in
141 ctx
->Point
._Attenuated
= (params
[0] != 1.0 ||
145 if (tmp
!= ctx
->Point
._Attenuated
) {
146 ctx
->_TriangleCaps
^= DD_POINT_ATTEN
;
150 _mesa_error(ctx
, GL_INVALID_ENUM
,
151 "glPointParameterf[v]{EXT,ARB}(pname)");
155 case GL_POINT_SIZE_MIN_EXT
:
156 if (ctx
->Extensions
.EXT_point_parameters
) {
157 if (params
[0] < 0.0F
) {
158 _mesa_error( ctx
, GL_INVALID_VALUE
,
159 "glPointParameterf[v]{EXT,ARB}(param)" );
162 if (ctx
->Point
.MinSize
== params
[0])
164 FLUSH_VERTICES(ctx
, _NEW_POINT
);
165 ctx
->Point
.MinSize
= params
[0];
168 _mesa_error(ctx
, GL_INVALID_ENUM
,
169 "glPointParameterf[v]{EXT,ARB}(pname)");
173 case GL_POINT_SIZE_MAX_EXT
:
174 if (ctx
->Extensions
.EXT_point_parameters
) {
175 if (params
[0] < 0.0F
) {
176 _mesa_error( ctx
, GL_INVALID_VALUE
,
177 "glPointParameterf[v]{EXT,ARB}(param)" );
180 if (ctx
->Point
.MaxSize
== params
[0])
182 FLUSH_VERTICES(ctx
, _NEW_POINT
);
183 ctx
->Point
.MaxSize
= params
[0];
186 _mesa_error(ctx
, GL_INVALID_ENUM
,
187 "glPointParameterf[v]{EXT,ARB}(pname)");
191 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
192 if (ctx
->Extensions
.EXT_point_parameters
) {
193 if (params
[0] < 0.0F
) {
194 _mesa_error( ctx
, GL_INVALID_VALUE
,
195 "glPointParameterf[v]{EXT,ARB}(param)" );
198 if (ctx
->Point
.Threshold
== params
[0])
200 FLUSH_VERTICES(ctx
, _NEW_POINT
);
201 ctx
->Point
.Threshold
= params
[0];
204 _mesa_error(ctx
, GL_INVALID_ENUM
,
205 "glPointParameterf[v]{EXT,ARB}(pname)");
209 case GL_POINT_SPRITE_R_MODE_NV
:
210 /* This is one area where ARB_point_sprite and NV_point_sprite
211 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
212 * always ZERO. NV_point_sprite adds the S and R modes.
214 if (ctx
->Extensions
.NV_point_sprite
) {
215 GLenum value
= (GLenum
) params
[0];
216 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
217 _mesa_error(ctx
, GL_INVALID_VALUE
,
218 "glPointParameterf[v]{EXT,ARB}(param)");
221 if (ctx
->Point
.SpriteRMode
== value
)
223 FLUSH_VERTICES(ctx
, _NEW_POINT
);
224 ctx
->Point
.SpriteRMode
= value
;
227 _mesa_error(ctx
, GL_INVALID_ENUM
,
228 "glPointParameterf[v]{EXT,ARB}(pname)");
233 _mesa_error( ctx
, GL_INVALID_ENUM
,
234 "glPointParameterf[v]{EXT,ARB}(pname)" );
238 if (ctx
->Driver
.PointParameterfv
)
239 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
245 * Initialize the context point state.
247 * \param ctx GL context.
249 * Initializes __GLcontextRec::Point and point related constants in
250 * __GLcontextRec::Const.
252 void _mesa_init_point( GLcontext
* ctx
)
257 ctx
->Point
.SmoothFlag
= GL_FALSE
;
258 ctx
->Point
.Size
= 1.0;
259 ctx
->Point
._Size
= 1.0;
260 ctx
->Point
.Params
[0] = 1.0;
261 ctx
->Point
.Params
[1] = 0.0;
262 ctx
->Point
.Params
[2] = 0.0;
263 ctx
->Point
._Attenuated
= GL_FALSE
;
264 ctx
->Point
.MinSize
= 0.0;
265 ctx
->Point
.MaxSize
= ctx
->Const
.MaxPointSize
;
266 ctx
->Point
.Threshold
= 1.0;
267 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB_point_sprite / GL_NV_point_sprite */
268 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
269 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
270 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB_point_sprite / GL_NV_point_sprite */