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