1 /* xlockmore.h --- xscreensaver compatibility layer for xlockmore modules.
2 * xscreensaver, Copyright (c) 1997, 1998 Jamie Zawinski <jwz@jwz.org>
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
12 * The definitions in this file make it possible to compile an xlockmore
13 * module into a standalone program, and thus use it with xscreensaver.
14 * By Jamie Zawinski <jwz@jwz.org> on 10-May-97; based on the ideas
15 * in the older xlock.h by Charles Hannum <mycroft@ai.mit.edu>. (I had
16 * to redo it, since xlockmore has diverged so far from xlock...)
19 #if !defined(PROGCLASS) || !defined(HACK_INIT) || !defined(HACK_DRAW)
20 ERROR! Define PROGCLASS, HACK_INIT, and HACK_DRAW before including xlockmore.h
26 ERROR! Sorry, xlockmore.h requires ANSI C (gcc, for example.)
27 /* (The ansi dependency is that we use string concatenation,
28 and cpp-based stringification of tokens.) */
33 #include "xlockmoreI.h"
37 extern GLXContext *init_GL (ModeInfo *);
38 # define FreeAllGL(dpy) /* */
41 /* Accessor macros for the ModeInfo structure
44 #define MI_DISPLAY(MI) ((MI)->dpy)
45 #define MI_WINDOW(MI) ((MI)->window)
46 #define MI_NUM_SCREENS(MI) (1) /* Only manage one screen at a time; */
47 #define MI_SCREEN(MI) (0) /* this might be fragile... */
48 #define MI_WIN_WHITE_PIXEL(MI) ((MI)->white)
49 #define MI_WIN_BLACK_PIXEL(MI) ((MI)->black)
50 #define MI_NPIXELS(MI) ((MI)->npixels)
51 #define MI_PIXEL(MI,N) ((MI)->pixels[(N)])
52 #define MI_WIN_WIDTH(MI) ((MI)->xgwa.width)
53 #define MI_WIN_HEIGHT(MI) ((MI)->xgwa.height)
54 #define MI_WIN_DEPTH(MI) ((MI)->xgwa.depth)
55 #define MI_WIN_COLORMAP(MI) ((MI)->xgwa.colormap)
56 #define MI_VISUAL(MI) ((MI)->xgwa.visual)
57 #define MI_GC(MI) ((MI)->gc)
58 #define MI_PAUSE(MI) ((MI)->pause)
59 #define MI_WIN_IS_FULLRANDOM(MI)((MI)->fullrandom)
60 #define MI_WIN_IS_VERBOSE(MI) (False)
61 #define MI_WIN_IS_INSTALL(MI) (True)
62 #define MI_WIN_IS_MONO(MI) (mono_p)
63 #define MI_WIN_IS_INROOT(MI) ((MI)->root_p)
64 #define MI_WIN_IS_INWINDOW(MI) (!(MI)->root_p)
65 #define MI_WIN_IS_ICONIC(MI) (False)
66 #define MI_WIN_IS_WIREFRAME(MI) ((MI)->wireframe_p)
67 #define MI_WIN_IS_USE3D(MI) ((MI)->threed)
68 #define MI_LEFT_COLOR(MI) ((MI)->threed_left_color)
69 #define MI_RIGHT_COLOR(MI) ((MI)->threed_right_color)
70 #define MI_BOTH_COLOR(MI) ((MI)->threed_both_color)
71 #define MI_NONE_COLOR(MI) ((MI)->threed_none_color)
72 #define MI_DELTA3D(MI) ((MI)->threed_delta)
73 #define MI_CYCLES(MI) ((MI)->cycles)
74 #define MI_BATCHCOUNT(MI) ((MI)->batchcount)
75 #define MI_SIZE(MI) ((MI)->size)
76 #define MI_IS_DRAWN(MI) ((MI)->is_drawn)
77 #define MI_IS_DRAWN(MI) ((MI)->is_drawn)
78 #define MI_NCOLORS(MI) ((MI)->npixels)
79 #define MI_NAME(MI) (progname)
81 #define MI_WIDTH(MI) (MI_WIN_WIDTH((MI)))
82 #define MI_HEIGHT(MI) (MI_WIN_HEIGHT((MI)))
83 #define MI_IS_ICONIC(MI) (MI_WIN_IS_ICONIC((MI)))
84 #define MI_IS_WIREFRAME(MI) (MI_WIN_IS_WIREFRAME((MI)))
85 #define MI_IS_MONO(MI) (MI_WIN_IS_MONO((MI)))
86 #define MI_COUNT(MI) (MI_BATCHCOUNT((MI)))
87 #define MI_BLACK_PIXEL(MI) (MI_WIN_BLACK_PIXEL(MI))
88 #define MI_WHITE_PIXEL(MI) (MI_WIN_WHITE_PIXEL(MI))
89 #define MI_IS_FULLRANDOM(MI) (MI_WIN_IS_FULLRANDOM(MI))
90 #define MI_IS_VERBOSE(MI) (MI_WIN_IS_VERBOSE(MI))
91 #define MI_IS_INSTALL(MI) (MI_WIN_IS_INSTALL(MI))
92 #define MI_IS_DEBUG(MI) (False)
94 #define MI_CLEARWINDOW(mi) XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi))
96 /* Some other utility macros.
98 #define SINF(n) ((float)sin((double)(n)))
99 #define COSF(n) ((float)cos((double)(n)))
100 #define FABSF(n) ((float)fabs((double)(n)))
105 #define MAX(a,b)((a)>(b)?(a):(b))
106 #define MIN(a,b)((a)<(b)?(a):(b))
107 #define ABS(a)((a)<0 ? -(a) : (a))
109 /* Maximum possible number of colors (*not* default number of colors.) */
110 #define NUMCOLORS 256
112 /* The globals that screenhack.c expects (initialized by xlockmore.c).
115 XrmOptionDescRec options[100];
117 /* Prototypes for the actual drawing routines...
119 extern void HACK_INIT(ModeInfo *);
120 extern void HACK_DRAW(ModeInfo *);
123 extern void HACK_FREE(ModeInfo *);
129 /* Emit code for the entrypoint used by screenhack.c, and pass control
130 down into xlockmore.c with the appropriate parameters.
133 char *progclass = PROGCLASS;
135 void screenhack (Display *dpy, Window window)
137 xlockmore_screenhack (dpy, window,
139 #ifdef WRITABLE_COLORS
145 #ifdef UNIFORM_COLORS
169 const char *app_defaults = DEFAULTS ;