Home | History | Annotate | Download | only in x11
      1 /*
      2  * Mesa 3-D graphics library
      3  * Version:  6.3
      4  *
      5  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
      6  *
      7  * Permission is hereby granted, free of charge, to any person obtaining a
      8  * copy of this software and associated documentation files (the "Software"),
      9  * to deal in the Software without restriction, including without limitation
     10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  * and/or sell copies of the Software, and to permit persons to whom the
     12  * Software is furnished to do so, subject to the following conditions:
     13  *
     14  * The above copyright notice and this permission notice shall be included
     15  * in all copies or substantial portions of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     21  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     23  */
     24 
     25 
     26 #ifndef _glxapi_h_
     27 #define _glxapi_h_
     28 
     29 
     30 #define GLX_GLXEXT_PROTOTYPES
     31 #include "GL/glx.h"
     32 
     33 
     34 /* The GLX API dispatcher (i.e. this code) is being built into stand-alone
     35  * Mesa.  We don't know anything about XFree86 or real GLX so we define a
     36  * minimal __GLXContextRec here so some of the functions in this file can
     37  * work properly.
     38  */
     39 typedef struct __GLXcontextRec {
     40    Display *currentDpy;
     41    GLboolean isDirect;
     42    GLXDrawable currentDrawable;
     43    GLXDrawable currentReadable;
     44    XID xid;
     45 } __GLXcontext;
     46 
     47 
     48 /*
     49  * Almost all the GLX API functions get routed through this dispatch table.
     50  * The exceptions are the glXGetCurrentXXX() functions.
     51  *
     52  * This dispatch table allows multiple GLX client-side modules to coexist.
     53  * Specifically, a real GLX library (like SGI's or the Utah GLX) and Mesa's
     54  * pseudo-GLX can be present at the same time.  The former being used on
     55  * GLX-enabled X servers and the later on non-GLX X servers.
     56  *
     57  * Red Hat has been using this since Red Hat Linux 7.0 (I think).
     58  * This'll be a standard feature in XFree86 4.3.  It basically allows one
     59  * libGL to do both DRI-rendering and "fake GLX" rendering to X displays
     60  * that lack the GLX extension.
     61  */
     62 struct _glxapi_table {
     63    /*** GLX_VERSION_1_0 ***/
     64    XVisualInfo *(*ChooseVisual)(Display *dpy, int screen, int *list);
     65    void (*CopyContext)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
     66    GLXContext (*CreateContext)(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct);
     67    GLXPixmap (*CreateGLXPixmap)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap);
     68    void (*DestroyContext)(Display *dpy, GLXContext ctx);
     69    void (*DestroyGLXPixmap)(Display *dpy, GLXPixmap pixmap);
     70    int (*GetConfig)(Display *dpy, XVisualInfo *visinfo, int attrib, int *value);
     71    /*GLXContext (*GetCurrentContext)(void);*/
     72    /*GLXDrawable (*GetCurrentDrawable)(void);*/
     73    Bool (*IsDirect)(Display *dpy, GLXContext ctx);
     74    Bool (*MakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
     75    Bool (*QueryExtension)(Display *dpy, int *errorb, int *event);
     76    Bool (*QueryVersion)(Display *dpy, int *maj, int *min);
     77    void (*SwapBuffers)(Display *dpy, GLXDrawable drawable);
     78    void (*UseXFont)(Font font, int first, int count, int listBase);
     79    void (*WaitGL)(void);
     80    void (*WaitX)(void);
     81 
     82    /*** GLX_VERSION_1_1 ***/
     83    const char *(*GetClientString)(Display *dpy, int name);
     84    const char *(*QueryExtensionsString)(Display *dpy, int screen);
     85    const char *(*QueryServerString)(Display *dpy, int screen, int name);
     86 
     87    /*** GLX_VERSION_1_2 ***/
     88    /*Display *(*GetCurrentDisplay)(void);*/
     89 
     90    /*** GLX_VERSION_1_3 ***/
     91    GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
     92    GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
     93    GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList);
     94    GLXPixmap (*CreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList);
     95    GLXWindow (*CreateWindow)(Display *dpy, GLXFBConfig config, Window win, const int *attribList);
     96    void (*DestroyPbuffer)(Display *dpy, GLXPbuffer pbuf);
     97    void (*DestroyPixmap)(Display *dpy, GLXPixmap pixmap);
     98    void (*DestroyWindow)(Display *dpy, GLXWindow window);
     99    /*GLXDrawable (*GetCurrentReadDrawable)(void);*/
    100    int (*GetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value);
    101    GLXFBConfig *(*GetFBConfigs)(Display *dpy, int screen, int *nelements);
    102    void (*GetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask);
    103    XVisualInfo *(*GetVisualFromFBConfig)(Display *dpy, GLXFBConfig config);
    104    Bool (*MakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
    105    int (*QueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value);
    106    void (*QueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
    107    void (*SelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask);
    108 
    109    /*** GLX_SGI_swap_control ***/
    110    int (*SwapIntervalSGI)(int);
    111 
    112    /*** GLX_SGI_video_sync ***/
    113    int (*GetVideoSyncSGI)(unsigned int *count);
    114    int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
    115 
    116    /*** GLX_SGI_make_current_read ***/
    117    Bool (*MakeCurrentReadSGI)(Display *, GLXDrawable, GLXDrawable, GLXContext);
    118    /*GLXDrawable (*GetCurrentReadDrawableSGI)(void);*/
    119 
    120    /*** GLX_SGIX_video_source (needs video library) ***/
    121 #if defined(_VL_H_)
    122    GLXVideoSourceSGIX (*CreateGLXVideoSourceSGIX)(Display *, int, VLServer, VLPath, int, VLNode);
    123    void (*DestroyGLXVideoSourceSGIX)(Display *, GLXVideoSourceSGIX);
    124 #else
    125    void *CreateGLXVideoSourceSGIX;
    126    void *DestroyGLXVideoSourceSGIX;
    127 #endif
    128 
    129    /*** GLX_EXT_import_context ***/
    130    void (*FreeContextEXT)(Display *dpy, GLXContext context);
    131    GLXContextID (*GetContextIDEXT)(const GLXContext context);
    132    /*Display *(*GetCurrentDisplayEXT)(void);*/
    133    GLXContext (*ImportContextEXT)(Display *dpy, GLXContextID contextID);
    134    int (*QueryContextInfoEXT)(Display *dpy, GLXContext context, int attribute,int *value);
    135 
    136    /*** GLX_SGIX_fbconfig ***/
    137    int (*GetFBConfigAttribSGIX)(Display *, GLXFBConfigSGIX, int, int *);
    138    GLXFBConfigSGIX * (*ChooseFBConfigSGIX)(Display *, int, int *, int *);
    139    GLXPixmap (*CreateGLXPixmapWithConfigSGIX)(Display *, GLXFBConfigSGIX, Pixmap);
    140    GLXContext (*CreateContextWithConfigSGIX)(Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
    141    XVisualInfo * (*GetVisualFromFBConfigSGIX)(Display *, GLXFBConfigSGIX);
    142    GLXFBConfigSGIX (*GetFBConfigFromVisualSGIX)(Display *, XVisualInfo *);
    143 
    144    /*** GLX_SGIX_pbuffer ***/
    145    GLXPbufferSGIX (*CreateGLXPbufferSGIX)(Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
    146    void (*DestroyGLXPbufferSGIX)(Display *, GLXPbufferSGIX);
    147    int (*QueryGLXPbufferSGIX)(Display *, GLXPbufferSGIX, int, unsigned int *);
    148    void (*SelectEventSGIX)(Display *, GLXDrawable, unsigned long);
    149    void (*GetSelectedEventSGIX)(Display *, GLXDrawable, unsigned long *);
    150 
    151    /*** GLX_SGI_cushion ***/
    152    void (*CushionSGI)(Display *, Window, float);
    153 
    154    /*** GLX_SGIX_video_resize ***/
    155    int (*BindChannelToWindowSGIX)(Display *, int, int, Window);
    156    int (*ChannelRectSGIX)(Display *, int, int, int, int, int, int);
    157    int (*QueryChannelRectSGIX)(Display *, int, int, int *, int *, int *, int *);
    158    int (*QueryChannelDeltasSGIX)(Display *, int, int, int *, int *, int *, int *);
    159    int (*ChannelRectSyncSGIX)(Display *, int, int, GLenum);
    160 
    161    /*** GLX_SGIX_dmbuffer (needs dmedia library) ***/
    162 #if defined (_DM_BUFFER_H_)
    163    Bool (*AssociateDMPbufferSGIX)(Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
    164 #else
    165    void *AssociciateDMPbufferSGIX;
    166 #endif
    167 
    168    /*** GLX_SGIX_swap_group ***/
    169    void (*JoinSwapGroupSGIX)(Display *, GLXDrawable, GLXDrawable);
    170 
    171    /*** GLX_SGIX_swap_barrier ***/
    172    void (*BindSwapBarrierSGIX)(Display *, GLXDrawable, int);
    173    Bool (*QueryMaxSwapBarriersSGIX)(Display *, int, int *);
    174 
    175    /*** GLX_SUN_get_transparent_index ***/
    176    Status (*GetTransparentIndexSUN)(Display *, Window, Window, long *);
    177 
    178    /*** GLX_MESA_copy_sub_buffer ***/
    179    void (*CopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
    180 
    181    /*** GLX_MESA_release_buffers ***/
    182    Bool (*ReleaseBuffersMESA)(Display *dpy, Window w);
    183 
    184    /*** GLX_MESA_pixmap_colormap ***/
    185    GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
    186 
    187    /*** GLX_MESA_set_3dfx_mode ***/
    188    Bool (*Set3DfxModeMESA)(int mode);
    189 
    190    /*** GLX_NV_vertex_array_range ***/
    191    void * (*AllocateMemoryNV)( GLsizei size,
    192                                GLfloat readFrequency,
    193                                GLfloat writeFrequency,
    194                                GLfloat priority );
    195    void (*FreeMemoryNV)( GLvoid *pointer );
    196 
    197    /*** GLX_MESA_agp_offset ***/
    198    GLuint (*GetAGPOffsetMESA)( const GLvoid *pointer );
    199 
    200    /*** GLX_EXT_texture_from_pixmap ***/
    201    void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
    202                            const int *attrib_list);
    203    void (*ReleaseTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer);
    204 };
    205 
    206 
    207 
    208 extern const char *
    209 _glxapi_get_version(void);
    210 
    211 
    212 extern const char **
    213 _glxapi_get_extensions(void);
    214 
    215 
    216 extern GLuint
    217 _glxapi_get_dispatch_table_size(void);
    218 
    219 
    220 extern void
    221 _glxapi_set_no_op_table(struct _glxapi_table *t);
    222 
    223 
    224 extern __GLXextFuncPtr
    225 _glxapi_get_proc_address(const char *funcName);
    226 
    227 
    228 #endif
    229