http://slackware.bholcomb.com/slackware/slackware-11.0/source/xap/xscreensaver/xscree...
[xscreensaver] / hacks / bumps.h
index f5e8c29213c6746cbb059a89a16ff46fdae7771f..ee61755db866e1e406ff4e46d5de84ea71cf53b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Bumps, Copyright (c) 1999 Shane Smit <blackend@inconnect.com>
+/* Bumps, Copyright (c) 2001 Shane Smit <CodeWeaver@DigitalLoom.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  * Tab Size: 4
  *
  * Description:
- *  Header file for module "Bumps.cpp"
+ *  Header file for module "Bumps.c"
  *
  * Modification History:
  *  [10/01/99] - Shane Smit: Creation
  *  [10/08/99] - Shane Smit: Port to C. (Ick)
+ *  [03/08/02] - Shane Smit: New movement code.
+ *  [09/12/02] - Shane Smit: MIT-SHM XImages.
+ *                                                      Thanks to Kennett Galbraith <http://www.Alpha-II.com/>
+ *                                                      for code optimization.
  */
 
 
 
 #include <math.h>
 #include "screenhack.h"
-#include <X11/Xutil.h>
+
+#ifdef HAVE_XSHM_EXTENSION
+#include "xshm.h"
+#endif /* HAVE_XSHM_EXTENSION */
 
 
 /* Defines: */
 /* #define VERBOSE */
-#define PI             3.141592654
 #define RANDOM() ((int) (random() & 0X7FFFFFFFL))
 
 typedef signed char            int8_;
@@ -44,30 +50,35 @@ typedef unsigned char       BOOL;
 
 
 /* Globals: */
-char *progclass = "Bumps";
 
-char *defaults [] = {
+static const char *bumps_defaults [] = {
   ".background: black",
   ".foreground: white",
-  "*degrees:   360",
   "*color:             random",
   "*colorcount:        64",
-  "*delay:             50000",
+  "*delay:             30000",
   "*soften:            1",
   "*invert:            FALSE",
 #ifdef __sgi    /* really, HAVE_READ_DISPLAY_EXTENSION */
-   "*visualID:         Best",
+  "*visualID:  Best",
 #endif
+#ifdef HAVE_XSHM_EXTENSION
+  "*useSHM:            True",
+#endif /* HAVE_XSHM_EXTENSION */
   0
 };
 
-XrmOptionDescRec options [] = {
-  { "-degrees",                ".degrees",             XrmoptionSepArg, 0 },
+static XrmOptionDescRec bumps_options [] = {
   { "-color",          ".color",               XrmoptionSepArg, 0 },
   { "-colorcount",     ".colorcount",  XrmoptionSepArg, 0 },
   { "-delay",          ".delay",               XrmoptionSepArg, 0 },
   { "-soften",         ".soften",              XrmoptionSepArg, 0 },
   { "-invert",         ".invert",              XrmoptionNoArg, "TRUE" },
+#ifdef HAVE_XSHM_EXTENSION
+  { "-shm",                    ".useSHM",              XrmoptionNoArg, "True" },
+  { "-no-shm",         ".useSHM",              XrmoptionNoArg, "False" },
+#endif /* HAVE_XSHM_EXTENSION */
+
   { 0, 0, 0, 0 }
 };
 
@@ -76,54 +87,49 @@ XrmOptionDescRec options [] = {
  * a member of TBumps. */
 typedef struct
 {
-       uint16_ nDegreeCount;
-       double *aSinTable;
-
        uint8_ *aLightMap;
-       uint16_ nDiameter, nRadius;
-       float nAngleX, nAngleY;         /* Spotlight's movement direction. */
+       uint16_ nFalloffDiameter, nFalloffRadius;
+       uint16_ nLightDiameter, nLightRadius;
+       float nAccelX, nAccelY;
+       float nAccelMax;
        float nVelocityX, nVelocityY;
-       uint16_ iWinXCenter, iWinYCenter;
+       float nVelocityMax;
+       float nXPos, nYPos;
 } SSpotLight;
 
-void CreateSpotLight( SSpotLight *, uint16_, uint16_ );
 void CreateTables( SSpotLight * );
-void CalcLightPos( SSpotLight *, uint16_ *, uint16_ * );
-void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLightMap ); free( pSpotLight->aSinTable ); }
 
 
 /* The entire program's operation is contained within this structure. */
 typedef struct
 {
        /* XWindows specific variables. */
-       Display *pDisplay;
+       Display *dpy;
        Window Win;
+        Pixmap source;
        GC GraphicsContext;
-       XColor *aXColors;
+       XColor *xColors;
+       uint32_ *aColors;
        XImage *pXImage;
+#ifdef HAVE_XSHM_EXTENSION
+       XShmSegmentInfo XShmInfo;
+       Bool    bUseShm;
+#endif /* HAVE_XSHM_EXTENSION */
 
        uint8_ nColorCount;                             /* Number of colors used. */
+       uint8_ bytesPerPixel;
        uint16_ iWinWidth, iWinHeight;
        uint16_ *aBumpMap;                              /* The actual bump map. */
-
        SSpotLight SpotLight;
-} SBumps;
 
-void CreateBumps( SBumps *, Display *, Window );
-void Execute( SBumps * );
-void DestroyBumps( SBumps * );
+        int delay;
 
-void SetPalette( SBumps *, XWindowAttributes * );
-void InitBumpMap( SBumps *, XWindowAttributes * );
-void SoftenBumpMap( SBumps * );
+        async_load_state *img_loader;
+} SBumps;
 
 
 #endif /* _BUMPS_H */
 
 
-/*
- * End of Module: "Bumps.h"
- */
-
 /* vim: ts=4
  */