-/* $Id: fakeglx.c,v 1.17 1999/11/25 17:37:49 brianp Exp $ */
+/* $Id: fakeglx.c,v 1.18 1999/11/28 20:08:02 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
-
-
-
/*
* A pseudo-GLX implementation to allow OpenGL/GLX programs to work with Mesa.
* The Fake_glX*() functions implemented here are called from glxapi.c
#include "glxheader.h"
+#include "glxapi.h"
#include "GL/xmesa.h"
#include "context.h"
#include "config.h"
-#include "fakeglx.h"
#include "macros.h"
#include "types.h"
#include "xmesaP.h"
-XVisualInfo *Fake_glXChooseVisual( Display *dpy, int screen, int *list )
+static XVisualInfo *
+Fake_glXChooseVisual( Display *dpy, int screen, int *list )
{
int *parselist;
XVisualInfo *vis;
-GLXContext Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct )
+static GLXContext
+Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext share_list, Bool direct )
{
XMesaVisual glxvis;
XMesaContext xmctx;
static XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
static XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
-Bool Fake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
-{
-#if 1
- return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
-#endif
-#if 0
- if (ctx && drawable) {
- XMesaBuffer buffer;
- XMesaContext xmctx = (XMesaContext) ctx;
-
- if (drawable==MakeCurrent_PrevDrawable && ctx==MakeCurrent_PrevContext) {
- buffer = MakeCurrent_PrevDrawBuffer;
- }
- else {
- buffer = XMesaFindBuffer( dpy, drawable );
- }
- if (!buffer) {
- /* drawable must be a new window! */
- buffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, drawable, ctx );
- if (!buffer) {
- /* Out of memory, or context/drawable depth mismatch */
- return False;
- }
- }
- MakeCurrent_PrevContext = ctx;
- MakeCurrent_PrevDrawable = drawable;
- MakeCurrent_PrevDrawBuffer = buffer;
-
- /* Now make current! */
- return (Bool) XMesaMakeCurrent( (XMesaContext) ctx, buffer );
- }
- else if (!ctx && !drawable) {
- /* release current context w/out assigning new one. */
- XMesaMakeCurrent( NULL, NULL );
- MakeCurrent_PrevContext = 0;
- MakeCurrent_PrevDrawable = 0;
- MakeCurrent_PrevDrawBuffer = 0;
- return True;
- }
- else {
- /* ctx XOR drawable is NULL, this is an error */
- return False;
- }
-#endif
-}
-
-
-
/* GLX 1.3 and later */
-Bool Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext ctx )
+static Bool
+Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx )
{
if (ctx && draw && read) {
XMesaBuffer drawBuffer, readBuffer;
}
+
+static Bool
+Fake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
+{
+ return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
+}
+
+
+
/* GLX 1.3 and later */
-GLXDrawable Fake_glXGetCurrentReadDrawable( void )
+#if 0
+static GLXDrawable
+Fake_glXGetCurrentReadDrawable( void )
{
XMesaBuffer b = XMesaGetCurrentReadBuffer();
if (b) {
return 0;
}
}
+#endif
-
-GLXPixmap Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo,
- Pixmap pixmap )
+static GLXPixmap
+Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
{
XMesaVisual v;
XMesaBuffer b;
#ifdef GLX_MESA_pixmap_colormap
-GLXPixmap Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
- Pixmap pixmap, Colormap cmap )
+static GLXPixmap
+Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
+ Pixmap pixmap, Colormap cmap )
{
XMesaVisual v;
XMesaBuffer b;
#endif
-void Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
+static void
+Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
{
XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
if (b) {
}
-void Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
- GLuint mask )
+static void
+Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ GLuint mask )
{
XMesaContext xm_src = (XMesaContext) src;
XMesaContext xm_dst = (XMesaContext) dst;
-Bool Fake_glXQueryExtension( Display *dpy, int *errorb, int *event )
+static Bool
+Fake_glXQueryExtension( Display *dpy, int *errorb, int *event )
{
/* Mesa's GLX isn't really an X extension but we try to act like one. */
(void) dpy;
}
-void Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
+static void
+Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
{
(void) dpy;
MakeCurrent_PrevContext = 0;
-Bool Fake_glXIsDirect( Display *dpy, GLXContext ctx )
+static Bool
+Fake_glXIsDirect( Display *dpy, GLXContext ctx )
{
(void) dpy;
return ((XMesaContext) ctx)->direct;
-void Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
+static void
+Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
{
XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
}
-void Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
- int x, int y, int width, int height )
+static void
+Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height )
{
XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
if (buffer) {
-Bool Fake_glXQueryVersion( Display *dpy, int *maj, int *min )
+static Bool
+Fake_glXQueryVersion( Display *dpy, int *maj, int *min )
{
(void) dpy;
/* Return GLX version, not Mesa version */
/*
* Query the GLX attributes of the given XVisualInfo.
*/
-int Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
- int attrib, int *value )
+static int
+Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
+ int attrib, int *value )
{
XMesaVisual glxvis;
-GLXContext Fake_glXGetCurrentContext( void )
+#if 0
+static GLXContext
+Fake_glXGetCurrentContext( void )
{
return (GLXContext) XMesaGetCurrentContext();
}
+#endif
-
-GLXDrawable Fake_glXGetCurrentDrawable( void )
+#if 0
+static GLXDrawable
+Fake_glXGetCurrentDrawable( void )
{
XMesaBuffer b = XMesaGetCurrentBuffer();
if (b) {
return 0;
}
}
+#endif
-void Fake_glXWaitGL( void )
+static void
+Fake_glXWaitGL( void )
{
XMesaContext xmesa = XMesaGetCurrentContext();
XMesaFlush( xmesa );
-void Fake_glXWaitX( void )
+static void
+Fake_glXWaitX( void )
{
XMesaContext xmesa = XMesaGetCurrentContext();
XMesaFlush( xmesa );
/* GLX 1.1 and later */
-const char *Fake_glXQueryExtensionsString( Display *dpy, int screen )
+static const char *
+Fake_glXQueryExtensionsString( Display *dpy, int screen )
{
(void) dpy;
(void) screen;
/* GLX 1.1 and later */
-const char *Fake_glXQueryServerString( Display *dpy, int screen, int name )
+static const char *
+Fake_glXQueryServerString( Display *dpy, int screen, int name )
{
static char version[1000];
sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION,
/* GLX 1.1 and later */
-const char *Fake_glXGetClientString( Display *dpy, int name )
+static const char *
+Fake_glXGetClientString( Display *dpy, int name )
{
static char version[1000];
sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION,
/* GLX 1.2 and later */
-Display *Fake_glXGetCurrentDisplay( void )
+#if 0
+static Display *
+Fake_glXGetCurrentDisplay( void )
{
XMesaContext xmesa = XMesaGetCurrentContext();
if (xmesa && xmesa->xm_visual)
else
return NULL;
}
+#endif
+
+
+/*
+ * GLX 1.3 and later
+ */
+
+static GLXFBConfig
+Fake_glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems )
+{
+ (void) dpy;
+ (void) screen;
+ (void) attribList;
+ (void) nitems;
+ return 0;
+}
+
+
+static int
+Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value )
+{
+ (void) dpy;
+ (void) config;
+ (void) attribute;
+ (void) value;
+ return 0;
+}
+
+
+static XVisualInfo *
+Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
+{
+ (void) dpy;
+ (void) config;
+ return 0;
+}
+
+
+static GLXWindow
+Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
+ const int *attribList )
+{
+ (void) dpy;
+ (void) config;
+ (void) win;
+ (void) attribList;
+ return 0;
+}
+
+
+static void
+Fake_glXDestroyWindow( Display *dpy, GLXWindow window )
+{
+ (void) dpy;
+ (void) window;
+ return;
+}
+
+
+static GLXPixmap
+Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attribList )
+{
+ (void) dpy;
+ (void) config;
+ (void) pixmap;
+ (void) attribList;
+ return 0;
+}
+
+
+static void
+Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
+{
+ (void) dpy;
+ (void) pixmap;
+ return;
+}
+
+
+static GLXPbuffer
+Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList )
+{
+ (void) dpy;
+ (void) config;
+ (void) attribList;
+ return 0;
+}
+
+
+static void
+Fake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
+{
+ (void) dpy;
+ (void) pbuf;
+}
+
+
+static void
+Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value )
+{
+ (void) dpy;
+ (void) draw;
+ (void) attribute;
+ (void) value;
+}
+
+
+static GLXContext
+Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList, Bool direct )
+{
+ (void) dpy;
+ (void) config;
+ (void) renderType;
+ (void) shareList;
+ (void) direct;
+ return 0;
+}
+
+
+static int
+Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
+{
+ (void) dpy;
+ (void) ctx;
+ (void) attribute;
+ (void) value;
+ return 0;
+}
+
+
+static void
+Fake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
+{
+ (void) dpy;
+ (void) drawable;
+ (void) mask;
+}
+
+
+static void
+Fake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask )
+{
+ (void) dpy;
+ (void) drawable;
+ (void) mask;
+}
* Release the depth, stencil, accum buffers attached to a GLXDrawable
* (a window or pixmap) prior to destroying the GLXDrawable.
*/
-Bool Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+static Bool
+Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
{
XMesaBuffer b = XMesaFindBuffer(dpy, d);
if (b) {
/*
* GLX_MESA_set_3dfx_mode
*/
-GLboolean Fake_glXSet3DfxModeMESA( GLint mode )
+static GLboolean
+Fake_glXSet3DfxModeMESA( GLint mode )
{
return XMesaSetFXmode( mode );
}
+/*
+ * GLX_SGI_video_sync
+ */
+
+#ifdef GLX_SGI_video_sync
+
+static int
+Fake_glXGetVideoSyncSGI(unsigned int *count)
+{
+ return 0;
+}
+
+
+static int
+Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+ return 0;
+}
+
+#endif
+
+
#if 0
-/*GLfunction Fake_glXGetProcAddress( const GLubyte *procName )*/
+/*GLfunction glXGetProcAddress( const GLubyte *procName )*/
void (*Fake_glXGetProcAddress( const GLubyte *procName ))()
{
typedef void (*GLfunction)();
return NULL;
}
#endif
+
+
+extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
+
+
+struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
+{
+ static struct _glxapi_table glx;
+
+ /* be sure our dispatch table size <= libGL's table */
+ {
+ int size = sizeof(struct _glxapi_table) / sizeof(void *);
+ (void) size;
+ assert(_glxapi_get_dispatch_table_size() >= size);
+ }
+
+ /* initialize the whole table to no-ops */
+ _glxapi_set_no_op_table(&glx);
+
+ /* now initialize the table with the functions I implement */
+ glx.ChooseVisual = Fake_glXChooseVisual;
+ glx.CopyContext = Fake_glXCopyContext;
+ glx.CreateContext = Fake_glXCreateContext;
+ glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
+ glx.DestroyContext = Fake_glXDestroyContext;
+ glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
+ glx.GetConfig = Fake_glXGetConfig;
+ /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
+ /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
+ glx.IsDirect = Fake_glXIsDirect;
+ glx.MakeCurrent = Fake_glXMakeCurrent;
+ glx.QueryExtension = Fake_glXQueryExtension;
+ glx.QueryVersion = Fake_glXQueryVersion;
+ glx.SwapBuffers = Fake_glXSwapBuffers;
+ glx.UseXFont = Fake_glXUseXFont;
+ glx.WaitGL = Fake_glXWaitGL;
+ glx.WaitX = Fake_glXWaitX;
+
+#ifdef _GLXAPI_VERSION_1_1
+ glx.GetClientString = Fake_glXGetClientString;
+ glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
+ glx.QueryServerString = Fake_glXQueryServerString;
+#endif
+
+#ifdef _GLXAPI_VERSION_1_2
+ /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
+#endif
+
+#ifdef _GLXAPI_VERSION_1_3
+ glx.ChooseFBConfig = Fake_glXChooseFBConfig;
+ glx.CreateNewContext = Fake_glXCreateNewContext;
+ glx.CreatePbuffer = Fake_glXCreatePbuffer;
+ glx.CreatePixmap = Fake_glXCreatePixmap;
+ glx.CreateWindow = Fake_glXCreateWindow;
+ glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
+ glx.DestroyPixmap = Fake_glXDestroyPixmap;
+ glx.DestroyWindow = Fake_glXDestroyWindow;
+ /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
+ glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
+ glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
+ glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
+ glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
+ glx.QueryContext = Fake_glXQueryContext;
+ glx.QueryDrawable = Fake_glXQueryDrawable;
+ glx.SelectEvent = Fake_glXSelectEvent;
+#endif
+
+#ifdef _GLXAPI_SGI_video_sync
+ glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
+ glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
+#endif
+
+#ifdef _GLXAPI_MESA_copy_sub_buffer
+ glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
+#endif
+
+#ifdef _GLXAPI_MESA_release_buffers
+ glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
+#endif
+
+#ifdef _GLXAPI_MESA_pixmap_colormap
+ glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
+#endif
+
+#ifdef _GLXAPI_MESA_set_3dfx_mode
+ glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
+#endif
+
+ return &glx;
+}