1 /* -*- mode: C; tab-width: 4 -*-
2 * Bumps, Copyright (c) 2002, 2006 Shane Smit <CodeWeaver@DigitalLoom.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
16 * This is typical bump-mapping. The actual bump map is generated by a screen
17 * grab. The light source is represented by a spotlight of random color. This
18 * spotlight randomly traverses the bump map in a sinus pattern.
20 * Essentially, it 3D-izes your desktop, based on color intensity.
22 * Modification History:
23 * [10/01/99] - Shane Smit: Creation
24 * [10/08/99] - Shane Smit: Port to C. (Ick)
25 * [03/08/02] - Shane Smit: New movement code.
26 * [09/12/02] - Shane Smit: MIT-SHM XImages.
27 * Thanks to Kennett Galbraith <http://www.Alpha-II.com/>
28 * for code optimization.
33 static void SetPalette(Display *, SBumps *, XWindowAttributes * );
34 static void InitBumpMap(Display *, SBumps *, XWindowAttributes * );
35 static void InitBumpMap_2(Display *, SBumps *);
36 static void SoftenBumpMap( SBumps * );
41 /* This function pointer will point to the appropriate PutPixel*() function below. */
42 static void (*MyPutPixel)( int8_ *, uint32_ );
44 static void PutPixel32( int8_ *pData, uint32_ pixel )
46 *(uint32_ *)pData = pixel;
49 static void PutPixel24( int8_ *pData, uint32_ pixel )
51 pData[ 2 ] = ( pixel & 0x00FF0000 ) >> 16;
52 pData[ 1 ] = ( pixel & 0x0000FF00 ) >> 8;
53 pData[ 0 ] = ( pixel & 0x000000FF );
56 static void PutPixel16( int8_ *pData, uint32_ pixel )
58 *(uint16_ *)pData = (uint16_)pixel;
61 static void PutPixel8( int8_ *pData, uint32_ pixel )
63 *(uint8_ *)pData = (uint8_)pixel;
66 /* Creates the light map, which is a circular image... going from black around the edges
67 * to white in the center. */
68 static void CreateSpotLight( SSpotLight *pSpotLight, uint16_ iDiameter, uint16_ nColorCount )
71 int16_ iDistX, iDistY;
74 pSpotLight->nFalloffDiameter = iDiameter;
75 pSpotLight->nFalloffRadius = pSpotLight->nFalloffDiameter / 2;
76 pSpotLight->nLightDiameter = iDiameter / 2;
77 pSpotLight->nLightRadius = pSpotLight->nLightDiameter / 2;
79 printf( "%s: Falloff Diameter: %d\n", progclass, pSpotLight->nFalloffDiameter );
80 printf( "%s: Spot Light Diameter: %d\n", progclass, pSpotLight->nLightDiameter );
83 pSpotLight->aLightMap = malloc( pSpotLight->nLightDiameter * pSpotLight->nLightDiameter * sizeof(uint8_) );
85 pLOffset = pSpotLight->aLightMap;
86 for( iDistY=-pSpotLight->nLightRadius; iDistY<pSpotLight->nLightRadius; ++iDistY )
88 for( iDistX=-pSpotLight->nLightRadius; iDistX<pSpotLight->nLightRadius; ++iDistX )
90 nDist = sqrt( pow( iDistX+0.5F, 2 ) + pow( iDistY+0.5F, 2 ) );
91 if( nDist / pSpotLight->nLightRadius <= 1.0f )
92 *pLOffset = (uint8_)(nColorCount - ( ( nDist / pSpotLight->nLightRadius ) * ( nColorCount - 1 ) ));
100 /* Initialize movement variables. */
101 pSpotLight->nAccelX = 0;
102 pSpotLight->nAccelY = 0;
103 pSpotLight->nVelocityX = ( RANDOM() % 2 ) ? pSpotLight->nVelocityMax : -pSpotLight->nVelocityMax;
104 pSpotLight->nVelocityY = ( RANDOM() % 2 ) ? pSpotLight->nVelocityMax : -pSpotLight->nVelocityMax;
108 /* Calculates the position of the spot light on the screen. */
109 static void CalcLightPos( SBumps *pBumps )
111 SSpotLight *pSpotLight = &pBumps->SpotLight;
115 if( pSpotLight->nXPos < pSpotLight->nFalloffRadius ) nGravity = 1.0f;
116 else if( pSpotLight->nXPos > pBumps->iWinWidth - pSpotLight->nFalloffRadius ) nGravity = -1.0f;
117 else nGravity = ( ( RANDOM() % 201 ) / 100.0f ) - 1.0f;
119 pSpotLight->nAccelX += nGravity * ( pSpotLight->nAccelMax / 5.0f );
120 if( pSpotLight->nAccelX < -pSpotLight->nAccelMax ) pSpotLight->nAccelX = -pSpotLight->nAccelMax;
121 else if( pSpotLight->nAccelX > pSpotLight->nAccelMax ) pSpotLight->nAccelX = pSpotLight->nAccelMax;
123 pSpotLight->nVelocityX += pSpotLight->nAccelX;
124 if( pSpotLight->nVelocityX < -pSpotLight->nVelocityMax ) pSpotLight->nVelocityX = -pSpotLight->nVelocityMax;
125 else if( pSpotLight->nVelocityX > pSpotLight->nVelocityMax ) pSpotLight->nVelocityX = pSpotLight->nVelocityMax;
127 pSpotLight->nXPos += pSpotLight->nVelocityX;
130 if( pSpotLight->nYPos < pSpotLight->nFalloffRadius ) nGravity = 1.0f;
131 else if( pSpotLight->nYPos > pBumps->iWinHeight - pSpotLight->nFalloffRadius ) nGravity = -1.0f;
132 else nGravity = ( ( RANDOM() % 201 ) / 100.0f ) - 1.0f;
134 pSpotLight->nAccelY += nGravity * ( pSpotLight->nAccelMax / 5.0f );
135 if( pSpotLight->nAccelY < -pSpotLight->nAccelMax ) pSpotLight->nAccelY = -pSpotLight->nAccelMax;
136 else if( pSpotLight->nAccelY > pSpotLight->nAccelMax ) pSpotLight->nAccelY = pSpotLight->nAccelMax;
138 pSpotLight->nVelocityY += pSpotLight->nAccelY;
139 if( pSpotLight->nVelocityY < -pSpotLight->nVelocityMax ) pSpotLight->nVelocityY = -pSpotLight->nVelocityMax;
140 else if( pSpotLight->nVelocityY > pSpotLight->nVelocityMax ) pSpotLight->nVelocityY = pSpotLight->nVelocityMax;
142 pSpotLight->nYPos += pSpotLight->nVelocityY;
146 /* Main initialization function. */
147 static void CreateBumps( SBumps *pBumps, Display *dpy, Window NewWin )
149 XWindowAttributes XWinAttribs;
154 /* Make size and velocity a function of window size, so it appears the same at 100x60 as it does in 3200x1200. */
155 XGetWindowAttributes( dpy, NewWin, &XWinAttribs );
156 pBumps->iWinWidth = XWinAttribs.width;
157 pBumps->iWinHeight = XWinAttribs.height;
158 pBumps->SpotLight.nXPos = XWinAttribs.width / 2.0f;
159 pBumps->SpotLight.nYPos = XWinAttribs.height / 2.0f;
160 pBumps->SpotLight.nVelocityMax = ( ( XWinAttribs.width < XWinAttribs.height ) ? XWinAttribs.width : XWinAttribs.height ) / 140.0f;
161 pBumps->SpotLight.nAccelMax = pBumps->SpotLight.nVelocityMax / 10.0f;
163 pBumps->Win = NewWin;
164 pBumps->screen = XWinAttribs.screen;
165 pBumps->pXImage = NULL;
167 iDiameter = ( ( pBumps->iWinWidth < pBumps->iWinHeight ) ? pBumps->iWinWidth : pBumps->iWinHeight ) / 2;
169 /* jwz: sometimes we get tearing if this lands on the wrong bounaary;
170 constraining it to be a multiple of 8 seems to fix it. */
171 iDiameter = ((iDiameter+7)/8)*8;
173 #ifdef HAVE_XSHM_EXTENSION
174 pBumps->bUseShm = get_boolean_resource(dpy, "useSHM", "Boolean" );
176 if( pBumps->bUseShm )
178 pBumps->pXImage = create_xshm_image( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
179 ZPixmap, NULL, &pBumps->XShmInfo, iDiameter, iDiameter );
180 if( !pBumps->pXImage )
182 fprintf( stderr, "%s: Unable to create XShmImage.\n", progname );
183 pBumps->bUseShm = False;
186 #endif /* HAVE_XSHM_EXTENSION */
187 if( !pBumps->pXImage )
189 pBumps->pXImage = XCreateImage( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
190 ZPixmap, 0, NULL, iDiameter, iDiameter, BitmapPad( pBumps->dpy ), 0 );
191 pBumps->pXImage->data = malloc( pBumps->pXImage->bytes_per_line * pBumps->pXImage->height * sizeof(int8_) );
194 /* For speed, access the XImage data directly using my own PutPixel routine. */
195 switch( pBumps->pXImage->bits_per_pixel )
198 pBumps->bytesPerPixel = 4;
199 MyPutPixel = PutPixel32;
203 pBumps->bytesPerPixel = 3;
204 MyPutPixel = PutPixel24;
208 pBumps->bytesPerPixel = 2;
209 MyPutPixel = PutPixel16;
213 pBumps->bytesPerPixel = 1;
214 MyPutPixel = PutPixel8;
218 fprintf( stderr, "%s: Unknown XImage depth.", progname );
219 #ifdef HAVE_XSHM_EXTENSION
220 if( pBumps->bUseShm )
221 destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
223 #endif /* HAVE_XSHM_EXTENSION */
224 XDestroyImage( pBumps->pXImage );
228 GCValues.function = GXcopy;
229 GCValues.subwindow_mode = IncludeInferiors;
230 nGCFlags = GCFunction;
231 if( use_subwindow_mode_p( XWinAttribs.screen, pBumps->Win ) ) /* See grabscreen.c */
232 nGCFlags |= GCSubwindowMode;
233 pBumps->GraphicsContext = XCreateGC( pBumps->dpy, pBumps->Win, nGCFlags, &GCValues );
235 SetPalette(dpy, pBumps, &XWinAttribs );
236 CreateSpotLight( &pBumps->SpotLight, iDiameter, pBumps->nColorCount );
237 InitBumpMap(dpy, pBumps, &XWinAttribs );
241 /* Creates a specialized phong shade palette. */
242 static void SetPalette(Display *dpy, SBumps *pBumps, XWindowAttributes *pXWinAttribs )
246 char *sColor; /* Spotlight Color */
249 sColor = get_string_resource(dpy, "color", "Color" );
251 BaseColor.red = RANDOM() % 0xFFFF;
252 BaseColor.green = RANDOM() % 0xFFFF;
253 BaseColor.blue = RANDOM() % 0xFFFF;
255 /* Make one color full intesity to avoid dark spotlights. */
256 switch( RANDOM() % 3 )
258 case 0: BaseColor.red = 0xFFFF; break;
259 case 1: BaseColor.green = 0xFFFF; break;
260 case 2: BaseColor.blue = 0xFFFF; break;
263 if( strcasecmp( sColor, "random" ) && !XParseColor( pBumps->dpy, pXWinAttribs->colormap, sColor, &BaseColor ) )
264 fprintf( stderr, "%s: color %s not found in database. Choosing random...\n", progname, sColor );
267 printf( "%s: Spotlight color is <%d,%d,%d> RGB.\n", progclass, BaseColor.red, BaseColor.green, BaseColor.blue );
270 pBumps->nColorCount = get_integer_resource(dpy, "colorcount", "Integer" );
271 if( pBumps->nColorCount < 2 ) pBumps->nColorCount = 2;
272 if( pBumps->nColorCount > 128 ) pBumps->nColorCount = 128;
274 pBumps->aColors = malloc( pBumps->nColorCount * sizeof(uint32_ ) );
276 /* Creates a phong shade: / BaseColor \ Index/ColorCount
277 * PhongShade = | ------------ | Index + ( 65535 - BaseColor )^
279 pBumps->nColorCount--;
280 for( iColor=0; iColor<=pBumps->nColorCount; iColor++ )
282 Color.red = (uint16_)( ( ( BaseColor.red / (double)pBumps->nColorCount ) * iColor ) + pow( 0xFFFF - BaseColor.red, iColor/(double)pBumps->nColorCount ) );
283 Color.green = (uint16_)( ( ( BaseColor.green / (double)pBumps->nColorCount ) * iColor ) + pow( 0xFFFF - BaseColor.green, iColor/(double)pBumps->nColorCount ) );
284 Color.blue = (uint16_)( ( ( BaseColor.blue / (double)pBumps->nColorCount ) * iColor ) + pow( 0xFFFF - BaseColor.blue, iColor/(double)pBumps->nColorCount ) );
286 if( !XAllocColor( pBumps->dpy, pXWinAttribs->colormap, &Color ) )
288 XFreeColors( pBumps->dpy, pXWinAttribs->colormap, pBumps->aColors, iColor, 0 );
289 free( pBumps->aColors );
290 pBumps->aColors = malloc( pBumps->nColorCount * sizeof(uint32_) );
291 pBumps->nColorCount--;
295 pBumps->aColors[ iColor ] = Color.pixel;
297 pBumps->nColorCount++;
300 printf( "%s: Allocated %d colors.\n", progclass, pBumps->nColorCount );
303 XSetWindowBackground( pBumps->dpy, pBumps->Win, pBumps->aColors[ 0 ] );
307 /* Grabs the current contents of the window to use an intensity-based bump map. */
308 static void InitBumpMap(Display *dpy, SBumps *pBumps, XWindowAttributes *pXWinAttribs )
310 pBumps->xColors = (XColor*)malloc( pBumps->iWinWidth * sizeof(XColor) );
312 if (pBumps->source) abort();
313 pBumps->source = XCreatePixmap(pBumps->dpy, pBumps->Win,
314 pXWinAttribs->width, pXWinAttribs->height,
315 pXWinAttribs->depth);
316 pBumps->img_loader = load_image_async_simple (0, pXWinAttribs->screen,
317 pBumps->Win, pBumps->source, 0, 0);
320 static void InitBumpMap_2(Display *dpy, SBumps *pBumps)
322 XImage *pScreenImage;
325 uint16_ iWidth, iHeight;
329 double softenMultiplier = 1.0f;
330 BOOL bInvert = (BOOL)get_boolean_resource(dpy, "invert", "Boolean" );
331 XWindowAttributes XWinAttribs;
332 XGetWindowAttributes( pBumps->dpy, pBumps->Win, &XWinAttribs );
334 pBumps->start_time = time ((time_t) 0);
336 pScreenImage = XGetImage( pBumps->dpy, pBumps->source, 0, 0,
337 pBumps->iWinWidth, pBumps->iWinHeight,
339 /* XFreePixmap (pBumps->dpy, pBumps->source);
340 pBumps->source = 0;*/
342 XSetWindowBackground( pBumps->dpy, pBumps->Win, pBumps->aColors[ 0 ] );
343 XClearWindow (pBumps->dpy, pBumps->Win);
344 XSync (pBumps->dpy, 0);
346 pBumps->aBumpMap = malloc( pBumps->iWinWidth * pBumps->iWinHeight * sizeof(uint16_) );
348 nSoften = get_integer_resource(dpy, "soften", "Integer" );
350 softenMultiplier *= 1.0f + ( 1.0f / 3.0f ); /* Softening takes the max height down, so scale up to compensate. */
351 maxHeight = pBumps->SpotLight.nLightRadius * softenMultiplier;
352 nAverager = maxHeight ? ( 3 * 0xFFFF ) / maxHeight : 0;
354 pBump = pBumps->aBumpMap;
355 if( bInvert ) /* Funny, it's actually the 'else' that inverts the bump map... */
357 for( iHeight=0; iHeight<pBumps->iWinHeight; iHeight++ )
359 pColor = pBumps->xColors;
360 for( iWidth=0; iWidth<pBumps->iWinWidth; iWidth++ )
361 (pColor++)->pixel = XGetPixel( pScreenImage, iWidth, iHeight );
363 XQueryColors( pBumps->dpy, XWinAttribs.colormap, pBumps->xColors, pBumps->iWinWidth );
365 pColor = pBumps->xColors;
366 for( iWidth=pBumps->iWinWidth; iWidth; --iWidth, ++pColor, ++pBump )
367 *pBump = ( nAverager ? ( pColor->red + pColor->green + pColor->blue ) / nAverager : 0 );
372 for( iHeight=0; iHeight<pBumps->iWinHeight; iHeight++ )
374 pColor = pBumps->xColors;
375 for( iWidth=0; iWidth<pBumps->iWinWidth; iWidth++ )
376 (pColor++)->pixel = XGetPixel( pScreenImage, iWidth, iHeight );
378 XQueryColors( pBumps->dpy, XWinAttribs.colormap, pBumps->xColors, pBumps->iWinWidth );
380 pColor = pBumps->xColors;
381 for( iWidth=pBumps->iWinWidth; iWidth; --iWidth, ++pColor, ++pBump )
382 *pBump = ( maxHeight - ( nAverager ? ( pColor->red + pColor->green + pColor->blue ) / nAverager : 0 ) );
386 XDestroyImage( pScreenImage );
388 nSoften = get_integer_resource(dpy, "soften", "Integer" );
390 if( nSoften ) printf( "%s: Softening Bump Map %d time(s)...\n", progclass, nSoften );
393 SoftenBumpMap( pBumps );
395 /* free( pBumps->xColors );
396 pBumps->xColors = 0;*/
399 /* Soften the bump map. This is to avoid pixelated-looking ridges.
400 * |-----|-----|-----|
401 * | 0% |12.5%| 0% | The adjacent pixels are averaged together
402 * |-----|-----|-----| first. Then than value is averaged with
403 * |12.5%| 50% |12.5%| the pixel is question. This essentially weights
404 * |-----|-----|-----| each pixel as shown on the left.
406 * |-----|-----|-----|
408 static void SoftenBumpMap( SBumps *pBumps )
410 uint16_ *pOffset, *pTOffset;
412 uint32_ iWidth, iHeight;
413 uint16_ *aTempBuffer = malloc( pBumps->iWinWidth * pBumps->iWinHeight * sizeof(uint16_) );
415 pOffset = pBumps->aBumpMap;
416 pTOffset = aTempBuffer;
417 for( iHeight=pBumps->iWinHeight; iHeight; --iHeight )
419 for( iWidth=pBumps->iWinWidth; iWidth; --iWidth, ++pOffset, ++pTOffset )
421 if( iHeight==pBumps->iWinHeight || iHeight==1 ||
422 iWidth==pBumps->iWinWidth || iWidth==1 )
428 nHeight = pOffset[ -pBumps->iWinWidth ];
429 nHeight += pOffset[ 1 ];
430 nHeight += pOffset[ pBumps->iWinWidth ];
431 nHeight += pOffset[ -1 ];
433 nHeight += pOffset[ 0 ];
439 memcpy( pBumps->aBumpMap, aTempBuffer, pBumps->iWinWidth * pBumps->iWinHeight * sizeof(uint16_) );
444 /* This is where we slap down some pixels... */
445 static void Execute( SBumps *pBumps )
447 int32_ nLightXPos, nLightYPos;
448 int32_ iScreenX, iScreenY;
449 int32_ iLightX, iLightY;
454 int32_ nLightOffsetFar = pBumps->SpotLight.nFalloffDiameter - pBumps->SpotLight.nLightRadius;
456 CalcLightPos( pBumps );
458 /* Offset to upper left hand corner. */
459 nLightXPos = pBumps->SpotLight.nXPos - pBumps->SpotLight.nFalloffRadius;
460 nLightYPos = pBumps->SpotLight.nYPos - pBumps->SpotLight.nFalloffRadius;
462 for( iScreenY=nLightYPos, iLightY=-pBumps->SpotLight.nLightRadius; iLightY<nLightOffsetFar; ++iScreenY, ++iLightY )
464 if( iScreenY < 0 ) continue;
465 else if( iScreenY >= pBumps->iWinHeight ) break;
467 /* warning: pointer targets in assignment differ in signedness
468 Should pDOffset be a int8? I can't tell. -jwz, 22-Jul-2003 */
469 pDOffset = (int8_ *) &pBumps->pXImage->data[ (iLightY+pBumps->SpotLight.nLightRadius) * pBumps->pXImage->bytes_per_line ];
470 pBOffset = pBumps->aBumpMap + ( iScreenY * pBumps->iWinWidth ) + nLightXPos;
471 for( iScreenX=nLightXPos, iLightX=-pBumps->SpotLight.nLightRadius; iLightX<nLightOffsetFar; ++iScreenX, ++iLightX, ++pBOffset, pDOffset+=pBumps->bytesPerPixel )
473 if( iScreenX < 0 ) continue;
474 else if( iScreenX >= pBumps->iWinWidth ) break;
475 else if( iScreenY == 0 || iScreenY >= pBumps->iWinHeight-2 ||
476 iScreenX == 0 || iScreenX >= pBumps->iWinWidth-2 )
478 MyPutPixel( pDOffset, pBumps->aColors[ 0 ] );
482 /* That's right folks, all the magic of bump mapping occurs in these two lines. (kinda disappointing, isn't it?) */
483 nX = ( pBOffset[ 1 ] - pBOffset[ 0 ] ) + iLightX;
484 nY = ( pBOffset[ pBumps->iWinWidth ] - pBOffset[ 0 ] ) + iLightY;
486 if( nX<0 || nX>=pBumps->SpotLight.nLightDiameter
487 || nY<0 || nY>=pBumps->SpotLight.nLightDiameter )
489 MyPutPixel( pDOffset, pBumps->aColors[ 0 ] );
493 nColor = pBumps->SpotLight.aLightMap[ ( nY * pBumps->SpotLight.nLightDiameter ) + nX ];
494 MyPutPixel( pDOffset, pBumps->aColors[ nColor ] );
498 /* Allow the spotlight to go *slightly* off the screen by clipping the XImage. */
499 iLightX = iLightY = 0; /* Use these for XImages X and Y now. */
500 nX = nY = pBumps->SpotLight.nFalloffDiameter; /* Use these for XImage width and height now. */
503 iLightX = -nLightXPos;
507 else if( nLightXPos + nX >= pBumps->iWinWidth )
509 nX -= ( nLightXPos + nX ) - pBumps->iWinWidth;
514 iLightY = -nLightYPos;
518 else if( nLightYPos + nY >= pBumps->iWinHeight )
520 nY -= ( nLightYPos + nY ) - pBumps->iWinHeight;
523 #ifdef HAVE_XSHM_EXTENSION
524 if( pBumps->bUseShm )
525 XShmPutImage( pBumps->dpy, pBumps->Win, pBumps->GraphicsContext, pBumps->pXImage, iLightX, iLightY, nLightXPos, nLightYPos,
528 #endif /* HAVE_XSHM_EXTENSION */
529 XPutImage( pBumps->dpy, pBumps->Win, pBumps->GraphicsContext, pBumps->pXImage, iLightX, iLightY, nLightXPos, nLightYPos,
534 static void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLightMap ); }
537 static void DestroyBumps( SBumps *pBumps )
539 DestroySpotLight( &pBumps->SpotLight );
540 free( pBumps->aColors );
541 free( pBumps->aBumpMap );
542 #ifdef HAVE_XSHM_EXTENSION
543 if( pBumps->bUseShm )
544 destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
546 #endif /* HAVE_XSHM_EXTENSION */
547 XDestroyImage( pBumps->pXImage );
551 /* All messages to the screensaver are processed here. */
553 bumps_init (Display *dpy, Window Win)
555 SBumps *Bumps = (SBumps *) calloc (1, sizeof(SBumps));
558 time_t Time = time( NULL );
562 CreateBumps( Bumps, dpy, Win );
563 Bumps->delay = get_integer_resource(dpy, "delay", "Integer" );
564 Bumps->duration = get_integer_resource (dpy, "duration", "Seconds");
565 if (Bumps->delay < 0) Bumps->delay = 0;
566 if (Bumps->duration < 1) Bumps->duration = 1;
567 Bumps->start_time = time ((time_t) 0);
572 bumps_draw (Display *dpy, Window window, void *closure)
574 SBumps *Bumps = (SBumps *) closure;
576 if (Bumps->img_loader) /* still loading */
578 Bumps->img_loader = load_image_async_simple (Bumps->img_loader, 0, 0, 0, 0, 0);
579 if (! Bumps->img_loader) /* just finished */
580 InitBumpMap_2(dpy, Bumps);
584 if (!Bumps->img_loader &&
585 Bumps->start_time + Bumps->duration < time ((time_t) 0)) {
586 Bumps->img_loader = load_image_async_simple (0, Bumps->screen,
587 Bumps->Win, Bumps->source,
595 if( Time - time( NULL ) )
597 printf( "FPS: %d\n", iFrame );
607 bumps_reshape (Display *dpy, Window window, void *closure,
608 unsigned int w, unsigned int h)
613 bumps_event (Display *dpy, Window window, void *closure, XEvent *event)
619 bumps_free (Display *dpy, Window window, void *closure)
621 SBumps *Bumps = (SBumps *) closure;
622 DestroyBumps( Bumps );
626 XSCREENSAVER_MODULE ("Bumps", bumps)