1 /* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
3 * (C) Copyright IBM Corporation 2005
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sub license,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include "glxclient.h"
31 #include "indirect_vertex_array.h"
32 #include <GL/glxproto.h>
35 do_vertex_attrib_enable(GLuint index
, GLboolean val
)
37 __GLXcontext
*gc
= __glXGetCurrentContext();
38 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
40 if (!__glXSetArrayEnable(state
, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
,
42 __glXSetError(gc
, GL_INVALID_ENUM
);
48 __indirect_glEnableVertexAttribArrayARB(GLuint index
)
50 do_vertex_attrib_enable(index
, GL_TRUE
);
55 __indirect_glDisableVertexAttribArrayARB(GLuint index
)
57 do_vertex_attrib_enable(index
, GL_FALSE
);
62 get_parameter(unsigned opcode
, unsigned size
, GLenum target
, GLuint index
,
65 __GLXcontext
*const gc
= __glXGetCurrentContext();
66 Display
*const dpy
= gc
->currentDpy
;
67 const GLuint cmdlen
= 12;
69 if (__builtin_expect(dpy
!= NULL
, 1)) {
70 GLubyte
const *pc
= __glXSetupVendorRequest(gc
,
71 X_GLXVendorPrivateWithReply
,
74 *((GLenum
*) (pc
+ 0)) = target
;
75 *((GLuint
*) (pc
+ 4)) = index
;
76 *((GLuint
*) (pc
+ 8)) = 0;
78 (void) __glXReadReply(dpy
, size
, params
, GL_FALSE
);
87 __indirect_glGetProgramEnvParameterfvARB(GLenum target
, GLuint index
,
90 get_parameter(1296, 4, target
, index
, params
);
95 __indirect_glGetProgramEnvParameterdvARB(GLenum target
, GLuint index
,
98 get_parameter(1297, 8, target
, index
, params
);
103 __indirect_glGetProgramLocalParameterfvARB(GLenum target
, GLuint index
,
106 get_parameter(1305, 4, target
, index
, params
);
111 __indirect_glGetProgramLocalParameterdvARB(GLenum target
, GLuint index
,
114 get_parameter(1306, 8, target
, index
, params
);
119 __indirect_glGetVertexAttribPointervNV(GLuint index
, GLenum pname
,
122 __GLXcontext
*const gc
= __glXGetCurrentContext();
123 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
125 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
126 __glXSetError(gc
, GL_INVALID_ENUM
);
129 if (!__glXGetArrayPointer(state
, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
,
131 __glXSetError(gc
, GL_INVALID_VALUE
);
137 * Get the selected attribute from the vertex array state vector.
140 * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
143 get_attrib_array_data(__GLXattribute
* state
, GLuint index
, GLenum cap
,
146 GLboolean retval
= GL_FALSE
;
147 const GLenum attrib
= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
;
150 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
151 retval
= __glXGetArrayEnable(state
, attrib
, index
, data
);
154 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
155 retval
= __glXGetArraySize(state
, attrib
, index
, data
);
158 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
159 retval
= __glXGetArrayStride(state
, attrib
, index
, data
);
162 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
163 retval
= __glXGetArrayType(state
, attrib
, index
, data
);
166 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
167 retval
= __glXGetArrayNormalized(state
, attrib
, index
, data
);
177 get_vertex_attrib(__GLXcontext
* gc
, unsigned vop
,
178 GLuint index
, GLenum pname
, xReply
* reply
)
180 Display
*const dpy
= gc
->currentDpy
;
181 GLubyte
*const pc
= __glXSetupVendorRequest(gc
,
182 X_GLXVendorPrivateWithReply
,
185 *((uint32_t *) (pc
+ 0)) = index
;
186 *((uint32_t *) (pc
+ 4)) = pname
;
188 (void) _XReply(dpy
, reply
, 0, False
);
193 __indirect_glGetVertexAttribivARB(GLuint index
, GLenum pname
, GLint
* params
)
195 __GLXcontext
*const gc
= __glXGetCurrentContext();
196 Display
*const dpy
= gc
->currentDpy
;
197 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
198 xGLXSingleReply reply
;
201 get_vertex_attrib(gc
, 1303, index
, pname
, (xReply
*) & reply
);
203 if (reply
.size
!= 0) {
207 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
208 *params
= (GLint
) data
;
211 if (reply
.size
== 1) {
212 *params
= (GLint
) reply
.pad3
;
215 _XRead(dpy
, (void *) params
, 4 * reply
.size
);
226 __indirect_glGetVertexAttribfvARB(GLuint index
, GLenum pname
,
229 __GLXcontext
*const gc
= __glXGetCurrentContext();
230 Display
*const dpy
= gc
->currentDpy
;
231 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
232 xGLXSingleReply reply
;
235 get_vertex_attrib(gc
, 1302, index
, pname
, (xReply
*) & reply
);
237 if (reply
.size
!= 0) {
241 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
242 *params
= (GLfloat
) data
;
245 if (reply
.size
== 1) {
246 (void) memcpy(params
, &reply
.pad3
, sizeof(GLfloat
));
249 _XRead(dpy
, (void *) params
, 4 * reply
.size
);
260 __indirect_glGetVertexAttribdvARB(GLuint index
, GLenum pname
,
263 __GLXcontext
*const gc
= __glXGetCurrentContext();
264 Display
*const dpy
= gc
->currentDpy
;
265 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
266 xGLXSingleReply reply
;
269 get_vertex_attrib(gc
, 1301, index
, pname
, (xReply
*) & reply
);
271 if (reply
.size
!= 0) {
275 if (get_attrib_array_data(state
, index
, pname
, &data
)) {
276 *params
= (GLdouble
) data
;
279 if (reply
.size
== 1) {
280 (void) memcpy(params
, &reply
.pad3
, sizeof(GLdouble
));
283 _XRead(dpy
, (void *) params
, 8 * reply
.size
);