glxclient.h revision ad919c30df71bc191be6f107385638b456da6a0f
1ef8225444452a1486bd721f3285301fe84643b00Stephen Hines/*
2ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** License Applicability. Except to the extent portions of this file are
3ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** made subject to an alternative license as permitted in the SGI Free
4ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Software License B, Version 1.1 (the "License"), the contents of this
5ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** file are subject only to the provisions of the License. You may not use
6ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** this file except in compliance with the License. You may obtain a copy
7ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9ef8225444452a1486bd721f3285301fe84643b00Stephen Hines**
10ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** http://oss.sgi.com/projects/FreeB
11ef8225444452a1486bd721f3285301fe84643b00Stephen Hines**
12ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Note that, as provided in the License, the Software is distributed on an
13ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17ef8225444452a1486bd721f3285301fe84643b00Stephen Hines**
18ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Original Code. The Original Code is: OpenGL Sample Implementation,
19ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Copyright in any portions created by third parties is as indicated
22ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** elsewhere herein. All Rights Reserved.
23ef8225444452a1486bd721f3285301fe84643b00Stephen Hines**
24ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** Additional Notice Provisions: The application programming interfaces
25ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** established by SGI in conjunction with the Original Code are The
26ef8225444452a1486bd721f3285301fe84643b00Stephen Hines** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29** Window System(R) (Version 1.3), released October 19, 1998. This software
30** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31** published by SGI, but has not been independently verified as being
32** compliant with the OpenGL(R) version 1.2.1 Specification.
33*/
34/* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.21 2004/02/09 23:46:31 alanh Exp $ */
35
36/**
37 * \file glxclient.h
38 * Direct rendering support added by Precision Insight, Inc.
39 *
40 * \author Kevin E. Martin <kevin@precisioninsight.com>
41 */
42
43#ifndef _GLX_client_h_
44#define _GLX_client_h_
45#define NEED_REPLIES
46#define NEED_EVENTS
47#include <X11/Xproto.h>
48#include <X11/Xlibint.h>
49#define GLX_GLXEXT_PROTOTYPES
50#include <GL/glx.h>
51#include <GL/glxext.h>
52#include <string.h>
53#include <stdlib.h>
54#include <stdio.h>
55#ifdef WIN32
56#include <stdint.h>
57#endif
58#include "GL/glxint.h"
59#include "GL/glxproto.h"
60#include "GL/internal/glcore.h"
61#include "glapitable.h"
62#ifdef NEED_GL_FUNCS_WRAPPED
63#include "indirect.h"
64#endif
65#ifdef XTHREADS
66#include "Xthreads.h"
67#endif
68#ifdef GLX_BUILT_IN_XMESA
69#include "realglx.h"  /* just silences prototype warnings */
70#endif
71
72#define GLX_MAJOR_VERSION	1	/* current version numbers */
73#define GLX_MINOR_VERSION	4
74
75#define __GLX_MAX_TEXTURE_UNITS 32
76
77typedef struct __GLXcontextRec __GLXcontext;
78typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
79typedef struct _glapi_table __GLapi;
80
81/************************************************************************/
82
83#ifdef GLX_DIRECT_RENDERING
84
85#include <GL/internal/dri_interface.h>
86
87typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
88                                  int numConfigs, __GLXvisualConfig *config);
89
90typedef void *(*CreateNewScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
91    const __GLcontextModes * modes, const __DRIversion * ddx_version,
92    const __DRIversion * dri_version, const __DRIversion * drm_version,
93    const __DRIframebuffer * frame_buffer, void * pSAREA,
94    int fd, int internal_api_version, __GLcontextModes ** driver_modes);
95
96
97/**
98 * Display dependent methods.  This structure is initialized during the
99 * \c driCreateDisplay call.
100 */
101struct __DRIdisplayRec {
102    /**
103     * Method to destroy the private DRI display data.
104     */
105    void (*destroyDisplay)(Display *dpy, void *displayPrivate);
106
107    /**
108     * Methods to create the private DRI screen data and initialize the
109     * screen dependent methods.
110     * This is an array [indexed by screen number] of function pointers.
111     *
112     * \deprecated  This array of function pointers has been replaced by
113     *              \c __DRIdisplayRec::createNewScreen.
114     * \sa __DRIdisplayRec::createNewScreen
115     */
116    CreateScreenFunc * createScreen;
117
118    /**
119     * Opaque pointer to private per display direct rendering data.
120     * \c NULL if direct rendering is not supported on this display.
121     */
122    struct __DRIdisplayPrivateRec *private;
123
124    /**
125     * Array of pointers to methods to create and initialize the private DRI
126     * screen data.
127     *
128     * \sa __DRIdisplayRec::createScreen
129     */
130    CreateNewScreenFunc * createNewScreen;
131};
132
133
134/*
135** We keep a linked list of these structures, one per DRI device driver.
136*/
137struct __DRIdriverRec {
138   const char *name;
139   void *handle;
140   CreateScreenFunc createScreenFunc;
141   CreateNewScreenFunc createNewScreenFunc;
142   struct __DRIdriverRec *next;
143};
144
145/*
146** Function to create and DRI display data and initialize the display
147** dependent methods.
148*/
149extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
150
151extern  __DRIdriver *driGetDriver(Display *dpy, int scrNum);
152
153extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
154
155/*
156** Functions to obtain driver configuration information from a direct
157** rendering client application
158*/
159extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
160
161extern const char *glXGetDriverConfig (const char *driverName);
162
163#endif
164
165/************************************************************************/
166
167#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
168
169typedef struct __GLXpixelStoreModeRec {
170    GLboolean swapEndian;
171    GLboolean lsbFirst;
172    GLuint rowLength;
173    GLuint imageHeight;
174    GLuint imageDepth;
175    GLuint skipRows;
176    GLuint skipPixels;
177    GLuint skipImages;
178    GLuint alignment;
179} __GLXpixelStoreMode;
180
181/* The next 3 structures are deprecated.  Client state is no longer tracked
182 * using them.  They only remain to maintain the layout / structure offset of
183 * __GLXcontextRec.  In XFree86 5.0 they will be removed altogether.
184 */
185
186typedef struct __GLXvertexArrayPointerStateRecDEPRECATED {
187    GLboolean enable;
188    void (*proc)(const void *);
189    const GLubyte *ptr;
190    GLsizei skip;
191    GLint size;
192    GLenum type;
193    GLsizei stride;
194} __GLXvertexArrayPointerStateDEPRECATED;
195
196typedef struct __GLXvertArrayStateRecDEPRECATED {
197    __GLXvertexArrayPointerStateDEPRECATED vertex;
198    __GLXvertexArrayPointerStateDEPRECATED normal;
199    __GLXvertexArrayPointerStateDEPRECATED color;
200    __GLXvertexArrayPointerStateDEPRECATED index;
201    __GLXvertexArrayPointerStateDEPRECATED texCoord[__GLX_MAX_TEXTURE_UNITS];
202    __GLXvertexArrayPointerStateDEPRECATED edgeFlag;
203    GLint maxElementsVertices;
204    GLint maxElementsIndices;
205    GLint activeTexture;
206} __GLXvertArrayStateDEPRECATED;
207
208typedef struct __GLXattributeRecDEPRECATED {
209	GLuint mask;
210
211	/*
212	** Pixel storage state.  Most of the pixel store mode state is kept
213	** here and used by the client code to manage the packing and
214	** unpacking of data sent to/received from the server.
215	*/
216	__GLXpixelStoreMode storePack, storeUnpack;
217
218	/*
219	** Vertex Array storage state.  The vertex array component
220	** state is stored here and is used to manage the packing of
221	** DrawArrays data sent to the server.
222	*/
223	__GLXvertArrayStateDEPRECATED vertArray;
224} __GLXattributeDEPRECATED;
225
226typedef struct __GLXvertexArrayPointerStateRec {
227    void (*proc)(const void *);
228    void (*mtex_proc)(GLenum, const void *);
229    const GLubyte *ptr;
230    GLsizei skip;
231    GLint size;
232    GLenum type;
233    GLsizei stride;
234} __GLXvertexArrayPointerState;
235
236/**
237 * Define which entries of \c __GLXvertArrayState::arrays match which
238 * vertex arrays in the client-state vector.  These are only the one-of
239 * arrays.  See the \c __GLXvertArrayState::arrays documentation for more
240 * details.
241 *
242 * \sa __GLXvertArrayState
243 */
244enum {
245    edgeFlag_ARRAY,       /**< \c GL_EDGE_FLAG_ARRAY */
246    index_ARRAY,          /**< \c GL_INDEX_ARRAY */
247    fogCoord_ARRAY,       /**< \c GL_FOG_COORD_ARRAY */
248    secondaryColor_ARRAY, /**< \c GL_SECONDARY_COLOR_ARRAY */
249    color_ARRAY,          /**< \c GL_COLOR_ARRAY */
250    normal_ARRAY,         /**< \c GL_NORMAL_ARRAY */
251
252    /**
253     * \c GL_VERTEX_ARRAY \b must be last!  All of the code for emitting arrays
254     * and array elements is written based on the assumption that the vertex
255     * array is last.
256     */
257    vertex_ARRAY,
258
259    __GLX_MAX_ARRAYS      /**< Place holder entry. */
260};
261
262#define ENABLE_ARRAY(state,a) \
263    do { (state)->vertArray.enables |=  (1U << (a ## _ARRAY)); } while( 0 )
264#define DISABLE_ARRAY(state,a) \
265    do { (state)->vertArray.enables &= ~(1U << (a ## _ARRAY)); } while( 0 )
266#define IS_ARRAY_ENABLED_BY_INDEX(state, i) \
267    (((state)->vertArray.enables & (1U << (i))) != 0)
268#define IS_ARRAY_ENABLED(state, a) \
269    IS_ARRAY_ENABLED_BY_INDEX(state, a ## _ARRAY)
270
271#define ENABLE_TEXARRAY(state,a) \
272    do { (state)->vertArray.texture_enables |=  (1U << a); } while( 0 )
273#define DISABLE_TEXARRAY(state,a) \
274    do { (state)->vertArray.texture_enables &= ~(1U << a); } while( 0 )
275#define IS_TEXARRAY_ENABLED(state, a) \
276    (((state)->vertArray.texture_enables & (1U << a)) != 0)
277
278/**
279 * Client-side vertex array state.
280 */
281typedef struct __GLXvertArrayStateRec {
282    /**
283     * Which client-side arrays are enabled?  These are the flag bits for
284     * all of the non-texture coordinate arrays.
285     */
286    GLuint enables;
287
288    /**
289     * Which of the texture coordinate arrays are enabled?
290     */
291    GLuint texture_enables;
292
293    /**
294     * State for "one-of" arrays.  These are the arrays, such as
295     * GL_COLOR_ARRAY or GL_FOG_COORD_ARRAY for which there is only one
296     * array.  There are also "many-of" arrays, such as
297     * GL_TEXTURE_COORD_ARRAY.
298     */
299    __GLXvertexArrayPointerState arrays[__GLX_MAX_ARRAYS];
300
301    __GLXvertexArrayPointerState texCoord[__GLX_MAX_TEXTURE_UNITS];
302
303    GLint maxElementsVertices;
304    GLint maxElementsIndices;
305    GLint activeTexture;
306} __GLXvertArrayState;
307
308typedef struct __GLXattributeRec {
309	GLuint mask;
310
311	/*
312	** Pixel storage state.  Most of the pixel store mode state is kept
313	** here and used by the client code to manage the packing and
314	** unpacking of data sent to/received from the server.
315	*/
316	__GLXpixelStoreMode storePack, storeUnpack;
317
318	/*
319	** Vertex Array storage state.  The vertex array component
320	** state is stored here and is used to manage the packing of
321	** DrawArrays data sent to the server.
322	*/
323	__GLXvertArrayState vertArray;
324
325	/**
326	 * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
327	 * disabled?
328	 */
329	GLboolean NoDrawArraysProtocol;
330} __GLXattribute;
331
332typedef struct __GLXattributeMachineRec {
333	__GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
334	__GLXattribute **stackPointer;
335} __GLXattributeMachine;
336
337/**
338 * GLX state that needs to be kept on the client.  One of these records
339 * exist for each context that has been made current by this client.
340 */
341struct __GLXcontextRec {
342    /**
343     * \name Drawing command buffer.
344     *
345     * Drawing commands are packed into this buffer before being sent as a
346     * single GLX protocol request.  The buffer is sent when it overflows or
347     * is flushed by \c __glXFlushRenderBuffer.  \c pc is the next location
348     * in the buffer to be filled.  \c limit is described above in the buffer
349     * slop discussion.
350     *
351     * Commands that require large amounts of data to be transfered will
352     * also use this buffer to hold a header that describes the large
353     * command.
354     *
355     * These must be the first 6 fields since they are static initialized
356     * in the dummy context in glxext.c
357     */
358    /*@{*/
359    GLubyte *buf;
360    GLubyte *pc;
361    GLubyte *limit;
362    GLubyte *bufEnd;
363    GLint bufSize;
364    /*@}*/
365
366    /**
367     * The XID of this rendering context.  When the context is created a
368     * new XID is allocated.  This is set to None when the context is
369     * destroyed but is still current to some thread. In this case the
370     * context will be freed on next MakeCurrent.
371     */
372    XID xid;
373
374    /**
375     * The XID of the \c shareList context.
376     */
377    XID share_xid;
378
379    /**
380     * Visual id.
381     *
382     * \deprecated
383     * This filed has been largely been replaced by the \c mode field, but
384     * the work is not quite done.
385     */
386    VisualID vid;
387
388    /**
389     * Screen number.
390     */
391    GLint screen;
392
393    /**
394     * \c GL_TRUE if the context was created with ImportContext, which
395     * means the server-side context was created by another X client.
396     */
397    GLboolean imported;
398
399    /**
400     * The context tag returned by MakeCurrent when this context is made
401     * current. This tag is used to identify the context that a thread has
402     * current so that proper server context management can be done.  It is
403     * used for all context specific commands (i.e., \c Render, \c RenderLarge,
404     * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
405     * context)).
406     */
407    GLXContextTag currentContextTag;
408
409    /**
410     * \name Rendering mode
411     *
412     * The rendering mode is kept on the client as well as the server.
413     * When \c glRenderMode is called, the buffer associated with the
414     * previous rendering mode (feedback or select) is filled.
415     */
416    /*@{*/
417    GLenum renderMode;
418    GLfloat *feedbackBuf;
419    GLuint *selectBuf;
420    /*@}*/
421
422    /**
423     * This is \c GL_TRUE if the pixel unpack modes are such that an image
424     * can be unpacked from the clients memory by just copying.  It may
425     * still be true that the server will have to do some work.  This
426     * just promises that a straight copy will fetch the correct bytes.
427     */
428    GLboolean fastImageUnpack;
429
430    /**
431     * Fill newImage with the unpacked form of \c oldImage getting it
432     * ready for transport to the server.
433     */
434    void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
435		      GLenum, const GLvoid*, GLubyte*, GLubyte*);
436
437    /**
438     * \name Client side attribs.
439     */
440    /*@{*/
441    __GLXattributeDEPRECATED stateDEPRECATED;
442    __GLXattributeMachine attributes;
443    /*@}*/
444
445    /**
446     * Client side error code.  This is set when client side gl API
447     * routines need to set an error because of a bad enumerant or
448     * running out of memory, etc.
449     */
450    GLenum error;
451
452    /**
453     * Whether this context does direct rendering.
454     */
455    Bool isDirect;
456
457    /**
458     * \c dpy of current display for this context.  Will be \c NULL if not
459     * current to any display, or if this is the "dummy context".
460     */
461    Display *currentDpy;
462
463    /**
464     * The current drawable for this context.  Will be None if this
465     * context is not current to any drawable.  currentReadable is below.
466     */
467    GLXDrawable currentDrawable;
468
469    /**
470     * \name GL Constant Strings
471     *
472     * Constant strings that describe the server implementation
473     * These pertain to GL attributes, not to be confused with
474     * GLX versioning attributes.
475     */
476    /*@{*/
477    GLubyte *vendor;
478    GLubyte *renderer;
479    GLubyte *version;
480    GLubyte *extensions;
481    /*@}*/
482
483    /**
484     * Record the dpy this context was created on for later freeing
485     */
486    Display *createDpy;
487
488    /**
489     * Maximum small render command size.  This is the smaller of 64k and
490     * the size of the above buffer.
491     */
492    GLint maxSmallRenderCommandSize;
493
494    /**
495     * Major opcode for the extension.  Copied here so a lookup isn't
496     * needed.
497     */
498    GLint majorOpcode;
499
500#ifdef GLX_DIRECT_RENDERING
501    /**
502     * Per context direct rendering interface functions and data.
503     */
504    __DRIcontext driContext;
505#endif
506
507    /**
508     * \c GLXFBConfigID used to create this context.  May be \c None.  This
509     * field has been replaced by the \c mode field.
510     *
511     * \since Internal API version 20030317.
512     *
513     * \deprecated
514     * This filed has been largely been replaced by the \c mode field, but
515     * the work is not quite done.
516     */
517    GLXFBConfigID  fbconfigID;
518
519    /**
520     * The current read-drawable for this context.  Will be None if this
521     * context is not current to any drawable.
522     *
523     * \since Internal API version 20030606.
524     */
525    GLXDrawable currentReadable;
526
527   /**
528    * Pointer to client-state data that is private to libGL.  This is only
529    * used for indirect rendering contexts.
530    *
531    * No internal API version change was made for this change.  Client-side
532    * drivers should NEVER use this data or even care that it exists.
533    */
534   void * client_state_private;
535
536   /**
537    * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
538    */
539   int renderType;
540
541   /**
542    * \name Raw server GL version
543    *
544    * True core GL version supported by the server.  This is the raw value
545    * returned by the server, and it may not reflect what is actually
546    * supported (or reported) by the client-side library.
547    */
548    /*@{*/
549   int server_major;        /**< Major version number. */
550   int server_minor;        /**< Minor version number. */
551    /*@}*/
552};
553
554#define __glXSetError(gc,code) \
555    if (!(gc)->error) {	       \
556	(gc)->error = code;    \
557    }
558
559extern void __glFreeAttributeState(__GLXcontext *);
560
561/************************************************************************/
562
563/**
564 * The size of the largest drawing command known to the implementation
565 * that will use the GLXRender GLX command.  In this case it is
566 * \c glPolygonStipple.
567 */
568#define __GLX_MAX_SMALL_RENDER_CMD_SIZE	156
569
570/**
571 * To keep the implementation fast, the code uses a "limit" pointer
572 * to determine when the drawing command buffer is too full to hold
573 * another fixed size command.  This constant defines the amount of
574 * space that must always be available in the drawing command buffer
575 * at all times for the implementation to work.  It is important that
576 * the number be just large enough, but not so large as to reduce the
577 * efficacy of the buffer.  The "+32" is just to keep the code working
578 * in case somebody counts wrong.
579 */
580#define __GLX_BUFFER_LIMIT_SIZE	(__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
581
582/**
583 * This implementation uses a smaller threshold for switching
584 * to the RenderLarge protocol than the protcol requires so that
585 * large copies don't occur.
586 */
587#define __GLX_RENDER_CMD_SIZE_LIMIT	4096
588
589/**
590 * One of these records exists per screen of the display.  It contains
591 * a pointer to the config data for that screen (if the screen supports GL).
592 */
593typedef struct __GLXscreenConfigsRec {
594    /**
595     * GLX visuals formated as \c __GLXvisualConfig structures.
596     */
597    /*@{*/
598    __GLXvisualConfig * old_configs;
599    int numOldConfigs;
600    /*@}*/
601
602    /**
603     * GLX extension string reported by the X-server.
604     */
605    const char *serverGLXexts;
606
607    /**
608     * GLX extension string to be reported to applications.  This is the
609     * set of extensions that the application can actually use.
610     */
611    char *effectiveGLXexts;
612
613#ifdef GLX_DIRECT_RENDERING
614    /**
615     * Per screen direct rendering interface functions and data.
616     */
617    __DRIscreen driScreen;
618#endif
619
620    /**
621     * Linked list of configurations for this screen.  This is intended to
622     * be a superset of \c old_configs.
623     */
624    __GLcontextModes *configs;
625    /**
626     * Per-screen dynamic GLX extension tracking.  The \c direct_support
627     * field only contains enough bits for 64 extensions.  Should libGL
628     * ever need to track more than 64 GLX extensions, we can safely grow
629     * this field.  The \c __GLXscreenConfigs structure is not used outside
630     * libGL.
631     */
632    /*@{*/
633    unsigned char direct_support[8];
634    GLboolean ext_list_first_time;
635    /*@}*/
636
637} __GLXscreenConfigs;
638
639/**
640 * Per display private data.  One of these records exists for each display
641 * that is using the OpenGL (GLX) extension.
642 */
643struct __GLXdisplayPrivateRec {
644    /**
645     * Back pointer to the display
646     */
647    Display *dpy;
648
649    /**
650     * The \c majorOpcode is common to all connections to the same server.
651     * It is also copied into the context structure.
652     */
653    int majorOpcode;
654
655    /**
656     * \name Server Version
657     *
658     * Major and minor version returned by the server during initialization.
659     */
660    /*@{*/
661    int majorVersion, minorVersion;
662    /*@}*/
663
664    /**
665     * \name Storage for the servers GLX vendor and versions strings.
666     *
667     * These are the same for all screens on this display. These fields will
668     * be filled in on demand.
669     */
670    /*@{*/
671    const char *serverGLXvendor;
672    const char *serverGLXversion;
673    /*@}*/
674
675    /**
676     * Configurations of visuals for all screens on this display.
677     * Also, per screen data which now includes the server \c GLX_EXTENSION
678     * string.
679     */
680    __GLXscreenConfigs *screenConfigs;
681
682#ifdef GLX_DIRECT_RENDERING
683    /**
684     * Per display direct rendering interface functions and data.
685     */
686    __DRIdisplay driDisplay;
687#endif
688};
689
690void __glXFreeContext(__GLXcontext*);
691
692extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
693
694extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
695				GLint totalRequests,
696				const GLvoid * data, GLint dataLen);
697
698extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
699				  const GLvoid *, GLint);
700
701/* Initialize the GLX extension for dpy */
702extern __GLXdisplayPrivate *__glXInitialize(Display*);
703
704/************************************************************************/
705
706extern int __glXDebug;
707
708/* This is per-thread storage in an MT environment */
709#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
710extern __GLXcontext *__glXGetCurrentContext(void);
711extern void __glXSetCurrentContext(__GLXcontext *c);
712#else
713extern __GLXcontext *__glXcurrentContext;
714#define __glXGetCurrentContext()	__glXcurrentContext
715#define __glXSetCurrentContext(gc)	__glXcurrentContext = gc
716#endif
717
718
719/*
720** Global lock for all threads in this address space using the GLX
721** extension
722*/
723#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
724extern xmutex_rec __glXmutex;
725#define __glXLock()    xmutex_lock(&__glXmutex)
726#define __glXUnlock()  xmutex_unlock(&__glXmutex)
727#else
728#define __glXLock()
729#define __glXUnlock()
730#endif
731
732/*
733** Setup for a command.  Initialize the extension for dpy if necessary.
734*/
735extern CARD8 __glXSetupForCommand(Display *dpy);
736
737/************************************************************************/
738
739/*
740** Data conversion and packing support.
741*/
742
743/* Return the size, in bytes, of some pixel data */
744extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum);
745
746/* Return the number of elements per group of a specified format*/
747extern GLint __glElementsPerGroup(GLenum format, GLenum type);
748
749/* Return the number of bytes per element, based on the element type (other
750** than GL_BITMAP).
751*/
752extern GLint __glBytesPerElement(GLenum type);
753
754/* Return the k value for a given map target */
755extern GLint __glEvalComputeK(GLenum);
756
757/*
758** Fill the transport buffer with the data from the users buffer,
759** applying some of the pixel store modes (unpack modes) to the data
760** first.  As a side effect of this call, the "modes" field is
761** updated to contain the modes needed by the server to decode the
762** sent data.
763*/
764extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
765			  GLenum, const GLvoid*, GLubyte*, GLubyte*);
766
767/* Copy map data with a stride into a packed buffer */
768extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
769extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
770extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
771			  const GLfloat *, GLfloat *);
772extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
773			  const GLdouble *, GLdouble *);
774
775/*
776** Empty an image out of the reply buffer into the clients memory applying
777** the pack modes to pack back into the clients requested format.
778*/
779extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
780		           GLenum, const GLubyte *, GLvoid *);
781
782
783/*
784** Allocate and Initialize Vertex Array client state
785*/
786extern void __glXInitVertexArrayState(__GLXcontext*);
787
788/*
789** Inform the Server of the major and minor numbers and of the client
790** libraries extension string.
791*/
792extern void __glXClientInfo (  Display *dpy, int opcode );
793
794/************************************************************************/
795
796/*
797** Declarations that should be in Xlib
798*/
799#ifdef __GL_USE_OUR_PROTOTYPES
800extern void _XFlush(Display*);
801extern Status _XReply(Display*, xReply*, int, Bool);
802extern void _XRead(Display*, void*, long);
803extern void _XSend(Display*, const void*, long);
804#endif
805
806
807/*
808** GLX_BUILT_IN_XMESA controls whether libGL has a built-in verions of
809** Mesa that can render to non-GLX displays.
810*/
811#ifdef GLX_BUILT_IN_XMESA
812#define GLX_PREFIX(function)  _real_##function
813#else
814#define GLX_PREFIX(function)  function
815#endif
816
817
818extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
819    int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
820
821extern char * __glXGetStringFromServer( Display * dpy, int opcode,
822    CARD32 glxCode, CARD32 for_whom, CARD32 name );
823
824extern char *__glXstrdup(const char *str);
825
826
827extern const char __glXGLClientVersion[];
828extern const char __glXGLClientExtensions[];
829
830/* Determine the internal API version */
831extern int __glXGetInternalVersion(void);
832
833/* Get the unadjusted system time */
834extern int __glXGetUST( int64_t * ust );
835
836#endif /* !__GLX_client_h__ */
837