Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xgl / glxext / xglglxext.c
blobc260d8e2da2b38091d1c375c0a384c8a415e3617
1 /*
2 * Copyright © 2005 Novell, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Novell, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Novell, Inc. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
15 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: David Reveman <davidr@novell.com>
26 #include "xgl.h"
27 #include "xglglx.h"
28 #include "xglglxext.h"
30 #include <GL/gl.h>
31 #include <GL/glext.h>
32 #include <GL/internal/glcore.h>
34 #include "glxserver.h"
35 #include "glxdrawable.h"
36 #include "glxscreens.h"
37 #include "glxutil.h"
38 #include "unpack.h"
39 #include "g_disptab.h"
40 #include "glapitable.h"
41 #include "glxext.h"
42 #include "micmap.h"
44 #define XGL_MAX_TEXTURE_UNITS 8
45 #define XGL_MAX_ATTRIB_STACK_DEPTH 16
47 #define XGL_TEXTURE_1D_BIT (1 << 0)
48 #define XGL_TEXTURE_2D_BIT (1 << 1)
49 #define XGL_TEXTURE_3D_BIT (1 << 2)
50 #define XGL_TEXTURE_RECTANGLE_BIT (1 << 3)
51 #define XGL_TEXTURE_CUBE_MAP_BIT (1 << 4)
53 typedef Bool (*GLXScreenProbeProc) (int screen);
54 typedef __GLinterface *(*GLXCreateContextProc) (__GLimports *imports,
55 __GLcontextModes *modes,
56 __GLinterface *shareGC);
57 typedef void (*GLXCreateBufferProc) (__GLXdrawablePrivate *glxPriv);
58 typedef GLboolean (*GLXSwapBuffersProc) (__GLXdrawablePrivate *glxPriv);
59 typedef int (*GLXBindBuffersProc) (__GLXdrawablePrivate *glxPriv,
60 int buffer);
61 typedef int (*GLXReleaseBuffersProc) (__GLXdrawablePrivate *glxPriv,
62 int buffer);
64 typedef struct _xglGLXScreenInfo {
65 GLXScreenProbeProc screenProbe;
66 GLXCreateContextProc createContext;
67 GLXCreateBufferProc createBuffer;
68 } xglGLXScreenInfoRec, *xglGLXScreenInfoPtr;
70 extern __GLXscreenInfo *__xglScreenInfoPtr;
72 static xglGLXScreenInfoRec screenInfoPriv;
74 //extern __GLXscreenInfo __glDDXScreenInfo;
76 typedef GLboolean (*GLResizeBuffersProc) (__GLdrawableBuffer *buffer,
77 GLint x,
78 GLint y,
79 GLuint width,
80 GLuint height,
81 __GLdrawablePrivate *glPriv,
82 GLuint bufferMask);
83 typedef void (*GLFreeBuffersProc) (__GLdrawablePrivate *glPriv);
85 typedef struct _xglGLBuffer {
86 GLXSwapBuffersProc swapBuffers;
87 GLXBindBuffersProc bindBuffers;
88 GLXReleaseBuffersProc releaseBuffers;
89 GLResizeBuffersProc resizeBuffers;
90 GLFreeBuffersProc freeBuffers;
91 ScreenPtr pScreen;
92 DrawablePtr pDrawable;
93 xglVisualPtr pVisual;
94 glitz_drawable_t *drawable;
95 glitz_surface_t *backSurface;
96 PixmapPtr pPixmap;
97 GCPtr pGC;
98 RegionRec damage;
99 void *private;
100 int screenX, screenY;
101 int xOff, yOff;
102 int yFlip;
103 } xglGLBufferRec, *xglGLBufferPtr;
105 typedef int xglGLXVisualConfigRec, *xglGLXVisualConfigPtr;
106 typedef struct _xglDisplayList *xglDisplayListPtr;
108 #define XGL_LIST_OP_CALLS 0
109 #define XGL_LIST_OP_DRAW 1
110 #define XGL_LIST_OP_GL 2
111 #define XGL_LIST_OP_LIST 3
113 typedef struct _xglGLOp {
114 void (*glProc) (struct _xglGLOp *pOp);
115 union {
116 GLenum enumeration;
117 GLbitfield bitfield;
118 GLsizei size;
119 struct {
120 GLint x;
121 GLint y;
122 GLsizei width;
123 GLsizei height;
124 } rect;
125 struct {
126 GLenum target;
127 GLuint texture;
128 } bind_texture;
129 struct {
130 GLenum target;
131 GLenum pname;
132 GLfloat params[4];
133 } tex_parameter_fv;
134 struct {
135 GLint x;
136 GLint y;
137 GLsizei width;
138 GLsizei height;
139 GLenum type;
140 } copy_pixels;
141 struct {
142 GLenum target;
143 GLint level;
144 GLenum internalformat;
145 GLint x;
146 GLint y;
147 GLsizei width;
148 GLint border;
149 } copy_tex_image_1d;
150 struct {
151 GLenum target;
152 GLint level;
153 GLenum internalformat;
154 GLint x;
155 GLint y;
156 GLsizei width;
157 GLsizei height;
158 GLint border;
159 } copy_tex_image_2d;
160 struct {
161 GLenum target;
162 GLint level;
163 GLint xoffset;
164 GLint x;
165 GLint y;
166 GLsizei width;
167 } copy_tex_sub_image_1d;
168 struct {
169 GLenum target;
170 GLint level;
171 GLint xoffset;
172 GLint yoffset;
173 GLint x;
174 GLint y;
175 GLsizei width;
176 GLsizei height;
177 } copy_tex_sub_image_2d;
178 struct {
179 GLenum target;
180 GLenum internalformat;
181 GLint x;
182 GLint y;
183 GLsizei width;
184 } copy_color_table;
185 struct {
186 GLenum target;
187 GLsizei start;
188 GLint x;
189 GLint y;
190 GLsizei width;
191 } copy_color_sub_table;
192 struct {
193 GLenum target;
194 GLenum internalformat;
195 GLint x;
196 GLint y;
197 GLsizei width;
198 } copy_convolution_filter_1d;
199 struct {
200 GLenum target;
201 GLenum internalformat;
202 GLint x;
203 GLint y;
204 GLsizei width;
205 GLsizei height;
206 } copy_convolution_filter_2d;
207 struct {
208 GLenum target;
209 GLint level;
210 GLint xoffset;
211 GLint yoffset;
212 GLint zoffset;
213 GLint x;
214 GLint y;
215 GLsizei width;
216 GLsizei height;
217 } copy_tex_sub_image_3d;
218 struct {
219 GLfloat x;
220 GLfloat y;
221 GLfloat z;
222 } window_pos_3f;
223 } u;
224 } xglGLOpRec, *xglGLOpPtr;
226 typedef struct _xglListOp {
227 int type;
228 union {
229 GLuint list;
230 xglGLOpPtr gl;
231 } u;
232 } xglListOpRec, *xglListOpPtr;
234 typedef struct _xglDisplayList {
235 xglListOpPtr pOp;
236 int nOp;
237 int size;
238 } xglDisplayListRec;
240 typedef struct _xglTexObj {
241 GLuint key;
242 GLuint name;
243 PixmapPtr pPixmap;
244 glitz_texture_object_t *object;
245 int refcnt;
246 } xglTexObjRec, *xglTexObjPtr;
248 typedef struct _xglTexUnit {
249 GLbitfield enabled;
250 xglTexObjPtr p1D;
251 xglTexObjPtr p2D;
252 xglTexObjPtr p3D;
253 xglTexObjPtr pRect;
254 xglTexObjPtr pCubeMap;
255 } xglTexUnitRec, *xglTexUnitPtr;
257 typedef struct _xglGLAttributes {
258 GLbitfield mask;
259 GLenum drawBuffer;
260 GLenum readBuffer;
261 xRectangle viewport;
262 xRectangle scissor;
263 GLboolean scissorTest;
264 xglTexUnitRec texUnits[XGL_MAX_TEXTURE_UNITS];
265 } xglGLAttributesRec, *xglGLAttributesPtr;
267 typedef struct _xglGLContext {
268 __GLinterface iface;
269 __GLinterface *mIface;
270 int refcnt;
271 struct _xglGLContext *shared;
272 glitz_context_t *context;
273 struct _glapi_table glRenderTable;
274 PFNGLACTIVETEXTUREARBPROC ActiveTextureARB;
275 PFNGLWINDOWPOS3FMESAPROC WindowPos3fMESA;
276 Bool needInit;
277 xglGLBufferPtr pDrawBuffer;
278 xglGLBufferPtr pReadBuffer;
279 int drawXoff, drawYoff;
280 __GLdrawablePrivate *readPriv;
281 __GLdrawablePrivate *drawPriv;
282 char *versionString;
283 GLenum errorValue;
284 GLboolean doubleBuffer;
285 GLint depthBits;
286 GLint stencilBits;
287 xglHashTablePtr texObjects;
288 xglHashTablePtr displayLists;
289 GLuint list;
290 GLenum listMode;
291 GLuint beginCnt;
292 xglDisplayListPtr pList;
293 GLuint groupList;
294 xglGLAttributesRec attrib;
295 xglGLAttributesRec attribStack[XGL_MAX_ATTRIB_STACK_DEPTH];
296 int nAttribStack;
297 int activeTexUnit;
298 GLint maxTexUnits;
299 GLint maxListNesting;
300 GLint maxAttribStackDepth;
301 } xglGLContextRec, *xglGLContextPtr;
303 static xglGLContextPtr cctx = NULL;
305 static void
306 xglSetCurrentContext (xglGLContextPtr pContext);
308 #define XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES(pBox, nBox, pScissorBox) \
309 (pBox) = REGION_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \
310 (nBox) = REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \
311 (pScissorBox)->x1 = cctx->attrib.scissor.x + cctx->pDrawBuffer->xOff; \
312 (pScissorBox)->x2 = (pScissorBox)->x1 + cctx->attrib.scissor.width; \
313 (pScissorBox)->y2 = cctx->attrib.scissor.y + cctx->pDrawBuffer->yOff; \
314 (pScissorBox)->y2 = cctx->pDrawBuffer->yFlip - (pScissorBox)->y2; \
315 (pScissorBox)->y1 = (pScissorBox)->y2 - cctx->attrib.scissor.height
317 #define XGL_GLX_DRAW_PROLOGUE(pBox, nBox, pScissorBox) \
318 XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, pScissorBox); \
319 xglSetupTextures ()
321 #define XGL_GLX_DRAW_BOX(pBox1, pBox2) \
322 (pBox1)->x1 = cctx->pDrawBuffer->screenX + (pBox2)->x1; \
323 (pBox1)->y1 = cctx->pDrawBuffer->screenY + (pBox2)->y1; \
324 (pBox1)->x2 = cctx->pDrawBuffer->screenX + (pBox2)->x2; \
325 (pBox1)->y2 = cctx->pDrawBuffer->screenY + (pBox2)->y2
327 #define XGL_GLX_INTERSECT_BOX(pBox1, pBox2) \
329 if ((pBox1)->x1 < (pBox2)->x1) \
330 (pBox1)->x1 = (pBox2)->x1; \
331 if ((pBox1)->y1 < (pBox2)->y1) \
332 (pBox1)->y1 = (pBox2)->y1; \
333 if ((pBox1)->x2 > (pBox2)->x2) \
334 (pBox1)->x2 = (pBox2)->x2; \
335 if ((pBox1)->y2 > (pBox2)->y2) \
336 (pBox1)->y2 = (pBox2)->y2; \
339 #define XGL_GLX_SET_SCISSOR_BOX(pBox) \
340 glScissor ((pBox)->x1, \
341 cctx->pDrawBuffer->yFlip - (pBox)->y2, \
342 (pBox)->x2 - (pBox)->x1, \
343 (pBox)->y2 - (pBox)->y1)
345 #define XGL_GLX_DRAW_DAMAGE(pBox, pRegion) \
346 if (cctx->attrib.drawBuffer != GL_BACK) \
348 (pRegion)->extents.x1 = (pBox)->x1 - cctx->pDrawBuffer->screenX; \
349 (pRegion)->extents.y1 = (pBox)->y1 - cctx->pDrawBuffer->screenY; \
350 (pRegion)->extents.x2 = (pBox)->x2 - cctx->pDrawBuffer->screenX; \
351 (pRegion)->extents.y2 = (pBox)->y2 - cctx->pDrawBuffer->screenY; \
352 (pRegion)->data = (RegDataPtr) NULL; \
353 REGION_UNION (cctx->pDrawBuffer->pGC->pScreen, \
354 &cctx->pDrawBuffer->damage, \
355 &cctx->pDrawBuffer->damage, \
356 pRegion); \
357 xglAddBitDamage (cctx->pDrawBuffer->pDrawable, pRegion); \
360 static void
361 xglRecordError (GLenum error)
363 if (cctx->errorValue == GL_NO_ERROR)
364 cctx->errorValue = error;
367 static xglDisplayListPtr
368 xglCreateList (void)
370 xglDisplayListPtr pDisplayList;
372 pDisplayList = xalloc (sizeof (xglDisplayListRec));
373 if (!pDisplayList)
374 return NULL;
376 pDisplayList->pOp = NULL;
377 pDisplayList->nOp = 0;
378 pDisplayList->size = 0;
380 return pDisplayList;
383 static void
384 xglDestroyList (xglDisplayListPtr pDisplayList)
386 xglListOpPtr pOp = pDisplayList->pOp;
387 int nOp = pDisplayList->nOp;
389 while (nOp--)
391 switch (pOp->type) {
392 case XGL_LIST_OP_CALLS:
393 case XGL_LIST_OP_DRAW:
394 glDeleteLists (pOp->u.list, 1);
395 break;
396 case XGL_LIST_OP_GL:
397 xfree (pOp->u.gl);
398 break;
399 case XGL_LIST_OP_LIST:
400 break;
403 pOp++;
406 if (pDisplayList->pOp)
407 xfree (pDisplayList->pOp);
409 xfree (pDisplayList);
412 static Bool
413 xglResizeList (xglDisplayListPtr pDisplayList,
414 int nOp)
416 if (pDisplayList->size < nOp)
418 int size = pDisplayList->nOp ? pDisplayList->nOp : 4;
420 while (size < nOp)
421 size <<= 1;
423 pDisplayList->pOp = xrealloc (pDisplayList->pOp,
424 sizeof (xglListOpRec) * size);
425 if (!pDisplayList->pOp)
426 return FALSE;
428 pDisplayList->size = size;
431 return TRUE;
434 static void
435 xglStartList (int type,
436 GLenum mode)
438 if (!xglResizeList (cctx->pList, cctx->pList->nOp + 1))
440 xglRecordError (GL_OUT_OF_MEMORY);
441 return;
444 cctx->pList->pOp[cctx->pList->nOp].type = type;
445 cctx->pList->pOp[cctx->pList->nOp].u.list = glGenLists (1);
447 glNewList (cctx->pList->pOp[cctx->pList->nOp].u.list, mode);
449 cctx->pList->nOp++;
452 static void
453 xglGLOp (xglGLOpPtr pOp)
455 if (cctx->list)
457 xglGLOpPtr pGLOp;
459 pGLOp = xalloc (sizeof (xglGLOpRec));
460 if (!pGLOp)
462 xglRecordError (GL_OUT_OF_MEMORY);
463 return;
466 if (!xglResizeList (cctx->pList, cctx->pList->nOp + 1))
468 xfree (pGLOp);
469 xglRecordError (GL_OUT_OF_MEMORY);
470 return;
473 glEndList ();
475 *pGLOp = *pOp;
477 cctx->pList->pOp[cctx->pList->nOp].type = XGL_LIST_OP_GL;
478 cctx->pList->pOp[cctx->pList->nOp].u.gl = pGLOp;
479 cctx->pList->nOp++;
481 if (cctx->listMode == GL_COMPILE_AND_EXECUTE)
482 (*pOp->glProc) (pOp);
484 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
486 else
487 (*pOp->glProc) (pOp);
490 static void
491 xglViewportProc (xglGLOpPtr pOp)
493 cctx->attrib.viewport.x = pOp->u.rect.x;
494 cctx->attrib.viewport.y = pOp->u.rect.y;
495 cctx->attrib.viewport.width = pOp->u.rect.width;
496 cctx->attrib.viewport.height = pOp->u.rect.height;
498 glViewport (pOp->u.rect.x + cctx->pDrawBuffer->xOff,
499 pOp->u.rect.y + cctx->pDrawBuffer->yOff,
500 pOp->u.rect.width,
501 pOp->u.rect.height);
504 static void
505 xglViewport (GLint x,
506 GLint y,
507 GLsizei width,
508 GLsizei height)
510 xglGLOpRec gl;
512 gl.glProc = xglViewportProc;
514 gl.u.rect.x = x;
515 gl.u.rect.y = y;
516 gl.u.rect.width = width;
517 gl.u.rect.height = height;
519 xglGLOp (&gl);
522 static void
523 xglScissorProc (xglGLOpPtr pOp)
525 cctx->attrib.scissor.x = pOp->u.rect.x;
526 cctx->attrib.scissor.y = pOp->u.rect.y;
527 cctx->attrib.scissor.width = pOp->u.rect.width;
528 cctx->attrib.scissor.height = pOp->u.rect.height;
531 static void
532 xglScissor (GLint x,
533 GLint y,
534 GLsizei width,
535 GLsizei height)
537 xglGLOpRec gl;
539 gl.glProc = xglScissorProc;
541 gl.u.rect.x = x;
542 gl.u.rect.y = y;
543 gl.u.rect.width = width;
544 gl.u.rect.height = height;
546 xglGLOp (&gl);
549 static void
550 xglDrawBufferProc (xglGLOpPtr pOp)
552 glitz_drawable_buffer_t buffers[2];
554 switch (pOp->u.enumeration) {
555 case GL_FRONT:
556 buffers[0] = GLITZ_DRAWABLE_BUFFER_FRONT_COLOR;
557 glitz_context_draw_buffers (cctx->context, buffers, 1);
558 break;
559 case GL_FRONT_AND_BACK:
560 buffers[0] = GLITZ_DRAWABLE_BUFFER_FRONT_COLOR;
561 if (cctx->doubleBuffer)
563 buffers[1] = GLITZ_DRAWABLE_BUFFER_BACK_COLOR;
564 glitz_context_draw_buffers (cctx->context, buffers, 2);
566 else
567 glitz_context_draw_buffers (cctx->context, buffers, 1);
568 break;
569 case GL_BACK:
570 if (!cctx->doubleBuffer)
572 xglRecordError (GL_INVALID_OPERATION);
573 return;
575 buffers[0] = GLITZ_DRAWABLE_BUFFER_BACK_COLOR;
576 glitz_context_draw_buffers (cctx->context, buffers, 1);
577 break;
578 default:
579 xglRecordError (GL_INVALID_ENUM);
580 return;
583 cctx->attrib.drawBuffer = pOp->u.enumeration;
586 static void
587 xglDrawBuffer (GLenum mode)
589 xglGLOpRec gl;
591 gl.glProc = xglDrawBufferProc;
593 gl.u.enumeration = mode;
595 xglGLOp (&gl);
598 static void
599 xglReadBufferProc (xglGLOpPtr pOp)
601 switch (pOp->u.enumeration) {
602 case GL_FRONT:
603 glitz_context_read_buffer (cctx->context,
604 GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
605 break;
606 case GL_BACK:
607 if (!cctx->doubleBuffer)
609 xglRecordError (GL_INVALID_OPERATION);
610 return;
612 glitz_context_read_buffer (cctx->context,
613 GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
614 break;
615 default:
616 xglRecordError (GL_INVALID_ENUM);
617 return;
620 cctx->attrib.readBuffer = pOp->u.enumeration;
623 static void
624 xglReadBuffer (GLenum mode)
626 xglGLOpRec gl;
628 gl.glProc = xglReadBufferProc;
630 gl.u.enumeration = mode;
632 xglGLOp (&gl);
635 static void
636 xglDisableProc (xglGLOpPtr pOp)
638 xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit];
640 switch (pOp->u.enumeration) {
641 case GL_SCISSOR_TEST:
642 cctx->attrib.scissorTest = GL_FALSE;
643 return;
644 case GL_TEXTURE_1D:
645 pTexUnit->enabled &= ~XGL_TEXTURE_1D_BIT;
646 break;
647 case GL_TEXTURE_2D:
648 pTexUnit->enabled &= ~XGL_TEXTURE_2D_BIT;
649 break;
650 case GL_TEXTURE_3D:
651 pTexUnit->enabled &= ~XGL_TEXTURE_3D_BIT;
652 break;
653 case GL_TEXTURE_RECTANGLE_NV:
654 pTexUnit->enabled &= ~XGL_TEXTURE_RECTANGLE_BIT;
655 break;
656 case GL_TEXTURE_CUBE_MAP_ARB:
657 pTexUnit->enabled &= ~XGL_TEXTURE_CUBE_MAP_BIT;
658 break;
659 default:
660 break;
663 glDisable (pOp->u.enumeration);
666 static void
667 xglDisable (GLenum cap)
669 xglGLOpRec gl;
671 gl.glProc = xglDisableProc;
673 gl.u.enumeration = cap;
675 xglGLOp (&gl);
678 static void
679 xglEnableProc (xglGLOpPtr pOp)
681 xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit];
683 switch (pOp->u.enumeration) {
684 case GL_SCISSOR_TEST:
685 cctx->attrib.scissorTest = GL_TRUE;
686 return;
687 case GL_DEPTH_TEST:
688 if (!cctx->depthBits)
689 return;
690 case GL_STENCIL_TEST:
691 if (!cctx->stencilBits)
692 return;
693 case GL_TEXTURE_1D:
694 pTexUnit->enabled |= XGL_TEXTURE_1D_BIT;
695 break;
696 case GL_TEXTURE_2D:
697 pTexUnit->enabled |= XGL_TEXTURE_2D_BIT;
698 break;
699 case GL_TEXTURE_3D:
700 pTexUnit->enabled |= XGL_TEXTURE_3D_BIT;
701 break;
702 case GL_TEXTURE_RECTANGLE_NV:
703 pTexUnit->enabled |= XGL_TEXTURE_RECTANGLE_BIT;
704 break;
705 case GL_TEXTURE_CUBE_MAP_ARB:
706 pTexUnit->enabled |= XGL_TEXTURE_CUBE_MAP_BIT;
707 break;
708 default:
709 break;
712 glEnable (pOp->u.enumeration);
715 static void
716 xglEnable (GLenum cap)
718 xglGLOpRec gl;
720 gl.glProc = xglEnableProc;
722 gl.u.enumeration = cap;
724 xglGLOp (&gl);
727 static void
728 xglDeleteTexObj (xglTexObjPtr pTexObj)
730 if (pTexObj->pPixmap)
732 ScreenPtr pScreen = pTexObj->pPixmap->drawable.pScreen;
734 (*pScreen->DestroyPixmap) (pTexObj->pPixmap);
736 glitz_texture_object_destroy (pTexObj->object);
739 if (pTexObj->name)
741 glDeleteTextures (1, &pTexObj->name);
744 pTexObj->key = 0;
745 pTexObj->name = 0;
746 pTexObj->pPixmap = NULL;
747 pTexObj->object = NULL;
750 static void
751 xglRefTexObj (xglTexObjPtr pTexObj)
753 if (!pTexObj)
754 return;
756 pTexObj->refcnt++;
759 static void
760 xglUnrefTexObj (xglTexObjPtr pTexObj)
762 if (!pTexObj)
763 return;
765 pTexObj->refcnt--;
766 if (pTexObj->refcnt)
767 return;
769 xglDeleteTexObj (pTexObj);
771 xfree (pTexObj);
774 static void
775 xglPushAttribProc (xglGLOpPtr pOp)
777 xglGLAttributesPtr pAttrib;
779 if (cctx->nAttribStack == cctx->maxAttribStackDepth)
781 xglRecordError (GL_STACK_OVERFLOW);
782 return;
785 pAttrib = &cctx->attribStack[cctx->nAttribStack];
787 *pAttrib = cctx->attrib;
788 pAttrib->mask = pOp->u.bitfield;
790 if (pOp->u.bitfield & GL_TEXTURE_BIT)
792 int i;
794 for (i = 0; i < cctx->maxTexUnits; i++)
796 xglRefTexObj (pAttrib->texUnits[i].p1D);
797 xglRefTexObj (pAttrib->texUnits[i].p2D);
798 xglRefTexObj (pAttrib->texUnits[i].p3D);
799 xglRefTexObj (pAttrib->texUnits[i].pRect);
800 xglRefTexObj (pAttrib->texUnits[i].pCubeMap);
804 cctx->nAttribStack++;
806 glPushAttrib (pOp->u.bitfield);
809 static void
810 xglPushAttrib (GLbitfield mask)
812 xglGLOpRec gl;
814 gl.glProc = xglPushAttribProc;
816 gl.u.bitfield = mask;
818 xglGLOp (&gl);
821 static void
822 xglPopAttribProc (xglGLOpPtr pOp)
824 xglGLAttributesPtr pAttrib;
825 GLbitfield mask;
827 if (!cctx->nAttribStack)
829 xglRecordError (GL_STACK_UNDERFLOW);
830 return;
833 cctx->nAttribStack--;
835 pAttrib = &cctx->attribStack[cctx->nAttribStack];
836 mask = pAttrib->mask;
838 if (mask & GL_COLOR_BUFFER_BIT)
839 xglDrawBuffer (pAttrib->drawBuffer);
841 if (mask & GL_PIXEL_MODE_BIT)
842 xglReadBuffer (pAttrib->readBuffer);
844 if (mask & GL_SCISSOR_BIT)
846 xglScissor (pAttrib->scissor.x,
847 pAttrib->scissor.y,
848 pAttrib->scissor.width,
849 pAttrib->scissor.height);
851 if (pAttrib->scissorTest)
852 xglEnable (GL_SCISSOR_TEST);
853 else
854 xglDisable (GL_SCISSOR_TEST);
856 else if (mask & GL_ENABLE_BIT)
858 if (pAttrib->scissorTest)
859 xglEnable (GL_SCISSOR_TEST);
860 else
861 xglDisable (GL_SCISSOR_TEST);
864 if (mask & GL_VIEWPORT_BIT)
865 xglViewport (pAttrib->viewport.x,
866 pAttrib->viewport.y,
867 pAttrib->viewport.width,
868 pAttrib->viewport.height);
870 if (mask & GL_TEXTURE_BIT)
872 int i;
874 for (i = 0; i < cctx->maxTexUnits; i++)
876 xglUnrefTexObj (cctx->attrib.texUnits[i].p1D);
877 xglUnrefTexObj (cctx->attrib.texUnits[i].p2D);
878 xglUnrefTexObj (cctx->attrib.texUnits[i].p3D);
879 xglUnrefTexObj (cctx->attrib.texUnits[i].pRect);
880 xglUnrefTexObj (cctx->attrib.texUnits[i].pCubeMap);
882 cctx->attrib.texUnits[i] = pAttrib->texUnits[i];
885 else if (mask & GL_ENABLE_BIT)
887 int i;
889 for (i = 0; i < cctx->maxTexUnits; i++)
890 cctx->attrib.texUnits[i].enabled = pAttrib->texUnits[i].enabled;
893 glPopAttrib ();
896 static void
897 xglPopAttrib (void)
899 xglGLOpRec gl;
901 gl.glProc = xglPopAttribProc;
903 xglGLOp (&gl);
906 static GLuint
907 xglActiveTextureBinding (GLenum target)
909 xglTexObjPtr pTexObj;
911 switch (target) {
912 case GL_TEXTURE_BINDING_1D:
913 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p1D;
914 break;
915 case GL_TEXTURE_BINDING_2D:
916 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
917 break;
918 case GL_TEXTURE_BINDING_3D:
919 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p3D;
920 break;
921 case GL_TEXTURE_BINDING_RECTANGLE_NV:
922 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
923 break;
924 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
925 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pCubeMap;
926 break;
927 default:
928 return 0;
931 if (pTexObj)
932 return pTexObj->key;
934 return 0;
937 #define DOUBLE_TO_BOOLEAN(X) ((X) ? GL_TRUE : GL_FALSE)
938 #define INT_TO_BOOLEAN(I) ((I) ? GL_TRUE : GL_FALSE)
939 #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
941 static void
942 xglGetBooleanv (GLenum pname,
943 GLboolean *params)
945 switch (pname) {
946 case GL_CURRENT_RASTER_POSITION:
948 GLdouble v[4];
950 glGetDoublev (GL_CURRENT_RASTER_POSITION, v);
952 params[0] = DOUBLE_TO_BOOLEAN (v[0] - (GLdouble) cctx->drawXoff);
953 params[1] = DOUBLE_TO_BOOLEAN (v[1] - (GLdouble) cctx->drawYoff);
954 params[2] = DOUBLE_TO_BOOLEAN (v[2]);
955 params[3] = DOUBLE_TO_BOOLEAN (v[3]);
956 } break;
957 case GL_DOUBLEBUFFER:
958 params[0] = cctx->doubleBuffer;
959 break;
960 case GL_DEPTH_BITS:
961 params[0] = INT_TO_BOOLEAN (cctx->depthBits);
962 break;
963 case GL_STENCIL_BITS:
964 params[0] = INT_TO_BOOLEAN (cctx->stencilBits);
965 break;
966 case GL_DRAW_BUFFER:
967 params[0] = ENUM_TO_BOOLEAN (cctx->attrib.drawBuffer);
968 break;
969 case GL_READ_BUFFER:
970 params[0] = ENUM_TO_BOOLEAN (cctx->attrib.readBuffer);
971 break;
972 case GL_SCISSOR_BOX:
973 params[0] = INT_TO_BOOLEAN (cctx->attrib.scissor.x);
974 params[1] = INT_TO_BOOLEAN (cctx->attrib.scissor.y);
975 params[2] = INT_TO_BOOLEAN (cctx->attrib.scissor.width);
976 params[3] = INT_TO_BOOLEAN (cctx->attrib.scissor.height);
977 break;
978 case GL_SCISSOR_TEST:
979 params[0] = cctx->attrib.scissorTest;
980 break;
981 case GL_VIEWPORT:
982 params[0] = INT_TO_BOOLEAN (cctx->attrib.viewport.x);
983 params[1] = INT_TO_BOOLEAN (cctx->attrib.viewport.y);
984 params[2] = INT_TO_BOOLEAN (cctx->attrib.viewport.width);
985 params[3] = INT_TO_BOOLEAN (cctx->attrib.viewport.height);
986 break;
987 case GL_TEXTURE_BINDING_1D:
988 case GL_TEXTURE_BINDING_2D:
989 case GL_TEXTURE_BINDING_3D:
990 case GL_TEXTURE_BINDING_RECTANGLE_NV:
991 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
992 /* should be safe to fall-through here */
993 default:
994 glGetBooleanv (pname, params);
998 #define INT_TO_DOUBLE(I) ((GLdouble) (I))
999 #define ENUM_TO_DOUBLE(E) ((GLdouble) (E))
1000 #define BOOLEAN_TO_DOUBLE(B) ((B) ? 1.0F : 0.0F)
1002 static void
1003 xglGetDoublev (GLenum pname,
1004 GLdouble *params)
1006 switch (pname) {
1007 case GL_CURRENT_RASTER_POSITION:
1008 glGetDoublev (GL_CURRENT_RASTER_POSITION, params);
1010 params[0] -= (GLdouble) cctx->drawXoff;
1011 params[1] -= (GLdouble) cctx->drawYoff;
1012 break;
1013 case GL_DOUBLEBUFFER:
1014 params[0] = BOOLEAN_TO_DOUBLE (cctx->doubleBuffer);
1015 break;
1016 case GL_DEPTH_BITS:
1017 params[0] = INT_TO_DOUBLE (cctx->depthBits);
1018 break;
1019 case GL_STENCIL_BITS:
1020 params[0] = INT_TO_DOUBLE (cctx->stencilBits);
1021 break;
1022 case GL_DRAW_BUFFER:
1023 params[0] = ENUM_TO_DOUBLE (cctx->attrib.drawBuffer);
1024 break;
1025 case GL_READ_BUFFER:
1026 params[0] = ENUM_TO_DOUBLE (cctx->attrib.readBuffer);
1027 break;
1028 case GL_SCISSOR_BOX:
1029 params[0] = cctx->attrib.scissor.x;
1030 params[1] = cctx->attrib.scissor.y;
1031 params[2] = cctx->attrib.scissor.width;
1032 params[3] = cctx->attrib.scissor.height;
1033 break;
1034 case GL_SCISSOR_TEST:
1035 params[0] = BOOLEAN_TO_DOUBLE (cctx->attrib.scissorTest);
1036 break;
1037 case GL_VIEWPORT:
1038 params[0] = cctx->attrib.viewport.x;
1039 params[1] = cctx->attrib.viewport.y;
1040 params[2] = cctx->attrib.viewport.width;
1041 params[3] = cctx->attrib.viewport.height;
1042 break;
1043 case GL_TEXTURE_BINDING_1D:
1044 case GL_TEXTURE_BINDING_2D:
1045 case GL_TEXTURE_BINDING_3D:
1046 case GL_TEXTURE_BINDING_RECTANGLE_NV:
1047 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
1048 params[0] = xglActiveTextureBinding (pname);
1049 break;
1050 case GL_MAX_TEXTURE_UNITS_ARB:
1051 params[0] = cctx->maxTexUnits;
1052 break;
1053 case GL_MAX_ATTRIB_STACK_DEPTH:
1054 params[0] = cctx->maxAttribStackDepth;
1055 break;
1056 default:
1057 glGetDoublev (pname, params);
1061 #define INT_TO_FLOAT(I) ((GLfloat) (I))
1062 #define ENUM_TO_FLOAT(E) ((GLfloat) (E))
1063 #define BOOLEAN_TO_FLOAT(B) ((B) ? 1.0F : 0.0F)
1065 static void
1066 xglGetFloatv (GLenum pname,
1067 GLfloat *params)
1069 switch (pname) {
1070 case GL_CURRENT_RASTER_POSITION:
1071 glGetFloatv (GL_CURRENT_RASTER_POSITION, params);
1073 params[0] -= (GLfloat) cctx->drawXoff;
1074 params[1] -= (GLfloat) cctx->drawYoff;
1075 break;
1076 case GL_DOUBLEBUFFER:
1077 params[0] = BOOLEAN_TO_FLOAT (cctx->doubleBuffer);
1078 break;
1079 case GL_DEPTH_BITS:
1080 params[0] = INT_TO_FLOAT (cctx->depthBits);
1081 break;
1082 case GL_STENCIL_BITS:
1083 params[0] = INT_TO_FLOAT (cctx->stencilBits);
1084 break;
1085 case GL_DRAW_BUFFER:
1086 params[0] = ENUM_TO_FLOAT (cctx->attrib.drawBuffer);
1087 break;
1088 case GL_READ_BUFFER:
1089 params[0] = ENUM_TO_FLOAT (cctx->attrib.readBuffer);
1090 break;
1091 case GL_SCISSOR_BOX:
1092 params[0] = cctx->attrib.scissor.x;
1093 params[1] = cctx->attrib.scissor.y;
1094 params[2] = cctx->attrib.scissor.width;
1095 params[3] = cctx->attrib.scissor.height;
1096 break;
1097 case GL_SCISSOR_TEST:
1098 params[0] = BOOLEAN_TO_FLOAT (cctx->attrib.scissorTest);
1099 break;
1100 case GL_VIEWPORT:
1101 params[0] = cctx->attrib.viewport.x;
1102 params[1] = cctx->attrib.viewport.y;
1103 params[2] = cctx->attrib.viewport.width;
1104 params[3] = cctx->attrib.viewport.height;
1105 break;
1106 case GL_TEXTURE_BINDING_1D:
1107 case GL_TEXTURE_BINDING_2D:
1108 case GL_TEXTURE_BINDING_3D:
1109 case GL_TEXTURE_BINDING_RECTANGLE_NV:
1110 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
1111 params[0] = xglActiveTextureBinding (pname);
1112 break;
1113 case GL_MAX_TEXTURE_UNITS_ARB:
1114 params[0] = cctx->maxTexUnits;
1115 break;
1116 case GL_MAX_ATTRIB_STACK_DEPTH:
1117 params[0] = cctx->maxAttribStackDepth;
1118 break;
1119 default:
1120 glGetFloatv (pname, params);
1124 #define ENUM_TO_INT(E) ((GLint) (E))
1125 #define BOOLEAN_TO_INT(B) ((GLint) (B))
1127 static void
1128 xglGetIntegerv (GLenum pname,
1129 GLint *params)
1131 switch (pname) {
1132 case GL_CURRENT_RASTER_POSITION:
1133 glGetIntegerv (GL_CURRENT_RASTER_POSITION, params);
1135 params[0] -= (GLint) cctx->drawXoff;
1136 params[1] -= (GLint) cctx->drawYoff;
1137 break;
1138 case GL_DOUBLEBUFFER:
1139 params[0] = BOOLEAN_TO_INT (cctx->doubleBuffer);
1140 break;
1141 case GL_DEPTH_BITS:
1142 params[0] = cctx->depthBits;
1143 break;
1144 case GL_STENCIL_BITS:
1145 params[0] = cctx->stencilBits;
1146 break;
1147 case GL_DRAW_BUFFER:
1148 params[0] = ENUM_TO_INT (cctx->attrib.drawBuffer);
1149 break;
1150 case GL_READ_BUFFER:
1151 params[0] = ENUM_TO_INT (cctx->attrib.readBuffer);
1152 break;
1153 case GL_SCISSOR_BOX:
1154 params[0] = cctx->attrib.scissor.x;
1155 params[1] = cctx->attrib.scissor.y;
1156 params[2] = cctx->attrib.scissor.width;
1157 params[3] = cctx->attrib.scissor.height;
1158 break;
1159 case GL_SCISSOR_TEST:
1160 params[0] = BOOLEAN_TO_INT (cctx->attrib.scissorTest);
1161 break;
1162 case GL_VIEWPORT:
1163 params[0] = cctx->attrib.viewport.x;
1164 params[1] = cctx->attrib.viewport.y;
1165 params[2] = cctx->attrib.viewport.width;
1166 params[3] = cctx->attrib.viewport.height;
1167 break;
1168 case GL_TEXTURE_BINDING_1D:
1169 case GL_TEXTURE_BINDING_2D:
1170 case GL_TEXTURE_BINDING_3D:
1171 case GL_TEXTURE_BINDING_RECTANGLE_NV:
1172 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
1173 params[0] = xglActiveTextureBinding (pname);
1174 break;
1175 case GL_MAX_TEXTURE_UNITS_ARB:
1176 params[0] = cctx->maxTexUnits;
1177 break;
1178 case GL_MAX_ATTRIB_STACK_DEPTH:
1179 params[0] = cctx->maxAttribStackDepth;
1180 break;
1181 default:
1182 glGetIntegerv (pname, params);
1186 static GLboolean
1187 xglIsEnabled (GLenum cap)
1189 switch (cap) {
1190 case GL_SCISSOR_TEST:
1191 return cctx->attrib.scissorTest;
1192 default:
1193 return glIsEnabled (cap);
1197 static GLenum
1198 xglGetError (void)
1200 GLenum error = cctx->errorValue;
1202 if (error != GL_NO_ERROR)
1204 cctx->errorValue = GL_NO_ERROR;
1205 return error;
1208 return glGetError ();
1211 static const GLubyte *
1212 xglGetString (GLenum name)
1214 switch (name) {
1215 case GL_VERSION:
1216 if (!cctx->versionString)
1218 static char *version = "1.2 (%s)";
1219 char *nativeVersion = (char *) glGetString (GL_VERSION);
1221 cctx->versionString = xalloc (strlen (version) +
1222 strlen (nativeVersion));
1223 if (cctx->versionString)
1224 sprintf (cctx->versionString, version, nativeVersion);
1226 return (GLubyte *) cctx->versionString;
1227 default:
1228 return glGetString (name);
1232 static void
1233 xglGenTextures (GLsizei n,
1234 GLuint *textures)
1236 xglTexObjPtr pTexObj;
1237 GLuint name;
1239 name = xglHashFindFreeKeyBlock (cctx->shared->texObjects, n);
1241 glGenTextures (n, textures);
1243 while (n--)
1245 pTexObj = xalloc (sizeof (xglTexObjRec));
1246 if (pTexObj)
1248 pTexObj->key = name;
1249 pTexObj->name = *textures;
1250 pTexObj->pPixmap = NULL;
1251 pTexObj->object = NULL;
1252 pTexObj->refcnt = 1;
1254 xglHashInsert (cctx->shared->texObjects, name, pTexObj);
1256 else
1258 xglRecordError (GL_OUT_OF_MEMORY);
1261 *textures++ = name++;
1265 static void
1266 xglBindTextureProc (xglGLOpPtr pOp)
1268 xglTexObjPtr *ppTexObj;
1270 switch (pOp->u.bind_texture.target) {
1271 case GL_TEXTURE_1D:
1272 ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].p1D;
1273 break;
1274 case GL_TEXTURE_2D:
1275 ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
1276 break;
1277 case GL_TEXTURE_3D:
1278 ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].p3D;
1279 break;
1280 case GL_TEXTURE_RECTANGLE_NV:
1281 ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
1282 break;
1283 case GL_TEXTURE_CUBE_MAP_ARB:
1284 ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].pCubeMap;
1285 break;
1286 default:
1287 xglRecordError (GL_INVALID_ENUM);
1288 return;
1291 if (pOp->u.bind_texture.texture)
1293 if (!*ppTexObj || pOp->u.bind_texture.texture != (*ppTexObj)->key)
1295 xglTexObjPtr pTexObj;
1297 pTexObj = (xglTexObjPtr)
1298 xglHashLookup (cctx->shared->texObjects,
1299 pOp->u.bind_texture.texture);
1300 if (!pTexObj)
1302 pTexObj = xalloc (sizeof (xglTexObjRec));
1303 if (!pTexObj)
1305 xglRecordError (GL_OUT_OF_MEMORY);
1306 return;
1309 pTexObj->key = pOp->u.bind_texture.texture;
1310 pTexObj->pPixmap = NULL;
1311 pTexObj->object = NULL;
1312 pTexObj->refcnt = 1;
1314 glGenTextures (1, &pTexObj->name);
1316 xglHashInsert (cctx->shared->texObjects,
1317 pOp->u.bind_texture.texture,
1318 pTexObj);
1321 xglRefTexObj (pTexObj);
1322 xglUnrefTexObj (*ppTexObj);
1323 *ppTexObj = pTexObj;
1325 glBindTexture (pOp->u.bind_texture.target, pTexObj->name);
1328 else
1330 xglUnrefTexObj (*ppTexObj);
1331 *ppTexObj = NULL;
1333 glBindTexture (pOp->u.bind_texture.target, 0);
1337 static void
1338 xglBindTexture (GLenum target,
1339 GLuint texture)
1341 xglGLOpRec gl;
1343 gl.glProc = xglBindTextureProc;
1345 gl.u.bind_texture.target = target;
1346 gl.u.bind_texture.texture = texture;
1348 xglGLOp (&gl);
1351 static void
1352 xglSetupTextures (void)
1354 xglGLContextPtr pContext = cctx;
1355 xglTexUnitPtr pTexUnit;
1356 xglTexObjPtr pTexObj[XGL_MAX_TEXTURE_UNITS];
1357 int i, activeTexUnit;
1359 for (i = 0; i < pContext->maxTexUnits; i++)
1361 pTexObj[i] = NULL;
1363 pTexUnit = &pContext->attrib.texUnits[i];
1364 if (pTexUnit->enabled)
1366 if (pTexUnit->enabled & XGL_TEXTURE_RECTANGLE_BIT)
1367 pTexObj[i] = pTexUnit->pRect;
1368 else if (pTexUnit->enabled & XGL_TEXTURE_2D_BIT)
1369 pTexObj[i] = pTexUnit->p2D;
1371 if (pTexObj[i] && pTexObj[i]->pPixmap)
1373 if (!xglSyncSurface (&pTexObj[i]->pPixmap->drawable))
1374 pTexObj[i] = NULL;
1376 else
1377 pTexObj[i] = NULL;
1381 if (pContext != cctx)
1383 XGL_SCREEN_PRIV (pContext->pDrawBuffer->pGC->pScreen);
1385 glitz_drawable_finish (pScreenPriv->drawable);
1387 xglSetCurrentContext (pContext);
1390 activeTexUnit = cctx->activeTexUnit;
1391 for (i = 0; i < pContext->maxTexUnits; i++)
1393 if (pTexObj[i])
1395 if (i != activeTexUnit)
1397 cctx->ActiveTextureARB (GL_TEXTURE0_ARB + i);
1398 activeTexUnit = i;
1400 glitz_context_bind_texture (cctx->context, pTexObj[i]->object);
1404 if (activeTexUnit != cctx->activeTexUnit)
1405 cctx->ActiveTextureARB (cctx->activeTexUnit);
1408 static GLboolean
1409 xglAreTexturesResident (GLsizei n,
1410 const GLuint *textures,
1411 GLboolean *residences)
1413 GLboolean allResident = GL_TRUE;
1414 int i, j;
1416 if (n < 0)
1418 xglRecordError (GL_INVALID_VALUE);
1419 return GL_FALSE;
1422 if (!textures || !residences)
1423 return GL_FALSE;
1425 for (i = 0; i < n; i++)
1427 xglTexObjPtr pTexObj;
1428 GLboolean resident;
1430 if (!textures[i])
1432 xglRecordError (GL_INVALID_VALUE);
1433 return GL_FALSE;
1436 pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects,
1437 textures[i]);
1438 if (!pTexObj)
1440 xglRecordError (GL_INVALID_VALUE);
1441 return GL_FALSE;
1444 if (pTexObj->name == 0 ||
1445 glAreTexturesResident (1, &pTexObj->name, &resident))
1447 if (!allResident)
1448 residences[i] = GL_TRUE;
1450 else
1452 if (allResident)
1454 allResident = GL_FALSE;
1456 for (j = 0; j < i; j++)
1457 residences[j] = GL_TRUE;
1459 residences[i] = GL_FALSE;
1463 return allResident;
1466 static void
1467 xglDeleteTextures (GLsizei n,
1468 const GLuint *textures)
1470 xglTexObjPtr pTexObj;
1472 while (n--)
1474 if (!*textures)
1475 continue;
1477 pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects,
1478 *textures);
1479 if (pTexObj)
1481 xglDeleteTexObj (pTexObj);
1482 xglUnrefTexObj (pTexObj);
1483 xglHashRemove (cctx->shared->texObjects, *textures);
1485 textures++;
1489 static GLboolean
1490 xglIsTexture (GLuint texture)
1492 xglTexObjPtr pTexObj;
1494 if (!texture)
1495 return GL_FALSE;
1497 pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects, texture);
1498 if (pTexObj)
1499 return GL_TRUE;
1501 return GL_FALSE;
1504 static void
1505 xglPrioritizeTextures (GLsizei n,
1506 const GLuint *textures,
1507 const GLclampf *priorities)
1509 xglTexObjPtr pTexObj;
1510 int i;
1512 if (n < 0)
1514 xglRecordError (GL_INVALID_VALUE);
1515 return;
1518 if (!priorities)
1519 return;
1521 for (i = 0; i < n; i++)
1523 if (!textures[i])
1524 continue;
1526 pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects,
1527 textures[i]);
1528 if (pTexObj && pTexObj->name)
1529 glPrioritizeTextures (1, &pTexObj->name, &priorities[i]);
1533 static glitz_texture_filter_t
1534 xglTextureFilter (GLenum param)
1536 switch (param) {
1537 case GL_LINEAR:
1538 return GLITZ_TEXTURE_FILTER_LINEAR;
1539 case GL_NEAREST:
1540 default:
1541 return GLITZ_TEXTURE_FILTER_NEAREST;
1545 static glitz_texture_wrap_t
1546 xglTextureWrap (GLenum param)
1548 switch (param) {
1549 case GL_CLAMP_TO_EDGE:
1550 return GLITZ_TEXTURE_WRAP_CLAMP_TO_EDGE;
1551 case GL_CLAMP_TO_BORDER:
1552 return GLITZ_TEXTURE_WRAP_CLAMP_TO_BORDER;
1553 case GL_REPEAT:
1554 return GLITZ_TEXTURE_WRAP_REPEAT;
1555 case GL_MIRRORED_REPEAT:
1556 return GLITZ_TEXTURE_WRAP_MIRRORED_REPEAT;
1557 case GL_CLAMP:
1558 default:
1559 return GLITZ_TEXTURE_WRAP_CLAMP;
1563 static void
1564 xglTexParameterfvProc (xglGLOpPtr pOp)
1566 xglTexObjPtr pTexObj;
1568 glTexParameterfv (pOp->u.tex_parameter_fv.target,
1569 pOp->u.tex_parameter_fv.pname,
1570 pOp->u.tex_parameter_fv.params);
1572 switch (pOp->u.tex_parameter_fv.target) {
1573 case GL_TEXTURE_2D:
1574 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
1575 break;
1576 case GL_TEXTURE_RECTANGLE_NV:
1577 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
1578 break;
1579 default:
1580 pTexObj = NULL;
1581 break;
1584 if (pTexObj && pTexObj->pPixmap)
1586 GLfloat *params = pOp->u.tex_parameter_fv.params;
1588 switch (pOp->u.tex_parameter_fv.pname) {
1589 case GL_TEXTURE_MIN_FILTER:
1590 glitz_texture_object_set_filter (pTexObj->object,
1591 GLITZ_TEXTURE_FILTER_TYPE_MIN,
1592 xglTextureFilter (params[0]));
1593 break;
1594 case GL_TEXTURE_MAG_FILTER:
1595 glitz_texture_object_set_filter (pTexObj->object,
1596 GLITZ_TEXTURE_FILTER_TYPE_MAG,
1597 xglTextureFilter (params[0]));
1598 break;
1599 case GL_TEXTURE_WRAP_S:
1600 glitz_texture_object_set_wrap (pTexObj->object,
1601 GLITZ_TEXTURE_WRAP_TYPE_S,
1602 xglTextureWrap (params[0]));
1603 break;
1604 case GL_TEXTURE_WRAP_T:
1605 glitz_texture_object_set_wrap (pTexObj->object,
1606 GLITZ_TEXTURE_WRAP_TYPE_T,
1607 xglTextureWrap (params[0]));
1608 break;
1609 case GL_TEXTURE_BORDER_COLOR: {
1610 glitz_color_t color;
1612 color.red = params[0] * 0xffff;
1613 color.green = params[1] * 0xffff;
1614 color.blue = params[2] * 0xffff;
1615 color.alpha = params[3] * 0xffff;
1617 glitz_texture_object_set_border_color (pTexObj->object, &color);
1619 default:
1620 break;
1625 static void
1626 xglTexParameterfv (GLenum target,
1627 GLenum pname,
1628 const GLfloat *params)
1630 xglGLOpRec gl;
1632 gl.glProc = xglTexParameterfvProc;
1634 gl.u.tex_parameter_fv.target = target;
1635 gl.u.tex_parameter_fv.pname = pname;
1637 switch (pname) {
1638 case GL_TEXTURE_BORDER_COLOR:
1639 gl.u.tex_parameter_fv.params[3] = params[3];
1640 gl.u.tex_parameter_fv.params[2] = params[2];
1641 gl.u.tex_parameter_fv.params[1] = params[1];
1642 /* fall-through */
1643 default:
1644 gl.u.tex_parameter_fv.params[0] = params[0];
1645 break;
1648 xglGLOp (&gl);
1651 static void
1652 xglTexParameteriv (GLenum target,
1653 GLenum pname,
1654 const GLint *params)
1656 xglGLOpRec gl;
1658 gl.glProc = xglTexParameterfvProc;
1660 gl.u.tex_parameter_fv.target = target;
1661 gl.u.tex_parameter_fv.pname = pname;
1663 switch (pname) {
1664 case GL_TEXTURE_BORDER_COLOR:
1665 gl.u.tex_parameter_fv.params[3] = (GLfloat) params[3] / INT_MAX;
1666 gl.u.tex_parameter_fv.params[2] = (GLfloat) params[2] / INT_MAX;
1667 gl.u.tex_parameter_fv.params[1] = (GLfloat) params[1] / INT_MAX;
1668 gl.u.tex_parameter_fv.params[0] = (GLfloat) params[0] / INT_MAX;
1669 break;
1670 default:
1671 gl.u.tex_parameter_fv.params[0] = params[0];
1672 break;
1675 xglGLOp (&gl);
1678 static void
1679 xglTexParameterf (GLenum target,
1680 GLenum pname,
1681 GLfloat param)
1683 xglTexParameterfv (target, pname, (const GLfloat *) &param);
1686 static void
1687 xglTexParameteri (GLenum target,
1688 GLenum pname,
1689 GLint param)
1691 xglTexParameteriv (target, pname, (const GLint *) &param);
1694 static void
1695 xglGetTexLevelParameterfv (GLenum target,
1696 GLint level,
1697 GLenum pname,
1698 GLfloat *params)
1700 xglTexObjPtr pTexObj;
1702 switch (target) {
1703 case GL_TEXTURE_2D:
1704 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
1705 break;
1706 case GL_TEXTURE_RECTANGLE_NV:
1707 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
1708 break;
1709 default:
1710 pTexObj = NULL;
1711 break;
1714 if (pTexObj && pTexObj->pPixmap)
1716 glitz_context_bind_texture (cctx->context, pTexObj->object);
1718 glGetTexLevelParameterfv (target, level, pname, params);
1719 glBindTexture (target, pTexObj->name);
1721 else
1722 glGetTexLevelParameterfv (target, level, pname, params);
1725 static void
1726 xglGetTexLevelParameteriv (GLenum target,
1727 GLint level,
1728 GLenum pname,
1729 GLint *params)
1731 xglTexObjPtr pTexObj;
1733 switch (target) {
1734 case GL_TEXTURE_2D:
1735 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
1736 break;
1737 case GL_TEXTURE_RECTANGLE_NV:
1738 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
1739 break;
1740 default:
1741 pTexObj = NULL;
1742 break;
1745 if (pTexObj && pTexObj->pPixmap)
1747 glitz_context_bind_texture (cctx->context, pTexObj->object);
1749 glGetTexLevelParameteriv (target, level, pname, params);
1750 glBindTexture (target, pTexObj->name);
1752 else
1753 glGetTexLevelParameteriv (target, level, pname, params);
1756 static GLuint
1757 xglGenLists (GLsizei range)
1759 xglDisplayListPtr pDisplayList;
1760 GLuint first, name;
1762 first = xglHashFindFreeKeyBlock (cctx->shared->displayLists, range);
1764 name = first;
1765 for (name = first; range--; name++)
1767 pDisplayList = xglCreateList ();
1768 if (pDisplayList)
1770 xglHashInsert (cctx->shared->displayLists, name, pDisplayList);
1772 else
1774 xglRecordError (GL_OUT_OF_MEMORY);
1778 return first;
1781 static void
1782 xglNewList (GLuint list,
1783 GLenum mode)
1785 if (!list)
1787 xglRecordError (GL_INVALID_VALUE);
1788 return;
1791 if (cctx->list)
1793 xglRecordError (GL_INVALID_OPERATION);
1794 return;
1797 cctx->pList = xglCreateList ();
1798 if (!cctx->pList)
1800 xglRecordError (GL_OUT_OF_MEMORY);
1801 return;
1804 cctx->list = list;
1805 cctx->listMode = mode;
1807 xglStartList (XGL_LIST_OP_CALLS, mode);
1810 static void
1811 xglEndList (void)
1813 xglDisplayListPtr pDisplayList;
1815 if (!cctx->list)
1817 xglRecordError (GL_INVALID_OPERATION);
1818 return;
1821 glEndList ();
1823 pDisplayList = (xglDisplayListPtr)
1824 xglHashLookup (cctx->shared->displayLists, cctx->list);
1825 if (pDisplayList)
1827 xglHashRemove (cctx->shared->displayLists, cctx->list);
1828 xglDestroyList (pDisplayList);
1831 xglHashInsert (cctx->shared->displayLists, cctx->list, cctx->pList);
1833 cctx->list = 0;
1836 static void
1837 xglDrawList (GLuint list)
1839 RegionRec region;
1840 BoxRec scissor, box;
1841 BoxPtr pBox;
1842 int nBox;
1844 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
1846 while (nBox--)
1848 XGL_GLX_DRAW_BOX (&box, pBox);
1850 pBox++;
1852 if (cctx->attrib.scissorTest)
1853 XGL_GLX_INTERSECT_BOX (&box, &scissor);
1855 if (box.x1 < box.x2 && box.y1 < box.y2)
1857 XGL_GLX_SET_SCISSOR_BOX (&box);
1859 glCallList (list);
1861 XGL_GLX_DRAW_DAMAGE (&box, &region);
1866 static void
1867 xglCallDisplayList (GLuint list,
1868 int nesting)
1870 if (nesting > cctx->maxListNesting)
1871 return;
1873 if (!list)
1875 xglRecordError (GL_INVALID_VALUE);
1876 return;
1879 if (cctx->list)
1881 if (!xglResizeList (cctx->pList, cctx->pList->nOp + 1))
1883 xglRecordError (GL_OUT_OF_MEMORY);
1884 return;
1887 cctx->pList->pOp[cctx->pList->nOp].type = XGL_LIST_OP_LIST;
1888 cctx->pList->pOp[cctx->pList->nOp].u.list = list;
1889 cctx->pList->nOp++;
1891 else
1893 xglDisplayListPtr pDisplayList;
1895 pDisplayList = (xglDisplayListPtr)
1896 xglHashLookup (cctx->shared->displayLists, list);
1897 if (pDisplayList)
1899 xglListOpPtr pOp = pDisplayList->pOp;
1900 int nOp = pDisplayList->nOp;
1902 while (nOp--)
1904 switch (pOp->type) {
1905 case XGL_LIST_OP_CALLS:
1906 glCallList (pOp->u.list);
1907 break;
1908 case XGL_LIST_OP_DRAW:
1909 xglDrawList (pOp->u.list);
1910 break;
1911 case XGL_LIST_OP_GL:
1912 (*pOp->u.gl->glProc) (pOp->u.gl);
1913 break;
1914 case XGL_LIST_OP_LIST:
1915 xglCallDisplayList (pOp->u.list, nesting + 1);
1916 break;
1919 pOp++;
1925 static void
1926 xglCallList (GLuint list)
1928 xglCallDisplayList (list, 1);
1931 static void
1932 xglCallLists (GLsizei n,
1933 GLenum type,
1934 const GLvoid *lists)
1936 GLuint list;
1937 GLint base, i;
1939 glGetIntegerv (GL_LIST_BASE, &base);
1941 for (i = 0; i < n; i++)
1943 switch (type) {
1944 case GL_BYTE:
1945 list = (GLuint) *(((GLbyte *) lists) + n);
1946 break;
1947 case GL_UNSIGNED_BYTE:
1948 list = (GLuint) *(((GLubyte *) lists) + n);
1949 break;
1950 case GL_SHORT:
1951 list = (GLuint) *(((GLshort *) lists) + n);
1952 break;
1953 case GL_UNSIGNED_SHORT:
1954 list = (GLuint) *(((GLushort *) lists) + n);
1955 break;
1956 case GL_INT:
1957 list = (GLuint) *(((GLint *) lists) + n);
1958 break;
1959 case GL_UNSIGNED_INT:
1960 list = (GLuint) *(((GLuint *) lists) + n);
1961 break;
1962 case GL_FLOAT:
1963 list = (GLuint) *(((GLfloat *) lists) + n);
1964 break;
1965 case GL_2_BYTES:
1967 GLubyte *ubptr = ((GLubyte *) lists) + 2 * n;
1968 list = (GLuint) *ubptr * 256 + (GLuint) *(ubptr + 1);
1969 } break;
1970 case GL_3_BYTES:
1972 GLubyte *ubptr = ((GLubyte *) lists) + 3 * n;
1973 list = (GLuint) * ubptr * 65536
1974 + (GLuint) * (ubptr + 1) * 256
1975 + (GLuint) * (ubptr + 2);
1976 } break;
1977 case GL_4_BYTES:
1979 GLubyte *ubptr = ((GLubyte *) lists) + 4 * n;
1980 list = (GLuint) * ubptr * 16777216
1981 + (GLuint) * (ubptr + 1) * 65536
1982 + (GLuint) * (ubptr + 2) * 256
1983 + (GLuint) * (ubptr + 3);
1984 } break;
1985 default:
1986 xglRecordError (GL_INVALID_ENUM);
1987 return;
1990 xglCallDisplayList (base + list, 1);
1994 static void
1995 xglDeleteLists (GLuint list,
1996 GLsizei range)
1998 xglDisplayListPtr pDisplayList;
1999 GLint i;
2001 if (range < 0)
2003 xglRecordError (GL_INVALID_VALUE);
2004 return;
2007 for (i = list; i < list + range; i++)
2009 if (!i)
2010 continue;
2012 pDisplayList = (xglDisplayListPtr)
2013 xglHashLookup (cctx->shared->displayLists, i);
2014 if (pDisplayList)
2016 xglHashRemove (cctx->shared->displayLists, i);
2017 xglDestroyList (pDisplayList);
2022 static GLboolean
2023 xglIsList (GLuint list)
2025 xglDisplayListPtr pDisplayList;
2027 if (!list)
2028 return GL_FALSE;
2030 pDisplayList = (xglDisplayListPtr)
2031 xglHashLookup (cctx->shared->displayLists, list);
2032 if (pDisplayList)
2033 return GL_TRUE;
2035 return GL_FALSE;
2038 static void
2039 xglFlush (void)
2041 glFlush ();
2043 if (cctx && cctx->pDrawBuffer->pDrawable)
2045 xglGLBufferPtr pBuffer = cctx->pDrawBuffer;
2047 if (REGION_NOTEMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage))
2049 XGL_DRAWABLE_PIXMAP_PRIV (pBuffer->pDrawable);
2051 DamageDamageRegion (pBuffer->pDrawable, &pBuffer->damage);
2052 REGION_EMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage);
2054 pPixmapPriv->damageBox = miEmptyBox;
2059 static void
2060 xglFinish (void)
2062 glFinish ();
2064 if (cctx && cctx->pDrawBuffer->pDrawable)
2066 xglGLBufferPtr pBuffer = cctx->pDrawBuffer;
2068 if (REGION_NOTEMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage))
2070 XGL_DRAWABLE_PIXMAP_PRIV (pBuffer->pDrawable);
2072 DamageDamageRegion (pBuffer->pDrawable, &pBuffer->damage);
2073 REGION_EMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage);
2075 pPixmapPriv->damageBox = miEmptyBox;
2080 static void
2081 xglClear (GLbitfield mask)
2083 GLenum mode;
2085 if (cctx->list)
2087 glEndList ();
2088 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2089 glClear (mask);
2090 glEndList ();
2092 mode = cctx->listMode;
2094 else
2095 mode = GL_COMPILE_AND_EXECUTE;
2097 if (mode == GL_COMPILE_AND_EXECUTE)
2099 RegionRec region;
2100 BoxRec scissor, box;
2101 BoxPtr pBox;
2102 int nBox;
2104 XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor);
2106 while (nBox--)
2108 XGL_GLX_DRAW_BOX (&box, pBox);
2110 pBox++;
2112 if (cctx->attrib.scissorTest)
2113 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2115 if (box.x1 < box.x2 && box.y1 < box.y2)
2117 XGL_GLX_SET_SCISSOR_BOX (&box);
2119 glClear (mask);
2121 if (mask & GL_COLOR_BUFFER_BIT)
2122 XGL_GLX_DRAW_DAMAGE (&box, &region);
2127 if (cctx->list)
2128 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2131 static void
2132 xglAccum (GLenum op,
2133 GLfloat value)
2135 if (op == GL_RETURN)
2137 GLenum listMode;
2139 if (cctx->list)
2141 glEndList ();
2142 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2143 glAccum (GL_RETURN, value);
2144 glEndList ();
2146 listMode = cctx->listMode;
2148 else
2149 listMode = GL_COMPILE_AND_EXECUTE;
2151 if (listMode == GL_COMPILE_AND_EXECUTE)
2153 RegionRec region;
2154 BoxRec scissor, box;
2155 BoxPtr pBox;
2156 int nBox;
2158 XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor);
2160 while (nBox--)
2162 XGL_GLX_DRAW_BOX (&box, pBox);
2164 pBox++;
2166 if (cctx->attrib.scissorTest)
2167 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2169 if (box.x1 < box.x2 && box.y1 < box.y2)
2171 XGL_GLX_SET_SCISSOR_BOX (&box);
2173 glAccum (GL_RETURN, value);
2175 XGL_GLX_DRAW_DAMAGE (&box, &region);
2180 if (cctx->list)
2181 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2183 else
2184 glAccum (op, value);
2187 static void
2188 xglDrawArrays (GLenum mode,
2189 GLint first,
2190 GLsizei count)
2192 GLenum listMode;
2194 if (cctx->list)
2196 glEndList ();
2197 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2198 glDrawArrays (mode, first, count);
2199 glEndList ();
2201 listMode = cctx->listMode;
2203 else
2204 listMode = GL_COMPILE_AND_EXECUTE;
2206 if (listMode == GL_COMPILE_AND_EXECUTE)
2208 RegionRec region;
2209 BoxRec scissor, box;
2210 BoxPtr pBox;
2211 int nBox;
2213 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2215 while (nBox--)
2217 XGL_GLX_DRAW_BOX (&box, pBox);
2219 pBox++;
2221 if (cctx->attrib.scissorTest)
2222 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2224 if (box.x1 < box.x2 && box.y1 < box.y2)
2226 XGL_GLX_SET_SCISSOR_BOX (&box);
2228 glDrawArrays (mode, first, count);
2230 XGL_GLX_DRAW_DAMAGE (&box, &region);
2235 if (cctx->list)
2236 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2239 static void
2240 xglDrawElements (GLenum mode,
2241 GLsizei count,
2242 GLenum type,
2243 const GLvoid *indices)
2245 GLenum listMode;
2247 if (cctx->list)
2249 glEndList ();
2250 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2251 glDrawElements (mode, count, type, indices);
2252 glEndList ();
2254 listMode = cctx->listMode;
2256 else
2257 listMode = GL_COMPILE_AND_EXECUTE;
2259 if (listMode == GL_COMPILE_AND_EXECUTE)
2261 RegionRec region;
2262 BoxRec scissor, box;
2263 BoxPtr pBox;
2264 int nBox;
2266 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2268 while (nBox--)
2270 XGL_GLX_DRAW_BOX (&box, pBox);
2272 pBox++;
2274 if (cctx->attrib.scissorTest)
2275 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2277 if (box.x1 < box.x2 && box.y1 < box.y2)
2279 XGL_GLX_SET_SCISSOR_BOX (&box);
2281 glDrawElements (mode, count, type, indices);
2283 XGL_GLX_DRAW_DAMAGE (&box, &region);
2288 if (cctx->list)
2289 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2292 static void
2293 xglDrawPixels (GLsizei width,
2294 GLsizei height,
2295 GLenum format,
2296 GLenum type,
2297 const GLvoid *pixels)
2299 GLenum listMode;
2301 if (cctx->list)
2303 glEndList ();
2304 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2305 glDrawPixels (width, height, format, type, pixels);
2306 glEndList ();
2308 listMode = cctx->listMode;
2310 else
2311 listMode = GL_COMPILE_AND_EXECUTE;
2313 if (listMode == GL_COMPILE_AND_EXECUTE)
2315 RegionRec region;
2316 BoxRec scissor, box;
2317 BoxPtr pBox;
2318 int nBox;
2320 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2322 while (nBox--)
2324 XGL_GLX_DRAW_BOX (&box, pBox);
2326 pBox++;
2328 if (cctx->attrib.scissorTest)
2329 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2331 if (box.x1 < box.x2 && box.y1 < box.y2)
2333 XGL_GLX_SET_SCISSOR_BOX (&box);
2335 glDrawPixels (width, height, format, type, pixels);
2337 if (format != GL_STENCIL_INDEX)
2338 XGL_GLX_DRAW_DAMAGE (&box, &region);
2343 if (cctx->list)
2344 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2347 static void
2348 xglBitmap (GLsizei width,
2349 GLsizei height,
2350 GLfloat xorig,
2351 GLfloat yorig,
2352 GLfloat xmove,
2353 GLfloat ymove,
2354 const GLubyte *bitmap)
2356 GLenum listMode;
2358 if (cctx->list)
2360 glEndList ();
2361 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2362 glBitmap (width, height, xorig, yorig, 0, 0, bitmap);
2363 glEndList ();
2365 listMode = cctx->listMode;
2367 else
2368 listMode = GL_COMPILE_AND_EXECUTE;
2370 if (listMode == GL_COMPILE_AND_EXECUTE && width && height)
2372 RegionRec region;
2373 BoxRec scissor, box;
2374 BoxPtr pBox;
2375 int nBox;
2377 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2379 while (nBox--)
2381 XGL_GLX_DRAW_BOX (&box, pBox);
2383 pBox++;
2385 if (cctx->attrib.scissorTest)
2386 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2388 if (box.x1 < box.x2 && box.y1 < box.y2)
2390 XGL_GLX_SET_SCISSOR_BOX (&box);
2392 glBitmap (width, height, xorig, yorig, 0, 0, bitmap);
2394 XGL_GLX_DRAW_DAMAGE (&box, &region);
2399 if (cctx->list)
2400 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2402 glBitmap (0, 0, 0, 0, xmove, ymove, NULL);
2405 static void
2406 xglRectdv (const GLdouble *v1,
2407 const GLdouble *v2)
2409 GLenum listMode;
2411 if (cctx->list)
2413 glEndList ();
2414 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2415 glRectdv (v1, v2);
2416 glEndList ();
2418 listMode = cctx->listMode;
2420 else
2421 listMode = GL_COMPILE_AND_EXECUTE;
2423 if (listMode == GL_COMPILE_AND_EXECUTE)
2425 RegionRec region;
2426 BoxRec scissor, box;
2427 BoxPtr pBox;
2428 int nBox;
2430 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2432 while (nBox--)
2434 XGL_GLX_DRAW_BOX (&box, pBox);
2436 pBox++;
2438 if (cctx->attrib.scissorTest)
2439 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2441 if (box.x1 < box.x2 && box.y1 < box.y2)
2443 XGL_GLX_SET_SCISSOR_BOX (&box);
2445 glRectdv (v1, v2);
2447 XGL_GLX_DRAW_DAMAGE (&box, &region);
2452 if (cctx->list)
2453 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2456 static void
2457 xglRectfv (const GLfloat *v1,
2458 const GLfloat *v2)
2460 GLdouble dv1[2];
2461 GLdouble dv2[2];
2463 dv1[0] = (GLdouble) v1[0];
2464 dv1[1] = (GLdouble) v1[1];
2465 dv2[0] = (GLdouble) v2[0];
2466 dv2[1] = (GLdouble) v2[1];
2468 xglRectdv (dv1, dv2);
2471 static void
2472 xglRectiv (const GLint *v1,
2473 const GLint *v2)
2475 GLdouble dv1[2];
2476 GLdouble dv2[2];
2478 dv1[0] = (GLdouble) v1[0];
2479 dv1[1] = (GLdouble) v1[1];
2480 dv2[0] = (GLdouble) v2[0];
2481 dv2[1] = (GLdouble) v2[1];
2483 xglRectdv (dv1, dv2);
2486 static void
2487 xglRectsv (const GLshort *v1,
2488 const GLshort *v2)
2490 GLdouble dv1[2];
2491 GLdouble dv2[2];
2493 dv1[0] = (GLdouble) v1[0];
2494 dv1[1] = (GLdouble) v1[1];
2495 dv2[0] = (GLdouble) v2[0];
2496 dv2[1] = (GLdouble) v2[1];
2498 xglRectdv (dv1, dv2);
2501 static void
2502 xglBegin (GLenum mode)
2504 if (mode > GL_POLYGON)
2506 xglRecordError (GL_INVALID_ENUM);
2507 return;
2510 if (cctx->beginCnt)
2512 xglRecordError (GL_INVALID_OPERATION);
2513 return;
2516 cctx->beginCnt++;
2518 if (cctx->list)
2520 glEndList ();
2521 xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE);
2523 else
2525 if (REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip) == 1)
2527 BoxRec scissor, box;
2528 BoxPtr pBox;
2529 int nBox;
2531 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2533 XGL_GLX_DRAW_BOX (&box, pBox);
2535 if (cctx->attrib.scissorTest)
2536 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2538 XGL_GLX_SET_SCISSOR_BOX (&box);
2540 else
2542 if (!cctx->groupList)
2543 cctx->groupList = glGenLists (1);
2545 glNewList (cctx->groupList, GL_COMPILE);
2549 glBegin (mode);
2552 static void
2553 xglEnd (void)
2555 if (!cctx->beginCnt)
2557 xglRecordError (GL_INVALID_OPERATION);
2558 return;
2561 cctx->beginCnt--;
2563 glEnd ();
2565 if (!cctx->list || cctx->listMode == GL_COMPILE_AND_EXECUTE)
2567 RegionRec region;
2568 BoxRec scissor, box;
2569 BoxPtr pBox;
2570 int nBox;
2571 GLuint list = 0;
2573 if (cctx->list)
2575 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2577 list = cctx->pList->pOp[cctx->pList->nOp - 1].u.list;
2579 else
2581 if (REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip) == 1)
2583 XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor);
2585 else
2587 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2589 list = cctx->groupList;
2593 if (list)
2594 glEndList ();
2596 while (nBox--)
2598 XGL_GLX_DRAW_BOX (&box, pBox);
2600 pBox++;
2602 if (cctx->attrib.scissorTest)
2603 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2605 if (box.x1 < box.x2 && box.y1 < box.y2)
2607 if (list)
2609 XGL_GLX_SET_SCISSOR_BOX (&box);
2611 glCallList (list);
2614 XGL_GLX_DRAW_DAMAGE (&box, &region);
2618 else
2620 glEndList ();
2623 if (cctx->list)
2624 xglStartList (XGL_LIST_OP_CALLS, cctx->listMode);
2627 static void
2628 xglCopyPixelsProc (xglGLOpPtr pOp)
2630 RegionRec region;
2631 BoxRec scissor, box;
2632 BoxPtr pBox;
2633 int nBox;
2635 XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor);
2637 while (nBox--)
2639 XGL_GLX_DRAW_BOX (&box, pBox);
2641 pBox++;
2643 if (cctx->attrib.scissorTest)
2644 XGL_GLX_INTERSECT_BOX (&box, &scissor);
2646 if (box.x1 < box.x2 && box.y1 < box.y2)
2648 XGL_GLX_SET_SCISSOR_BOX (&box);
2650 glCopyPixels (pOp->u.copy_pixels.x + cctx->pReadBuffer->xOff,
2651 pOp->u.copy_pixels.y + cctx->pReadBuffer->yOff,
2652 pOp->u.copy_pixels.width,
2653 pOp->u.copy_pixels.height,
2654 pOp->u.copy_pixels.type);
2656 if (pOp->u.copy_pixels.type == GL_COLOR)
2657 XGL_GLX_DRAW_DAMAGE (&box, &region);
2662 static void
2663 xglCopyPixels (GLint x,
2664 GLint y,
2665 GLsizei width,
2666 GLsizei height,
2667 GLenum type)
2669 xglGLOpRec gl;
2671 gl.glProc = xglCopyPixelsProc;
2673 gl.u.copy_pixels.x = x;
2674 gl.u.copy_pixels.y = y;
2675 gl.u.copy_pixels.width = width;
2676 gl.u.copy_pixels.height = height;
2677 gl.u.copy_pixels.type = type;
2679 xglGLOp (&gl);
2682 static void
2683 xglReadPixels (GLint x,
2684 GLint y,
2685 GLsizei width,
2686 GLsizei height,
2687 GLenum format,
2688 GLenum type,
2689 GLvoid *pixels)
2691 glReadPixels (x + cctx->pReadBuffer->xOff,
2692 y + cctx->pReadBuffer->yOff,
2693 width, height, format, type, pixels);
2696 static void
2697 xglCopyTexImage1DProc (xglGLOpPtr pOp)
2699 glCopyTexImage1D (pOp->u.copy_tex_image_1d.target,
2700 pOp->u.copy_tex_image_1d.level,
2701 pOp->u.copy_tex_image_1d.internalformat,
2702 pOp->u.copy_tex_image_1d.x + cctx->pReadBuffer->xOff,
2703 pOp->u.copy_tex_image_1d.y + cctx->pReadBuffer->yOff,
2704 pOp->u.copy_tex_image_1d.width,
2705 pOp->u.copy_tex_image_1d.border);
2708 static void
2709 xglCopyTexImage1D (GLenum target,
2710 GLint level,
2711 GLenum internalformat,
2712 GLint x,
2713 GLint y,
2714 GLsizei width,
2715 GLint border)
2717 xglGLOpRec gl;
2719 gl.glProc = xglCopyTexImage1DProc;
2721 gl.u.copy_tex_image_1d.target = target;
2722 gl.u.copy_tex_image_1d.level = level;
2723 gl.u.copy_tex_image_1d.internalformat = internalformat;
2724 gl.u.copy_tex_image_1d.x = x;
2725 gl.u.copy_tex_image_1d.y = y;
2726 gl.u.copy_tex_image_1d.width = width;
2727 gl.u.copy_tex_image_1d.border = border;
2729 xglGLOp (&gl);
2732 static void
2733 xglCopyTexImage2DProc (xglGLOpPtr pOp)
2735 glCopyTexImage2D (pOp->u.copy_tex_image_2d.target,
2736 pOp->u.copy_tex_image_2d.level,
2737 pOp->u.copy_tex_image_2d.internalformat,
2738 pOp->u.copy_tex_image_2d.x + cctx->pReadBuffer->xOff,
2739 pOp->u.copy_tex_image_2d.y + cctx->pReadBuffer->yOff,
2740 pOp->u.copy_tex_image_2d.width,
2741 pOp->u.copy_tex_image_2d.height,
2742 pOp->u.copy_tex_image_2d.border);
2745 static void
2746 xglCopyTexImage2D (GLenum target,
2747 GLint level,
2748 GLenum internalformat,
2749 GLint x,
2750 GLint y,
2751 GLsizei width,
2752 GLsizei height,
2753 GLint border)
2755 xglGLOpRec gl;
2757 gl.glProc = xglCopyTexImage2DProc;
2759 gl.u.copy_tex_image_2d.target = target;
2760 gl.u.copy_tex_image_2d.level = level;
2761 gl.u.copy_tex_image_2d.internalformat = internalformat;
2762 gl.u.copy_tex_image_2d.x = x;
2763 gl.u.copy_tex_image_2d.y = y;
2764 gl.u.copy_tex_image_2d.width = width;
2765 gl.u.copy_tex_image_2d.height = height;
2766 gl.u.copy_tex_image_2d.border = border;
2768 xglGLOp (&gl);
2771 static void
2772 xglCopyTexSubImage1DProc (xglGLOpPtr pOp)
2774 glCopyTexSubImage1D (pOp->u.copy_tex_sub_image_1d.target,
2775 pOp->u.copy_tex_sub_image_1d.level,
2776 pOp->u.copy_tex_sub_image_1d.xoffset,
2777 pOp->u.copy_tex_sub_image_1d.x +
2778 cctx->pReadBuffer->xOff,
2779 pOp->u.copy_tex_sub_image_1d.y +
2780 cctx->pReadBuffer->yOff,
2781 pOp->u.copy_tex_sub_image_1d.width);
2784 static void
2785 xglCopyTexSubImage1D (GLenum target,
2786 GLint level,
2787 GLint xoffset,
2788 GLint x,
2789 GLint y,
2790 GLsizei width)
2792 xglGLOpRec gl;
2794 gl.glProc = xglCopyTexSubImage1DProc;
2796 gl.u.copy_tex_sub_image_1d.target = target;
2797 gl.u.copy_tex_sub_image_1d.level = level;
2798 gl.u.copy_tex_sub_image_1d.xoffset = xoffset;
2799 gl.u.copy_tex_sub_image_1d.x = x;
2800 gl.u.copy_tex_sub_image_1d.y = y;
2801 gl.u.copy_tex_sub_image_1d.width = width;
2803 xglGLOp (&gl);
2806 static void
2807 xglCopyTexSubImage2DProc (xglGLOpPtr pOp)
2809 glCopyTexSubImage2D (pOp->u.copy_tex_sub_image_2d.target,
2810 pOp->u.copy_tex_sub_image_2d.level,
2811 pOp->u.copy_tex_sub_image_2d.xoffset,
2812 pOp->u.copy_tex_sub_image_2d.yoffset,
2813 pOp->u.copy_tex_sub_image_2d.x +
2814 cctx->pReadBuffer->xOff,
2815 pOp->u.copy_tex_sub_image_2d.y +
2816 cctx->pReadBuffer->yOff,
2817 pOp->u.copy_tex_sub_image_2d.width,
2818 pOp->u.copy_tex_sub_image_2d.height);
2821 static void
2822 xglCopyTexSubImage2D (GLenum target,
2823 GLint level,
2824 GLint xoffset,
2825 GLint yoffset,
2826 GLint x,
2827 GLint y,
2828 GLsizei width,
2829 GLsizei height)
2831 xglGLOpRec gl;
2833 gl.glProc = xglCopyTexSubImage2DProc;
2835 gl.u.copy_tex_sub_image_2d.target = target;
2836 gl.u.copy_tex_sub_image_2d.level = level;
2837 gl.u.copy_tex_sub_image_2d.xoffset = xoffset;
2838 gl.u.copy_tex_sub_image_2d.yoffset = yoffset;
2839 gl.u.copy_tex_sub_image_2d.x = x;
2840 gl.u.copy_tex_sub_image_2d.y = y;
2841 gl.u.copy_tex_sub_image_2d.width = width;
2842 gl.u.copy_tex_sub_image_2d.height = height;
2844 xglGLOp (&gl);
2847 static void
2848 xglCopyColorTableProc (xglGLOpPtr pOp)
2850 glCopyColorTable (pOp->u.copy_color_table.target,
2851 pOp->u.copy_color_table.internalformat,
2852 pOp->u.copy_color_table.x + cctx->pReadBuffer->xOff,
2853 pOp->u.copy_color_table.y + cctx->pReadBuffer->yOff,
2854 pOp->u.copy_color_table.width);
2857 static void
2858 xglCopyColorTable (GLenum target,
2859 GLenum internalformat,
2860 GLint x,
2861 GLint y,
2862 GLsizei width)
2864 xglGLOpRec gl;
2866 gl.glProc = xglCopyColorTableProc;
2868 gl.u.copy_color_table.target = target;
2869 gl.u.copy_color_table.internalformat = internalformat;
2870 gl.u.copy_color_table.x = x;
2871 gl.u.copy_color_table.y = y;
2872 gl.u.copy_color_table.width = width;
2874 xglGLOp (&gl);
2877 static void
2878 xglCopyColorSubTableProc (xglGLOpPtr pOp)
2880 glCopyColorTable (pOp->u.copy_color_sub_table.target,
2881 pOp->u.copy_color_sub_table.start,
2882 pOp->u.copy_color_sub_table.x + cctx->pReadBuffer->xOff,
2883 pOp->u.copy_color_sub_table.y + cctx->pReadBuffer->yOff,
2884 pOp->u.copy_color_sub_table.width);
2887 static void
2888 xglCopyColorSubTable (GLenum target,
2889 GLsizei start,
2890 GLint x,
2891 GLint y,
2892 GLsizei width)
2894 xglGLOpRec gl;
2896 gl.glProc = xglCopyColorSubTableProc;
2898 gl.u.copy_color_sub_table.target = target;
2899 gl.u.copy_color_sub_table.start = start;
2900 gl.u.copy_color_sub_table.x = x;
2901 gl.u.copy_color_sub_table.y = y;
2902 gl.u.copy_color_sub_table.width = width;
2904 xglGLOp (&gl);
2907 static void
2908 xglCopyConvolutionFilter1DProc (xglGLOpPtr pOp)
2910 GLenum internalformat = pOp->u.copy_convolution_filter_1d.internalformat;
2912 glCopyConvolutionFilter1D (pOp->u.copy_convolution_filter_1d.target,
2913 internalformat,
2914 pOp->u.copy_convolution_filter_1d.x +
2915 cctx->pReadBuffer->xOff,
2916 pOp->u.copy_convolution_filter_1d.y +
2917 cctx->pReadBuffer->yOff,
2918 pOp->u.copy_convolution_filter_1d.width);
2921 static void
2922 xglCopyConvolutionFilter1D (GLenum target,
2923 GLenum internalformat,
2924 GLint x,
2925 GLint y,
2926 GLsizei width)
2928 xglGLOpRec gl;
2930 gl.glProc = xglCopyConvolutionFilter1DProc;
2932 gl.u.copy_convolution_filter_1d.target = target;
2933 gl.u.copy_convolution_filter_1d.internalformat = internalformat;
2934 gl.u.copy_convolution_filter_1d.x = x;
2935 gl.u.copy_convolution_filter_1d.y = y;
2936 gl.u.copy_convolution_filter_1d.width = width;
2938 xglGLOp (&gl);
2941 static void
2942 xglCopyConvolutionFilter2DProc (xglGLOpPtr pOp)
2944 GLenum internalformat = pOp->u.copy_convolution_filter_2d.internalformat;
2946 glCopyConvolutionFilter2D (pOp->u.copy_convolution_filter_2d.target,
2947 internalformat,
2948 pOp->u.copy_convolution_filter_2d.x +
2949 cctx->pReadBuffer->xOff,
2950 pOp->u.copy_convolution_filter_2d.y +
2951 cctx->pReadBuffer->yOff,
2952 pOp->u.copy_convolution_filter_2d.width,
2953 pOp->u.copy_convolution_filter_2d.height);
2956 static void
2957 xglCopyConvolutionFilter2D (GLenum target,
2958 GLenum internalformat,
2959 GLint x,
2960 GLint y,
2961 GLsizei width,
2962 GLsizei height)
2964 xglGLOpRec gl;
2966 gl.glProc = xglCopyConvolutionFilter2DProc;
2968 gl.u.copy_convolution_filter_2d.target = target;
2969 gl.u.copy_convolution_filter_2d.internalformat = internalformat;
2970 gl.u.copy_convolution_filter_2d.x = x;
2971 gl.u.copy_convolution_filter_2d.y = y;
2972 gl.u.copy_convolution_filter_2d.width = width;
2973 gl.u.copy_convolution_filter_2d.height = height;
2975 xglGLOp (&gl);
2978 static void
2979 xglCopyTexSubImage3DProc (xglGLOpPtr pOp)
2981 glCopyTexSubImage3D (pOp->u.copy_tex_sub_image_3d.target,
2982 pOp->u.copy_tex_sub_image_3d.level,
2983 pOp->u.copy_tex_sub_image_3d.xoffset,
2984 pOp->u.copy_tex_sub_image_3d.yoffset,
2985 pOp->u.copy_tex_sub_image_3d.zoffset,
2986 pOp->u.copy_tex_sub_image_3d.x +
2987 cctx->pReadBuffer->xOff,
2988 pOp->u.copy_tex_sub_image_3d.y +
2989 cctx->pReadBuffer->yOff,
2990 pOp->u.copy_tex_sub_image_3d.width,
2991 pOp->u.copy_tex_sub_image_3d.height);
2994 static void
2995 xglCopyTexSubImage3D (GLenum target,
2996 GLint level,
2997 GLint xoffset,
2998 GLint yoffset,
2999 GLint zoffset,
3000 GLint x,
3001 GLint y,
3002 GLsizei width,
3003 GLsizei height)
3005 xglGLOpRec gl;
3007 gl.glProc = xglCopyTexSubImage3DProc;
3009 gl.u.copy_tex_sub_image_3d.target = target;
3010 gl.u.copy_tex_sub_image_3d.level = level;
3011 gl.u.copy_tex_sub_image_3d.xoffset = xoffset;
3012 gl.u.copy_tex_sub_image_3d.yoffset = yoffset;
3013 gl.u.copy_tex_sub_image_3d.zoffset = zoffset;
3014 gl.u.copy_tex_sub_image_3d.x = x;
3015 gl.u.copy_tex_sub_image_3d.y = y;
3016 gl.u.copy_tex_sub_image_3d.width = width;
3017 gl.u.copy_tex_sub_image_3d.height = height;
3019 xglGLOp (&gl);
3022 /* GL_ARB_multitexture */
3023 static void
3024 xglNoOpActiveTextureARB (GLenum texture) {}
3025 static void
3026 xglActiveTextureARBProc (xglGLOpPtr pOp)
3028 GLenum texUnit;
3030 texUnit = pOp->u.enumeration - GL_TEXTURE0;
3031 if (texUnit < 0 || texUnit >= cctx->maxTexUnits)
3033 xglRecordError (GL_INVALID_ENUM);
3035 else
3037 cctx->activeTexUnit = texUnit;
3038 (*cctx->ActiveTextureARB) (pOp->u.enumeration);
3041 static void
3042 xglActiveTextureARB (GLenum texture)
3044 xglGLOpRec gl;
3046 gl.glProc = xglActiveTextureARBProc;
3048 gl.u.enumeration = texture;
3050 xglGLOp (&gl);
3052 static void
3053 xglNoOpClientActiveTextureARB (GLenum texture) {}
3054 static void
3055 xglNoOpMultiTexCoord1dvARB (GLenum target, const GLdouble *v) {}
3056 static void
3057 xglNoOpMultiTexCoord1fvARB (GLenum target, const GLfloat *v) {}
3058 static void
3059 xglNoOpMultiTexCoord1ivARB (GLenum target, const GLint *v) {}
3060 static void
3061 xglNoOpMultiTexCoord1svARB (GLenum target, const GLshort *v) {}
3062 static void
3063 xglNoOpMultiTexCoord2dvARB (GLenum target, const GLdouble *v) {}
3064 static void
3065 xglNoOpMultiTexCoord2fvARB (GLenum target, const GLfloat *v) {}
3066 static void
3067 xglNoOpMultiTexCoord2ivARB (GLenum target, const GLint *v) {}
3068 static void
3069 xglNoOpMultiTexCoord2svARB (GLenum target, const GLshort *v) {}
3070 static void
3071 xglNoOpMultiTexCoord3dvARB (GLenum target, const GLdouble *v) {}
3072 static void
3073 xglNoOpMultiTexCoord3fvARB (GLenum target, const GLfloat *v) {}
3074 static void
3075 xglNoOpMultiTexCoord3ivARB (GLenum target, const GLint *v) {}
3076 static void
3077 xglNoOpMultiTexCoord3svARB (GLenum target, const GLshort *v) {}
3078 static void
3079 xglNoOpMultiTexCoord4dvARB (GLenum target, const GLdouble *v) {}
3080 static void
3081 xglNoOpMultiTexCoord4fvARB (GLenum target, const GLfloat *v) {}
3082 static void
3083 xglNoOpMultiTexCoord4ivARB (GLenum target, const GLint *v) {}
3084 static void
3085 xglNoOpMultiTexCoord4svARB (GLenum target, const GLshort *v) {}
3087 /* GL_ARB_multisample */
3088 static void
3089 xglNoOpSampleCoverageARB (GLclampf value, GLboolean invert) {}
3091 /* GL_EXT_texture_object */
3092 static GLboolean
3093 xglNoOpAreTexturesResidentEXT (GLsizei n,
3094 const GLuint *textures,
3095 GLboolean *residences)
3097 return GL_FALSE;
3099 static void
3100 xglNoOpGenTexturesEXT (GLsizei n, GLuint *textures) {}
3101 static GLboolean
3102 xglNoOpIsTextureEXT (GLuint texture)
3104 return GL_FALSE;
3107 /* GL_SGIS_multisample */
3108 static void
3109 xglNoOpSampleMaskSGIS (GLclampf value, GLboolean invert) {}
3110 static void
3111 xglNoOpSamplePatternSGIS (GLenum pattern) {}
3113 /* GL_EXT_point_parameters */
3114 static void
3115 xglNoOpPointParameterfEXT (GLenum pname, GLfloat param) {}
3116 static void
3117 xglNoOpPointParameterfvEXT (GLenum pname, const GLfloat *params) {}
3119 /* GL_MESA_window_pos */
3120 static void
3121 xglNoOpWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z) {}
3122 static void
3123 xglWindowPos3fMESAProc (xglGLOpPtr pOp)
3125 (*cctx->WindowPos3fMESA) (pOp->u.window_pos_3f.x + cctx->pDrawBuffer->xOff,
3126 pOp->u.window_pos_3f.y + cctx->pDrawBuffer->yOff,
3127 pOp->u.window_pos_3f.z);
3129 static void
3130 xglWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z)
3132 xglGLOpRec gl;
3134 gl.glProc = xglWindowPos3fMESAProc;
3136 gl.u.window_pos_3f.x = x;
3137 gl.u.window_pos_3f.y = y;
3138 gl.u.window_pos_3f.z = z;
3140 xglGLOp (&gl);
3143 /* GL_EXT_blend_func_separate */
3144 static void
3145 xglNoOpBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB,
3146 GLenum sfactorAlpha, GLenum dfactorAlpha) {}
3148 /* GL_EXT_fog_coord */
3149 static void
3150 xglNoOpFogCoordfvEXT (const GLfloat *coord) {}
3151 static void
3152 xglNoOpFogCoorddvEXT (const GLdouble *coord) {}
3153 static void
3154 xglNoOpFogCoordPointerEXT (GLenum type, GLsizei stride,
3155 const GLvoid *pointer) {}
3157 /* GL_EXT_secondary_color */
3158 static void
3159 xglNoOpSecondaryColor3bvEXT (const GLbyte *v) {}
3160 static void
3161 xglNoOpSecondaryColor3dvEXT (const GLdouble *v) {}
3162 static void
3163 xglNoOpSecondaryColor3fvEXT (const GLfloat *v) {}
3164 static void
3165 xglNoOpSecondaryColor3ivEXT (const GLint *v) {}
3166 static void
3167 xglNoOpSecondaryColor3svEXT (const GLshort *v) {}
3168 static void
3169 xglNoOpSecondaryColor3ubvEXT (const GLubyte *v) {}
3170 static void
3171 xglNoOpSecondaryColor3uivEXT (const GLuint *v) {}
3172 static void
3173 xglNoOpSecondaryColor3usvEXT (const GLushort *v) {}
3174 static void
3175 xglNoOpSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride,
3176 const GLvoid *pointer) {}
3178 /* GL_NV_point_sprite */
3179 static void
3180 xglNoOpPointParameteriNV (GLenum pname, GLint params) {}
3181 static void
3182 xglNoOpPointParameterivNV (GLenum pname, const GLint *params) {}
3184 /* GL_EXT_stencil_two_side */
3185 static void
3186 xglNoOpActiveStencilFaceEXT (GLenum face) {}
3188 /* GL_EXT_framebuffer_object */
3189 static GLboolean
3190 xglNoOpIsRenderbufferEXT (GLuint renderbuffer)
3192 return FALSE;
3194 static void
3195 xglNoOpBindRenderbufferEXT (GLenum target, GLuint renderbuffer) {}
3196 static void
3197 xglNoOpDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) {}
3198 static void
3199 xglNoOpGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) {}
3200 static void
3201 xglNoOpRenderbufferStorageEXT (GLenum target, GLenum internalformat,
3202 GLsizei width, GLsizei height) {}
3203 static void
3204 xglNoOpGetRenderbufferParameterivEXT (GLenum target, GLenum pname,
3205 GLint *params) {}
3206 static GLboolean
3207 xglNoOpIsFramebufferEXT (GLuint framebuffer)
3209 return FALSE;
3211 static void
3212 xglNoOpBindFramebufferEXT (GLenum target, GLuint framebuffer) {}
3213 static void
3214 xglNoOpDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) {}
3215 static void
3216 xglNoOpGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) {}
3217 static GLenum
3218 xglNoOpCheckFramebufferStatusEXT (GLenum target)
3220 return GL_FRAMEBUFFER_UNSUPPORTED_EXT;
3222 static void
3223 xglNoOpFramebufferTexture1DEXT (GLenum target, GLenum attachment,
3224 GLenum textarget, GLuint texture,
3225 GLint level) {}
3226 static void
3227 xglNoOpFramebufferTexture2DEXT (GLenum target, GLenum attachment,
3228 GLenum textarget, GLuint texture,
3229 GLint level) {}
3230 static void
3231 xglNoOpFramebufferTexture3DEXT (GLenum target, GLenum attachment,
3232 GLenum textarget, GLuint texture,
3233 GLint level, GLint zoffset) {}
3234 static void
3235 xglNoOpFramebufferRenderbufferEXT (GLenum target, GLenum attachment,
3236 GLenum renderbuffertarget,
3237 GLuint renderbuffer) {}
3238 static void
3239 xglNoOpGetFramebufferAttachmentParameterivEXT (GLenum target,
3240 GLenum attachment,
3241 GLenum pname,
3242 GLint *params) {}
3243 static void
3244 xglNoOpGenerateMipmapEXT (GLenum target) {}
3246 static struct _glapi_table __glNativeRenderTable = {
3247 xglNewList,
3248 xglEndList,
3249 xglCallList,
3250 xglCallLists,
3251 xglDeleteLists,
3252 xglGenLists,
3253 glListBase,
3254 xglBegin,
3255 xglBitmap,
3256 0, /* glColor3b */
3257 glColor3bv,
3258 0, /* glColor3d */
3259 glColor3dv,
3260 0, /* glColor3f */
3261 glColor3fv,
3262 0, /* glColor3i */
3263 glColor3iv,
3264 0, /* glColor3s */
3265 glColor3sv,
3266 0, /* glColor3ub */
3267 glColor3ubv,
3268 0, /* glColor3ui */
3269 glColor3uiv,
3270 0, /* glColor3us */
3271 glColor3usv,
3272 0, /* glColor4b */
3273 glColor4bv,
3274 0, /* glColor4d */
3275 glColor4dv,
3276 0, /* glColor4f */
3277 glColor4fv,
3278 0, /* glColor4i */
3279 glColor4iv,
3280 0, /* glColor4s */
3281 glColor4sv,
3282 0, /* glColor4ub */
3283 glColor4ubv,
3284 0, /* glColor4ui */
3285 glColor4uiv,
3286 0, /* glColor4us */
3287 glColor4usv,
3288 0, /* glEdgeFlag */
3289 glEdgeFlagv,
3290 xglEnd,
3291 0, /* glIndexd */
3292 glIndexdv,
3293 0, /* glIndexf */
3294 glIndexfv,
3295 0, /* glIndexi */
3296 glIndexiv,
3297 0, /* glIndexs */
3298 glIndexsv,
3299 0, /* glNormal3b */
3300 glNormal3bv,
3301 0, /* glNormal3d */
3302 glNormal3dv,
3303 0, /* glNormal3f */
3304 glNormal3fv,
3305 0, /* glNormal3i */
3306 glNormal3iv,
3307 0, /* glNormal3s */
3308 glNormal3sv,
3309 0, /* glRasterPos2d */
3310 glRasterPos2dv,
3311 0, /* glRasterPos2f */
3312 glRasterPos2fv,
3313 0, /* glRasterPos2i */
3314 glRasterPos2iv,
3315 0, /* glRasterPos2s */
3316 glRasterPos2sv,
3317 0, /* glRasterPos3d */
3318 glRasterPos3dv,
3319 0, /* glRasterPos3f */
3320 glRasterPos3fv,
3321 0, /* glRasterPos3i */
3322 glRasterPos3iv,
3323 0, /* glRasterPos3s */
3324 glRasterPos3sv,
3325 0, /* glRasterPos4d */
3326 glRasterPos4dv,
3327 0, /* glRasterPos4f */
3328 glRasterPos4fv,
3329 0, /* glRasterPos4i */
3330 glRasterPos4iv,
3331 0, /* glRasterPos4s */
3332 glRasterPos4sv,
3333 0, /* glRectd */
3334 xglRectdv,
3335 0, /* glRectf */
3336 xglRectfv,
3337 0, /* glRecti */
3338 xglRectiv,
3339 0, /* glRects */
3340 xglRectsv,
3341 0, /* glTexCoord1d */
3342 glTexCoord1dv,
3343 0, /* glTexCoord1f */
3344 glTexCoord1fv,
3345 0, /* glTexCoord1i */
3346 glTexCoord1iv,
3347 0, /* glTexCoord1s */
3348 glTexCoord1sv,
3349 0, /* glTexCoord2d */
3350 glTexCoord2dv,
3351 0, /* glTexCoord2f */
3352 glTexCoord2fv,
3353 0, /* glTexCoord2i */
3354 glTexCoord2iv,
3355 0, /* glTexCoord2s */
3356 glTexCoord2sv,
3357 0, /* glTexCoord3d */
3358 glTexCoord3dv,
3359 0, /* glTexCoord3f */
3360 glTexCoord3fv,
3361 0, /* glTexCoord3i */
3362 glTexCoord3iv,
3363 0, /* glTexCoord3s */
3364 glTexCoord3sv,
3365 0, /* glTexCoord4d */
3366 glTexCoord4dv,
3367 0, /* glTexCoord4f */
3368 glTexCoord4fv,
3369 0, /* glTexCoord4i */
3370 glTexCoord4iv,
3371 0, /* glTexCoord4s */
3372 glTexCoord4sv,
3373 0, /* glVertex2d */
3374 glVertex2dv,
3375 0, /* glVertex2f */
3376 glVertex2fv,
3377 0, /* glVertex2i */
3378 glVertex2iv,
3379 0, /* glVertex2s */
3380 glVertex2sv,
3381 0, /* glVertex3d */
3382 glVertex3dv,
3383 0, /* glVertex3f */
3384 glVertex3fv,
3385 0, /* glVertex3i */
3386 glVertex3iv,
3387 0, /* glVertex3s */
3388 glVertex3sv,
3389 0, /* glVertex4d */
3390 glVertex4dv,
3391 0, /* glVertex4f */
3392 glVertex4fv,
3393 0, /* glVertex4i */
3394 glVertex4iv,
3395 0, /* glVertex4s */
3396 glVertex4sv,
3397 glClipPlane,
3398 glColorMaterial,
3399 glCullFace,
3400 glFogf,
3401 glFogfv,
3402 glFogi,
3403 glFogiv,
3404 glFrontFace,
3405 glHint,
3406 glLightf,
3407 glLightfv,
3408 glLighti,
3409 glLightiv,
3410 glLightModelf,
3411 glLightModelfv,
3412 glLightModeli,
3413 glLightModeliv,
3414 glLineStipple,
3415 glLineWidth,
3416 glMaterialf,
3417 glMaterialfv,
3418 glMateriali,
3419 glMaterialiv,
3420 glPointSize,
3421 glPolygonMode,
3422 glPolygonStipple,
3423 xglScissor,
3424 glShadeModel,
3425 xglTexParameterf,
3426 xglTexParameterfv,
3427 xglTexParameteri,
3428 xglTexParameteriv,
3429 glTexImage1D,
3430 glTexImage2D,
3431 glTexEnvf,
3432 glTexEnvfv,
3433 glTexEnvi,
3434 glTexEnviv,
3435 glTexGend,
3436 glTexGendv,
3437 glTexGenf,
3438 glTexGenfv,
3439 glTexGeni,
3440 glTexGeniv,
3441 glFeedbackBuffer,
3442 glSelectBuffer,
3443 glRenderMode,
3444 glInitNames,
3445 glLoadName,
3446 glPassThrough,
3447 glPopName,
3448 glPushName,
3449 xglDrawBuffer,
3450 xglClear,
3451 glClearAccum,
3452 glClearIndex,
3453 glClearColor,
3454 glClearStencil,
3455 glClearDepth,
3456 glStencilMask,
3457 glColorMask,
3458 glDepthMask,
3459 glIndexMask,
3460 xglAccum,
3461 xglDisable,
3462 xglEnable,
3463 xglFinish,
3464 xglFlush,
3465 xglPopAttrib,
3466 xglPushAttrib,
3467 glMap1d,
3468 glMap1f,
3469 glMap2d,
3470 glMap2f,
3471 glMapGrid1d,
3472 glMapGrid1f,
3473 glMapGrid2d,
3474 glMapGrid2f,
3475 0, /* glEvalCoord1d */
3476 glEvalCoord1dv,
3477 0, /* glEvalCoord1f */
3478 glEvalCoord1fv,
3479 0, /* glEvalCoord2d */
3480 glEvalCoord2dv,
3481 0, /* glEvalCoord2f */
3482 glEvalCoord2fv,
3483 glEvalMesh1,
3484 glEvalPoint1,
3485 glEvalMesh2,
3486 glEvalPoint2,
3487 glAlphaFunc,
3488 glBlendFunc,
3489 glLogicOp,
3490 glStencilFunc,
3491 glStencilOp,
3492 glDepthFunc,
3493 glPixelZoom,
3494 glPixelTransferf,
3495 glPixelTransferi,
3496 glPixelStoref,
3497 glPixelStorei,
3498 glPixelMapfv,
3499 glPixelMapuiv,
3500 glPixelMapusv,
3501 xglReadBuffer,
3502 xglCopyPixels,
3503 xglReadPixels,
3504 xglDrawPixels,
3505 xglGetBooleanv,
3506 glGetClipPlane,
3507 xglGetDoublev,
3508 xglGetError,
3509 xglGetFloatv,
3510 xglGetIntegerv,
3511 glGetLightfv,
3512 glGetLightiv,
3513 glGetMapdv,
3514 glGetMapfv,
3515 glGetMapiv,
3516 glGetMaterialfv,
3517 glGetMaterialiv,
3518 glGetPixelMapfv,
3519 glGetPixelMapuiv,
3520 glGetPixelMapusv,
3521 glGetPolygonStipple,
3522 xglGetString,
3523 glGetTexEnvfv,
3524 glGetTexEnviv,
3525 glGetTexGendv,
3526 glGetTexGenfv,
3527 glGetTexGeniv,
3528 glGetTexImage,
3529 glGetTexParameterfv,
3530 glGetTexParameteriv,
3531 xglGetTexLevelParameterfv,
3532 xglGetTexLevelParameteriv,
3533 xglIsEnabled,
3534 xglIsList,
3535 glDepthRange,
3536 glFrustum,
3537 glLoadIdentity,
3538 glLoadMatrixf,
3539 glLoadMatrixd,
3540 glMatrixMode,
3541 glMultMatrixf,
3542 glMultMatrixd,
3543 glOrtho,
3544 glPopMatrix,
3545 glPushMatrix,
3546 glRotated,
3547 glRotatef,
3548 glScaled,
3549 glScalef,
3550 glTranslated,
3551 glTranslatef,
3552 xglViewport,
3553 glArrayElement,
3554 xglBindTexture,
3555 glColorPointer,
3556 glDisableClientState,
3557 xglDrawArrays,
3558 xglDrawElements,
3559 glEdgeFlagPointer,
3560 glEnableClientState,
3561 glIndexPointer,
3562 0, /* glIndexub */
3563 glIndexubv,
3564 glInterleavedArrays,
3565 glNormalPointer,
3566 glPolygonOffset,
3567 glTexCoordPointer,
3568 glVertexPointer,
3569 xglAreTexturesResident,
3570 xglCopyTexImage1D,
3571 xglCopyTexImage2D,
3572 xglCopyTexSubImage1D,
3573 xglCopyTexSubImage2D,
3574 xglDeleteTextures,
3575 xglGenTextures,
3576 glGetPointerv,
3577 xglIsTexture,
3578 xglPrioritizeTextures,
3579 glTexSubImage1D,
3580 glTexSubImage2D,
3581 glPopClientAttrib,
3582 glPushClientAttrib,
3583 glBlendColor,
3584 glBlendEquation,
3585 0, /* glDrawRangeElements */
3586 glColorTable,
3587 glColorTableParameterfv,
3588 glColorTableParameteriv,
3589 xglCopyColorTable,
3590 glGetColorTable,
3591 glGetColorTableParameterfv,
3592 glGetColorTableParameteriv,
3593 glColorSubTable,
3594 xglCopyColorSubTable,
3595 glConvolutionFilter1D,
3596 glConvolutionFilter2D,
3597 glConvolutionParameterf,
3598 glConvolutionParameterfv,
3599 glConvolutionParameteri,
3600 glConvolutionParameteriv,
3601 xglCopyConvolutionFilter1D,
3602 xglCopyConvolutionFilter2D,
3603 glGetConvolutionFilter,
3604 glGetConvolutionParameterfv,
3605 glGetConvolutionParameteriv,
3606 glGetSeparableFilter,
3607 glSeparableFilter2D,
3608 glGetHistogram,
3609 glGetHistogramParameterfv,
3610 glGetHistogramParameteriv,
3611 glGetMinmax,
3612 glGetMinmaxParameterfv,
3613 glGetMinmaxParameteriv,
3614 glHistogram,
3615 glMinmax,
3616 glResetHistogram,
3617 glResetMinmax,
3618 glTexImage3D,
3619 glTexSubImage3D,
3620 xglCopyTexSubImage3D,
3621 xglNoOpActiveTextureARB,
3622 xglNoOpClientActiveTextureARB,
3623 0, /* glMultiTexCoord1dARB */
3624 xglNoOpMultiTexCoord1dvARB,
3625 0, /* glMultiTexCoord1fARB */
3626 xglNoOpMultiTexCoord1fvARB,
3627 0, /* glMultiTexCoord1iARB */
3628 xglNoOpMultiTexCoord1ivARB,
3629 0, /* glMultiTexCoord1sARB */
3630 xglNoOpMultiTexCoord1svARB,
3631 0, /* glMultiTexCoord2dARB */
3632 xglNoOpMultiTexCoord2dvARB,
3633 0, /* glMultiTexCoord2fARB */
3634 xglNoOpMultiTexCoord2fvARB,
3635 0, /* glMultiTexCoord2iARB */
3636 xglNoOpMultiTexCoord2ivARB,
3637 0, /* glMultiTexCoord2sARB */
3638 xglNoOpMultiTexCoord2svARB,
3639 0, /* glMultiTexCoord3dARB */
3640 xglNoOpMultiTexCoord3dvARB,
3641 0, /* glMultiTexCoord3fARB */
3642 xglNoOpMultiTexCoord3fvARB,
3643 0, /* glMultiTexCoord3iARB */
3644 xglNoOpMultiTexCoord3ivARB,
3645 0, /* glMultiTexCoord3sARB */
3646 xglNoOpMultiTexCoord3svARB,
3647 0, /* glMultiTexCoord4dARB */
3648 xglNoOpMultiTexCoord4dvARB,
3649 0, /* glMultiTexCoord4fARB */
3650 xglNoOpMultiTexCoord4fvARB,
3651 0, /* glMultiTexCoord4iARB */
3652 xglNoOpMultiTexCoord4ivARB,
3653 0, /* glMultiTexCoord4sARB */
3654 xglNoOpMultiTexCoord4svARB,
3655 0, /* glLoadTransposeMatrixfARB */
3656 0, /* glLoadTransposeMatrixdARB */
3657 0, /* glMultTransposeMatrixfARB */
3658 0, /* glMultTransposeMatrixdARB */
3659 xglNoOpSampleCoverageARB,
3660 0, /* glDrawBuffersARB */
3661 0, /* glPolygonOffsetEXT */
3662 0, /* glGetTexFilterFuncSGIS */
3663 0, /* glTexFilterFuncSGIS */
3664 0, /* glGetHistogramEXT */
3665 0, /* glGetHistogramParameterfvEXT */
3666 0, /* glGetHistogramParameterivEXT */
3667 0, /* glGetMinmaxEXT */
3668 0, /* glGetMinmaxParameterfvEXT */
3669 0, /* glGetMinmaxParameterivEXT */
3670 0, /* glGetConvolutionFilterEXT */
3671 0, /* glGetConvolutionParameterfvEXT */
3672 0, /* glGetConvolutionParameterivEXT */
3673 0, /* glGetSeparableFilterEXT */
3674 0, /* glGetColorTableSGI */
3675 0, /* glGetColorTableParameterfvSGI */
3676 0, /* glGetColorTableParameterivSGI */
3677 0, /* glPixelTexGenSGIX */
3678 0, /* glPixelTexGenParameteriSGIS */
3679 0, /* glPixelTexGenParameterivSGIS */
3680 0, /* glPixelTexGenParameterfSGIS */
3681 0, /* glPixelTexGenParameterfvSGIS */
3682 0, /* glGetPixelTexGenParameterivSGIS */
3683 0, /* glGetPixelTexGenParameterfvSGIS */
3684 0, /* glTexImage4DSGIS */
3685 0, /* glTexSubImage4DSGIS */
3686 xglNoOpAreTexturesResidentEXT,
3687 xglNoOpGenTexturesEXT,
3688 xglNoOpIsTextureEXT,
3689 0, /* glDetailTexFuncSGIS */
3690 0, /* glGetDetailTexFuncSGIS */
3691 0, /* glSharpenTexFuncSGIS */
3692 0, /* glGetSharpenTexFuncSGIS */
3693 xglNoOpSampleMaskSGIS,
3694 xglNoOpSamplePatternSGIS,
3695 0, /* glColorPointerEXT */
3696 0, /* glEdgeFlagPointerEXT */
3697 0, /* glIndexPointerEXT */
3698 0, /* glNormalPointerEXT */
3699 0, /* glTexCoordPointerEXT */
3700 0, /* glVertexPointerEXT */
3701 0, /* glSpriteParameterfSGIX */
3702 0, /* glSpriteParameterfvSGIX */
3703 0, /* glSpriteParameteriSGIX */
3704 0, /* glSpriteParameterivSGIX */
3705 xglNoOpPointParameterfEXT,
3706 xglNoOpPointParameterfvEXT,
3707 0, /* glGetInstrumentsSGIX */
3708 0, /* glInstrumentsBufferSGIX */
3709 0, /* glPollInstrumentsSGIX */
3710 0, /* glReadInstrumentsSGIX */
3711 0, /* glStartInstrumentsSGIX */
3712 0, /* glStopInstrumentsSGIX */
3713 0, /* glFrameZoomSGIX */
3714 0, /* glTagSampleBufferSGIX */
3715 0, /* glReferencePlaneSGIX */
3716 0, /* glFlushRasterSGIX */
3717 0, /* glGetListParameterfvSGIX */
3718 0, /* glGetListParameterivSGIX */
3719 0, /* glListParameterfSGIX */
3720 0, /* glListParameterfvSGIX */
3721 0, /* glListParameteriSGIX */
3722 0, /* glListParameterivSGIX */
3723 0, /* glFragmentColorMaterialSGIX */
3724 0, /* glFragmentLightfSGIX */
3725 0, /* glFragmentLightfvSGIX */
3726 0, /* glFragmentLightiSGIX */
3727 0, /* glFragmentLightivSGIX */
3728 0, /* glFragmentLightModelfSGIX */
3729 0, /* glFragmentLightModelfvSGIX */
3730 0, /* glFragmentLightModeliSGIX */
3731 0, /* glFragmentLightModelivSGIX */
3732 0, /* glFragmentMaterialfSGIX */
3733 0, /* glFragmentMaterialfvSGIX */
3734 0, /* glFragmentMaterialiSGIX */
3735 0, /* glFragmentMaterialivSGIX */
3736 0, /* glGetFragmentLightfvSGIX */
3737 0, /* glGetFragmentLightivSGIX */
3738 0, /* glGetFragmentMaterialfvSGIX */
3739 0, /* glGetFragmentMaterialivSGIX */
3740 0, /* glLightEnviSGIX */
3741 0, /* glVertexWeightfEXT */
3742 0, /* glVertexWeightfvEXT */
3743 0, /* glVertexWeightPointerEXT */
3744 0, /* glFlushVertexArrayRangeNV */
3745 0, /* glVertexArrayRangeNV */
3746 0, /* glCombinerParameterfvNV */
3747 0, /* glCombinerParameterfNV */
3748 0, /* glCombinerParameterivNV */
3749 0, /* glCombinerParameteriNV */
3750 0, /* glCombinerInputNV */
3751 0, /* glCombinerOutputNV */
3752 0, /* glFinalCombinerInputNV */
3753 0, /* glGetCombinerInputParameterfvNV */
3754 0, /* glGetCombinerInputParameterivNV */
3755 0, /* glGetCombinerOutputParameterfvNV */
3756 0, /* glGetCombinerOutputParameterivNV */
3757 0, /* glGetFinalCombinerInputParameterfvNV */
3758 0, /* glGetFinalCombinerInputParameterivNV */
3759 0, /* glResizeBuffersMESA */
3760 0, /* glWindowPos2dMESA */
3761 0, /* glWindowPos2dvMESA */
3762 0, /* glWindowPos2fMESA */
3763 0, /* glWindowPos2fvMESA */
3764 0, /* glWindowPos2iMESA */
3765 0, /* glWindowPos2ivMESA */
3766 0, /* glWindowPos2sMESA */
3767 0, /* glWindowPos2svMESA */
3768 0, /* glWindowPos3dMESA */
3769 0, /* glWindowPos3dvMESA */
3770 xglNoOpWindowPos3fMESA,
3771 0, /* glWindowPos3fvMESA */
3772 0, /* glWindowPos3iMESA */
3773 0, /* glWindowPos3ivMESA */
3774 0, /* glWindowPos3sMESA */
3775 0, /* glWindowPos3svMESA */
3776 0, /* glWindowPos4dMESA */
3777 0, /* glWindowPos4dvMESA */
3778 0, /* glWindowPos4fMESA */
3779 0, /* glWindowPos4fvMESA */
3780 0, /* glWindowPos4iMESA */
3781 0, /* glWindowPos4ivMESA */
3782 0, /* glWindowPos4sMESA */
3783 0, /* glWindowPos4svMESA */
3784 xglNoOpBlendFuncSeparateEXT,
3785 0, /* glIndexMaterialEXT */
3786 0, /* glIndexFuncEXT */
3787 0, /* glLockArraysEXT */
3788 0, /* glUnlockArraysEXT */
3789 0, /* glCullParameterdvEXT */
3790 0, /* glCullParameterfvEXT */
3791 0, /* glHintPGI */
3792 0, /* glFogCoordfEXT */
3793 xglNoOpFogCoordfvEXT,
3794 0, /* glFogCoorddEXT */
3795 xglNoOpFogCoorddvEXT,
3796 xglNoOpFogCoordPointerEXT,
3797 0, /* glGetColorTableEXT */
3798 0, /* glGetColorTableParameterivEXT */
3799 0, /* glGetColorTableParameterfvEXT */
3800 0, /* glTbufferMask3DFX */
3801 0, /* glCompressedTexImage3DARB */
3802 0, /* glCompressedTexImage2DARB */
3803 0, /* glCompressedTexImage1DARB */
3804 0, /* glCompressedTexSubImage3DARB */
3805 0, /* glCompressedTexSubImage2DARB */
3806 0, /* glCompressedTexSubImage1DARB */
3807 0, /* glGetCompressedTexImageARB */
3808 0, /* glSecondaryColor3bEXT */
3809 xglNoOpSecondaryColor3bvEXT,
3810 0, /* glSecondaryColor3dEXT */
3811 xglNoOpSecondaryColor3dvEXT,
3812 0, /* glSecondaryColor3fEXT */
3813 xglNoOpSecondaryColor3fvEXT,
3814 0, /* glSecondaryColor3iEXT */
3815 xglNoOpSecondaryColor3ivEXT,
3816 0, /* glSecondaryColor3sEXT */
3817 xglNoOpSecondaryColor3svEXT,
3818 0, /* glSecondaryColor3ubEXT */
3819 xglNoOpSecondaryColor3ubvEXT,
3820 0, /* glSecondaryColor3uiEXT */
3821 xglNoOpSecondaryColor3uivEXT,
3822 0, /* glSecondaryColor3usEXT */
3823 xglNoOpSecondaryColor3usvEXT,
3824 xglNoOpSecondaryColorPointerEXT,
3825 0, /* glAreProgramsResidentNV */
3826 0, /* glBindProgramNV */
3827 0, /* glDeleteProgramsNV */
3828 0, /* glExecuteProgramNV */
3829 0, /* glGenProgramsNV */
3830 0, /* glGetProgramParameterdvNV */
3831 0, /* glGetProgramParameterfvNV */
3832 0, /* glGetProgramivNV */
3833 0, /* glGetProgramStringNV */
3834 0, /* glGetTrackMatrixivNV */
3835 0, /* glGetVertexAttribdvARB */
3836 0, /* glGetVertexAttribfvARB */
3837 0, /* glGetVertexAttribivARB */
3838 0, /* glGetVertexAttribPointervNV */
3839 0, /* glIsProgramNV */
3840 0, /* glLoadProgramNV */
3841 0, /* glProgramParameter4dNV */
3842 0, /* glProgramParameter4dvNV */
3843 0, /* glProgramParameter4fNV */
3844 0, /* glProgramParameter4fvNV */
3845 0, /* glProgramParameters4dvNV */
3846 0, /* glProgramParameters4fvNV */
3847 0, /* glRequestResidentProgramsNV */
3848 0, /* glTrackMatrixNV */
3849 0, /* glVertexAttribPointerNV */
3850 0, /* glVertexAttrib1dARB */
3851 0, /* glVertexAttrib1dvARB */
3852 0, /* glVertexAttrib1fARB */
3853 0, /* glVertexAttrib1fvARB */
3854 0, /* glVertexAttrib1sARB */
3855 0, /* glVertexAttrib1svARB */
3856 0, /* glVertexAttrib2dARB */
3857 0, /* glVertexAttrib2dvARB */
3858 0, /* glVertexAttrib2fARB */
3859 0, /* glVertexAttrib2fvARB */
3860 0, /* glVertexAttrib2sARB */
3861 0, /* glVertexAttrib2svARB */
3862 0, /* glVertexAttrib3dARB */
3863 0, /* glVertexAttrib3dvARB */
3864 0, /* glVertexAttrib3fARB */
3865 0, /* glVertexAttrib3fvARB */
3866 0, /* glVertexAttrib3sARB */
3867 0, /* glVertexAttrib3svARB */
3868 0, /* glVertexAttrib4dARB */
3869 0, /* glVertexAttrib4dvARB */
3870 0, /* glVertexAttrib4fARB */
3871 0, /* glVertexAttrib4fvARB */
3872 0, /* glVertexAttrib4sARB */
3873 0, /* glVertexAttrib4svARB */
3874 0, /* glVertexAttrib4NubARB */
3875 0, /* glVertexAttrib4NubvARB */
3876 0, /* glVertexAttribs1dvNV */
3877 0, /* glVertexAttribs1fvNV */
3878 0, /* glVertexAttribs1svNV */
3879 0, /* glVertexAttribs2dvNV */
3880 0, /* glVertexAttribs2fvNV */
3881 0, /* glVertexAttribs2svNV */
3882 0, /* glVertexAttribs3dvNV */
3883 0, /* glVertexAttribs3fvNV */
3884 0, /* glVertexAttribs3svNV */
3885 0, /* glVertexAttribs4dvNV */
3886 0, /* glVertexAttribs4fvNV */
3887 0, /* glVertexAttribs4svNV */
3888 0, /* glVertexAttribs4ubvNV */
3889 xglNoOpPointParameteriNV,
3890 xglNoOpPointParameterivNV,
3891 0, /* glMultiDrawArraysEXT */
3892 0, /* glMultiDrawElementsEXT */
3893 xglNoOpActiveStencilFaceEXT,
3894 0, /* glDeleteFencesNV */
3895 0, /* glGenFencesNV */
3896 0, /* glIsFenceNV */
3897 0, /* glTestFenceNV */
3898 0, /* glGetFenceivNV */
3899 0, /* glFinishFenceNV */
3900 0, /* glSetFenceNV */
3901 0, /* glVertexAttrib4bvARB */
3902 0, /* glVertexAttrib4ivARB */
3903 0, /* glVertexAttrib4ubvARB */
3904 0, /* glVertexAttrib4usvARB */
3905 0, /* glVertexAttrib4uivARB */
3906 0, /* glVertexAttrib4NbvARB */
3907 0, /* glVertexAttrib4NsvARB */
3908 0, /* glVertexAttrib4NivARB */
3909 0, /* glVertexAttrib4NusvARB */
3910 0, /* glVertexAttrib4NuivARB */
3911 0, /* glVertexAttribPointerARB */
3912 0, /* glEnableVertexAttribArrayARB */
3913 0, /* glDisableVertexAttribArrayARB */
3914 0, /* glProgramStringARB */
3915 0, /* glProgramEnvParameter4dARB */
3916 0, /* glProgramEnvParameter4dvARB */
3917 0, /* glProgramEnvParameter4fARB */
3918 0, /* glProgramEnvParameter4fvARB */
3919 0, /* glProgramLocalParameter4dARB */
3920 0, /* glProgramLocalParameter4dvARB */
3921 0, /* glProgramLocalParameter4fARB */
3922 0, /* glProgramLocalParameter4fvARB */
3923 0, /* glGetProgramEnvParameterdvARB */
3924 0, /* glGetProgramEnvParameterfvARB */
3925 0, /* glGetProgramLocalParameterdvARB */
3926 0, /* glGetProgramLocalParameterfvARB */
3927 0, /* glGetProgramivARB */
3928 0, /* glGetProgramStringARB */
3929 0, /* glProgramNamedParameter4fNV */
3930 0, /* glProgramNamedParameter4dNV */
3931 0, /* glProgramNamedParameter4fvNV */
3932 0, /* glProgramNamedParameter4dvNV */
3933 0, /* glGetProgramNamedParameterfvNV */
3934 0, /* glGetProgramNamedParameterdvNV */
3935 0, /* glBindBufferARB */
3936 0, /* glBufferDataARB */
3937 0, /* glBufferSubDataARB */
3938 0, /* glDeleteBuffersARB */
3939 0, /* glGenBuffersARB */
3940 0, /* glGetBufferParameterivARB */
3941 0, /* glGetBufferPointervARB */
3942 0, /* glGetBufferSubDataARB */
3943 0, /* glIsBufferARB */
3944 0, /* glMapBufferARB */
3945 0, /* glUnmapBufferARB */
3946 0, /* glDepthBoundsEXT */
3947 0, /* glGenQueriesARB */
3948 0, /* glDeleteQueriesARB */
3949 0, /* glIsQueryARB */
3950 0, /* glBeginQueryARB */
3951 0, /* glEndQueryARB */
3952 0, /* glGetQueryivARB */
3953 0, /* glGetQueryObjectivARB */
3954 0, /* glGetQueryObjectuivARB */
3955 0, /* glMultiModeDrawArraysIBM */
3956 0, /* glMultiModeDrawElementsIBM */
3957 0, /* glBlendEquationSeparateEXT */
3958 0, /* glDeleteObjectARB */
3959 0, /* glGetHandleARB */
3960 0, /* glDetachObjectARB */
3961 0, /* glCreateShaderObjectARB */
3962 0, /* glShaderSourceARB */
3963 0, /* glCompileShaderARB */
3964 0, /* glCreateProgramObjectARB */
3965 0, /* glAttachObjectARB */
3966 0, /* glLinkProgramARB */
3967 0, /* glUseProgramObjectARB */
3968 0, /* glValidateProgramARB */
3969 0, /* glUniform1fARB */
3970 0, /* glUniform2fARB */
3971 0, /* glUniform3fARB */
3972 0, /* glUniform4fARB */
3973 0, /* glUniform1iARB */
3974 0, /* glUniform2iARB */
3975 0, /* glUniform3iARB */
3976 0, /* glUniform4iARB */
3977 0, /* glUniform1fvARB */
3978 0, /* glUniform2fvARB */
3979 0, /* glUniform3fvARB */
3980 0, /* glUniform4fvARB */
3981 0, /* glUniform1ivARB */
3982 0, /* glUniform2ivARB */
3983 0, /* glUniform3ivARB */
3984 0, /* glUniform4ivARB */
3985 0, /* glUniformMatrix2fvARB */
3986 0, /* glUniformMatrix3fvARB */
3987 0, /* glUniformMatrix4fvARB */
3988 0, /* glGetObjectParameterfvARB */
3989 0, /* glGetObjectParameterivARB */
3990 0, /* glGetInfoLogARB */
3991 0, /* glGetAttachedObjectsARB */
3992 0, /* glGetUniformLocationARB */
3993 0, /* glGetActiveUniformARB */
3994 0, /* glGetUniformfvARB */
3995 0, /* glGetUniformivARB */
3996 0, /* glGetShaderSourceARB */
3997 0, /* glBindAttribLocationARB */
3998 0, /* glGetActiveAttribARB */
3999 0, /* glGetAttribLocationARB */
4000 0, /* glGetVertexAttribdvNV */
4001 0, /* glGetVertexAttribfvNV */
4002 0, /* glGetVertexAttribivNV */
4003 0, /* glVertexAttrib1dNV */
4004 0, /* glVertexAttrib1dvNV */
4005 0, /* glVertexAttrib1fNV */
4006 0, /* glVertexAttrib1fvNV */
4007 0, /* glVertexAttrib1sNV */
4008 0, /* glVertexAttrib1svNV */
4009 0, /* glVertexAttrib2dNV */
4010 0, /* glVertexAttrib2dvNV */
4011 0, /* glVertexAttrib2fNV */
4012 0, /* glVertexAttrib2fvNV */
4013 0, /* glVertexAttrib2sNV */
4014 0, /* glVertexAttrib2svNV */
4015 0, /* glVertexAttrib3dNV */
4016 0, /* glVertexAttrib3dvNV */
4017 0, /* glVertexAttrib3fNV */
4018 0, /* glVertexAttrib3fvNV */
4019 0, /* glVertexAttrib3sNV */
4020 0, /* glVertexAttrib3svNV */
4021 0, /* glVertexAttrib4dNV */
4022 0, /* glVertexAttrib4dvNV */
4023 0, /* glVertexAttrib4fNV */
4024 0, /* glVertexAttrib4fvNV */
4025 0, /* glVertexAttrib4sNV */
4026 0, /* glVertexAttrib4svNV */
4027 0, /* glVertexAttrib4ubNV */
4028 0, /* glVertexAttrib4ubvNV */
4029 0, /* glGenFragmentShadersATI */
4030 0, /* glBindFragmentShaderATI */
4031 0, /* glDeleteFragmentShaderATI */
4032 0, /* glBeginFragmentShaderATI */
4033 0, /* glEndFragmentShaderATI */
4034 0, /* glPassTexCoordATI */
4035 0, /* glSampleMapATI */
4036 0, /* glColorFragmentOp1ATI */
4037 0, /* glColorFragmentOp2ATI */
4038 0, /* glColorFragmentOp3ATI */
4039 0, /* glAlphaFragmentOp1ATI */
4040 0, /* glAlphaFragmentOp2ATI */
4041 0, /* glAlphaFragmentOp3ATI */
4042 0, /* glSetFragmentShaderConstantATI */
4043 xglNoOpIsRenderbufferEXT,
4044 xglNoOpBindRenderbufferEXT,
4045 xglNoOpDeleteRenderbuffersEXT,
4046 xglNoOpGenRenderbuffersEXT,
4047 xglNoOpRenderbufferStorageEXT,
4048 xglNoOpGetRenderbufferParameterivEXT,
4049 xglNoOpIsFramebufferEXT,
4050 xglNoOpBindFramebufferEXT,
4051 xglNoOpDeleteFramebuffersEXT,
4052 xglNoOpGenFramebuffersEXT,
4053 xglNoOpCheckFramebufferStatusEXT,
4054 xglNoOpFramebufferTexture1DEXT,
4055 xglNoOpFramebufferTexture2DEXT,
4056 xglNoOpFramebufferTexture3DEXT,
4057 xglNoOpFramebufferRenderbufferEXT,
4058 xglNoOpGetFramebufferAttachmentParameterivEXT,
4059 xglNoOpGenerateMipmapEXT,
4060 0, /* glStencilFuncSeparate */
4061 0, /* glStencilOpSeparate */
4062 0, /* glStencilMaskSeparate */
4063 0, /* glGetQueryObjecti64vEXT */
4064 0 /* glGetQueryObjectui64vEXT */
4067 static void
4068 xglInitExtensions (xglGLContextPtr pContext)
4070 const char *extensions;
4072 extensions = (const char *) glGetString (GL_EXTENSIONS);
4074 if (strstr (extensions, "GL_ARB_multitexture"))
4076 pContext->ActiveTextureARB =
4077 (PFNGLACTIVETEXTUREARBPROC)
4078 glitz_context_get_proc_address (pContext->context,
4079 "glActiveTextureARB");
4080 pContext->glRenderTable.ClientActiveTextureARB =
4081 (PFNGLCLIENTACTIVETEXTUREARBPROC)
4082 glitz_context_get_proc_address (pContext->context,
4083 "glClientActiveTextureARB");
4084 pContext->glRenderTable.MultiTexCoord1dvARB =
4085 (PFNGLMULTITEXCOORD1DVARBPROC)
4086 glitz_context_get_proc_address (pContext->context,
4087 "glMultiTexCoord1dvARB");
4088 pContext->glRenderTable.MultiTexCoord1fvARB =
4089 (PFNGLMULTITEXCOORD1FVARBPROC)
4090 glitz_context_get_proc_address (pContext->context,
4091 "glMultiTexCoord1fvARB");
4092 pContext->glRenderTable.MultiTexCoord1ivARB =
4093 (PFNGLMULTITEXCOORD1IVARBPROC)
4094 glitz_context_get_proc_address (pContext->context,
4095 "glMultiTexCoord1ivARB");
4096 pContext->glRenderTable.MultiTexCoord1svARB =
4097 (PFNGLMULTITEXCOORD1SVARBPROC)
4098 glitz_context_get_proc_address (pContext->context,
4099 "glMultiTexCoord1svARB");
4100 pContext->glRenderTable.MultiTexCoord2dvARB =
4101 (PFNGLMULTITEXCOORD2DVARBPROC)
4102 glitz_context_get_proc_address (pContext->context,
4103 "glMultiTexCoord2dvARB");
4104 pContext->glRenderTable.MultiTexCoord2fvARB =
4105 (PFNGLMULTITEXCOORD2FVARBPROC)
4106 glitz_context_get_proc_address (pContext->context,
4107 "glMultiTexCoord2fvARB");
4108 pContext->glRenderTable.MultiTexCoord2ivARB =
4109 (PFNGLMULTITEXCOORD2IVARBPROC)
4110 glitz_context_get_proc_address (pContext->context,
4111 "glMultiTexCoord2ivARB");
4112 pContext->glRenderTable.MultiTexCoord2svARB =
4113 (PFNGLMULTITEXCOORD2SVARBPROC)
4114 glitz_context_get_proc_address (pContext->context,
4115 "glMultiTexCoord2svARB");
4116 pContext->glRenderTable.MultiTexCoord3dvARB =
4117 (PFNGLMULTITEXCOORD3DVARBPROC)
4118 glitz_context_get_proc_address (pContext->context,
4119 "glMultiTexCoord3dvARB");
4120 pContext->glRenderTable.MultiTexCoord3fvARB =
4121 (PFNGLMULTITEXCOORD3FVARBPROC)
4122 glitz_context_get_proc_address (pContext->context,
4123 "glMultiTexCoord3fvARB");
4124 pContext->glRenderTable.MultiTexCoord3ivARB =
4125 (PFNGLMULTITEXCOORD3IVARBPROC)
4126 glitz_context_get_proc_address (pContext->context,
4127 "glMultiTexCoord3ivARB");
4128 pContext->glRenderTable.MultiTexCoord3svARB =
4129 (PFNGLMULTITEXCOORD3SVARBPROC)
4130 glitz_context_get_proc_address (pContext->context,
4131 "glMultiTexCoord3svARB");
4132 pContext->glRenderTable.MultiTexCoord4dvARB =
4133 (PFNGLMULTITEXCOORD4DVARBPROC)
4134 glitz_context_get_proc_address (pContext->context,
4135 "glMultiTexCoord4dvARB");
4136 pContext->glRenderTable.MultiTexCoord4fvARB =
4137 (PFNGLMULTITEXCOORD4FVARBPROC)
4138 glitz_context_get_proc_address (pContext->context,
4139 "glMultiTexCoord4fvARB");
4140 pContext->glRenderTable.MultiTexCoord4ivARB =
4141 (PFNGLMULTITEXCOORD4IVARBPROC)
4142 glitz_context_get_proc_address (pContext->context,
4143 "glMultiTexCoord4ivARB");
4144 pContext->glRenderTable.MultiTexCoord4svARB =
4145 (PFNGLMULTITEXCOORD4SVARBPROC)
4146 glitz_context_get_proc_address (pContext->context,
4147 "glMultiTexCoord4svARB");
4149 glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &pContext->maxTexUnits);
4150 if (pContext->maxTexUnits > XGL_MAX_TEXTURE_UNITS)
4151 pContext->maxTexUnits = XGL_MAX_TEXTURE_UNITS;
4153 pContext->glRenderTable.ActiveTextureARB = xglActiveTextureARB;
4155 else
4156 pContext->maxTexUnits = 1;
4158 if (strstr (extensions, "GL_ARB_multisample"))
4160 pContext->glRenderTable.SampleCoverageARB =
4161 (PFNGLSAMPLECOVERAGEARBPROC)
4162 glitz_context_get_proc_address (pContext->context,
4163 "glSampleCoverageARB");
4166 if (strstr (extensions, "GL_EXT_texture_object"))
4168 pContext->glRenderTable.AreTexturesResidentEXT =
4169 xglAreTexturesResident;
4170 pContext->glRenderTable.GenTexturesEXT = xglGenTextures;
4171 pContext->glRenderTable.IsTextureEXT = xglIsTexture;
4174 if (strstr (extensions, "GL_SGIS_multisample"))
4176 pContext->glRenderTable.SampleMaskSGIS =
4177 (PFNGLSAMPLEMASKSGISPROC)
4178 glitz_context_get_proc_address (pContext->context,
4179 "glSampleMaskSGIS");
4180 pContext->glRenderTable.SamplePatternSGIS =
4181 (PFNGLSAMPLEPATTERNSGISPROC)
4182 glitz_context_get_proc_address (pContext->context,
4183 "glSamplePatternSGIS");
4186 if (strstr (extensions, "GL_EXT_point_parameters"))
4188 pContext->glRenderTable.PointParameterfEXT =
4189 (PFNGLPOINTPARAMETERFEXTPROC)
4190 glitz_context_get_proc_address (pContext->context,
4191 "glPointParameterfEXT");
4192 pContext->glRenderTable.PointParameterfvEXT =
4193 (PFNGLPOINTPARAMETERFVEXTPROC)
4194 glitz_context_get_proc_address (pContext->context,
4195 "glPointParameterfvEXT");
4198 if (strstr (extensions, "GL_MESA_window_pos"))
4200 pContext->WindowPos3fMESA =
4201 (PFNGLWINDOWPOS3FMESAPROC)
4202 glitz_context_get_proc_address (pContext->context,
4203 "glWindowPos3fMESA");
4205 pContext->glRenderTable.WindowPos3fMESA = xglWindowPos3fMESA;
4208 if (strstr (extensions, "GL_EXT_blend_func_separate"))
4210 pContext->glRenderTable.BlendFuncSeparateEXT =
4211 (PFNGLBLENDFUNCSEPARATEEXTPROC)
4212 glitz_context_get_proc_address (pContext->context,
4213 "glBlendFuncSeparateEXT");
4216 if (strstr (extensions, "GL_EXT_fog_coord"))
4218 pContext->glRenderTable.FogCoordfvEXT =
4219 (PFNGLFOGCOORDFVEXTPROC)
4220 glitz_context_get_proc_address (pContext->context,
4221 "glFogCoordfvEXT");
4222 pContext->glRenderTable.FogCoorddvEXT =
4223 (PFNGLFOGCOORDDVEXTPROC)
4224 glitz_context_get_proc_address (pContext->context,
4225 "glFogCoorddvEXT");
4226 pContext->glRenderTable.FogCoordPointerEXT =
4227 (PFNGLFOGCOORDPOINTEREXTPROC)
4228 glitz_context_get_proc_address (pContext->context,
4229 "glFogCoordPointerEXT");
4232 if (strstr (extensions, "GL_EXT_secondary_color"))
4234 pContext->glRenderTable.SecondaryColor3bvEXT =
4235 (PFNGLSECONDARYCOLOR3BVEXTPROC)
4236 glitz_context_get_proc_address (pContext->context,
4237 "glSecondaryColor3bvEXT");
4238 pContext->glRenderTable.SecondaryColor3dvEXT =
4239 (PFNGLSECONDARYCOLOR3DVEXTPROC)
4240 glitz_context_get_proc_address (pContext->context,
4241 "glSecondaryColor3dvEXT");
4242 pContext->glRenderTable.SecondaryColor3fvEXT =
4243 (PFNGLSECONDARYCOLOR3FVEXTPROC)
4244 glitz_context_get_proc_address (pContext->context,
4245 "glSecondaryColor3fvEXT");
4246 pContext->glRenderTable.SecondaryColor3ivEXT =
4247 (PFNGLSECONDARYCOLOR3IVEXTPROC)
4248 glitz_context_get_proc_address (pContext->context,
4249 "glSecondaryColor3ivEXT");
4250 pContext->glRenderTable.SecondaryColor3svEXT =
4251 (PFNGLSECONDARYCOLOR3SVEXTPROC)
4252 glitz_context_get_proc_address (pContext->context,
4253 "glSecondaryColor3svEXT");
4254 pContext->glRenderTable.SecondaryColor3ubvEXT =
4255 (PFNGLSECONDARYCOLOR3UBVEXTPROC)
4256 glitz_context_get_proc_address (pContext->context,
4257 "glSecondaryColor3ubvEXT");
4258 pContext->glRenderTable.SecondaryColor3uivEXT =
4259 (PFNGLSECONDARYCOLOR3UIVEXTPROC)
4260 glitz_context_get_proc_address (pContext->context,
4261 "glSecondaryColor3uivEXT");
4262 pContext->glRenderTable.SecondaryColor3usvEXT =
4263 (PFNGLSECONDARYCOLOR3USVEXTPROC)
4264 glitz_context_get_proc_address (pContext->context,
4265 "glSecondaryColor3usvEXT");
4266 pContext->glRenderTable.SecondaryColorPointerEXT =
4267 (PFNGLSECONDARYCOLORPOINTEREXTPROC)
4268 glitz_context_get_proc_address (pContext->context,
4269 "glSecondaryColorPointerEXT");
4272 if (strstr (extensions, "GL_NV_point_sprite"))
4274 pContext->glRenderTable.PointParameteriNV =
4275 (PFNGLPOINTPARAMETERINVPROC)
4276 glitz_context_get_proc_address (pContext->context,
4277 "glPointParameteriNV");
4278 pContext->glRenderTable.PointParameterivNV =
4279 (PFNGLPOINTPARAMETERIVNVPROC)
4280 glitz_context_get_proc_address (pContext->context,
4281 "glPointParameterivNV");
4284 if (strstr (extensions, "GL_EXT_stencil_two_side"))
4286 pContext->glRenderTable.ActiveStencilFaceEXT =
4287 (PFNGLACTIVESTENCILFACEEXTPROC)
4288 glitz_context_get_proc_address (pContext->context,
4289 "glActiveStencilFaceEXT");
4292 if (strstr (extensions, "GL_EXT_framebuffer_object"))
4294 pContext->glRenderTable.IsRenderbufferEXT =
4295 (PFNGLISRENDERBUFFEREXTPROC)
4296 glitz_context_get_proc_address (pContext->context,
4297 "glIsRenderbufferEXT");
4298 pContext->glRenderTable.BindRenderbufferEXT =
4299 (PFNGLBINDRENDERBUFFEREXTPROC)
4300 glitz_context_get_proc_address (pContext->context,
4301 "glBindRenderbufferEXT");
4302 pContext->glRenderTable.DeleteRenderbuffersEXT =
4303 (PFNGLDELETERENDERBUFFERSEXTPROC)
4304 glitz_context_get_proc_address (pContext->context,
4305 "glDeleteRenderbuffersEXT");
4306 pContext->glRenderTable.GenRenderbuffersEXT =
4307 (PFNGLGENRENDERBUFFERSEXTPROC)
4308 glitz_context_get_proc_address (pContext->context,
4309 "glGenRenderbuffersEXT");
4310 pContext->glRenderTable.RenderbufferStorageEXT =
4311 (PFNGLRENDERBUFFERSTORAGEEXTPROC)
4312 glitz_context_get_proc_address (pContext->context,
4313 "glRenderbufferStorageEXT");
4314 pContext->glRenderTable.GetRenderbufferParameterivEXT =
4315 (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)
4316 glitz_context_get_proc_address (pContext->context,
4317 "glGetRenderbufferParameterivEXT");
4318 pContext->glRenderTable.IsFramebufferEXT =
4319 (PFNGLISFRAMEBUFFEREXTPROC)
4320 glitz_context_get_proc_address (pContext->context,
4321 "glIsFramebufferEXT");
4322 pContext->glRenderTable.BindFramebufferEXT =
4323 (PFNGLBINDFRAMEBUFFEREXTPROC)
4324 glitz_context_get_proc_address (pContext->context,
4325 "glBindFramebufferEXT");
4326 pContext->glRenderTable.DeleteFramebuffersEXT =
4327 (PFNGLDELETEFRAMEBUFFERSEXTPROC)
4328 glitz_context_get_proc_address (pContext->context,
4329 "glDeleteFramebuffersEXT");
4330 pContext->glRenderTable.GenFramebuffersEXT =
4331 (PFNGLGENFRAMEBUFFERSEXTPROC)
4332 glitz_context_get_proc_address (pContext->context,
4333 "glGenFramebuffersEXT");
4334 pContext->glRenderTable.CheckFramebufferStatusEXT =
4335 (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
4336 glitz_context_get_proc_address (pContext->context,
4337 "glCheckFramebufferStatusEXT");
4338 pContext->glRenderTable.FramebufferTexture1DEXT =
4339 (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)
4340 glitz_context_get_proc_address (pContext->context,
4341 "glFramebufferTexture1DEXT");
4342 pContext->glRenderTable.FramebufferTexture2DEXT =
4343 (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)
4344 glitz_context_get_proc_address (pContext->context,
4345 "glFramebufferTexture2DEXT");
4346 pContext->glRenderTable.FramebufferTexture3DEXT =
4347 (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)
4348 glitz_context_get_proc_address (pContext->context,
4349 "glFramebufferTexture3DEXT");
4350 pContext->glRenderTable.FramebufferRenderbufferEXT =
4351 (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)
4352 glitz_context_get_proc_address (pContext->context,
4353 "glFramebufferRenderbufferEXT");
4354 pContext->glRenderTable.GetFramebufferAttachmentParameterivEXT =
4355 (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)
4356 glitz_context_get_proc_address (pContext->context,
4357 "glGetFramebufferAttachment"
4358 "ParameterivEXT");
4359 pContext->glRenderTable.GenerateMipmapEXT =
4360 (PFNGLGENERATEMIPMAPEXTPROC)
4361 glitz_context_get_proc_address (pContext->context,
4362 "glGenerateMipmapEXT");
4366 static void
4367 xglSetCurrentContext (xglGLContextPtr pContext)
4369 cctx = pContext;
4371 glitz_context_make_current (cctx->context, cctx->pDrawBuffer->drawable);
4373 GlxSetRenderTables (&cctx->glRenderTable);
4376 static void
4377 xglFreeContext (xglGLContextPtr pContext)
4379 int i;
4381 pContext->refcnt--;
4382 if (pContext->shared == pContext)
4383 pContext->refcnt--;
4385 if (pContext->refcnt)
4386 return;
4388 if (pContext->shared != pContext)
4389 xglFreeContext (pContext->shared);
4391 if (pContext->texObjects)
4393 xglTexObjPtr pTexObj;
4394 GLuint key;
4396 do {
4397 key = xglHashFirstEntry (pContext->texObjects);
4398 if (key)
4400 pTexObj = (xglTexObjPtr) xglHashLookup (pContext->texObjects,
4401 key);
4402 if (pTexObj)
4403 xglUnrefTexObj (pTexObj);
4405 xglHashRemove (pContext->texObjects, key);
4407 } while (key);
4409 xglDeleteHashTable (pContext->texObjects);
4412 if (pContext->displayLists)
4414 xglDisplayListPtr pDisplayList;
4415 GLuint key;
4417 do {
4418 key = xglHashFirstEntry (pContext->displayLists);
4419 if (key)
4421 pDisplayList = (xglDisplayListPtr)
4422 xglHashLookup (pContext->displayLists, key);
4423 if (pDisplayList)
4424 xglDestroyList (pDisplayList);
4426 xglHashRemove (pContext->displayLists, key);
4428 } while (key);
4430 xglDeleteHashTable (pContext->displayLists);
4433 for (i = 0; i < pContext->maxTexUnits; i++)
4435 xglUnrefTexObj (pContext->attrib.texUnits[i].p1D);
4436 xglUnrefTexObj (pContext->attrib.texUnits[i].p2D);
4437 xglUnrefTexObj (pContext->attrib.texUnits[i].p3D);
4438 xglUnrefTexObj (pContext->attrib.texUnits[i].pRect);
4439 xglUnrefTexObj (pContext->attrib.texUnits[i].pCubeMap);
4442 if (pContext->groupList)
4443 glDeleteLists (pContext->groupList, 1);
4445 if (pContext->context)
4446 glitz_context_destroy (pContext->context);
4448 if (pContext->versionString)
4449 xfree (pContext->versionString);
4451 xfree (pContext);
4454 static GLboolean
4455 xglDestroyContext (__GLcontext *gc)
4457 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4458 __GLinterface *iface = pContext->mIface;
4460 xglFreeContext (pContext);
4462 if (!iface)
4463 return GL_TRUE;
4465 return (*iface->exports.destroyContext) ((__GLcontext *) iface);
4468 static GLboolean
4469 xglLoseCurrent (__GLcontext *gc)
4471 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4472 __GLinterface *iface = pContext->mIface;
4474 GlxFlushContextCache ();
4475 GlxSetRenderTables (0);
4477 if (!iface)
4478 return GL_TRUE;
4480 return (*iface->exports.loseCurrent) ((__GLcontext *) iface);
4483 static GLboolean
4484 xglMakeCurrent (__GLcontext *gc)
4486 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4487 __GLinterface *iface = &pContext->iface;
4488 __GLinterface *mIface = pContext->mIface;
4489 __GLdrawablePrivate *drawPriv = iface->imports.getDrawablePrivate (gc);
4490 __GLdrawablePrivate *readPriv = iface->imports.getReadablePrivate (gc);
4491 xglGLBufferPtr pDrawBufferPriv = drawPriv->private;
4492 xglGLBufferPtr pReadBufferPriv = readPriv->private;
4493 GLboolean status = GL_TRUE;
4495 if (pReadBufferPriv->pDrawable && pDrawBufferPriv->pDrawable)
4497 XID values[2] = { ClipByChildren, 0 };
4498 int status;
4500 #ifdef COMPOSITE
4501 /* XXX: temporary hack for root window drawing using
4502 IncludeInferiors */
4503 if (pDrawBufferPriv->pDrawable->type == DRAWABLE_WINDOW &&
4504 (!((WindowPtr) (pDrawBufferPriv->pDrawable))->parent))
4505 values[0] = IncludeInferiors;
4506 #endif
4508 /* this happens if client previously used this context with a buffer
4509 not supported by the native GL stack */
4510 if (!pContext->context)
4511 return GL_FALSE;
4513 /* XXX: GLX_SGI_make_current_read disabled for now */
4514 if (pDrawBufferPriv != pReadBufferPriv)
4515 return GL_FALSE;
4517 if (!pReadBufferPriv->pGC)
4518 pReadBufferPriv->pGC =
4519 CreateGC (pReadBufferPriv->pDrawable,
4520 GCSubwindowMode | GCGraphicsExposures, values,
4521 &status);
4523 ValidateGC (pReadBufferPriv->pDrawable, pReadBufferPriv->pGC);
4525 if (!pDrawBufferPriv->pGC)
4526 pDrawBufferPriv->pGC =
4527 CreateGC (pDrawBufferPriv->pDrawable,
4528 GCSubwindowMode | GCGraphicsExposures, values,
4529 &status);
4531 ValidateGC (pDrawBufferPriv->pDrawable, pDrawBufferPriv->pGC);
4533 pReadBufferPriv->pPixmap = (PixmapPtr) 0;
4534 pDrawBufferPriv->pPixmap = (PixmapPtr) 0;
4536 pContext->pReadBuffer = pReadBufferPriv;
4537 pContext->pDrawBuffer = pDrawBufferPriv;
4539 pContext->readPriv = readPriv;
4540 pContext->drawPriv = drawPriv;
4542 /* from now on this context can only be used with native GL stack */
4543 if (mIface)
4545 (*mIface->exports.destroyContext) ((__GLcontext *) mIface);
4546 pContext->mIface = NULL;
4549 else
4551 /* this happens if client previously used this context with a buffer
4552 supported by the native GL stack */
4553 if (!mIface)
4554 return GL_FALSE;
4556 drawPriv->private = pDrawBufferPriv->private;
4557 readPriv->private = pReadBufferPriv->private;
4559 status = (*mIface->exports.makeCurrent) ((__GLcontext *) mIface);
4561 drawPriv->private = pDrawBufferPriv;
4562 readPriv->private = pReadBufferPriv;
4564 /* from now on this context can not be used with native GL stack */
4565 if (status == GL_TRUE && pContext->context)
4567 glitz_context_destroy (pContext->context);
4568 pContext->context = NULL;
4572 return status;
4575 static GLboolean
4576 xglShareContext (__GLcontext *gc,
4577 __GLcontext *gcShare)
4579 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4580 xglGLContextPtr pContextShare = (xglGLContextPtr) gcShare;
4581 __GLinterface *iface = pContext->mIface;
4582 __GLinterface *ifaceShare = pContextShare->mIface;
4584 if (!iface || !ifaceShare)
4585 return GL_TRUE;
4587 return (*iface->exports.shareContext) ((__GLcontext *) iface,
4588 (__GLcontext *) ifaceShare);
4591 static GLboolean
4592 xglCopyContext (__GLcontext *dst,
4593 const __GLcontext *src,
4594 GLuint mask)
4596 xglGLContextPtr pDst = (xglGLContextPtr) dst;
4597 xglGLContextPtr pSrc = (xglGLContextPtr) src;
4598 const __GLcontext *srcCtx = (const __GLcontext *) pSrc->mIface;
4599 __GLinterface *dstIface = (__GLinterface *) pDst->mIface;
4600 GLboolean status = GL_TRUE;
4602 if (pSrc->context && pDst->context)
4603 glitz_context_copy (pSrc->context, pDst->context, mask);
4604 else
4605 status = GL_FALSE;
4607 if (dstIface && srcCtx)
4608 status = (*dstIface->exports.copyContext) ((__GLcontext *) dstIface,
4609 srcCtx,
4610 mask);
4612 return status;
4615 static Bool
4616 xglResizeBuffer (__GLdrawablePrivate *glPriv,
4617 int x,
4618 int y,
4619 unsigned int width,
4620 unsigned int height)
4622 xglGLBufferPtr pBufferPriv = glPriv->private;
4623 DrawablePtr pDrawable = pBufferPriv->pDrawable;
4625 XGL_SCREEN_PRIV (pDrawable->pScreen);
4626 XGL_DRAWABLE_PIXMAP (pBufferPriv->pDrawable);
4628 if (pPixmap != pScreenPriv->pScreenPixmap)
4630 if (!xglCreatePixmapSurface (pPixmap))
4631 return FALSE;
4633 if (pBufferPriv->drawable == pScreenPriv->drawable)
4635 if (pBufferPriv->backSurface)
4636 glitz_surface_destroy (pBufferPriv->backSurface);
4638 glitz_drawable_destroy (pBufferPriv->drawable);
4640 pBufferPriv->drawable = NULL;
4641 pBufferPriv->backSurface = NULL;
4644 if (pBufferPriv->drawable)
4646 glitz_drawable_update_size (pBufferPriv->drawable,
4647 pPixmap->drawable.width,
4648 pPixmap->drawable.height);
4650 else
4652 glitz_drawable_format_t *format;
4654 format = pBufferPriv->pVisual->format.drawable;
4655 if (pBufferPriv->pVisual->pbuffer)
4657 pBufferPriv->drawable =
4658 glitz_create_pbuffer_drawable (pScreenPriv->drawable,
4659 format,
4660 pPixmap->drawable.width,
4661 pPixmap->drawable.height);
4663 else
4665 pBufferPriv->drawable =
4666 glitz_create_drawable (pScreenPriv->drawable, format,
4667 pPixmap->drawable.width,
4668 pPixmap->drawable.height);
4670 if (!pBufferPriv->drawable)
4671 return FALSE;
4673 if (format->doublebuffer)
4675 glitz_format_t *backFormat;
4677 backFormat = pBufferPriv->pVisual->format.surface;
4679 pBufferPriv->backSurface =
4680 glitz_surface_create (pScreenPriv->drawable, backFormat,
4681 pPixmap->drawable.width,
4682 pPixmap->drawable.height,
4683 0, NULL);
4684 if (pBufferPriv->backSurface)
4685 glitz_surface_attach (pBufferPriv->backSurface,
4686 pBufferPriv->drawable,
4687 GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
4692 else
4694 glitz_drawable_reference (pScreenPriv->drawable);
4696 if (pBufferPriv->backSurface)
4697 glitz_surface_destroy (pBufferPriv->backSurface);
4699 if (pBufferPriv->drawable)
4700 glitz_drawable_destroy (pBufferPriv->drawable);
4702 pBufferPriv->drawable = pScreenPriv->drawable;
4703 pBufferPriv->backSurface = NULL;
4706 ValidateGC (pDrawable, pBufferPriv->pGC);
4708 return TRUE;
4711 static GLboolean
4712 xglForceCurrent (__GLcontext *gc)
4714 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4715 __GLinterface *iface = pContext->mIface;
4716 GLboolean status = GL_TRUE;
4718 if (pContext && pContext->context)
4720 __GLdrawablePrivate *readPriv, *drawPriv;
4722 readPriv = pContext->readPriv;
4723 drawPriv = pContext->drawPriv;
4725 drawPriv->lockDP (drawPriv, gc);
4726 if (readPriv != drawPriv)
4727 readPriv->lockDP (readPriv, gc);
4729 cctx = pContext;
4731 if (cctx->pReadBuffer->pDrawable && cctx->pDrawBuffer->pDrawable)
4733 DrawablePtr pDrawable = cctx->pReadBuffer->pDrawable;
4734 PixmapPtr pReadPixmap, pDrawPixmap;
4736 XGL_SCREEN_PRIV (pDrawable->pScreen);
4738 if (pDrawable->type != DRAWABLE_PIXMAP)
4740 pReadPixmap = XGL_GET_WINDOW_PIXMAP (pDrawable);
4741 cctx->pReadBuffer->screenX = __XGL_OFF_X_WIN (pReadPixmap);
4742 cctx->pReadBuffer->screenY = __XGL_OFF_Y_WIN (pReadPixmap);
4743 cctx->pReadBuffer->xOff = pDrawable->x +
4744 __XGL_OFF_X_WIN (pReadPixmap);
4745 cctx->pReadBuffer->yOff = pReadPixmap->drawable.height -
4746 ((pDrawable->y + __XGL_OFF_Y_WIN (pReadPixmap)) +
4747 pDrawable->height);
4748 cctx->pReadBuffer->yFlip = pReadPixmap->drawable.height;
4750 else
4752 pReadPixmap = (PixmapPtr) pDrawable;
4753 cctx->pReadBuffer->screenX = cctx->pReadBuffer->screenY = 0;
4754 cctx->pReadBuffer->xOff = cctx->pReadBuffer->yOff = 0;
4755 cctx->pReadBuffer->yFlip = pDrawable->height;
4758 pDrawable = cctx->pDrawBuffer->pDrawable;
4759 if (pDrawable->type != DRAWABLE_PIXMAP)
4761 pDrawPixmap = XGL_GET_WINDOW_PIXMAP (pDrawable);
4762 cctx->pDrawBuffer->screenX = __XGL_OFF_X_WIN (pDrawPixmap);
4763 cctx->pDrawBuffer->screenY = __XGL_OFF_Y_WIN (pDrawPixmap);
4764 cctx->pDrawBuffer->xOff = pDrawable->x +
4765 __XGL_OFF_X_WIN (pDrawPixmap);
4766 cctx->pDrawBuffer->yOff = pDrawPixmap->drawable.height -
4767 ((pDrawable->y + __XGL_OFF_Y_WIN (pDrawPixmap)) +
4768 pDrawable->height);
4769 cctx->pDrawBuffer->yFlip = pDrawPixmap->drawable.height;
4771 else
4773 pDrawPixmap = (PixmapPtr) pDrawable;
4774 cctx->pDrawBuffer->screenX = cctx->pDrawBuffer->screenY = 0;
4775 cctx->pDrawBuffer->xOff = cctx->pDrawBuffer->yOff = 0;
4776 cctx->pDrawBuffer->yFlip = pDrawable->height;
4779 /* buffer changed */
4780 if (cctx->pDrawBuffer->pPixmap != pDrawPixmap ||
4781 cctx->pReadBuffer->pPixmap != pReadPixmap)
4783 if (!xglResizeBuffer (drawPriv,
4784 pDrawable->x,
4785 pDrawable->y,
4786 pDrawable->width,
4787 pDrawable->height))
4789 drawPriv->unlockDP (drawPriv);
4790 if (readPriv != drawPriv)
4791 readPriv->unlockDP (readPriv);
4793 return FALSE;
4796 if (!xglResizeBuffer (readPriv,
4797 cctx->pReadBuffer->pDrawable->x,
4798 cctx->pReadBuffer->pDrawable->y,
4799 cctx->pReadBuffer->pDrawable->width,
4800 cctx->pReadBuffer->pDrawable->height))
4802 drawPriv->unlockDP (drawPriv);
4803 if (readPriv != drawPriv)
4804 readPriv->unlockDP (readPriv);
4806 return FALSE;
4809 cctx->pReadBuffer->pPixmap = pReadPixmap;
4810 cctx->pDrawBuffer->pPixmap = pDrawPixmap;
4813 if (!xglSyncSurface (pContext->pDrawBuffer->pDrawable))
4815 drawPriv->unlockDP (drawPriv);
4816 if (readPriv != drawPriv)
4817 readPriv->unlockDP (readPriv);
4819 return FALSE;
4822 if (pDrawPixmap != pScreenPriv->pScreenPixmap)
4824 XGL_PIXMAP_PRIV (pDrawPixmap);
4826 glitz_surface_attach (pPixmapPriv->surface,
4827 pContext->pDrawBuffer->drawable,
4828 GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
4830 if (pPixmapPriv->target)
4831 pPixmapPriv->target = xglPixmapTargetOut;
4834 xglSetCurrentContext (pContext);
4836 if (cctx->needInit)
4838 int i;
4840 xglInitExtensions (cctx);
4842 glGetIntegerv (GL_MAX_LIST_NESTING, &cctx->maxListNesting);
4843 glGetIntegerv (GL_MAX_ATTRIB_STACK_DEPTH,
4844 &cctx->maxAttribStackDepth);
4845 if (cctx->maxAttribStackDepth > XGL_MAX_ATTRIB_STACK_DEPTH)
4846 cctx->maxAttribStackDepth = XGL_MAX_ATTRIB_STACK_DEPTH;
4848 cctx->attrib.scissorTest = GL_FALSE;
4849 cctx->attrib.scissor.x = cctx->attrib.scissor.y = 0;
4850 cctx->attrib.scissor.width =
4851 cctx->pDrawBuffer->pDrawable->width;
4852 cctx->attrib.scissor.height =
4853 cctx->pDrawBuffer->pDrawable->height;
4854 cctx->attrib.viewport = cctx->attrib.scissor;
4856 cctx->activeTexUnit = 0;
4858 for (i = 0; i < cctx->maxTexUnits; i++)
4860 cctx->attrib.texUnits[i].enabled = 0;
4862 cctx->attrib.texUnits[i].p1D = NULL;
4863 cctx->attrib.texUnits[i].p2D = NULL;
4864 cctx->attrib.texUnits[i].p3D = NULL;
4865 cctx->attrib.texUnits[i].pRect = NULL;
4866 cctx->attrib.texUnits[i].pCubeMap = NULL;
4869 glEnable (GL_SCISSOR_TEST);
4871 cctx->needInit = FALSE;
4874 /* update viewport and raster position */
4875 if (cctx->pDrawBuffer->xOff != cctx->drawXoff ||
4876 cctx->pDrawBuffer->yOff != cctx->drawYoff)
4878 glViewport (cctx->attrib.viewport.x + cctx->pDrawBuffer->xOff,
4879 cctx->attrib.viewport.y + cctx->pDrawBuffer->yOff,
4880 cctx->attrib.viewport.width,
4881 cctx->attrib.viewport.height);
4883 glBitmap (0, 0, 0, 0,
4884 cctx->pDrawBuffer->xOff - cctx->drawXoff,
4885 cctx->pDrawBuffer->yOff - cctx->drawYoff,
4886 NULL);
4888 cctx->drawXoff = cctx->pDrawBuffer->xOff;
4889 cctx->drawYoff = cctx->pDrawBuffer->yOff;
4892 xglDrawBuffer (cctx->attrib.drawBuffer);
4893 xglReadBuffer (cctx->attrib.readBuffer);
4895 else
4897 xglSetCurrentContext (pContext);
4900 drawPriv->unlockDP (drawPriv);
4901 if (readPriv != drawPriv)
4902 readPriv->unlockDP (readPriv);
4904 else
4906 cctx = NULL;
4907 status = (*iface->exports.forceCurrent) ((__GLcontext *) iface);
4910 return status;
4913 static GLboolean
4914 xglNotifyResize (__GLcontext *gc)
4916 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4917 __GLinterface *iface = pContext->mIface;
4919 if (!iface)
4920 return GL_TRUE;
4922 return (*iface->exports.notifyResize) ((__GLcontext *) iface);
4925 static void
4926 xglNotifyDestroy (__GLcontext *gc)
4928 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4929 __GLinterface *iface = pContext->mIface;
4931 pContext->pReadBuffer->pDrawable = 0;
4932 pContext->pDrawBuffer->pDrawable = 0;
4934 if (iface)
4935 (*iface->exports.notifyDestroy) ((__GLcontext *) iface);
4938 static void
4939 xglNotifySwapBuffers (__GLcontext *gc)
4941 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4942 __GLinterface *iface = pContext->mIface;
4944 if (iface)
4945 (*iface->exports.notifySwapBuffers) ((__GLcontext *) iface);
4948 static struct __GLdispatchStateRec *
4949 xglDispatchExec (__GLcontext *gc)
4951 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4952 __GLinterface *iface = pContext->mIface;
4954 if (!iface)
4955 return NULL;
4957 return (*iface->exports.dispatchExec) ((__GLcontext *) iface);
4960 static void
4961 xglBeginDispatchOverride (__GLcontext *gc)
4963 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4964 __GLinterface *iface = pContext->mIface;
4966 if (iface)
4967 (*iface->exports.beginDispatchOverride) ((__GLcontext *) iface);
4970 static void
4971 xglEndDispatchOverride (__GLcontext *gc)
4973 xglGLContextPtr pContext = (xglGLContextPtr) gc;
4974 __GLinterface *iface = pContext->mIface;
4976 if (iface)
4977 (*iface->exports.endDispatchOverride) ((__GLcontext *) iface);
4980 static void
4981 xglLoseCurrentContext (void *closure)
4983 if (closure == cctx)
4985 cctx = NULL;
4987 GlxFlushContextCache ();
4988 GlxSetRenderTables (0);
4992 static __GLinterface *
4993 xglCreateContext (__GLimports *imports,
4994 __GLcontextModes *modes,
4995 __GLinterface *shareGC)
4997 glitz_drawable_format_t *format;
4998 xglGLContextPtr pShareContext = (xglGLContextPtr) shareGC;
4999 xglGLContextPtr pContext;
5000 __GLinterface *shareIface = NULL;
5001 __GLinterface *iface;
5002 __GLXcontext *glxCtx = (__GLXcontext *) imports->other;
5004 XGL_SCREEN_PRIV (glxCtx->pScreen);
5006 pContext = xalloc (sizeof (xglGLContextRec));
5007 if (!pContext)
5008 return NULL;
5010 format = glitz_drawable_get_format (pScreenPriv->drawable);
5011 pContext->context = glitz_context_create (pScreenPriv->drawable, format);
5012 glitz_context_set_user_data (pContext->context, pContext,
5013 xglLoseCurrentContext);
5015 pContext->glRenderTable = __glNativeRenderTable;
5016 pContext->needInit = TRUE;
5017 pContext->versionString = NULL;
5018 pContext->errorValue = GL_NO_ERROR;
5019 pContext->shared = NULL;
5020 pContext->list = 0;
5021 pContext->groupList = 0;
5022 pContext->beginCnt = 0;
5023 pContext->nAttribStack = 0;
5024 pContext->refcnt = 1;
5025 pContext->doubleBuffer = glxCtx->modes->doubleBufferMode;
5026 pContext->depthBits = glxCtx->modes->depthBits;
5027 pContext->stencilBits = glxCtx->modes->stencilBits;
5028 pContext->drawXoff = 0;
5029 pContext->drawYoff = 0;
5030 pContext->maxTexUnits = 0;
5032 if (pContext->doubleBuffer)
5034 pContext->attrib.drawBuffer = GL_BACK;
5035 pContext->attrib.readBuffer = GL_BACK;
5037 else
5039 pContext->attrib.drawBuffer = GL_FRONT;
5040 pContext->attrib.readBuffer = GL_FRONT;
5043 pContext->attrib.scissorTest = GL_FALSE;
5045 if (shareGC)
5047 pContext->texObjects = NULL;
5048 pContext->displayLists = NULL;
5050 pContext->shared = pShareContext->shared;
5051 shareIface = pShareContext->mIface;
5053 else
5055 pContext->texObjects = xglNewHashTable ();
5056 if (!pContext->texObjects)
5058 xglFreeContext (pContext);
5059 return NULL;
5062 pContext->displayLists = xglNewHashTable ();
5063 if (!pContext->displayLists)
5065 xglFreeContext (pContext);
5066 return NULL;
5069 pContext->shared = pContext;
5072 pContext->shared->refcnt++;
5074 iface = (*screenInfoPriv.createContext) (imports, modes, shareIface);
5075 if (!iface)
5077 xglFreeContext (pContext);
5078 return NULL;
5081 pContext->mIface = iface;
5082 pContext->iface.imports = *imports;
5084 pContext->iface.exports.destroyContext = xglDestroyContext;
5085 pContext->iface.exports.loseCurrent = xglLoseCurrent;
5086 pContext->iface.exports.makeCurrent = xglMakeCurrent;
5087 pContext->iface.exports.shareContext = xglShareContext;
5088 pContext->iface.exports.copyContext = xglCopyContext;
5089 pContext->iface.exports.forceCurrent = xglForceCurrent;
5090 pContext->iface.exports.notifyResize = xglNotifyResize;
5091 pContext->iface.exports.notifyDestroy = xglNotifyDestroy;
5092 pContext->iface.exports.notifySwapBuffers = xglNotifySwapBuffers;
5093 pContext->iface.exports.dispatchExec = xglDispatchExec;
5094 pContext->iface.exports.beginDispatchOverride = xglBeginDispatchOverride;
5095 pContext->iface.exports.endDispatchOverride = xglEndDispatchOverride;
5097 return (__GLinterface *) pContext;
5100 static GLboolean
5101 xglSwapBuffers (__GLXdrawablePrivate *glxPriv)
5103 __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
5104 xglGLBufferPtr pBufferPriv = glPriv->private;
5105 DrawablePtr pDrawable = pBufferPriv->pDrawable;
5106 GLboolean status = GL_TRUE;
5108 if (pDrawable)
5110 if (glPriv->modes->doubleBufferMode)
5112 glitz_surface_t *surface;
5113 int xOff, yOff;
5114 GCPtr pGC = pBufferPriv->pGC;
5115 BoxPtr pBox = REGION_RECTS (pGC->pCompositeClip);
5116 int nBox = REGION_NUM_RECTS (pGC->pCompositeClip);
5118 XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
5120 glitz_drawable_swap_buffer_region (pBufferPriv->drawable,
5121 xOff, yOff,
5122 (glitz_box_t *) pBox, nBox);
5124 xglAddBitDamage (pDrawable, pGC->pCompositeClip);
5125 DamageDamageRegion (pDrawable, pGC->pCompositeClip);
5126 REGION_EMPTY (pGC->pScreen, &pBufferPriv->damage);
5129 else if (pBufferPriv->private)
5131 glPriv->private = pBufferPriv->private;
5132 status = (*pBufferPriv->swapBuffers) (glxPriv);
5133 glPriv->private = pBufferPriv;
5136 return status;
5139 static GLboolean
5140 xglResizeBuffers (__GLdrawableBuffer *buffer,
5141 GLint x,
5142 GLint y,
5143 GLuint width,
5144 GLuint height,
5145 __GLdrawablePrivate *glPriv,
5146 GLuint bufferMask)
5148 xglGLBufferPtr pBufferPriv = glPriv->private;
5149 DrawablePtr pDrawable = pBufferPriv->pDrawable;
5150 GLboolean status = GL_TRUE;
5152 if (pDrawable)
5154 if (!xglResizeBuffer (glPriv, x, y, width, height))
5155 return GL_FALSE;
5157 else if (pBufferPriv->private)
5159 glPriv->private = pBufferPriv->private;
5160 status = (*pBufferPriv->resizeBuffers) (buffer,
5161 x, y, width, height,
5162 glPriv,
5163 bufferMask);
5164 glPriv->private = pBufferPriv;
5167 return status;
5170 static int
5171 xglBindBuffers (__GLXdrawablePrivate *glxPriv,
5172 int buffer)
5174 __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
5175 xglGLBufferPtr pBufferPriv = glPriv->private;
5177 if (cctx)
5179 xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit];
5180 xglTexObjPtr pTexObj = NULL;
5181 DrawablePtr pDrawable;
5183 /* XXX: front left buffer is only supported so far */
5184 if (buffer != GLX_FRONT_LEFT_EXT)
5185 return BadMatch;
5187 /* Must be a GLXpixmap */
5188 if (!glxPriv->pGlxPixmap)
5189 return BadDrawable;
5191 pDrawable = glxPriv->pGlxPixmap->pDraw;
5193 switch (glxPriv->texTarget) {
5194 case GLX_TEXTURE_RECTANGLE_EXT:
5195 pTexObj = pTexUnit->pRect;
5196 break;
5197 case GLX_TEXTURE_2D_EXT:
5198 pTexObj = pTexUnit->p2D;
5199 break;
5200 default:
5201 break;
5204 if (pTexObj)
5206 glitz_texture_object_t *object;
5208 XGL_SCREEN_PRIV (pDrawable->pScreen);
5209 XGL_DRAWABLE_PIXMAP (pDrawable);
5210 XGL_PIXMAP_PRIV (pPixmap);
5212 if (pPixmap == pScreenPriv->pScreenPixmap)
5213 return BadDrawable;
5215 object = glitz_texture_object_create (pPixmapPriv->surface);
5216 if (object)
5218 pPixmap->refcnt++;
5220 if (pTexObj->pPixmap)
5221 (*pDrawable->pScreen->DestroyPixmap) (pTexObj->pPixmap);
5223 if (pTexObj->object)
5224 glitz_texture_object_destroy (pTexObj->object);
5226 pTexObj->pPixmap = pPixmap;
5227 pTexObj->object = object;
5229 return Success;
5233 else if (pBufferPriv->private)
5235 int status;
5237 glPriv->private = pBufferPriv->private;
5238 status = (*pBufferPriv->bindBuffers) (glxPriv, buffer);
5239 glPriv->private = pBufferPriv;
5241 return status;
5244 return BadDrawable;
5247 static int
5248 xglReleaseBuffers (__GLXdrawablePrivate *glxPriv,
5249 int buffer)
5251 __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
5252 xglGLBufferPtr pBufferPriv = glPriv->private;
5254 if (cctx)
5256 xglTexObjPtr pTexObj;
5258 /* XXX: front left buffer is only supported so far */
5259 if (buffer != GLX_FRONT_LEFT_EXT)
5260 return BadMatch;
5262 /* Must be a GLXpixmap */
5263 if (glxPriv->pGlxPixmap)
5265 DrawablePtr pDrawable = glxPriv->pGlxPixmap->pDraw;
5267 XGL_DRAWABLE_PIXMAP (pDrawable);
5269 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p2D;
5270 if (pTexObj && pTexObj->pPixmap == pPixmap)
5272 (*pDrawable->pScreen->DestroyPixmap) (pTexObj->pPixmap);
5273 pTexObj->pPixmap = NULL;
5274 glitz_texture_object_destroy (pTexObj->object);
5275 pTexObj->object = NULL;
5277 return Success;
5279 else
5281 pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].pRect;
5282 if (pTexObj && pTexObj->pPixmap == pPixmap)
5284 (*pDrawable->pScreen->DestroyPixmap) (pTexObj->pPixmap);
5285 pTexObj->pPixmap = NULL;
5286 glitz_texture_object_destroy (pTexObj->object);
5287 pTexObj->object = NULL;
5289 return Success;
5294 else if (pBufferPriv->private)
5296 int status;
5298 glPriv->private = pBufferPriv->private;
5299 status = (*pBufferPriv->releaseBuffers) (glxPriv, buffer);
5300 glPriv->private = pBufferPriv;
5302 return status;
5305 return BadDrawable;
5307 static void
5308 xglFreeBuffers (__GLdrawablePrivate *glPriv)
5310 xglGLBufferPtr pBufferPriv = glPriv->private;
5312 glPriv->private = pBufferPriv->private;
5314 if (pBufferPriv->freeBuffers)
5315 (*pBufferPriv->freeBuffers) (glPriv);
5317 if (pBufferPriv->pGC)
5318 FreeGC (pBufferPriv->pGC, (GContext) 0);
5320 if (pBufferPriv->backSurface)
5321 glitz_surface_destroy (pBufferPriv->backSurface);
5323 if (pBufferPriv->drawable)
5324 glitz_drawable_destroy (pBufferPriv->drawable);
5326 xfree (pBufferPriv);
5329 static void
5330 xglCreateBuffer (__GLXdrawablePrivate *glxPriv)
5332 __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
5333 DrawablePtr pDrawable = glxPriv->pDraw;
5334 ScreenPtr pScreen = pDrawable->pScreen;
5335 xglGLBufferPtr pBufferPriv;
5336 xglVisualPtr v;
5338 XGL_SCREEN_PRIV (pScreen);
5339 XGL_DRAWABLE_PIXMAP (pDrawable);
5341 pBufferPriv = xalloc (sizeof (xglGLBufferRec));
5342 if (!pBufferPriv)
5343 FatalError ("xglCreateBuffer: No memory\n");
5345 pBufferPriv->pScreen = pScreen;
5346 pBufferPriv->pDrawable = NULL;
5347 pBufferPriv->pPixmap = NULL;
5348 pBufferPriv->pGC = NULL;
5350 pBufferPriv->swapBuffers = NULL;
5352 pBufferPriv->bindBuffers = NULL;
5353 pBufferPriv->releaseBuffers = NULL;
5355 pBufferPriv->resizeBuffers = NULL;
5356 pBufferPriv->private = NULL;
5357 pBufferPriv->freeBuffers = NULL;
5359 pBufferPriv->drawable = NULL;
5360 pBufferPriv->backSurface = NULL;
5362 REGION_INIT (pScreen, &pBufferPriv->damage, NullBox, 0);
5364 pBufferPriv->pVisual = 0;
5366 /* glx acceleration */
5367 if (pScreenPriv->accel.glx.enabled &&
5368 xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.glx.size))
5370 for (v = pScreenPriv->pGlxVisual; v; v = v->next)
5372 glitz_drawable_format_t *format;
5374 if (pScreenPriv->accel.glx.pbuffer != v->pbuffer)
5375 continue;
5377 format = v->format.drawable;
5378 if (!format)
5379 continue;
5381 if (format->color.red_size != glxPriv->modes->redBits ||
5382 format->color.green_size != glxPriv->modes->greenBits ||
5383 format->color.blue_size != glxPriv->modes->blueBits)
5384 continue;
5386 if (format->color.alpha_size < glxPriv->modes->alphaBits ||
5387 format->depth_size < glxPriv->modes->depthBits ||
5388 format->stencil_size < glxPriv->modes->stencilBits ||
5389 format->doublebuffer < glxPriv->modes->doubleBufferMode)
5390 continue;
5392 /* this is good enought for pbuffers */
5393 if (v->pbuffer)
5394 break;
5396 /* we want an exact match for non-pbuffer formats */
5397 if (format->color.alpha_size == glxPriv->modes->alphaBits &&
5398 format->depth_size == glxPriv->modes->depthBits &&
5399 format->stencil_size == glxPriv->modes->stencilBits &&
5400 format->doublebuffer == glxPriv->modes->doubleBufferMode)
5401 break;
5404 pBufferPriv->pVisual = v;
5407 if ((pDrawable->type == DRAWABLE_WINDOW)
5409 #ifdef COMPOSITE
5410 && (pBufferPriv->pVisual
5412 /* this is a root window, can't be redirected */
5413 || (!((WindowPtr) pDrawable)->parent))
5414 #endif
5418 pBufferPriv->pDrawable = pDrawable;
5420 else
5422 (*screenInfoPriv.createBuffer) (glxPriv);
5424 /* Wrap the swap buffers routine */
5425 pBufferPriv->swapBuffers = glxPriv->swapBuffers;
5427 /* Wrap the render texture routines */
5428 pBufferPriv->bindBuffers = glxPriv->bindBuffers;
5429 pBufferPriv->releaseBuffers = glxPriv->releaseBuffers;
5431 /* Wrap the front buffer's resize routine */
5432 pBufferPriv->resizeBuffers = glPriv->frontBuffer.resize;
5434 /* Save Xgl's private buffer structure */
5435 pBufferPriv->freeBuffers = glPriv->freePrivate;
5436 pBufferPriv->private = glPriv->private;
5439 glxPriv->texTarget = GLX_NO_TEXTURE_EXT;
5441 /* We enable render texture for all GLXPixmaps right now. Eventually, this
5442 should only be enabled when fbconfig attribute GLX_RENDER_TEXTURE_RGB or
5443 GLX_RENDER_TEXTURE_RGBA is set to TRUE. */
5444 if (pDrawable->type != DRAWABLE_WINDOW)
5446 XGL_DRAWABLE_PIXMAP (pDrawable);
5448 if (xglCreatePixmapSurface (pPixmap))
5450 glitz_texture_object_t *texture;
5452 XGL_PIXMAP_PRIV (pPixmap);
5454 texture = glitz_texture_object_create (pPixmapPriv->surface);
5455 if (texture)
5457 switch (glitz_texture_object_get_target (texture)) {
5458 case GLITZ_TEXTURE_TARGET_2D:
5459 glxPriv->texTarget = GLX_TEXTURE_2D_EXT;
5460 break;
5461 case GLITZ_TEXTURE_TARGET_RECT:
5462 glxPriv->texTarget = GLX_TEXTURE_RECTANGLE_EXT;
5463 break;
5466 glitz_texture_object_destroy (texture);
5471 glxPriv->swapBuffers = xglSwapBuffers;
5473 glxPriv->bindBuffers = xglBindBuffers;
5474 glxPriv->releaseBuffers = xglReleaseBuffers;
5475 glPriv->frontBuffer.resize = xglResizeBuffers;
5477 glPriv->private = (void *) pBufferPriv;
5478 glPriv->freePrivate = xglFreeBuffers;
5481 static Bool
5482 xglScreenProbe (int screen)
5484 ScreenPtr pScreen = screenInfo.screens[screen];
5485 xglVisualPtr pVisual;
5486 Bool status;
5487 int i;
5489 XGL_SCREEN_PRIV (pScreen);
5491 status = (*screenInfoPriv.screenProbe) (screen);
5493 /* Create Xgl GLX visuals */
5494 for (i = 0; i < __xglScreenInfoPtr->numVisuals; i++)
5496 pVisual = xglFindVisualWithId (pScreen, pScreen->visuals[i].vid);
5497 if (pVisual)
5499 glitz_drawable_format_t templ, *format, *screenFormat;
5500 unsigned long mask;
5502 templ.color = pVisual->format.surface->color;
5503 templ.depth_size = __xglScreenInfoPtr->modes[i].depthBits;
5504 templ.stencil_size = __xglScreenInfoPtr->modes[i].stencilBits;
5505 templ.doublebuffer = __xglScreenInfoPtr->modes[i].doubleBufferMode;
5506 templ.samples = 1;
5508 mask =
5509 GLITZ_FORMAT_FOURCC_MASK |
5510 GLITZ_FORMAT_RED_SIZE_MASK |
5511 GLITZ_FORMAT_GREEN_SIZE_MASK |
5512 GLITZ_FORMAT_BLUE_SIZE_MASK |
5513 GLITZ_FORMAT_ALPHA_SIZE_MASK |
5514 GLITZ_FORMAT_DEPTH_SIZE_MASK |
5515 GLITZ_FORMAT_STENCIL_SIZE_MASK |
5516 GLITZ_FORMAT_DOUBLEBUFFER_MASK |
5517 GLITZ_FORMAT_SAMPLES_MASK;
5519 format = glitz_find_drawable_format (pScreenPriv->drawable,
5520 mask, &templ, 0);
5521 if (format)
5523 xglVisualPtr v, new, *prev;
5525 new = xalloc (sizeof (xglVisualRec));
5526 if (new)
5528 new->next = 0;
5529 new->vid = pVisual->vid;
5530 new->pPixel = pVisual->pPixel;
5531 new->pbuffer = FALSE;
5533 new->format.surface = pVisual->format.surface;
5534 new->format.drawable = format;
5536 prev = &pScreenPriv->pGlxVisual;
5537 while ((v = *prev))
5538 prev = &v->next;
5540 *prev = new;
5544 /* use same drawable format as screen for pbuffers */
5545 screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
5546 templ.id = screenFormat->id;
5548 mask =
5549 GLITZ_FORMAT_ID_MASK |
5550 GLITZ_FORMAT_FOURCC_MASK |
5551 GLITZ_FORMAT_RED_SIZE_MASK |
5552 GLITZ_FORMAT_GREEN_SIZE_MASK |
5553 GLITZ_FORMAT_BLUE_SIZE_MASK |
5554 GLITZ_FORMAT_SAMPLES_MASK;
5556 format = glitz_find_pbuffer_format (pScreenPriv->drawable,
5557 mask, &templ, 0);
5558 if (format)
5560 xglVisualPtr v, new, *prev;
5562 new = xalloc (sizeof (xglVisualRec));
5563 if (new)
5565 new->next = 0;
5566 new->vid = pVisual->vid;
5567 new->pPixel = pVisual->pPixel;
5568 new->pbuffer = TRUE;
5570 new->format.surface = pVisual->format.surface;
5571 new->format.drawable = format;
5573 prev = &pScreenPriv->pGlxVisual;
5574 while ((v = *prev))
5575 prev = &v->next;
5577 *prev = new;
5583 /* Wrap createBuffer */
5584 if (__xglScreenInfoPtr->createBuffer != xglCreateBuffer)
5586 screenInfoPriv.createBuffer = __xglScreenInfoPtr->createBuffer;
5587 __xglScreenInfoPtr->createBuffer = xglCreateBuffer;
5590 /* Wrap createContext */
5591 if (__xglScreenInfoPtr->createContext != xglCreateContext)
5593 screenInfoPriv.createContext = __xglScreenInfoPtr->createContext;
5594 __xglScreenInfoPtr->createContext = xglCreateContext;
5597 return status;
5600 Bool
5601 xglInitVisualConfigs (ScreenPtr pScreen)
5603 miInitVisualsProcPtr initVisualsProc = NULL;
5604 VisualPtr visuals;
5605 int nvisuals;
5606 DepthPtr depths;
5607 int ndepths;
5608 int rootDepth;
5609 VisualID defaultVis;
5610 glitz_drawable_format_t *format;
5611 xglVisualPtr pVisual;
5612 __GLXvisualConfig *pConfig;
5613 xglGLXVisualConfigPtr pConfigPriv, *ppConfigPriv;
5614 XID *installedCmaps;
5615 ColormapPtr installedCmap;
5616 int numInstalledCmaps;
5617 int numConfig = 1;
5618 int bpp, i;
5620 XGL_SCREEN_PRIV (pScreen);
5622 if (xglScreenInfo.depth != 16 && xglScreenInfo.depth != 24)
5623 return FALSE;
5625 for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
5627 if (pVisual->pPixel->depth == xglScreenInfo.depth)
5628 break;
5631 if (!pVisual)
5632 return FALSE;
5634 bpp = pVisual->pPixel->masks.bpp;
5636 format = glitz_drawable_get_format (pScreenPriv->drawable);
5637 if (format->doublebuffer)
5638 numConfig *= 2;
5640 pConfig = xcalloc (sizeof (__GLXvisualConfig), numConfig);
5641 if (!pConfig)
5642 return FALSE;
5644 pConfigPriv = xcalloc (sizeof (xglGLXVisualConfigRec), numConfig);
5645 if (!pConfigPriv)
5647 xfree (pConfig);
5648 return FALSE;
5651 ppConfigPriv = xcalloc (sizeof (xglGLXVisualConfigPtr), numConfig);
5652 if (!ppConfigPriv)
5654 xfree (pConfigPriv);
5655 xfree (pConfig);
5656 return FALSE;
5659 installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
5660 if (!installedCmaps)
5662 xfree (ppConfigPriv);
5663 xfree (pConfigPriv);
5664 xfree (pConfig);
5665 return FALSE;
5668 for (i = 0; i < numConfig; i++)
5670 ppConfigPriv[i] = &pConfigPriv[i];
5672 pConfig[i].vid = (VisualID) (-1);
5673 pConfig[i].class = -1;
5674 pConfig[i].rgba = TRUE;
5676 pConfig[i].redSize = format->color.red_size;
5677 pConfig[i].greenSize = format->color.green_size;
5678 pConfig[i].blueSize = format->color.blue_size;
5679 pConfig[i].alphaSize = format->color.alpha_size;
5681 pConfig[i].redMask = pVisual->pPixel->masks.red_mask;
5682 pConfig[i].greenMask = pVisual->pPixel->masks.green_mask;
5683 pConfig[i].blueMask = pVisual->pPixel->masks.blue_mask;
5684 pConfig[i].alphaMask = pVisual->pPixel->masks.alpha_mask;
5686 if (i == 1)
5688 pConfig[i].doubleBuffer = FALSE;
5689 pConfig[i].depthSize = 0;
5690 pConfig[i].stencilSize = 0;
5692 else
5694 pConfig[i].doubleBuffer = TRUE;
5695 pConfig[i].depthSize = format->depth_size;
5696 pConfig[i].stencilSize = format->stencil_size;
5699 pConfig[i].stereo = FALSE;
5701 if (pScreen->rootDepth == 16)
5702 pConfig[i].bufferSize = 16;
5703 else
5704 pConfig[i].bufferSize = 32;
5706 pConfig[i].auxBuffers = 0;
5707 pConfig[i].level = 0;
5709 pConfig[i].visualRating = GLX_NONE;
5711 pConfig[i].transparentPixel = GLX_NONE;
5712 pConfig[i].transparentRed = 0;
5713 pConfig[i].transparentGreen = 0;
5714 pConfig[i].transparentBlue = 0;
5715 pConfig[i].transparentAlpha = 0;
5716 pConfig[i].transparentIndex = 0;
5719 GlxSetVisualConfigs (numConfig, pConfig, (void **) ppConfigPriv);
5721 /* Wrap screenProbe */
5722 if (__xglScreenInfoPtr->screenProbe != xglScreenProbe)
5724 screenInfoPriv.screenProbe = __xglScreenInfoPtr->screenProbe;
5725 __xglScreenInfoPtr->screenProbe = xglScreenProbe;
5728 visuals = pScreen->visuals;
5729 nvisuals = pScreen->numVisuals;
5730 depths = pScreen->allowedDepths;
5731 ndepths = pScreen->numDepths;
5732 rootDepth = pScreen->rootDepth;
5733 defaultVis = pScreen->rootVisual;
5735 /* Find installed colormaps */
5736 numInstalledCmaps = (*pScreen->ListInstalledColormaps) (pScreen,
5737 installedCmaps);
5739 GlxWrapInitVisuals (&initVisualsProc);
5740 GlxInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootDepth,
5741 &defaultVis, ((unsigned long) 1 << (bpp - 1)), 8, -1);
5743 /* Fix up any existing installed colormaps. */
5744 for (i = 0; i < numInstalledCmaps; i++)
5746 int j;
5748 installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP);
5749 if (!installedCmap)
5750 continue;
5752 j = installedCmap->pVisual - pScreen->visuals;
5753 installedCmap->pVisual = &visuals[j];
5756 pScreen->visuals = visuals;
5757 pScreen->numVisuals = nvisuals;
5758 pScreen->allowedDepths = depths;
5759 pScreen->numDepths = ndepths;
5760 pScreen->rootDepth = rootDepth;
5761 pScreen->rootVisual = defaultVis;
5763 #ifndef NGLXLOG
5764 xglInitGlxLog ();
5765 #endif
5767 xfree (installedCmaps);
5768 xfree (pConfigPriv);
5769 xfree (pConfig);
5771 return TRUE;