http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.02.tar.gz
[xscreensaver] / hacks / bumps.h
1 /* Bumps, Copyright (c) 2001 Shane Smit <CodeWeaver@DigitalLoom.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or
9  * implied warranty.
10  *
11  * Module: "Bumps.h"
12  * Tab Size: 4
13  *
14  * Description:
15  *  Header file for module "Bumps.c"
16  *
17  * Modification History:
18  *  [10/01/99] - Shane Smit: Creation
19  *  [10/08/99] - Shane Smit: Port to C. (Ick)
20  *  [03/08/02] - Shane Smit: New movement code.
21  */
22
23
24 #ifndef _BUMPS_H
25 #define _BUMPS_H
26
27
28 #include <math.h>
29 #include "screenhack.h"
30 #include <X11/Xutil.h>
31
32
33 /* Defines: */
34 /* #define VERBOSE */
35 #define RANDOM() ((int) (random() & 0X7FFFFFFFL))
36
37 typedef signed char             int8_;
38 typedef unsigned char   uint8_;
39 typedef short                   int16_;
40 typedef unsigned short  uint16_;
41 typedef long                    int32_;
42 typedef unsigned long   uint32_;
43 typedef unsigned char   BOOL;
44
45
46 /* Globals: */
47 char *progclass = "Bumps";
48
49 char *defaults [] = {
50   ".background: black",
51   ".foreground: white",
52   "*color:              random",
53   "*colorcount: 64",
54   "*delay:              50000",
55   "*soften:             1",
56   "*invert:             FALSE",
57 #ifdef __sgi    /* really, HAVE_READ_DISPLAY_EXTENSION */
58    "*visualID:          Best",
59 #endif
60   0
61 };
62
63 XrmOptionDescRec options [] = {
64   { "-color",           ".color",               XrmoptionSepArg, 0 },
65   { "-colorcount",      ".colorcount",  XrmoptionSepArg, 0 },
66   { "-delay",           ".delay",               XrmoptionSepArg, 0 },
67   { "-soften",          ".soften",              XrmoptionSepArg, 0 },
68   { "-invert",          ".invert",              XrmoptionNoArg, "TRUE" },
69   { 0, 0, 0, 0 }
70 };
71
72
73 /* This structure handles everything to do with the spotlight, and is designed to be
74  * a member of TBumps. */
75 typedef struct
76 {
77         uint8_ *aLightMap;
78         uint16_ nDiameter, nRadius;
79         float nAccelX, nAccelY;
80         float nAccelMax;
81         float nVelocityX, nVelocityY;
82         float nVelocityMax;
83         float nXPos, nYPos;
84 } SSpotLight;
85
86 void CreateSpotLight( SSpotLight *, uint16_, uint16_ );
87 void CreateTables( SSpotLight * );
88 void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLightMap ); }
89
90
91 /* The entire program's operation is contained within this structure. */
92 typedef struct
93 {
94         /* XWindows specific variables. */
95         Display *pDisplay;
96         Window Win;
97         GC GraphicsContext;
98         XColor *aXColors;
99         XImage *pXImage;
100
101         uint8_ nColorCount;                             /* Number of colors used. */
102         uint16_ iWinWidth, iWinHeight;
103         uint16_ *aBumpMap;                              /* The actual bump map. */
104
105         SSpotLight SpotLight;
106 } SBumps;
107
108 void CreateBumps( SBumps *, Display *, Window );
109 void Execute( SBumps * );
110 void DestroyBumps( SBumps * );
111
112 void SetPalette( SBumps *, XWindowAttributes * );
113 void InitBumpMap( SBumps *, XWindowAttributes * );
114 void SoftenBumpMap( SBumps * );
115
116
117 #endif /* _BUMPS_H */
118
119
120 /* vim: ts=4
121  */