removed all dependencies on XMesa
[mesa.git] / src / mesa / drivers / x11 / xfonts.c
index c0e0a5fcd0123f5fb98e8bf8d61d8f189ba6bad4..27b877dbabeea83cc3b975f3ce08406eb5d23a8f 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: xfonts.c,v 1.1 1999/08/19 00:55:42 jtg Exp $ */
+/* $Id: xfonts.c,v 1.8 2000/08/13 03:57:21 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.1
+ * Version:  3.4
  *
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 #include <X11/Xutil.h>
 #include "GL/gl.h"
 #include "GL/glx.h"
-#include "GL/xmesa.h"
 #include "context.h"
-#include "fakeglx.h"
-#include "macros.h"
-#include "xmesaP.h"
+#include "mem.h"
+#include "xfonts.h"
+
 
 /* Some debugging info.  */
 
@@ -222,7 +221,6 @@ static XCharStruct *isvalid(XFontStruct *fs, int which)
 
 void Fake_glXUseXFont( Font font, int first, int count, int listbase )
 {
-  XMesaContext CC;
   Display *dpy;
   Window win;
   Pixmap pixmap;
@@ -230,26 +228,23 @@ void Fake_glXUseXFont( Font font, int first, int count, int listbase )
   XGCValues values;
   unsigned long valuemask;
   XFontStruct *fs;
-
   GLint swapbytes, lsbfirst, rowlength;
   GLint skiprows, skippixels, alignment;
-
   unsigned int max_width, max_height, max_bm_width, max_bm_height;
   GLubyte *bm;
-
   int i;
 
-  CC = XMesaGetCurrentContext();
-  dpy = CC->display;
-  win = CC->xm_buffer->frontbuffer;
+  dpy = glXGetCurrentDisplay();
+  if (!dpy)
+     return;  /* I guess glXMakeCurrent wasn't called */
+  win = RootWindow(dpy, DefaultScreen(dpy));
 
   fs = XQueryFont (dpy, font);
-  if (!fs)
-    {
-      gl_error (CC->gl_ctx, GL_INVALID_VALUE,
-                "Couldn't get font structure information");
+  if (!fs) {
+      gl_error(NULL, GL_INVALID_VALUE,
+               "Couldn't get font structure information");
       return;
-    }
+  }
 
   /* Allocate a bitmap that can fit all characters.  */
   max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
@@ -257,14 +252,14 @@ void Fake_glXUseXFont( Font font, int first, int count, int listbase )
   max_bm_width = (max_width + 7) / 8;
   max_bm_height = max_height;
 
-  bm = (GLubyte *) malloc ((max_bm_width * max_bm_height) * sizeof 
+  bm = (GLubyte *) MALLOC((max_bm_width * max_bm_height) * sizeof 
 (GLubyte));
   if (!bm) {
       XFreeFontInfo( NULL, fs, 0 );
-      gl_error (CC->gl_ctx, GL_OUT_OF_MEMORY,
+      gl_error(NULL, GL_OUT_OF_MEMORY,
                 "Couldn't allocate bitmap in glXUseXFont()");
       return;
-    }
+  }
 
 #if 0
   /* get the page info */
@@ -338,7 +333,8 @@ void Fake_glXUseXFont( Font font, int first, int count, int listbase )
       width = ch->rbearing - ch->lbearing;
       height = ch->ascent + ch->descent;
       x0 = - ch->lbearing;
-      y0 = ch->descent - 1;
+      y0 = ch->descent - 0;  /* XXX used to subtract 1 here */
+                             /* but that caused a conformace failure */
       dx = ch->width;
       dy = 0;
 
@@ -373,7 +369,7 @@ bm_height);
       glEndList ();
     }
 
-  free (bm);
+  FREE(bm);
   XFreeFontInfo( NULL, fs, 0 );
   XFreeGC (dpy, gc);
 
@@ -385,14 +381,3 @@ bm_height);
   glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
   glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
 }
-
-void xmesa_xfonts_dummy( void )
-{
-   /* silence unused var warnings */
-   (void) kernel8;
-   (void) DitherValues;
-   (void) HPCR_DRGB;
-   (void) kernel1;
-}
-
-/* The End. */