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
);
70 _mesa_PointParameteri( GLenum pname
, GLint param
)
72 const GLfloat value
= (GLfloat
) param
;
73 _mesa_PointParameterfv(pname
, &value
);
78 _mesa_PointParameteriv( GLenum pname
, const GLint
*params
)
81 p
[0] = (GLfloat
) params
[0];
82 if (pname
== GL_DISTANCE_ATTENUATION_EXT
) {
83 p
[1] = (GLfloat
) params
[1];
84 p
[2] = (GLfloat
) params
[2];
86 _mesa_PointParameterfv(pname
, p
);
91 _mesa_PointParameterf( GLenum pname
, GLfloat param
)
93 _mesa_PointParameterfv(pname
, ¶m
);
98 _mesa_PointParameterfv( GLenum pname
, const GLfloat
*params
)
100 GET_CURRENT_CONTEXT(ctx
);
101 ASSERT_OUTSIDE_BEGIN_END(ctx
);
104 case GL_DISTANCE_ATTENUATION_EXT
:
105 if (ctx
->Extensions
.EXT_point_parameters
) {
106 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
108 FLUSH_VERTICES(ctx
, _NEW_POINT
);
109 COPY_3V(ctx
->Point
.Params
, params
);
110 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0 ||
111 ctx
->Point
.Params
[1] != 0.0 ||
112 ctx
->Point
.Params
[2] != 0.0);
114 if (ctx
->Point
._Attenuated
)
115 ctx
->_TriangleCaps
|= DD_POINT_ATTEN
;
117 ctx
->_TriangleCaps
&= ~DD_POINT_ATTEN
;
120 _mesa_error(ctx
, GL_INVALID_ENUM
,
121 "glPointParameterf[v]{EXT,ARB}(pname)");
125 case GL_POINT_SIZE_MIN_EXT
:
126 if (ctx
->Extensions
.EXT_point_parameters
) {
127 if (params
[0] < 0.0F
) {
128 _mesa_error( ctx
, GL_INVALID_VALUE
,
129 "glPointParameterf[v]{EXT,ARB}(param)" );
132 if (ctx
->Point
.MinSize
== params
[0])
134 FLUSH_VERTICES(ctx
, _NEW_POINT
);
135 ctx
->Point
.MinSize
= params
[0];
138 _mesa_error(ctx
, GL_INVALID_ENUM
,
139 "glPointParameterf[v]{EXT,ARB}(pname)");
143 case GL_POINT_SIZE_MAX_EXT
:
144 if (ctx
->Extensions
.EXT_point_parameters
) {
145 if (params
[0] < 0.0F
) {
146 _mesa_error( ctx
, GL_INVALID_VALUE
,
147 "glPointParameterf[v]{EXT,ARB}(param)" );
150 if (ctx
->Point
.MaxSize
== params
[0])
152 FLUSH_VERTICES(ctx
, _NEW_POINT
);
153 ctx
->Point
.MaxSize
= params
[0];
156 _mesa_error(ctx
, GL_INVALID_ENUM
,
157 "glPointParameterf[v]{EXT,ARB}(pname)");
161 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
162 if (ctx
->Extensions
.EXT_point_parameters
) {
163 if (params
[0] < 0.0F
) {
164 _mesa_error( ctx
, GL_INVALID_VALUE
,
165 "glPointParameterf[v]{EXT,ARB}(param)" );
168 if (ctx
->Point
.Threshold
== params
[0])
170 FLUSH_VERTICES(ctx
, _NEW_POINT
);
171 ctx
->Point
.Threshold
= params
[0];
174 _mesa_error(ctx
, GL_INVALID_ENUM
,
175 "glPointParameterf[v]{EXT,ARB}(pname)");
179 case GL_POINT_SPRITE_R_MODE_NV
:
180 /* This is one area where ARB_point_sprite and NV_point_sprite
181 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
182 * always ZERO. NV_point_sprite adds the S and R modes.
184 if (ctx
->Extensions
.NV_point_sprite
) {
185 GLenum value
= (GLenum
) params
[0];
186 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
187 _mesa_error(ctx
, GL_INVALID_VALUE
,
188 "glPointParameterf[v]{EXT,ARB}(param)");
191 if (ctx
->Point
.SpriteRMode
== value
)
193 FLUSH_VERTICES(ctx
, _NEW_POINT
);
194 ctx
->Point
.SpriteRMode
= value
;
197 _mesa_error(ctx
, GL_INVALID_ENUM
,
198 "glPointParameterf[v]{EXT,ARB}(pname)");
202 case GL_POINT_SPRITE_COORD_ORIGIN
:
203 if (ctx
->Extensions
.ARB_point_sprite
|| ctx
->Extensions
.NV_point_sprite
) {
204 GLenum value
= (GLenum
) params
[0];
205 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
206 _mesa_error(ctx
, GL_INVALID_VALUE
,
207 "glPointParameterf[v]{EXT,ARB}(param)");
210 if (ctx
->Point
.SpriteOrigin
== value
)
212 FLUSH_VERTICES(ctx
, _NEW_POINT
);
213 ctx
->Point
.SpriteOrigin
= value
;
216 _mesa_error(ctx
, GL_INVALID_ENUM
,
217 "glPointParameterf[v]{EXT,ARB}(pname)");
222 _mesa_error( ctx
, GL_INVALID_ENUM
,
223 "glPointParameterf[v]{EXT,ARB}(pname)" );
227 if (ctx
->Driver
.PointParameterfv
)
228 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
235 * Initialize the context point state.
237 * \param ctx GL context.
239 * Initializes __GLcontextRec::Point and point related constants in
240 * __GLcontextRec::Const.
243 _mesa_init_point(GLcontext
*ctx
)
247 ctx
->Point
.SmoothFlag
= GL_FALSE
;
248 ctx
->Point
.Size
= 1.0;
249 ctx
->Point
.Params
[0] = 1.0;
250 ctx
->Point
.Params
[1] = 0.0;
251 ctx
->Point
.Params
[2] = 0.0;
252 ctx
->Point
._Attenuated
= GL_FALSE
;
253 ctx
->Point
.MinSize
= 0.0;
255 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
256 ctx
->Point
.Threshold
= 1.0;
257 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB/NV_point_sprite */
258 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
259 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
260 for (i
= 0; i
< MAX_TEXTURE_COORD_UNITS
; i
++) {
261 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB/NV_point_sprite */