source: trunk/third/xscreensaver/hacks/bumps.h @ 20148

Revision 20148, 3.5 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20147, which included commits to RCS files with non-trunk default branches.
Line 
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#include <X11/Xutil.h>
34
35#ifdef HAVE_XSHM_EXTENSION
36#include "xshm.h"
37#endif /* HAVE_XSHM_EXTENSION */
38
39
40/* Defines: */
41/* #define VERBOSE */
42#define RANDOM() ((int) (random() & 0X7FFFFFFFL))
43
44typedef signed char             int8_;
45typedef unsigned char   uint8_;
46typedef short                   int16_;
47typedef unsigned short  uint16_;
48typedef long                    int32_;
49typedef unsigned long   uint32_;
50typedef unsigned char   BOOL;
51
52
53/* Globals: */
54char *progclass = "Bumps";
55
56char *defaults [] = {
57  ".background: black",
58  ".foreground: white",
59  "*color:              random",
60  "*colorcount: 64",
61  "*delay:              30000",
62  "*soften:             1",
63  "*invert:             FALSE",
64#ifdef __sgi    /* really, HAVE_READ_DISPLAY_EXTENSION */
65  "*visualID:   Best",
66#endif
67#ifdef HAVE_XSHM_EXTENSION
68  "*useSHM:             True",
69#endif /* HAVE_XSHM_EXTENSION */
70  0
71};
72
73XrmOptionDescRec options [] = {
74  { "-color",           ".color",               XrmoptionSepArg, 0 },
75  { "-colorcount",      ".colorcount",  XrmoptionSepArg, 0 },
76  { "-delay",           ".delay",               XrmoptionSepArg, 0 },
77  { "-soften",          ".soften",              XrmoptionSepArg, 0 },
78  { "-invert",          ".invert",              XrmoptionNoArg, "TRUE" },
79#ifdef HAVE_XSHM_EXTENSION
80  { "-shm",                     ".useSHM",              XrmoptionNoArg, "True" },
81  { "-no-shm",          ".useSHM",              XrmoptionNoArg, "False" },
82#endif /* HAVE_XSHM_EXTENSION */
83
84  { 0, 0, 0, 0 }
85};
86
87
88/* This structure handles everything to do with the spotlight, and is designed to be
89 * a member of TBumps. */
90typedef struct
91{
92        uint8_ *aLightMap;
93        uint16_ nFalloffDiameter, nFalloffRadius;
94        uint16_ nLightDiameter, nLightRadius;
95        float nAccelX, nAccelY;
96        float nAccelMax;
97        float nVelocityX, nVelocityY;
98        float nVelocityMax;
99        float nXPos, nYPos;
100} SSpotLight;
101
102void CreateSpotLight( SSpotLight *, uint16_, uint16_ );
103void CreateTables( SSpotLight * );
104void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLightMap ); }
105
106
107/* The entire program's operation is contained within this structure. */
108typedef struct
109{
110        /* XWindows specific variables. */
111        Display *pDisplay;
112        Window Win;
113        GC GraphicsContext;
114        uint32_ *aColors;
115        XImage *pXImage;
116#ifdef HAVE_XSHM_EXTENSION
117        XShmSegmentInfo XShmInfo;
118        Bool    bUseShm;
119#endif /* HAVE_XSHM_EXTENSION */
120
121        uint8_ nColorCount;                             /* Number of colors used. */
122        uint8_ bytesPerPixel;
123        uint16_ iWinWidth, iWinHeight;
124        uint16_ *aBumpMap;                              /* The actual bump map. */
125
126        SSpotLight SpotLight;
127} SBumps;
128
129void CreateBumps( SBumps *, Display *, Window );
130void Execute( SBumps * );
131void DestroyBumps( SBumps * );
132
133void SetPalette( SBumps *, XWindowAttributes * );
134void InitBumpMap( SBumps *, XWindowAttributes * );
135void SoftenBumpMap( SBumps * );
136
137
138#endif /* _BUMPS_H */
139
140
141/* vim: ts=4
142 */
Note: See TracBrowser for help on using the repository browser.