2 * (C) Copyright IBM Corporation 2005
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include "glxclient.h"
30 #include "indirect_vertex_array.h"
31 #include <GL/glxproto.h>
33 #if !defined(__GNUC__)
34 # define __builtin_expect(x, y) x
38 do_vertex_attrib_enable(GLuint index
, GLboolean val
)
40 struct glx_context
*gc
= __glXGetCurrentContext();
41 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
43 if (!__glXSetArrayEnable(state
, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
,
45 __glXSetError(gc
, GL_INVALID_ENUM
);
51 __indirect_glEnableVertexAttribArrayARB(GLuint index
)
53 do_vertex_attrib_enable(index
, GL_TRUE
);
58 __indirect_glDisableVertexAttribArrayARB(GLuint index
)
60 do_vertex_attrib_enable(index
, GL_FALSE
);
65 get_parameter(unsigned opcode
, unsigned size
, GLenum target
, GLuint index
,
68 struct glx_context
*const gc
= __glXGetCurrentContext();
69 Display
*const dpy
= gc
->currentDpy
;
70 const GLuint cmdlen
= 12;
72 if (__builtin_expect(dpy
!= NULL
, 1)) {
73 GLubyte
const *pc
= __glXSetupVendorRequest(gc
,
74 X_GLXVendorPrivateWithReply
,
77 *((GLenum
*) (pc
+ 0)) = target
;
78 *((GLuint
*) (pc
+ 4)) = index
;
79 *((GLuint
*) (pc
+ 8)) = 0;
81 (void) __glXReadReply(dpy
, size
, params
, GL_FALSE
);
90 __indirect_glGetProgramEnvParameterfvARB(GLenum target
, GLuint index
,
93 get_parameter(1296, 4, target
, index
, params
);
98 __indirect_glGetProgramEnvParameterdvARB(GLenum target
, GLuint index
,
101 get_parameter(1297, 8, target
, index
, params
);
106 __indirect_glGetProgramLocalParameterfvARB(GLenum target
, GLuint index
,
109 get_parameter(1305, 4, target
, index
, params
);
114 __indirect_glGetProgramLocalParameterdvARB(GLenum target
, GLuint index
,
117 get_parameter(1306, 8, target
, index
, params
);
122 __indirect_glGetVertexAttribPointervNV(GLuint index
, GLenum pname
,
125 struct glx_context
*const gc
= __glXGetCurrentContext();
126 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
128 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
129 __glXSetError(gc
, GL_INVALID_ENUM
);
132 if (!__glXGetArrayPointer(state
, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
,
134 __glXSetError(gc
, GL_INVALID_VALUE
);
140 * Get the selected attribute from the vertex array state vector.
143 * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
146 get_attrib_array_data(__GLXattribute
* state
, GLuint index
, GLenum cap
,
149 GLboolean retval
= GL_FALSE
;
150 const GLenum attrib
= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
;
153 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
154 retval
= __glXGetArrayEnable(state
, attrib
, index
, data
);
157 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
158 retval
= __glXGetArraySize(state
, attrib
, index
, data
);
161 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
162 retval
= __glXGetArrayStride(state
, attrib
, index
, data
);
165 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
166 retval
= __glXGetArrayType(state
, attrib
, index
, data
);
169 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
170 retval
= __glXGetArrayNormalized(state
, attrib
, index
, data
);
180 get_vertex_attrib(struct glx_context
* gc
, unsigned vop
,
181 GLuint index
, GLenum pname
, xReply
* reply
)
183 Display
*const dpy
= gc
->currentDpy
;
184 GLubyte
*const pc
= __glXSetupVendorRequest(gc
,
185 X_GLXVendorPrivateWithReply
,
188 *((uint32_t *) (pc
+ 0)) = index
;
189 *((uint32_t *) (pc
+ 4)) = pname
;
191 (void) _XReply(dpy
, reply
, 0, False
);
196 __indirect_glGetVertexAttribivARB(GLuint index
, GLenum pname
, GLint
* params
)
198 struct glx_context
*const gc
= __glXGetCurrentContext();
199 Display
*const dpy
= gc
->currentDpy
;
200 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
201 xGLXSingleReply reply
;
204 get_vertex_attrib(gc
, 1303, index
, pname
, (xReply
*) & reply
);
206 if (reply
.size
!= 0) {
210 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
211 *params
= (GLint
) data
;
214 if (reply
.size
== 1) {
215 *params
= (GLint
) reply
.pad3
;
218 _XRead(dpy
, (void *) params
, 4 * reply
.size
);
229 __indirect_glGetVertexAttribfvARB(GLuint index
, GLenum pname
,
232 struct glx_context
*const gc
= __glXGetCurrentContext();
233 Display
*const dpy
= gc
->currentDpy
;
234 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
235 xGLXSingleReply reply
;
238 get_vertex_attrib(gc
, 1302, index
, pname
, (xReply
*) & reply
);
240 if (reply
.size
!= 0) {
244 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
245 *params
= (GLfloat
) data
;
248 if (reply
.size
== 1) {
249 (void) memcpy(params
, &reply
.pad3
, sizeof(GLfloat
));
252 _XRead(dpy
, (void *) params
, 4 * reply
.size
);
263 __indirect_glGetVertexAttribdvARB(GLuint index
, GLenum pname
,
266 struct glx_context
*const gc
= __glXGetCurrentContext();
267 Display
*const dpy
= gc
->currentDpy
;
268 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
269 xGLXSingleReply reply
;
272 get_vertex_attrib(gc
, 1301, index
, pname
, (xReply
*) & reply
);
274 if (reply
.size
!= 0) {
278 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
279 *params
= (GLdouble
) data
;
282 if (reply
.size
== 1) {
283 (void) memcpy(params
, &reply
.pad3
, sizeof(GLdouble
));
286 _XRead(dpy
, (void *) params
, 8 * reply
.size
);