began for maemo
[xscreensaver] / 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  *  [09/12/02] - Shane Smit: MIT-SHM XImages.
22  *                                                       Thanks to Kennett Galbraith <http://www.Alpha-II.com/>
23  *                                                       for code optimization.
24  */
25
26
27 #ifndef _BUMPS_H
28 #define _BUMPS_H
29
30
31 #include <math.h>
32 #include "screenhack.h"
33
34 #ifdef HAVE_XSHM_EXTENSION
35 #include "xshm.h"
36 #endif /* HAVE_XSHM_EXTENSION */
37
38
39 /* Defines: */
40 /* #define VERBOSE */
41 #define RANDOM() ((int) (random() & 0X7FFFFFFFL))
42
43 typedef signed char             int8_;
44 typedef unsigned char   uint8_;
45 typedef short                   int16_;
46 typedef unsigned short  uint16_;
47 typedef long                    int32_;
48 typedef unsigned long   uint32_;
49 typedef unsigned char   BOOL;
50
51
52 /* Globals: */
53
54 static const char *bumps_defaults [] = {
55   ".background: black",
56   ".foreground: white",
57   "*color:              random",
58   "*colorcount: 64",
59   "*delay:              30000",
60   "*soften:             1",
61   "*invert:             FALSE",
62 #ifdef __sgi    /* really, HAVE_READ_DISPLAY_EXTENSION */
63   "*visualID:   Best",
64 #endif
65 #ifdef HAVE_XSHM_EXTENSION
66   "*useSHM:             True",
67 #endif /* HAVE_XSHM_EXTENSION */
68   0
69 };
70
71 static XrmOptionDescRec bumps_options [] = {
72   { "-color",           ".color",               XrmoptionSepArg, 0 },
73   { "-colorcount",      ".colorcount",  XrmoptionSepArg, 0 },
74   { "-delay",           ".delay",               XrmoptionSepArg, 0 },
75   { "-soften",          ".soften",              XrmoptionSepArg, 0 },
76   { "-invert",          ".invert",              XrmoptionNoArg, "TRUE" },
77 #ifdef HAVE_XSHM_EXTENSION
78   { "-shm",                     ".useSHM",              XrmoptionNoArg, "True" },
79   { "-no-shm",          ".useSHM",              XrmoptionNoArg, "False" },
80 #endif /* HAVE_XSHM_EXTENSION */
81
82   { 0, 0, 0, 0 }
83 };
84
85
86 /* This structure handles everything to do with the spotlight, and is designed to be
87  * a member of TBumps. */
88 typedef struct
89 {
90         uint8_ *aLightMap;
91         uint16_ nFalloffDiameter, nFalloffRadius;
92         uint16_ nLightDiameter, nLightRadius;
93         float nAccelX, nAccelY;
94         float nAccelMax;
95         float nVelocityX, nVelocityY;
96         float nVelocityMax;
97         float nXPos, nYPos;
98 } SSpotLight;
99
100 void CreateTables( SSpotLight * );
101
102
103 /* The entire program's operation is contained within this structure. */
104 typedef struct
105 {
106         /* XWindows specific variables. */
107         Display *dpy;
108         Window Win;
109         Pixmap source;
110         GC GraphicsContext;
111         XColor *xColors;
112         uint32_ *aColors;
113         XImage *pXImage;
114 #ifdef HAVE_XSHM_EXTENSION
115         XShmSegmentInfo XShmInfo;
116         Bool    bUseShm;
117 #endif /* HAVE_XSHM_EXTENSION */
118
119         uint8_ nColorCount;                             /* Number of colors used. */
120         uint8_ bytesPerPixel;
121         uint16_ iWinWidth, iWinHeight;
122         uint16_ *aBumpMap;                              /* The actual bump map. */
123         SSpotLight SpotLight;
124
125         int delay;
126
127         async_load_state *img_loader;
128 } SBumps;
129
130
131 #endif /* _BUMPS_H */
132
133
134 /* vim: ts=4
135  */