1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
2dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a
6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"),
7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation
8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the
10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions:
11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and
13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to
14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/
15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software.
16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE.
24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc.
26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or
27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from
28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc.
29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */
30cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <stdio.h>
32fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick#include <assert.h>
33cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxclient.h"
34cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "packsingle.h"
35cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxextensions.h"
36f434e07a6ac849cd127d70eee8b3349da7cfb360Ian Romanick#include "indirect.h"
37fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick#include "indirect_vertex_array.h"
3813f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#include "glapi.h"
39becf3d927255385592c8c6659c4555cf2dd2842dHanno Böck#ifdef USE_XCB
40becf3d927255385592c8c6659c4555cf2dd2842dHanno Böck#include <xcb/xcb.h>
41becf3d927255385592c8c6659c4555cf2dd2842dHanno Böck#include <xcb/glx.h>
42d52e8543b61ec5b8b8d9b1574a28ae2472fe4c56Bernd Buschinski#include <X11/Xlib-xcb.h>
43becf3d927255385592c8c6659c4555cf2dd2842dHanno Böck#endif /* USE_XCB */
44becf3d927255385592c8c6659c4555cf2dd2842dHanno Böck
4557c378a531a18d4ae97e04caa9e7bda19593db7eAlan Coopersmith#if !defined(__GNUC__)
4657c378a531a18d4ae97e04caa9e7bda19593db7eAlan Coopersmith#  define __builtin_expect(x, y) x
4757c378a531a18d4ae97e04caa9e7bda19593db7eAlan Coopersmith#endif
48cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
49cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Used for GL_ARB_transpose_matrix */
50dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófstatic void
51dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófTransposeMatrixf(GLfloat m[16])
52cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
53dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   int i, j;
54dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   for (i = 0; i < 4; i++) {
55dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      for (j = 0; j < i; j++) {
56dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         GLfloat tmp = m[i * 4 + j];
57dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[i * 4 + j] = m[j * 4 + i];
58dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[j * 4 + i] = tmp;
59dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
60dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
61cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
62cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
63cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Used for GL_ARB_transpose_matrix */
64dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófstatic void
65dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófTransposeMatrixb(GLboolean m[16])
66cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
67dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   int i, j;
68dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   for (i = 0; i < 4; i++) {
69dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      for (j = 0; j < i; j++) {
70dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         GLboolean tmp = m[i * 4 + j];
71dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[i * 4 + j] = m[j * 4 + i];
72dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[j * 4 + i] = tmp;
73dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
74dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
75cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
76cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
77cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Used for GL_ARB_transpose_matrix */
78dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófstatic void
79dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófTransposeMatrixd(GLdouble m[16])
80cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
81dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   int i, j;
82dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   for (i = 0; i < 4; i++) {
83dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      for (j = 0; j < i; j++) {
84dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         GLdouble tmp = m[i * 4 + j];
85dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[i * 4 + j] = m[j * 4 + i];
86dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[j * 4 + i] = tmp;
87dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
88dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
89cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
90cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
91cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Used for GL_ARB_transpose_matrix */
92dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófstatic void
93dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófTransposeMatrixi(GLint m[16])
94cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
95dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   int i, j;
96dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   for (i = 0; i < 4; i++) {
97dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      for (j = 0; j < i; j++) {
98dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         GLint tmp = m[i * 4 + j];
99dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[i * 4 + j] = m[j * 4 + i];
100dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         m[j * 4 + i] = tmp;
101dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
102dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
103cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
104cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
10570d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick
10670d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick/**
10770d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick * Remap a transpose-matrix enum to a non-transpose-matrix enum.  Enums
10870d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick * that are not transpose-matrix enums are unaffected.
10970d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick */
11070d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanickstatic GLenum
111dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófRemapTransposeEnum(GLenum e)
11270d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick{
113dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   switch (e) {
114dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TRANSPOSE_MODELVIEW_MATRIX:
115dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TRANSPOSE_PROJECTION_MATRIX:
116dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TRANSPOSE_TEXTURE_MATRIX:
117dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
118dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TRANSPOSE_COLOR_MATRIX:
119dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return GL_COLOR_MATRIX;
120dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   default:
121dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return e;
122dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   };
12370d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick}
12470d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick
12570d2f152f8e312a6c51dd4547d39b09284b2c0deIan Romanick
126dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófGLenum
127dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetError(void)
128cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
129dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
130dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLuint retval = GL_NO_ERROR;
131dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXGetErrorReply reply;
132dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
133dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (gc->error) {
134dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /* Use internal error first */
135dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = gc->error;
136dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      gc->error = GL_NO_ERROR;
137dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return retval;
138dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
139dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
140dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
141dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0);
142dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
143dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   retval = reply.error;
144dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
145dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
146dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   return retval;
147cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
148cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
149fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick
150fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick/**
151365a0a7c153da53c5e4fb6433751f9dab9a16fa4Ian Romanick * Get the selected attribute from the client state.
1520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *
153fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick * \returns
154fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick * On success \c GL_TRUE is returned.  Otherwise, \c GL_FALSE is returned.
155fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick */
156fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanickstatic GLboolean
157c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsbergget_client_data(struct glx_context * gc, GLenum cap, GLintptr * data)
158fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick{
159dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLboolean retval = GL_TRUE;
160dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
161dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const GLint tex_unit = __glXGetActiveTextureUnit(state);
162dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
163dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
164dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   switch (cap) {
165dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY:
166dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_NORMAL_ARRAY:
167dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY:
168dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_INDEX_ARRAY:
169dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_EDGE_FLAG_ARRAY:
170dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY:
171dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FOG_COORD_ARRAY:
172dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayEnable(state, cap, 0, data);
173dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
174dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
175dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY_SIZE:
176dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data);
177dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
178dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY_SIZE:
179dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data);
180dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
181dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY_SIZE:
182dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
183dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
184dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
185dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY_TYPE:
186dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data);
187dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
188dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_NORMAL_ARRAY_TYPE:
189dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data);
190dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
191dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_INDEX_ARRAY_TYPE:
192dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data);
193dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
194dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY_TYPE:
195dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data);
196dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
197dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY_TYPE:
198dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
199dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
200dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FOG_COORD_ARRAY_TYPE:
201dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data);
202dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
203dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
204dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY_STRIDE:
205dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data);
206dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
207dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_NORMAL_ARRAY_STRIDE:
208dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data);
209dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
210dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_INDEX_ARRAY_STRIDE:
211dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data);
212dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
213dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_EDGE_FLAG_ARRAY_STRIDE:
214dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data);
215dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
216dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY_STRIDE:
217dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data);
218dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
219dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY_STRIDE:
220dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
221dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
222dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FOG_COORD_ARRAY_STRIDE:
223dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data);
224dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
225dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
226dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY:
227dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval =
228dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
229dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
230dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY_SIZE:
231dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval =
232dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
233dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
234dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY_TYPE:
235dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval =
236dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
237dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
238dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY_STRIDE:
239dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval =
240dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
241dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
242dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
243dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_MAX_ELEMENTS_VERTICES:
244dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_MAX_ELEMENTS_INDICES:
245dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = GL_TRUE;
246dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = ~0UL;
247dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
248dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
249dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
250dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_ROW_LENGTH:
251dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.rowLength;
252dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
253dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_IMAGE_HEIGHT:
254dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.imageHeight;
255dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
256dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_SKIP_ROWS:
257dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.skipRows;
258dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
259dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_SKIP_PIXELS:
260dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.skipPixels;
261dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
262dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_SKIP_IMAGES:
263dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.skipImages;
264dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
265dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_ALIGNMENT:
266dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.alignment;
267dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
268dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_SWAP_BYTES:
269dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.swapEndian;
270dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
271dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_PACK_LSB_FIRST:
272dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storePack.lsbFirst;
273dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
274dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_ROW_LENGTH:
275dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.rowLength;
276dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
277dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_IMAGE_HEIGHT:
278dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.imageHeight;
279dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
280dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_SKIP_ROWS:
281dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.skipRows;
282dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
283dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_SKIP_PIXELS:
284dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.skipPixels;
285dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
286dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_SKIP_IMAGES:
287dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.skipImages;
288dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
289dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_ALIGNMENT:
290dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.alignment;
291dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
292dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_SWAP_BYTES:
293dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.swapEndian;
294dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
295dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_UNPACK_LSB_FIRST:
296dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) state->storeUnpack.lsbFirst;
297dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
298dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_CLIENT_ATTRIB_STACK_DEPTH:
299dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack);
300dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
301dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
302dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH;
303dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
304dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_CLIENT_ACTIVE_TEXTURE:
305dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *data = (GLintptr) (tex_unit + GL_TEXTURE0);
306dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
307dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
308dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   default:
309dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = GL_FALSE;
310dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
311dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
312dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
313dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
314dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   return retval;
315fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick}
316fdb07636f2e6324c5250cd5ee97778b7f5933beaIan Romanick
317cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
318dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
319dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetBooleanv(GLenum val, GLboolean * b)
320cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
321dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const GLenum origVal = val;
322dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
323dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
324dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
325dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   val = RemapTransposeEnum(val);
326dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
327dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
328dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4);
329dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, val);
330dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
331dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_SIZE(compsize);
332dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
333dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (compsize == 0) {
334dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
335dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Error occured; don't modify user's buffer.
336dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
337dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
338dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
339dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      GLintptr data;
340dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
341dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
342dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** We still needed to send the request to the server in order to
343dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** find out whether it was legal to make a query (it's illegal,
344dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** for example, to call a query between glBegin() and glEnd()).
345dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
346dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
347dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (get_client_data(gc, val, &data)) {
348dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         *b = (GLboolean) data;
349dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
350dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      else {
351dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         /*
352dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          ** Not a local value, so use what we got from the server.
353dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          */
354dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         if (compsize == 1) {
355dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_CHAR(b);
356dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
357dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         else {
358dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize);
359dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            if (val != origVal) {
360dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               /* matrix transpose */
361dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               TransposeMatrixb(b);
362dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
363dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
364dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
365dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
366dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
367cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
368cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
369dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
370dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetDoublev(GLenum val, GLdouble * d)
371cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
372dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const GLenum origVal = val;
373dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
374dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
375dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
376dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   val = RemapTransposeEnum(val);
377dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
378dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
379dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4);
380dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, val);
381dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
382dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_SIZE(compsize);
383dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
384dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (compsize == 0) {
385dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
386dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Error occured; don't modify user's buffer.
387dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
388dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
389dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
390dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      GLintptr data;
391dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
392dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
393dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** We still needed to send the request to the server in order to
394dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** find out whether it was legal to make a query (it's illegal,
395dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** for example, to call a query between glBegin() and glEnd()).
396dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
397dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
398dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (get_client_data(gc, val, &data)) {
399dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         *d = (GLdouble) data;
400dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
401dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      else {
402dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         /*
403dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          ** Not a local value, so use what we got from the server.
404dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          */
405dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         if (compsize == 1) {
406dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_DOUBLE(d);
407dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
408dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         else {
409dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize);
410dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            if (val != origVal) {
411dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               /* matrix transpose */
412dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               TransposeMatrixd(d);
413dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
414dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
415dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
416dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
417dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
418cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
419cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
420dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
421dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetFloatv(GLenum val, GLfloat * f)
422cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
423dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const GLenum origVal = val;
424dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
425dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
426dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
427dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   val = RemapTransposeEnum(val);
428dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
429dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
430dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4);
431dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, val);
432dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
433dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_SIZE(compsize);
434dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
435dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (compsize == 0) {
436dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
437dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Error occured; don't modify user's buffer.
438dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
439dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
440dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
441dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      GLintptr data;
442dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
443dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
444dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** We still needed to send the request to the server in order to
445dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** find out whether it was legal to make a query (it's illegal,
446dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** for example, to call a query between glBegin() and glEnd()).
447dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
448dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
449dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (get_client_data(gc, val, &data)) {
450dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         *f = (GLfloat) data;
451dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
452dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      else {
453dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         /*
454dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          ** Not a local value, so use what we got from the server.
455dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          */
456dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         if (compsize == 1) {
457dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_FLOAT(f);
458dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
459dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         else {
460dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize);
461dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            if (val != origVal) {
462dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               /* matrix transpose */
463dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               TransposeMatrixf(f);
464dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
465dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
466dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
467dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
468dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
469cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
470cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
471dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
472dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetIntegerv(GLenum val, GLint * i)
473cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
474dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const GLenum origVal = val;
475dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
476dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
477dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
478dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   val = RemapTransposeEnum(val);
479dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
480dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
481dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4);
482dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, val);
483dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
484dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_SIZE(compsize);
485dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
486dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (compsize == 0) {
487dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
488dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Error occured; don't modify user's buffer.
489dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
490dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
491dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
492dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      GLintptr data;
493dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
494dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
495dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** We still needed to send the request to the server in order to
496dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** find out whether it was legal to make a query (it's illegal,
497dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** for example, to call a query between glBegin() and glEnd()).
498dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
499dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
500dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (get_client_data(gc, val, &data)) {
501dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         *i = (GLint) data;
502dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
503dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      else {
504dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         /*
505dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          ** Not a local value, so use what we got from the server.
506dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf          */
507dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         if (compsize == 1) {
508dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_LONG(i);
509dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
510dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         else {
511dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __GLX_SINGLE_GET_LONG_ARRAY(i, compsize);
512dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            if (val != origVal) {
513dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               /* matrix transpose */
514dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               TransposeMatrixi(i);
515dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
516dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
517dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
518dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
519dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
520cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
521cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
522cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
523cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Send all pending commands to server.
524cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
525dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
526dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glFlush(void)
527cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
528dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
529cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
530dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
531dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
532cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
533dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
534dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0);
535dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
536cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
537dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   /* And finally flush the X protocol data */
538dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   XFlush(dpy);
539cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
540cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
541dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
542dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
543cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
544dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
545cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
546dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
547dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
548cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
549dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
550dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8);
551dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, size);
552dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(4, type);
553dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
554cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
555dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   gc->feedbackBuf = buffer;
556cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
557cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
558dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
559dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer)
560cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
561dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
562cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
563dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
564dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
565cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
566dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
567dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4);
568dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, numnames);
569dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
570cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
571dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   gc->selectBuf = buffer;
572cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
573cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
574dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófGLint
575dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glRenderMode(GLenum mode)
576cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
577dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
578dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLint retval = 0;
579dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXRenderModeReply reply;
580dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
581dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
582dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return -1;
583dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
584dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
585dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4);
586dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, mode);
587dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
588dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_RETVAL(retval, GLint);
589dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
590dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (reply.newMode != mode) {
591dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
592dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Switch to new mode did not take effect, therefore an error
593dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** occured.  When an error happens the server won't send us any
594dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** other data.
595dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
596dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
597dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
598dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /* Read the feedback or selection data */
599dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (gc->renderMode == GL_FEEDBACK) {
600dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __GLX_SINGLE_GET_SIZE(compsize);
601dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
602dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
603dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      else if (gc->renderMode == GL_SELECT) {
604dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __GLX_SINGLE_GET_SIZE(compsize);
605dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
606dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
607dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      gc->renderMode = mode;
608dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
609dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
610dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
611dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   return retval;
612cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
613cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
614dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
615dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glFinish(void)
616cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
617dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
618dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
619cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
620dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
621dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0);
622dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
623dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
624cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
625cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
626cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
627cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/**
628cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Extract the major and minor version numbers from a version string.
629cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */
630cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonstatic void
631dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófversion_from_string(const char *ver, int *major_version, int *minor_version)
632cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
633dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   const char *end;
634dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   long major;
635dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   long minor;
636dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
637dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   major = strtol(ver, (char **) &end, 10);
638dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   minor = strtol(end + 1, NULL, 10);
639dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   *major_version = major;
640dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   *minor_version = minor;
641cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
642cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
643cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
644dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófconst GLubyte *
645dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetString(GLenum name)
646cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
647c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *gc = __glXGetCurrentContext();
648dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   Display *dpy = gc->currentDpy;
649dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLubyte *s = NULL;
650cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
651dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
652dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return 0;
653cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
654dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   /*
655cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    ** Return the cached copy if the string has already been fetched
656cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    */
657dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   switch (name) {
658dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VENDOR:
659dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (gc->vendor)
660dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         return gc->vendor;
661dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
662dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_RENDERER:
663dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (gc->renderer)
664dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         return gc->renderer;
665dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
666dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERSION:
667dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (gc->version)
668dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         return gc->version;
669dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
670dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_EXTENSIONS:
671dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      if (gc->extensions)
672dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         return gc->extensions;
673dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
674dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   default:
675dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXSetError(gc, GL_INVALID_ENUM);
676dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return 0;
677dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
678dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
679dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   /*
680cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    ** Get requested string from server
681cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson    */
682cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
683dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   (void) __glXFlushRenderBuffer(gc, gc->pc);
6840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag,
6850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                  name);
686dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!s) {
687dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /* Throw data on the floor */
688dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXSetError(gc, GL_OUT_OF_MEMORY);
689dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
690dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   else {
691dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      /*
692dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       ** Update local cache
693dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf       */
694dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      switch (name) {
695dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      case GL_VENDOR:
696dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         gc->vendor = s;
697dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         break;
698dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
699dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      case GL_RENDERER:
700dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         gc->renderer = s;
701dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         break;
702dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
703dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      case GL_VERSION:{
704dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            int client_major;
705dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            int client_minor;
706dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
707dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            version_from_string((char *) s,
708dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                                &gc->server_major, &gc->server_minor);
709dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __glXGetGLVersion(&client_major, &client_minor);
710dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
711dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            if ((gc->server_major < client_major)
712dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                || ((gc->server_major == client_major)
713dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                    && (gc->server_minor <= client_minor))) {
714dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               gc->version = s;
715dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
716dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            else {
717dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               /* Allow 7 bytes for the client-side GL version.  This allows
718dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                * for upto version 999.999.  I'm not holding my breath for
719dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                * that one!  The extra 4 is for the ' ()\0' that will be
720dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                * added.
721dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                */
722dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               const size_t size = 7 + strlen((char *) s) + 4;
723dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
724dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               gc->version = Xmalloc(size);
725dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               if (gc->version == NULL) {
726dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  /* If we couldn't allocate memory for the new string,
727dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   * make a best-effort and just copy the client-side version
728dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   * to the string and use that.  It probably doesn't
729dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   * matter what is done here.  If there not memory available
730dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   * for a short string, the system is probably going to die
731dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   * soon anyway.
732dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                   */
733dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  snprintf((char *) s, strlen((char *) s) + 1, "%u.%u",
734dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                           client_major, client_minor);
735dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  gc->version = s;
736dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               }
737dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               else {
738dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  snprintf((char *) gc->version, size, "%u.%u (%s)",
739dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                           client_major, client_minor, s);
740dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  Xfree(s);
741dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                  s = gc->version;
742dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf               }
743dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            }
744dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            break;
745dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
746dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
747dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      case GL_EXTENSIONS:{
748dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            int major = 1;
749dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            int minor = 0;
750dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
751dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            /* This code is currently disabled.  I was reminded that some
752dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * vendors intentionally exclude some extensions from their
753dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * extension string that are part of the core version they
754dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * advertise.  In particular, on Nvidia drivers this means that
755dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * the functionality is supported by the driver, but is not
756dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * hardware accelerated.  For example, a TNT will show core
757dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * version 1.5, but most of the post-1.2 functionality is a
758dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * software fallback.
7590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf             *
760dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * I don't want to break applications that rely on this odd
761dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * behavior.  At the same time, the code is written and tested,
762dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * so I didn't want to throw it away.  Therefore, the code is here
763dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * but disabled.  In the future, we may wish to and an environment
764dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * variable to enable it.
765dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             */
766dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
767cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#if 0
768dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            /* Call glGetString just to make sure that gc->server_major and
769dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * gc->server_minor are set.  This version may be higher than we
770dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * can completely support, but it may imply support for some
771dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * extensions that we can support.
7720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf             *
773dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * For example, at the time of this writing, the client-side
774dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * library only supports upto core GL version 1.2.  However, cubic
775dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * textures, multitexture, multisampling, and some other 1.3
776dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * features are supported.  If the server reports back version
777dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * 1.3, but does not report all of those extensions, we will
778dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             * enable them.
779dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf             */
780dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            (void *) glGetString(GL_VERSION);
781dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            major = gc->server_major, minor = gc->server_minor;
782cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
783cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
784dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor);
785dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            XFree(s);
786dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            s = gc->extensions;
787dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf            break;
788dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf         }
789dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      }
790dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
791dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   return s;
792cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
793cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
794dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, KristófGLboolean
795dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glIsEnabled(GLenum cap)
796cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
797dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_DECLARE_VARIABLES();
798dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
799dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   xGLXSingleReply reply;
800dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLboolean retval = 0;
801dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   GLintptr enable;
802dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
803dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
804dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return 0;
805dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
806dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   switch (cap) {
807dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY:
808dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_NORMAL_ARRAY:
809dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY:
810dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_INDEX_ARRAY:
811dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_EDGE_FLAG_ARRAY:
812dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY:
813dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FOG_COORD_ARRAY:
814dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayEnable(state, cap, 0, &enable);
815dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      assert(retval);
816dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return (GLboolean) enable;
817dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
818dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY:
819dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY,
820dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                                   __glXGetActiveTextureUnit(state), &enable);
821dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      assert(retval);
822dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return (GLboolean) enable;
823dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      break;
824dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
825dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
826dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_LOAD_VARIABLES();
827dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4);
828dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_PUT_LONG(0, cap);
829dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_READ_XREPLY();
830dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
831dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLX_SINGLE_END();
832dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   return retval;
833cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
834cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
835dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristófvoid
836dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf__indirect_glGetPointerv(GLenum pname, void **params)
837cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{
838c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *gc = __glXGetCurrentContext();
839dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
840dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   Display *dpy = gc->currentDpy;
841dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
842dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   if (!dpy)
843dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
844dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf
845dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   switch (pname) {
846dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_VERTEX_ARRAY_POINTER:
847dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_NORMAL_ARRAY_POINTER:
848dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_COLOR_ARRAY_POINTER:
849dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_INDEX_ARRAY_POINTER:
850dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_EDGE_FLAG_ARRAY_POINTER:
851dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER
852dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                           + GL_VERTEX_ARRAY, 0, params);
853dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
854dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_TEXTURE_COORD_ARRAY_POINTER:
855dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY,
856dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                           __glXGetActiveTextureUnit(state), params);
857dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
858dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SECONDARY_COLOR_ARRAY_POINTER:
859dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FOG_COORD_ARRAY_POINTER:
860dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER
861dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf                           + GL_FOG_COORD_ARRAY, 0, params);
862dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
863dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_FEEDBACK_BUFFER_POINTER:
864dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *params = (void *) gc->feedbackBuf;
865dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
866dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   case GL_SELECTION_BUFFER_POINTER:
867dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      *params = (void *) gc->selectBuf;
868dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
869dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   default:
870dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      __glXSetError(gc, GL_INVALID_ENUM);
871dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf      return;
872dd0edeb8875823c4357ddf53271d8e7035747a3dRALOVICH, Kristóf   }
873cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson}
87413f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul
87513f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul
87613f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul
87713f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul/**
87813f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul * This was previously auto-generated, but we need to special-case
87913f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul * how we handle writing into the 'residences' buffer when n%4!=0.
88013f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul */
88113f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#define X_GLsop_AreTexturesResident 143
88213f96c5401ffe3869f08fecb2baf5bff2438b02eBrian PaulGLboolean
88313f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures,
88413f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul                                 GLboolean * residences)
88513f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul{
886c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *const gc = __glXGetCurrentContext();
8870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   Display *const dpy = gc->currentDpy;
8880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   GLboolean retval = (GLboolean) 0;
8890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
89013f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#ifdef USE_XCB
8910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      xcb_connection_t *c = XGetXCBConnection(dpy);
8920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      (void) __glXFlushRenderBuffer(gc, gc->pc);
8930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      xcb_glx_are_textures_resident_reply_t *reply =
8940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         xcb_glx_are_textures_resident_reply(c,
8950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                             xcb_glx_are_textures_resident
8960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                             (c, gc->currentContextTag, n,
8970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                              textures), NULL);
8980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply),
8990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                    xcb_glx_are_textures_resident_data_length(reply) *
9000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                    sizeof(GLboolean));
9010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      retval = reply->ret_val;
9020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      free(reply);
90313f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#else
904765ed3a6a9317607311bac1dcb0edee13ebcee16Paul Berry      const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
9050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      GLubyte const *pc =
9060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen);
9070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
9080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
9090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      if (n & 3) {
9100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         /* n is not a multiple of four.
9110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          * When reply_is_always_array is TRUE, __glXReadReply() will
9120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          * put a multiple of four bytes into the dest buffer.  If the
9130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          * caller's buffer is not a multiple of four in size, we'll write
9140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          * out of bounds.  So use a temporary buffer that's a few bytes
9150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          * larger.
9160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf          */
9170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         GLboolean *res4 = malloc((n + 3) & ~3);
9180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
9190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         memcpy(residences, res4, n);
9200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         free(res4);
9210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      }
9220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      else {
9230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
9240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      }
9250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      UnlockDisplay(dpy);
9260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      SyncHandle();
92713f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#endif /* USE_XCB */
9280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   }
9290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   return retval;
93013f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul}
93113f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul
93213f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul
93313f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul/**
93413f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul * This was previously auto-generated, but we need to special-case
93513f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul * how we handle writing into the 'residences' buffer when n%4!=0.
93613f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul */
93713f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul#define X_GLvop_AreTexturesResidentEXT 11
93813f96c5401ffe3869f08fecb2baf5bff2438b02eBrian PaulGLboolean
93913f96c5401ffe3869f08fecb2baf5bff2438b02eBrian PaulglAreTexturesResidentEXT(GLsizei n, const GLuint * textures,
94013f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul                         GLboolean * residences)
94113f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul{
942c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *const gc = __glXGetCurrentContext();
9430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf
9440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   if (gc->isDirect) {
94599fee476a102be898a1a093c037e06382f90a5b9Ian Romanick      const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH();
94699fee476a102be898a1a093c037e06382f90a5b9Ian Romanick      PFNGLARETEXTURESRESIDENTEXTPROC p =
94799fee476a102be898a1a093c037e06382f90a5b9Ian Romanick         (PFNGLARETEXTURESRESIDENTEXTPROC) table[332];
94899fee476a102be898a1a093c037e06382f90a5b9Ian Romanick
94999fee476a102be898a1a093c037e06382f90a5b9Ian Romanick      return p(n, textures, residences);
9500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   }
9510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   else {
952c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg      struct glx_context *const gc = __glXGetCurrentContext();
9530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      Display *const dpy = gc->currentDpy;
9540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      GLboolean retval = (GLboolean) 0;
9550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
9560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
9570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         GLubyte const *pc =
9580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
9590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                    X_GLvop_AreTexturesResidentEXT,
9600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf                                    cmdlen);
9610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
9620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
9630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         if (n & 3) {
9640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            /* see comments in __indirect_glAreTexturesResident() */
9650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            GLboolean *res4 = malloc((n + 3) & ~3);
9660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
9670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            memcpy(residences, res4, n);
9680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            free(res4);
9690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         }
9700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         else {
9710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf            retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
9720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         }
9730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         UnlockDisplay(dpy);
9740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf         SyncHandle();
9750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      }
9760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf      return retval;
9770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf   }
97813f96c5401ffe3869f08fecb2baf5bff2438b02eBrian Paul}
979