~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to GL/glx/singlepixswap.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/GL/glx/singlepixswap.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
 
2
/*
 
3
** License Applicability. Except to the extent portions of this file are
 
4
** made subject to an alternative license as permitted in the SGI Free
 
5
** Software License B, Version 1.1 (the "License"), the contents of this
 
6
** file are subject only to the provisions of the License. You may not use
 
7
** this file except in compliance with the License. You may obtain a copy
 
8
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 
9
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
 
10
** 
 
11
** http://oss.sgi.com/projects/FreeB
 
12
** 
 
13
** Note that, as provided in the License, the Software is distributed on an
 
14
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 
15
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 
16
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 
17
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
 
18
** 
 
19
** Original Code. The Original Code is: OpenGL Sample Implementation,
 
20
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 
21
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 
22
** Copyright in any portions created by third parties is as indicated
 
23
** elsewhere herein. All Rights Reserved.
 
24
** 
 
25
** Additional Notice Provisions: The application programming interfaces
 
26
** established by SGI in conjunction with the Original Code are The
 
27
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
 
28
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
 
29
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
 
30
** Window System(R) (Version 1.3), released October 19, 1998. This software
 
31
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
 
32
** published by SGI, but has not been independently verified as being
 
33
** compliant with the OpenGL(R) version 1.2.1 Specification.
 
34
**
 
35
*/
 
36
 
 
37
#define NEED_REPLIES
 
38
#ifdef HAVE_DIX_CONFIG_H
 
39
#include <dix-config.h>
 
40
#endif
 
41
 
 
42
#include "glxserver.h"
 
43
#include "glxext.h"
 
44
#include "singlesize.h"
 
45
#include "unpack.h"
 
46
#include "indirect_dispatch.h"
 
47
#include "indirect_size_get.h"
 
48
#include "glapitable.h"
 
49
#include "glapi.h"
 
50
#include "glthread.h"
 
51
#include "dispatch.h"
 
52
 
 
53
int __glXDispSwap_ReadPixels(__GLXclientState *cl, GLbyte *pc)
 
54
{
 
55
    GLsizei width, height;
 
56
    GLenum format, type;
 
57
    GLboolean swapBytes, lsbFirst;
 
58
    GLint compsize;
 
59
    __GLX_DECLARE_SWAP_VARIABLES;
 
60
    __GLXcontext *cx;
 
61
    ClientPtr client = cl->client;
 
62
    int error;
 
63
    char *answer, answerBuffer[200];
 
64
 
 
65
    __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
 
66
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
67
    if (!cx) {
 
68
        return error;
 
69
    }
 
70
 
 
71
    pc += __GLX_SINGLE_HDR_SIZE;
 
72
    __GLX_SWAP_INT(pc+0);
 
73
    __GLX_SWAP_INT(pc+4);
 
74
    __GLX_SWAP_INT(pc+8);
 
75
    __GLX_SWAP_INT(pc+12);
 
76
    __GLX_SWAP_INT(pc+16);
 
77
    __GLX_SWAP_INT(pc+20);
 
78
 
 
79
    width = *(GLsizei *)(pc + 8);
 
80
    height = *(GLsizei *)(pc + 12);
 
81
    format = *(GLenum *)(pc + 16);
 
82
    type = *(GLenum *)(pc + 20);
 
83
    swapBytes = *(GLboolean *)(pc + 24);
 
84
    lsbFirst = *(GLboolean *)(pc + 25);
 
85
    compsize = __glReadPixels_size(format,type,width,height);
 
86
    if (compsize < 0) compsize = 0;
 
87
 
 
88
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
89
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst) );
 
90
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
91
    __glXClearErrorOccured();
 
92
    CALL_ReadPixels( GET_DISPATCH(),
 
93
                 (*(GLint    *)(pc + 0),
 
94
                 *(GLint    *)(pc + 4),
 
95
                 *(GLsizei  *)(pc + 8),
 
96
                 *(GLsizei  *)(pc + 12),
 
97
                 *(GLenum   *)(pc + 16),
 
98
                 *(GLenum   *)(pc + 20),
 
99
                 answer)
 
100
                 );
 
101
 
 
102
    if (__glXErrorOccured()) {
 
103
        __GLX_BEGIN_REPLY(0);
 
104
        __GLX_SWAP_REPLY_HEADER();
 
105
        __GLX_SEND_HEADER();
 
106
    } else {
 
107
        __GLX_BEGIN_REPLY(compsize);
 
108
        __GLX_SWAP_REPLY_HEADER();
 
109
        __GLX_SEND_HEADER();
 
110
        __GLX_SEND_VOID_ARRAY(compsize);
 
111
    }
 
112
    return Success;
 
113
}
 
114
 
 
115
int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
 
116
{
 
117
    GLint level, compsize;
 
118
    GLenum format, type, target;
 
119
    GLboolean swapBytes;
 
120
    __GLX_DECLARE_SWAP_VARIABLES;
 
121
    __GLXcontext *cx;
 
122
    ClientPtr client = cl->client;
 
123
    int error;
 
124
    char *answer, answerBuffer[200];
 
125
    GLint width=0, height=0, depth=1;
 
126
 
 
127
    __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
 
128
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
129
    if (!cx) {
 
130
        return error;
 
131
    }
 
132
 
 
133
    pc += __GLX_SINGLE_HDR_SIZE;
 
134
    __GLX_SWAP_INT(pc+0);
 
135
    __GLX_SWAP_INT(pc+4);
 
136
    __GLX_SWAP_INT(pc+8);
 
137
    __GLX_SWAP_INT(pc+12);
 
138
 
 
139
    level = *(GLint *)(pc + 4);
 
140
    format = *(GLenum *)(pc + 8);
 
141
    type = *(GLenum *)(pc + 12);
 
142
    target = *(GLenum *)(pc + 0);
 
143
    swapBytes = *(GLboolean *)(pc + 16);
 
144
 
 
145
    CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_WIDTH, &width) );
 
146
    CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_HEIGHT, &height) );
 
147
    if ( target == GL_TEXTURE_3D) {
 
148
        CALL_GetTexLevelParameteriv( GET_DISPATCH(), (target, level, GL_TEXTURE_DEPTH, &depth) );
 
149
    }
 
150
    /*
 
151
     * The three queries above might fail if we're in a state where queries
 
152
     * are illegal, but then width, height, and depth would still be zero anyway.
 
153
     */
 
154
    compsize = __glGetTexImage_size(target,level,format,type,width,height,depth);
 
155
    if (compsize < 0) compsize = 0;
 
156
 
 
157
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
158
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
159
    __glXClearErrorOccured();
 
160
    CALL_GetTexImage( GET_DISPATCH(), (
 
161
                  *(GLenum   *)(pc + 0),
 
162
                  *(GLint    *)(pc + 4),
 
163
                  *(GLenum   *)(pc + 8),
 
164
                  *(GLenum   *)(pc + 12),
 
165
                  answer
 
166
                  ) );
 
167
 
 
168
    if (__glXErrorOccured()) {
 
169
        __GLX_BEGIN_REPLY(0);
 
170
        __GLX_SWAP_REPLY_HEADER();
 
171
        __GLX_SEND_HEADER();
 
172
    } else {
 
173
        __GLX_BEGIN_REPLY(compsize);
 
174
        __GLX_SWAP_REPLY_HEADER();
 
175
        __GLX_SWAP_INT(&width);
 
176
        __GLX_SWAP_INT(&height);
 
177
        __GLX_SWAP_INT(&depth);
 
178
        ((xGLXGetTexImageReply *)&__glXReply)->width = width;
 
179
        ((xGLXGetTexImageReply *)&__glXReply)->height = height;
 
180
        ((xGLXGetTexImageReply *)&__glXReply)->depth = depth;
 
181
        __GLX_SEND_HEADER();
 
182
        __GLX_SEND_VOID_ARRAY(compsize);
 
183
    }
 
184
    return Success;
 
185
}
 
186
 
 
187
int __glXDispSwap_GetPolygonStipple(__GLXclientState *cl, GLbyte *pc)
 
188
{
 
189
    GLboolean lsbFirst;
 
190
    __GLXcontext *cx;
 
191
    ClientPtr client = cl->client;
 
192
    int error;
 
193
    GLubyte answerBuffer[200];
 
194
    char *answer;
 
195
    __GLX_DECLARE_SWAP_VARIABLES;
 
196
 
 
197
    __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
 
198
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
199
    if (!cx) {
 
200
        return error;
 
201
    }
 
202
    pc += __GLX_SINGLE_HDR_SIZE;
 
203
    lsbFirst = *(GLboolean *)(pc + 0);
 
204
 
 
205
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst) );
 
206
    __GLX_GET_ANSWER_BUFFER(answer,cl,128,1);
 
207
 
 
208
    __glXClearErrorOccured();
 
209
    CALL_GetPolygonStipple( GET_DISPATCH(), ((GLubyte  *) answer) );
 
210
    if (__glXErrorOccured()) {
 
211
        __GLX_BEGIN_REPLY(0);
 
212
        __GLX_SWAP_REPLY_HEADER();
 
213
        __GLX_SEND_HEADER();
 
214
    } else {
 
215
        __GLX_BEGIN_REPLY(128);
 
216
        __GLX_SWAP_REPLY_HEADER();
 
217
        __GLX_SEND_HEADER();
 
218
        __GLX_SEND_BYTE_ARRAY(128);
 
219
    }
 
220
    return Success;
 
221
}
 
222
 
 
223
int __glXDispSwap_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc)
 
224
{
 
225
    GLint compsize, compsize2;
 
226
    GLenum format, type, target;
 
227
    GLboolean swapBytes;
 
228
    __GLXcontext *cx;
 
229
    ClientPtr client = cl->client;
 
230
    int error;
 
231
    __GLX_DECLARE_SWAP_VARIABLES;
 
232
    char *answer, answerBuffer[200];
 
233
    GLint width=0, height=0;
 
234
 
 
235
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
236
    if (!cx) {
 
237
        return error;
 
238
    }
 
239
 
 
240
    pc += __GLX_SINGLE_HDR_SIZE;
 
241
    __GLX_SWAP_INT(pc+0);
 
242
    __GLX_SWAP_INT(pc+4);
 
243
    __GLX_SWAP_INT(pc+8);
 
244
 
 
245
    format = *(GLenum *)(pc + 4);
 
246
    type = *(GLenum *)(pc + 8);
 
247
    target = *(GLenum *)(pc + 0);
 
248
    swapBytes = *(GLboolean *)(pc + 12);
 
249
 
 
250
    /* target must be SEPARABLE_2D, however I guess we can let the GL
 
251
       barf on this one.... */
 
252
 
 
253
    CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_WIDTH, &width) );
 
254
    CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_HEIGHT, &height) );
 
255
    /*
 
256
     * The two queries above might fail if we're in a state where queries
 
257
     * are illegal, but then width and height would still be zero anyway.
 
258
     */
 
259
    compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
 
260
    compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1);
 
261
 
 
262
    if (compsize < 0) compsize = 0;
 
263
    if (compsize2 < 0) compsize2 = 0;
 
264
    compsize = __GLX_PAD(compsize);
 
265
    compsize2 = __GLX_PAD(compsize2);
 
266
 
 
267
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
268
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize + compsize2,1);
 
269
    __glXClearErrorOccured();
 
270
    CALL_GetSeparableFilter( GET_DISPATCH(), (
 
271
                  *(GLenum   *)(pc + 0),
 
272
                  *(GLenum   *)(pc + 4),
 
273
                  *(GLenum   *)(pc + 8),
 
274
                  answer,
 
275
                  answer + compsize,
 
276
                  NULL
 
277
                  ) );
 
278
 
 
279
    if (__glXErrorOccured()) {
 
280
        __GLX_BEGIN_REPLY(0);
 
281
        __GLX_SWAP_REPLY_HEADER();
 
282
    } else {
 
283
        __GLX_BEGIN_REPLY(compsize + compsize2);
 
284
        __GLX_SWAP_REPLY_HEADER();
 
285
        __GLX_SWAP_INT(&width);
 
286
        __GLX_SWAP_INT(&height);
 
287
        ((xGLXGetSeparableFilterReply *)&__glXReply)->width = width;
 
288
        ((xGLXGetSeparableFilterReply *)&__glXReply)->height = height;
 
289
        __GLX_SEND_VOID_ARRAY(compsize + compsize2);
 
290
    }
 
291
 
 
292
    return Success;
 
293
}
 
294
 
 
295
int __glXDispSwap_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc)
 
296
{
 
297
    GLint compsize;
 
298
    GLenum format, type, target;
 
299
    GLboolean swapBytes;
 
300
    __GLXcontext *cx;
 
301
    ClientPtr client = cl->client;
 
302
    int error;
 
303
    __GLX_DECLARE_SWAP_VARIABLES;
 
304
    char *answer, answerBuffer[200];
 
305
    GLint width=0, height=0;
 
306
 
 
307
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
308
    if (!cx) {
 
309
        return error;
 
310
    }
 
311
 
 
312
    pc += __GLX_SINGLE_HDR_SIZE;
 
313
    __GLX_SWAP_INT(pc+0);
 
314
    __GLX_SWAP_INT(pc+4);
 
315
    __GLX_SWAP_INT(pc+8);
 
316
 
 
317
    format = *(GLenum *)(pc + 4);
 
318
    type = *(GLenum *)(pc + 8);
 
319
    target = *(GLenum *)(pc + 0);
 
320
    swapBytes = *(GLboolean *)(pc + 12);
 
321
 
 
322
    CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_WIDTH, &width) );
 
323
    if (target == GL_CONVOLUTION_2D) {
 
324
        height = 1;
 
325
    } else {
 
326
        CALL_GetConvolutionParameteriv( GET_DISPATCH(), (target, GL_CONVOLUTION_HEIGHT, &height) );
 
327
    }
 
328
    /*
 
329
     * The two queries above might fail if we're in a state where queries
 
330
     * are illegal, but then width and height would still be zero anyway.
 
331
     */
 
332
    compsize = __glGetTexImage_size(target,1,format,type,width,height,1);
 
333
    if (compsize < 0) compsize = 0;
 
334
 
 
335
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
336
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
337
    __glXClearErrorOccured();
 
338
    CALL_GetConvolutionFilter( GET_DISPATCH(), (
 
339
                  *(GLenum   *)(pc + 0),
 
340
                  *(GLenum   *)(pc + 4),
 
341
                  *(GLenum   *)(pc + 8),
 
342
                  answer
 
343
                  ) );
 
344
 
 
345
    if (__glXErrorOccured()) {
 
346
        __GLX_BEGIN_REPLY(0);
 
347
        __GLX_SWAP_REPLY_HEADER();
 
348
    } else {
 
349
        __GLX_BEGIN_REPLY(compsize);
 
350
        __GLX_SWAP_REPLY_HEADER();
 
351
        __GLX_SWAP_INT(&width);
 
352
        __GLX_SWAP_INT(&height);
 
353
        ((xGLXGetConvolutionFilterReply *)&__glXReply)->width = width;
 
354
        ((xGLXGetConvolutionFilterReply *)&__glXReply)->height = height;
 
355
        __GLX_SEND_VOID_ARRAY(compsize);
 
356
    }
 
357
 
 
358
    return Success;
 
359
}
 
360
 
 
361
int __glXDispSwap_GetHistogram(__GLXclientState *cl, GLbyte *pc)
 
362
{
 
363
    GLint compsize;
 
364
    GLenum format, type, target;
 
365
    GLboolean swapBytes, reset;
 
366
    __GLXcontext *cx;
 
367
    ClientPtr client = cl->client;
 
368
    int error;
 
369
    __GLX_DECLARE_SWAP_VARIABLES;
 
370
    char *answer, answerBuffer[200];
 
371
    GLint width=0;
 
372
 
 
373
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
374
    if (!cx) {
 
375
        return error;
 
376
    }
 
377
 
 
378
    pc += __GLX_SINGLE_HDR_SIZE;
 
379
    __GLX_SWAP_INT(pc+0);
 
380
    __GLX_SWAP_INT(pc+4);
 
381
    __GLX_SWAP_INT(pc+8);
 
382
 
 
383
    format = *(GLenum *)(pc + 4);
 
384
    type = *(GLenum *)(pc + 8);
 
385
    target = *(GLenum *)(pc + 0);
 
386
    swapBytes = *(GLboolean *)(pc + 12);
 
387
    reset = *(GLboolean *)(pc + 13);
 
388
 
 
389
    CALL_GetHistogramParameteriv( GET_DISPATCH(), (target, GL_HISTOGRAM_WIDTH, &width) );
 
390
    /*
 
391
     * The one query above might fail if we're in a state where queries
 
392
     * are illegal, but then width would still be zero anyway.
 
393
     */
 
394
    compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
 
395
    if (compsize < 0) compsize = 0;
 
396
 
 
397
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
398
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
399
    __glXClearErrorOccured();
 
400
    CALL_GetHistogram( GET_DISPATCH(), (target, reset, format, type, answer) );
 
401
 
 
402
    if (__glXErrorOccured()) {
 
403
        __GLX_BEGIN_REPLY(0);
 
404
        __GLX_SWAP_REPLY_HEADER();
 
405
    } else {
 
406
        __GLX_BEGIN_REPLY(compsize);
 
407
        __GLX_SWAP_REPLY_HEADER();
 
408
        __GLX_SWAP_INT(&width);
 
409
        ((xGLXGetHistogramReply *)&__glXReply)->width = width;
 
410
        __GLX_SEND_VOID_ARRAY(compsize);
 
411
    }
 
412
 
 
413
    return Success;
 
414
}
 
415
 
 
416
int __glXDispSwap_GetMinmax(__GLXclientState *cl, GLbyte *pc)
 
417
{
 
418
    GLint compsize;
 
419
    GLenum format, type, target;
 
420
    GLboolean swapBytes, reset;
 
421
    __GLXcontext *cx;
 
422
    ClientPtr client = cl->client;
 
423
    int error;
 
424
    __GLX_DECLARE_SWAP_VARIABLES;
 
425
    char *answer, answerBuffer[200];
 
426
 
 
427
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
428
    if (!cx) {
 
429
        return error;
 
430
    }
 
431
 
 
432
    pc += __GLX_SINGLE_HDR_SIZE;
 
433
    __GLX_SWAP_INT(pc+0);
 
434
    __GLX_SWAP_INT(pc+4);
 
435
    __GLX_SWAP_INT(pc+8);
 
436
 
 
437
    format = *(GLenum *)(pc + 4);
 
438
    type = *(GLenum *)(pc + 8);
 
439
    target = *(GLenum *)(pc + 0);
 
440
    swapBytes = *(GLboolean *)(pc + 12);
 
441
    reset = *(GLboolean *)(pc + 13);
 
442
 
 
443
    compsize = __glGetTexImage_size(target,1,format,type,2,1,1);
 
444
    if (compsize < 0) compsize = 0;
 
445
 
 
446
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
447
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
448
    __glXClearErrorOccured();
 
449
    CALL_GetMinmax( GET_DISPATCH(), (target, reset, format, type, answer) );
 
450
 
 
451
    if (__glXErrorOccured()) {
 
452
        __GLX_BEGIN_REPLY(0);
 
453
        __GLX_SWAP_REPLY_HEADER();
 
454
    } else {
 
455
        __GLX_BEGIN_REPLY(compsize);
 
456
        __GLX_SWAP_REPLY_HEADER();
 
457
        __GLX_SEND_VOID_ARRAY(compsize);
 
458
    }
 
459
 
 
460
    return Success;
 
461
}
 
462
 
 
463
int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
 
464
{
 
465
    GLint compsize;
 
466
    GLenum format, type, target;
 
467
    GLboolean swapBytes;
 
468
    __GLXcontext *cx;
 
469
    ClientPtr client = cl->client;
 
470
    int error;
 
471
    __GLX_DECLARE_SWAP_VARIABLES;
 
472
    char *answer, answerBuffer[200];
 
473
    GLint width=0;
 
474
 
 
475
    cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
 
476
    if (!cx) {
 
477
        return error;
 
478
    }
 
479
 
 
480
    pc += __GLX_SINGLE_HDR_SIZE;
 
481
    __GLX_SWAP_INT(pc+0);
 
482
    __GLX_SWAP_INT(pc+4);
 
483
    __GLX_SWAP_INT(pc+8);
 
484
 
 
485
    format = *(GLenum *)(pc + 4);
 
486
    type = *(GLenum *)(pc + 8);
 
487
    target = *(GLenum *)(pc + 0);
 
488
    swapBytes = *(GLboolean *)(pc + 12);
 
489
 
 
490
    CALL_GetColorTableParameteriv( GET_DISPATCH(), (target, GL_COLOR_TABLE_WIDTH, &width) );
 
491
    /*
 
492
     * The one query above might fail if we're in a state where queries
 
493
     * are illegal, but then width would still be zero anyway.
 
494
     */
 
495
    compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
 
496
    if (compsize < 0) compsize = 0;
 
497
 
 
498
    CALL_PixelStorei( GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes) );
 
499
    __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
 
500
    __glXClearErrorOccured();
 
501
    CALL_GetColorTable( GET_DISPATCH(), (
 
502
                  *(GLenum   *)(pc + 0),
 
503
                  *(GLenum   *)(pc + 4),
 
504
                  *(GLenum   *)(pc + 8),
 
505
                  answer
 
506
                  ) );
 
507
 
 
508
    if (__glXErrorOccured()) {
 
509
        __GLX_BEGIN_REPLY(0);
 
510
        __GLX_SWAP_REPLY_HEADER();
 
511
    } else {
 
512
        __GLX_BEGIN_REPLY(compsize);
 
513
        __GLX_SWAP_REPLY_HEADER();
 
514
        __GLX_SWAP_INT(&width);
 
515
        ((xGLXGetColorTableReply *)&__glXReply)->width = width;
 
516
        __GLX_SEND_VOID_ARRAY(compsize);
 
517
    }
 
518
 
 
519
    return Success;
 
520
}