7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2007 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.
40 * Set current point size.
41 * \param size point diameter in pixels
45 _mesa_PointSize( GLfloat size
)
47 GET_CURRENT_CONTEXT(ctx
);
48 ASSERT_OUTSIDE_BEGIN_END(ctx
);
51 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
55 if (ctx
->Point
.Size
== size
)
58 FLUSH_VERTICES(ctx
, _NEW_POINT
);
59 ctx
->Point
.Size
= size
;
60 ctx
->Point
._Size
= CLAMP(ctx
->Point
.Size
,
64 if (ctx
->Driver
.PointSize
)
65 ctx
->Driver
.PointSize(ctx
, size
);
72 * Added by GL_NV_point_sprite
75 _mesa_PointParameteriNV( GLenum pname
, GLint param
)
77 const GLfloat value
= (GLfloat
) param
;
78 _mesa_PointParameterfvEXT(pname
, &value
);
83 * Added by GL_NV_point_sprite
86 _mesa_PointParameterivNV( GLenum pname
, const GLint
*params
)
88 const GLfloat value
= (GLfloat
) params
[0];
89 _mesa_PointParameterfvEXT(pname
, &value
);
95 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
98 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
100 _mesa_PointParameterfvEXT(pname
, ¶m
);
106 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
109 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
111 GET_CURRENT_CONTEXT(ctx
);
112 ASSERT_OUTSIDE_BEGIN_END(ctx
);
115 case GL_DISTANCE_ATTENUATION_EXT
:
116 if (ctx
->Extensions
.EXT_point_parameters
) {
117 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
119 FLUSH_VERTICES(ctx
, _NEW_POINT
);
120 COPY_3V(ctx
->Point
.Params
, params
);
121 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0 ||
122 ctx
->Point
.Params
[1] != 0.0 ||
123 ctx
->Point
.Params
[2] != 0.0);
126 _mesa_error(ctx
, GL_INVALID_ENUM
,
127 "glPointParameterf[v]{EXT,ARB}(pname)");
131 case GL_POINT_SIZE_MIN_EXT
:
132 if (ctx
->Extensions
.EXT_point_parameters
) {
133 if (params
[0] < 0.0F
) {
134 _mesa_error( ctx
, GL_INVALID_VALUE
,
135 "glPointParameterf[v]{EXT,ARB}(param)" );
138 if (ctx
->Point
.MinSize
== params
[0])
140 FLUSH_VERTICES(ctx
, _NEW_POINT
);
141 ctx
->Point
.MinSize
= params
[0];
144 _mesa_error(ctx
, GL_INVALID_ENUM
,
145 "glPointParameterf[v]{EXT,ARB}(pname)");
149 case GL_POINT_SIZE_MAX_EXT
:
150 if (ctx
->Extensions
.EXT_point_parameters
) {
151 if (params
[0] < 0.0F
) {
152 _mesa_error( ctx
, GL_INVALID_VALUE
,
153 "glPointParameterf[v]{EXT,ARB}(param)" );
156 if (ctx
->Point
.MaxSize
== params
[0])
158 FLUSH_VERTICES(ctx
, _NEW_POINT
);
159 ctx
->Point
.MaxSize
= params
[0];
162 _mesa_error(ctx
, GL_INVALID_ENUM
,
163 "glPointParameterf[v]{EXT,ARB}(pname)");
167 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
168 if (ctx
->Extensions
.EXT_point_parameters
) {
169 if (params
[0] < 0.0F
) {
170 _mesa_error( ctx
, GL_INVALID_VALUE
,
171 "glPointParameterf[v]{EXT,ARB}(param)" );
174 if (ctx
->Point
.Threshold
== params
[0])
176 FLUSH_VERTICES(ctx
, _NEW_POINT
);
177 ctx
->Point
.Threshold
= params
[0];
180 _mesa_error(ctx
, GL_INVALID_ENUM
,
181 "glPointParameterf[v]{EXT,ARB}(pname)");
185 case GL_POINT_SPRITE_R_MODE_NV
:
186 /* This is one area where ARB_point_sprite and NV_point_sprite
187 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
188 * always ZERO. NV_point_sprite adds the S and R modes.
190 if (ctx
->Extensions
.NV_point_sprite
) {
191 GLenum value
= (GLenum
) params
[0];
192 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
193 _mesa_error(ctx
, GL_INVALID_VALUE
,
194 "glPointParameterf[v]{EXT,ARB}(param)");
197 if (ctx
->Point
.SpriteRMode
== value
)
199 FLUSH_VERTICES(ctx
, _NEW_POINT
);
200 ctx
->Point
.SpriteRMode
= value
;
203 _mesa_error(ctx
, GL_INVALID_ENUM
,
204 "glPointParameterf[v]{EXT,ARB}(pname)");
208 case GL_POINT_SPRITE_COORD_ORIGIN
:
209 if (ctx
->Extensions
.ARB_point_sprite
) {
210 GLenum value
= (GLenum
) params
[0];
211 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
212 _mesa_error(ctx
, GL_INVALID_VALUE
,
213 "glPointParameterf[v]{EXT,ARB}(param)");
216 if (ctx
->Point
.SpriteOrigin
== value
)
218 FLUSH_VERTICES(ctx
, _NEW_POINT
);
219 ctx
->Point
.SpriteOrigin
= value
;
222 _mesa_error(ctx
, GL_INVALID_ENUM
,
223 "glPointParameterf[v]{EXT,ARB}(pname)");
228 _mesa_error( ctx
, GL_INVALID_ENUM
,
229 "glPointParameterf[v]{EXT,ARB}(pname)" );
233 if (ctx
->Driver
.PointParameterfv
)
234 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
241 * Initialize the context point state.
243 * \param ctx GL context.
245 * Initializes __GLcontextRec::Point and point related constants in
246 * __GLcontextRec::Const.
249 _mesa_init_point(GLcontext
*ctx
)
253 ctx
->Point
.SmoothFlag
= GL_FALSE
;
254 ctx
->Point
.Size
= 1.0;
255 ctx
->Point
._Size
= 1.0;
256 ctx
->Point
.Params
[0] = 1.0;
257 ctx
->Point
.Params
[1] = 0.0;
258 ctx
->Point
.Params
[2] = 0.0;
259 ctx
->Point
._Attenuated
= GL_FALSE
;
260 ctx
->Point
.MinSize
= 0.0;
262 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
263 ctx
->Point
.Threshold
= 1.0;
264 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB/NV_point_sprite */
265 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
266 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
267 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
268 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB/NV_point_sprite */