From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver] / hacks / glx / glxfonts.h
1 /* glxfonts, Copyright (c) 2001-2012 Jamie Zawinski <jwz@jwz.org>
2  * Loads X11 fonts for use with OpenGL.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation.  No representations are made about the suitability of this
9  * software for any purpose.  It is provided "as is" without express or 
10  * implied warranty.
11  *
12  * Loads X11 fonts for use with OpenGL.
13  */
14
15 #ifndef __GLXFONTS_H__
16 #define __GLXFONTS_H__
17
18 #ifndef HAVE_GLBITMAP
19 # include "texfont.h"
20 #endif /* !HAVE_GLBITMAP */
21
22 #ifdef HAVE_GLBITMAP
23 /* This is basically the same as glXUseXFont().
24    We have our own version of it for portability.
25  */
26 extern void xscreensaver_glXUseXFont (Display *dpy, Font font, 
27                                       int first, int count, int listbase);
28 #endif /* HAVE_GLBITMAP */
29
30 /* Loads the font named by the X resource "res".
31    Returns an XFontStruct.
32    Also converts the font to a set of GL lists and returns the first list.
33 */
34 extern void load_font (Display *, char *resource,
35                        XFontStruct **font_ret,
36                        GLuint *dlist_ret);
37
38 /* Bounding box of the string in pixels.
39  */
40 extern int string_width (XFontStruct *f, const char *c, int *height_ret);
41
42 /* Draws the string on the window at the given pixel position.
43    Newlines and tab stops are honored.
44    Any text inside [] will be rendered as a subscript.
45    Assumes the font has been loaded as with load_font(). */
46 void print_gl_string (Display *dpy,
47 # ifdef HAVE_GLBITMAP
48                       XFontStruct *font,
49                       GLuint font_dlist,
50 # else  /* !HAVE_GLBITMAP */
51                       texture_font_data *font_data,
52 # endif /* !HAVE_GLBITMAP */
53                       int window_width, int window_height,
54                       GLfloat x, GLfloat y,
55                       const char *string,
56                       Bool clear_background_p);
57
58 #endif /* __GLXFONTS_H__ */