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