http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.01.tar.gz
[xscreensaver] / hacks / bumps.h
1 /* Bumps, Copyright (c) 1999 Shane Smit <blackend@inconnect.com>
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.cpp"
16  *
17  * Modification History:
18  *  [10/01/99] - Shane Smit: Creation
19  *  [10/08/99] - Shane Smit: Port to C. (Ick)
20  */
21
22
23 #ifndef _BUMPS_H
24 #define _BUMPS_H
25
26
27 #include <math.h>
28 #include "screenhack.h"
29 #include <X11/Xutil.h>
30
31
32 /* Defines: */
33 /* #define VERBOSE */
34 #define PI              3.141592654
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   "*degrees:    360",
53   "*color:              random",
54   "*colorcount: 64",
55   "*delay:              50000",
56   "*soften:             1",
57   "*invert:             FALSE",
58 #ifdef __sgi    /* really, HAVE_READ_DISPLAY_EXTENSION */
59    "*visualID:          Best",
60 #endif
61   0
62 };
63
64 XrmOptionDescRec options [] = {
65   { "-degrees",         ".degrees",             XrmoptionSepArg, 0 },
66   { "-color",           ".color",               XrmoptionSepArg, 0 },
67   { "-colorcount",      ".colorcount",  XrmoptionSepArg, 0 },
68   { "-delay",           ".delay",               XrmoptionSepArg, 0 },
69   { "-soften",          ".soften",              XrmoptionSepArg, 0 },
70   { "-invert",          ".invert",              XrmoptionNoArg, "TRUE" },
71   { 0, 0, 0, 0 }
72 };
73
74
75 /* This structure handles everything to do with the spotlight, and is designed to be
76  * a member of TBumps. */
77 typedef struct
78 {
79         uint16_ nDegreeCount;
80         double *aSinTable;
81
82         uint8_ *aLightMap;
83         uint16_ nDiameter, nRadius;
84         float nAngleX, nAngleY;         /* Spotlight's movement direction. */
85         float nVelocityX, nVelocityY;
86         uint16_ iWinXCenter, iWinYCenter;
87 } SSpotLight;
88
89 void CreateSpotLight( SSpotLight *, uint16_, uint16_ );
90 void CreateTables( SSpotLight * );
91 void CalcLightPos( SSpotLight *, uint16_ *, uint16_ * );
92 void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLightMap ); free( pSpotLight->aSinTable ); }
93
94
95 /* The entire program's operation is contained within this structure. */
96 typedef struct
97 {
98         /* XWindows specific variables. */
99         Display *pDisplay;
100         Window Win;
101         GC GraphicsContext;
102         XColor *aXColors;
103         XImage *pXImage;
104
105         uint8_ nColorCount;                             /* Number of colors used. */
106         uint16_ iWinWidth, iWinHeight;
107         uint16_ *aBumpMap;                              /* The actual bump map. */
108
109         SSpotLight SpotLight;
110 } SBumps;
111
112 void CreateBumps( SBumps *, Display *, Window );
113 void Execute( SBumps * );
114 void DestroyBumps( SBumps * );
115
116 void SetPalette( SBumps *, XWindowAttributes * );
117 void InitBumpMap( SBumps *, XWindowAttributes * );
118 void SoftenBumpMap( SBumps * );
119
120
121 #endif /* _BUMPS_H */
122
123
124 /*
125  * End of Module: "Bumps.h"
126  */
127
128 /* vim: ts=4
129  */