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
)
85 const GLfloat value
= (GLfloat
) params
[0];
86 _mesa_PointParameterfvEXT(pname
, &value
);
92 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
95 _mesa_PointParameterfEXT( GLenum pname
, GLfloat param
)
97 _mesa_PointParameterfvEXT(pname
, ¶m
);
103 * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
106 _mesa_PointParameterfvEXT( GLenum pname
, const GLfloat
*params
)
108 GET_CURRENT_CONTEXT(ctx
);
109 ASSERT_OUTSIDE_BEGIN_END(ctx
);
112 case GL_DISTANCE_ATTENUATION_EXT
:
113 if (ctx
->Extensions
.EXT_point_parameters
) {
114 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
116 FLUSH_VERTICES(ctx
, _NEW_POINT
);
117 COPY_3V(ctx
->Point
.Params
, params
);
118 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0 ||
119 ctx
->Point
.Params
[1] != 0.0 ||
120 ctx
->Point
.Params
[2] != 0.0);
123 _mesa_error(ctx
, GL_INVALID_ENUM
,
124 "glPointParameterf[v]{EXT,ARB}(pname)");
128 case GL_POINT_SIZE_MIN_EXT
:
129 if (ctx
->Extensions
.EXT_point_parameters
) {
130 if (params
[0] < 0.0F
) {
131 _mesa_error( ctx
, GL_INVALID_VALUE
,
132 "glPointParameterf[v]{EXT,ARB}(param)" );
135 if (ctx
->Point
.MinSize
== params
[0])
137 FLUSH_VERTICES(ctx
, _NEW_POINT
);
138 ctx
->Point
.MinSize
= params
[0];
141 _mesa_error(ctx
, GL_INVALID_ENUM
,
142 "glPointParameterf[v]{EXT,ARB}(pname)");
146 case GL_POINT_SIZE_MAX_EXT
:
147 if (ctx
->Extensions
.EXT_point_parameters
) {
148 if (params
[0] < 0.0F
) {
149 _mesa_error( ctx
, GL_INVALID_VALUE
,
150 "glPointParameterf[v]{EXT,ARB}(param)" );
153 if (ctx
->Point
.MaxSize
== params
[0])
155 FLUSH_VERTICES(ctx
, _NEW_POINT
);
156 ctx
->Point
.MaxSize
= params
[0];
159 _mesa_error(ctx
, GL_INVALID_ENUM
,
160 "glPointParameterf[v]{EXT,ARB}(pname)");
164 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
165 if (ctx
->Extensions
.EXT_point_parameters
) {
166 if (params
[0] < 0.0F
) {
167 _mesa_error( ctx
, GL_INVALID_VALUE
,
168 "glPointParameterf[v]{EXT,ARB}(param)" );
171 if (ctx
->Point
.Threshold
== params
[0])
173 FLUSH_VERTICES(ctx
, _NEW_POINT
);
174 ctx
->Point
.Threshold
= params
[0];
177 _mesa_error(ctx
, GL_INVALID_ENUM
,
178 "glPointParameterf[v]{EXT,ARB}(pname)");
182 case GL_POINT_SPRITE_R_MODE_NV
:
183 /* This is one area where ARB_point_sprite and NV_point_sprite
184 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
185 * always ZERO. NV_point_sprite adds the S and R modes.
187 if (ctx
->Extensions
.NV_point_sprite
) {
188 GLenum value
= (GLenum
) params
[0];
189 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
190 _mesa_error(ctx
, GL_INVALID_VALUE
,
191 "glPointParameterf[v]{EXT,ARB}(param)");
194 if (ctx
->Point
.SpriteRMode
== value
)
196 FLUSH_VERTICES(ctx
, _NEW_POINT
);
197 ctx
->Point
.SpriteRMode
= value
;
200 _mesa_error(ctx
, GL_INVALID_ENUM
,
201 "glPointParameterf[v]{EXT,ARB}(pname)");
205 case GL_POINT_SPRITE_COORD_ORIGIN
:
206 if (ctx
->Extensions
.ARB_point_sprite
) {
207 GLenum value
= (GLenum
) params
[0];
208 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
209 _mesa_error(ctx
, GL_INVALID_VALUE
,
210 "glPointParameterf[v]{EXT,ARB}(param)");
213 if (ctx
->Point
.SpriteOrigin
== value
)
215 FLUSH_VERTICES(ctx
, _NEW_POINT
);
216 ctx
->Point
.SpriteOrigin
= value
;
219 _mesa_error(ctx
, GL_INVALID_ENUM
,
220 "glPointParameterf[v]{EXT,ARB}(pname)");
225 _mesa_error( ctx
, GL_INVALID_ENUM
,
226 "glPointParameterf[v]{EXT,ARB}(pname)" );
230 if (ctx
->Driver
.PointParameterfv
)
231 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
238 * Initialize the context point state.
240 * \param ctx GL context.
242 * Initializes __GLcontextRec::Point and point related constants in
243 * __GLcontextRec::Const.
246 _mesa_init_point(GLcontext
*ctx
)
250 ctx
->Point
.SmoothFlag
= GL_FALSE
;
251 ctx
->Point
.Size
= 1.0;
252 ctx
->Point
.Params
[0] = 1.0;
253 ctx
->Point
.Params
[1] = 0.0;
254 ctx
->Point
.Params
[2] = 0.0;
255 ctx
->Point
._Attenuated
= GL_FALSE
;
256 ctx
->Point
.MinSize
= 0.0;
258 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
259 ctx
->Point
.Threshold
= 1.0;
260 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB/NV_point_sprite */
261 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
262 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
263 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
264 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB/NV_point_sprite */