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.
39 * Set current point size.
40 * \param size point diameter in pixels
44 _mesa_PointSize( GLfloat size
)
46 GET_CURRENT_CONTEXT(ctx
);
47 ASSERT_OUTSIDE_BEGIN_END(ctx
);
50 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
54 if (ctx
->Point
.Size
== size
)
57 FLUSH_VERTICES(ctx
, _NEW_POINT
);
58 ctx
->Point
.Size
= size
;
60 if (ctx
->Driver
.PointSize
)
61 ctx
->Driver
.PointSize(ctx
, size
);
69 _mesa_PointParameteri( GLenum pname
, GLint param
)
72 p
[0] = (GLfloat
) param
;
74 _mesa_PointParameterfv(pname
, p
);
79 _mesa_PointParameteriv( GLenum pname
, const GLint
*params
)
82 p
[0] = (GLfloat
) params
[0];
83 if (pname
== GL_DISTANCE_ATTENUATION_EXT
) {
84 p
[1] = (GLfloat
) params
[1];
85 p
[2] = (GLfloat
) params
[2];
87 _mesa_PointParameterfv(pname
, p
);
92 _mesa_PointParameterf( GLenum pname
, GLfloat param
)
97 _mesa_PointParameterfv(pname
, p
);
102 _mesa_PointParameterfv( GLenum pname
, const GLfloat
*params
)
104 GET_CURRENT_CONTEXT(ctx
);
105 ASSERT_OUTSIDE_BEGIN_END(ctx
);
107 /* Drivers that support point sprites must also support point parameters.
108 * If point parameters aren't supported, then this function shouldn't even
111 ASSERT(!(ctx
->Extensions
.ARB_point_sprite
112 || ctx
->Extensions
.NV_point_sprite
)
113 || ctx
->Extensions
.EXT_point_parameters
);
115 if (!ctx
->Extensions
.EXT_point_parameters
) {
116 _mesa_error(ctx
, GL_INVALID_OPERATION
,
117 "unsupported function called (unsupported extension)");
122 case GL_DISTANCE_ATTENUATION_EXT
:
123 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
125 FLUSH_VERTICES(ctx
, _NEW_POINT
);
126 COPY_3V(ctx
->Point
.Params
, params
);
127 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0 ||
128 ctx
->Point
.Params
[1] != 0.0 ||
129 ctx
->Point
.Params
[2] != 0.0);
131 if (ctx
->Point
._Attenuated
)
132 ctx
->_TriangleCaps
|= DD_POINT_ATTEN
;
134 ctx
->_TriangleCaps
&= ~DD_POINT_ATTEN
;
136 case GL_POINT_SIZE_MIN_EXT
:
137 if (params
[0] < 0.0F
) {
138 _mesa_error( ctx
, GL_INVALID_VALUE
,
139 "glPointParameterf[v]{EXT,ARB}(param)" );
142 if (ctx
->Point
.MinSize
== params
[0])
144 FLUSH_VERTICES(ctx
, _NEW_POINT
);
145 ctx
->Point
.MinSize
= params
[0];
147 case GL_POINT_SIZE_MAX_EXT
:
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];
158 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
159 if (params
[0] < 0.0F
) {
160 _mesa_error( ctx
, GL_INVALID_VALUE
,
161 "glPointParameterf[v]{EXT,ARB}(param)" );
164 if (ctx
->Point
.Threshold
== params
[0])
166 FLUSH_VERTICES(ctx
, _NEW_POINT
);
167 ctx
->Point
.Threshold
= params
[0];
169 case GL_POINT_SPRITE_R_MODE_NV
:
170 /* This is one area where ARB_point_sprite and NV_point_sprite
171 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
172 * always ZERO. NV_point_sprite adds the S and R modes.
174 if (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_point_sprite
) {
175 GLenum value
= (GLenum
) params
[0];
176 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
177 _mesa_error(ctx
, GL_INVALID_VALUE
,
178 "glPointParameterf[v]{EXT,ARB}(param)");
181 if (ctx
->Point
.SpriteRMode
== value
)
183 FLUSH_VERTICES(ctx
, _NEW_POINT
);
184 ctx
->Point
.SpriteRMode
= value
;
187 _mesa_error(ctx
, GL_INVALID_ENUM
,
188 "glPointParameterf[v]{EXT,ARB}(pname)");
192 case GL_POINT_SPRITE_COORD_ORIGIN
:
193 /* GL_POINT_SPRITE_COORD_ORIGIN was added to point sprites when the
194 * extension was merged into OpenGL 2.0.
196 if ((ctx
->API
== API_OPENGL
&& ctx
->Version
>= 20)
197 || ctx
->API
== API_OPENGL_CORE
) {
198 GLenum value
= (GLenum
) params
[0];
199 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
200 _mesa_error(ctx
, GL_INVALID_VALUE
,
201 "glPointParameterf[v]{EXT,ARB}(param)");
204 if (ctx
->Point
.SpriteOrigin
== value
)
206 FLUSH_VERTICES(ctx
, _NEW_POINT
);
207 ctx
->Point
.SpriteOrigin
= value
;
210 _mesa_error(ctx
, GL_INVALID_ENUM
,
211 "glPointParameterf[v]{EXT,ARB}(pname)");
216 _mesa_error( ctx
, GL_INVALID_ENUM
,
217 "glPointParameterf[v]{EXT,ARB}(pname)" );
221 if (ctx
->Driver
.PointParameterfv
)
222 (*ctx
->Driver
.PointParameterfv
)(ctx
, pname
, params
);
229 * Initialize the context point state.
231 * \param ctx GL context.
233 * Initializes __struct gl_contextRec::Point and point related constants in
234 * __struct gl_contextRec::Const.
237 _mesa_init_point(struct gl_context
*ctx
)
241 ctx
->Point
.SmoothFlag
= GL_FALSE
;
242 ctx
->Point
.Size
= 1.0;
243 ctx
->Point
.Params
[0] = 1.0;
244 ctx
->Point
.Params
[1] = 0.0;
245 ctx
->Point
.Params
[2] = 0.0;
246 ctx
->Point
._Attenuated
= GL_FALSE
;
247 ctx
->Point
.MinSize
= 0.0;
249 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
250 ctx
->Point
.Threshold
= 1.0;
251 ctx
->Point
.PointSprite
= GL_FALSE
; /* GL_ARB/NV_point_sprite */
252 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
253 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
254 for (i
= 0; i
< Elements(ctx
->Point
.CoordReplace
); i
++) {
255 ctx
->Point
.CoordReplace
[i
] = GL_FALSE
; /* GL_ARB/NV_point_sprite */