7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * 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
);
49 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSize" );
53 if (ctx
->Point
.Size
== size
)
56 FLUSH_VERTICES(ctx
, _NEW_POINT
);
57 ctx
->Point
.Size
= size
;
59 if (ctx
->Driver
.PointSize
)
60 ctx
->Driver
.PointSize(ctx
, size
);
65 _mesa_PointParameteri( GLenum pname
, GLint param
)
68 p
[0] = (GLfloat
) param
;
70 _mesa_PointParameterfv(pname
, p
);
75 _mesa_PointParameteriv( GLenum pname
, const GLint
*params
)
78 p
[0] = (GLfloat
) params
[0];
79 if (pname
== GL_DISTANCE_ATTENUATION_EXT
) {
80 p
[1] = (GLfloat
) params
[1];
81 p
[2] = (GLfloat
) params
[2];
83 _mesa_PointParameterfv(pname
, p
);
88 _mesa_PointParameterf( GLenum pname
, GLfloat param
)
93 _mesa_PointParameterfv(pname
, p
);
98 _mesa_PointParameterfv( GLenum pname
, const GLfloat
*params
)
100 GET_CURRENT_CONTEXT(ctx
);
102 /* Drivers that support point sprites must also support point parameters.
103 * If point parameters aren't supported, then this function shouldn't even
106 assert(!(ctx
->Extensions
.ARB_point_sprite
107 || ctx
->Extensions
.NV_point_sprite
)
108 || ctx
->Extensions
.EXT_point_parameters
);
110 if (!ctx
->Extensions
.EXT_point_parameters
) {
111 _mesa_error(ctx
, GL_INVALID_OPERATION
,
112 "unsupported function called (unsupported extension)");
117 case GL_DISTANCE_ATTENUATION_EXT
:
118 if (TEST_EQ_3V(ctx
->Point
.Params
, params
))
120 FLUSH_VERTICES(ctx
, _NEW_POINT
);
121 COPY_3V(ctx
->Point
.Params
, params
);
122 ctx
->Point
._Attenuated
= (ctx
->Point
.Params
[0] != 1.0F
||
123 ctx
->Point
.Params
[1] != 0.0F
||
124 ctx
->Point
.Params
[2] != 0.0F
);
126 case GL_POINT_SIZE_MIN_EXT
:
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];
137 case GL_POINT_SIZE_MAX_EXT
:
138 if (params
[0] < 0.0F
) {
139 _mesa_error( ctx
, GL_INVALID_VALUE
,
140 "glPointParameterf[v]{EXT,ARB}(param)" );
143 if (ctx
->Point
.MaxSize
== params
[0])
145 FLUSH_VERTICES(ctx
, _NEW_POINT
);
146 ctx
->Point
.MaxSize
= params
[0];
148 case GL_POINT_FADE_THRESHOLD_SIZE_EXT
:
149 if (params
[0] < 0.0F
) {
150 _mesa_error( ctx
, GL_INVALID_VALUE
,
151 "glPointParameterf[v]{EXT,ARB}(param)" );
154 if (ctx
->Point
.Threshold
== params
[0])
156 FLUSH_VERTICES(ctx
, _NEW_POINT
);
157 ctx
->Point
.Threshold
= params
[0];
159 case GL_POINT_SPRITE_R_MODE_NV
:
160 /* This is one area where ARB_point_sprite and NV_point_sprite
161 * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
162 * always ZERO. NV_point_sprite adds the S and R modes.
164 if (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_point_sprite
) {
165 GLenum value
= (GLenum
) params
[0];
166 if (value
!= GL_ZERO
&& value
!= GL_S
&& value
!= GL_R
) {
167 _mesa_error(ctx
, GL_INVALID_VALUE
,
168 "glPointParameterf[v]{EXT,ARB}(param)");
171 if (ctx
->Point
.SpriteRMode
== value
)
173 FLUSH_VERTICES(ctx
, _NEW_POINT
);
174 ctx
->Point
.SpriteRMode
= value
;
177 _mesa_error(ctx
, GL_INVALID_ENUM
,
178 "glPointParameterf[v]{EXT,ARB}(pname)");
182 case GL_POINT_SPRITE_COORD_ORIGIN
:
183 /* GL_POINT_SPRITE_COORD_ORIGIN was added to point sprites when the
184 * extension was merged into OpenGL 2.0.
186 if ((ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Version
>= 20)
187 || ctx
->API
== API_OPENGL_CORE
) {
188 GLenum value
= (GLenum
) params
[0];
189 if (value
!= GL_LOWER_LEFT
&& value
!= GL_UPPER_LEFT
) {
190 _mesa_error(ctx
, GL_INVALID_VALUE
,
191 "glPointParameterf[v]{EXT,ARB}(param)");
194 if (ctx
->Point
.SpriteOrigin
== value
)
196 FLUSH_VERTICES(ctx
, _NEW_POINT
);
197 ctx
->Point
.SpriteOrigin
= value
;
200 _mesa_error(ctx
, GL_INVALID_ENUM
,
201 "glPointParameterf[v]{EXT,ARB}(pname)");
206 _mesa_error( ctx
, GL_INVALID_ENUM
,
207 "glPointParameterf[v]{EXT,ARB}(pname)" );
211 if (ctx
->Driver
.PointParameterfv
)
212 ctx
->Driver
.PointParameterfv(ctx
, pname
, params
);
218 * Initialize the context point state.
220 * \param ctx GL context.
222 * Initializes __struct gl_contextRec::Point and point related constants in
223 * __struct gl_contextRec::Const.
226 _mesa_init_point(struct gl_context
*ctx
)
228 ctx
->Point
.SmoothFlag
= GL_FALSE
;
229 ctx
->Point
.Size
= 1.0;
230 ctx
->Point
.Params
[0] = 1.0;
231 ctx
->Point
.Params
[1] = 0.0;
232 ctx
->Point
.Params
[2] = 0.0;
233 ctx
->Point
._Attenuated
= GL_FALSE
;
234 ctx
->Point
.MinSize
= 0.0;
236 = MAX2(ctx
->Const
.MaxPointSize
, ctx
->Const
.MaxPointSizeAA
);
237 ctx
->Point
.Threshold
= 1.0;
239 /* Page 403 (page 423 of the PDF) of the OpenGL 3.0 spec says:
241 * "Non-sprite points (section 3.4) - Enable/Disable targets
242 * POINT_SMOOTH and POINT_SPRITE, and all associated state. Point
243 * rasterization is always performed as though POINT_SPRITE were
246 * In a core context, the state will default to true, and the setters and
247 * getters are disabled.
249 ctx
->Point
.PointSprite
= (ctx
->API
== API_OPENGL_CORE
||
250 ctx
->API
== API_OPENGLES2
);
252 ctx
->Point
.SpriteRMode
= GL_ZERO
; /* GL_NV_point_sprite (only!) */
253 ctx
->Point
.SpriteOrigin
= GL_UPPER_LEFT
; /* GL_ARB_point_sprite */
254 ctx
->Point
.CoordReplace
= 0; /* GL_ARB/NV_point_sprite */