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
;
61 if (ctx
->Driver
.PointSize
)
62 ctx
->Driver
.PointSize(ctx
, size
);
69 * Added by GL_NV_point_sprite
72 _mesa_PointParameteriNV( GLenum pname
, GLint param
)
74 const GLfloat value
= (GLfloat
) param
;
75 _mesa_PointParameterfvEXT(pname
, &value
);
80 * Added by GL_NV_point_sprite
83 _mesa_PointParameterivNV( GLenum pname
, const GLint
*params
)
86 p
[0] = (GLfloat
) params
[0];
87 if (pname
== GL_DISTANCE_ATTENUATION_EXT
) {
88 p
[1] = (GLfloat
) params
[1];
89 p
[2] = (GLfloat
) params
[2];
91 _mesa_PointParameterfvEXT(pname
, p
);
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 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
121 FLUSH_VERTICES(ctx
, _NEW_POINT
);
122 COPY_3V(ctx
->Point
.Params
, params
);
123 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0 ||
124 ctx
->Point
.Params
[1] != 0.0 ||
125 ctx
->Point
.Params
[2] != 0.0);
128 _mesa_error(ctx
, GL_INVALID_ENUM
,
129 "glPointParameterf[v]{EXT,ARB}(pname)");
133 case GL_POINT_SIZE_MIN_EXT
:
134 if (ctx
->Extensions
.EXT_point_parameters
) {
135 if (params
[0] < 0.0F
) {
136 _mesa_error( ctx
, GL_INVALID_VALUE
,
137 "glPointParameterf[v]{EXT,ARB}(param)" );
140 if (ctx
->Point
.MinSize
== params
[0])
142 FLUSH_VERTICES(ctx
, _NEW_POINT
);
143 ctx
->Point
.MinSize
= params
[0];
146 _mesa_error(ctx
, GL_INVALID_ENUM
,
147 "glPointParameterf[v]{EXT,ARB}(pname)");
151 case GL_POINT_SIZE_MAX_EXT
:
152 if (ctx
->Extensions
.EXT_point_parameters
) {
153 if (params
[0] < 0.0F
) {
154 _mesa_error( ctx
, GL_INVALID_VALUE
,
155 "glPointParameterf[v]{EXT,ARB}(param)" );
158 if (ctx
->Point
.MaxSize
== params
[0])
160 FLUSH_VERTICES(ctx
, _NEW_POINT
);
161 ctx
->Point
.MaxSize
= params
[0];
164 _mesa_error(ctx
, GL_INVALID_ENUM
,
165 "glPointParameterf[v]{EXT,ARB}(pname)");
169 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
170 if (ctx
->Extensions
.EXT_point_parameters
) {
171 if (params
[0] < 0.0F
) {
172 _mesa_error( ctx
, GL_INVALID_VALUE
,
173 "glPointParameterf[v]{EXT,ARB}(param)" );
176 if (ctx
->Point
.Threshold
== params
[0])
178 FLUSH_VERTICES(ctx
, _NEW_POINT
);
179 ctx
->Point
.Threshold
= params
[0];
182 _mesa_error(ctx
, GL_INVALID_ENUM
,
183 "glPointParameterf[v]{EXT,ARB}(pname)");
187 case GL_POINT_SPRITE_R_MODE_NV
:
188 /* This is one area where ARB_point_sprite and NV_point_sprite
189 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
190 * always ZERO. NV_point_sprite adds the S and R modes.
192 if (ctx
->Extensions
.NV_point_sprite
) {
193 GLenum value
= (GLenum
) params
[0];
194 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
195 _mesa_error(ctx
, GL_INVALID_VALUE
,
196 "glPointParameterf[v]{EXT,ARB}(param)");
199 if (ctx
->Point
.SpriteRMode
== value
)
201 FLUSH_VERTICES(ctx
, _NEW_POINT
);
202 ctx
->Point
.SpriteRMode
= value
;
205 _mesa_error(ctx
, GL_INVALID_ENUM
,
206 "glPointParameterf[v]{EXT,ARB}(pname)");
210 case GL_POINT_SPRITE_COORD_ORIGIN
:
211 if (ctx
->Extensions
.ARB_point_sprite
) {
212 GLenum value
= (GLenum
) params
[0];
213 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
214 _mesa_error(ctx
, GL_INVALID_VALUE
,
215 "glPointParameterf[v]{EXT,ARB}(param)");
218 if (ctx
->Point
.SpriteOrigin
== value
)
220 FLUSH_VERTICES(ctx
, _NEW_POINT
);
221 ctx
->Point
.SpriteOrigin
= value
;
224 _mesa_error(ctx
, GL_INVALID_ENUM
,
225 "glPointParameterf[v]{EXT,ARB}(pname)");
230 _mesa_error( ctx
, GL_INVALID_ENUM
,
231 "glPointParameterf[v]{EXT,ARB}(pname)" );
235 if (ctx
->Driver
.PointParameterfv
)
236 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
243 * Initialize the context point state.
245 * \param ctx GL context.
247 * Initializes __GLcontextRec::Point and point related constants in
248 * __GLcontextRec::Const.
251 _mesa_init_point(GLcontext
*ctx
)
255 ctx
->Point
.SmoothFlag
= GL_FALSE
;
256 ctx
->Point
.Size
= 1.0;
257 ctx
->Point
.Params
[0] = 1.0;
258 ctx
->Point
.Params
[1] = 0.0;
259 ctx
->Point
.Params
[2] = 0.0;
260 ctx
->Point
._Attenuated
= GL_FALSE
;
261 ctx
->Point
.MinSize
= 0.0;
263 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
264 ctx
->Point
.Threshold
= 1.0;
265 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB/NV_point_sprite */
266 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
267 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
268 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
269 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB/NV_point_sprite */