X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fmirrorblob.c;h=b5a9275602478c7d2a553d1f2d84856ac5dfb82d;hb=447db08c956099b3b183886729108bf5b364c4b8;hp=61250cc03be64bbb5cf3fa90ebb9a6571d88b52c;hpb=ffd8c0873576a9e3065696a624dce6b766b77062;p=xscreensaver diff --git a/hacks/glx/mirrorblob.c b/hacks/glx/mirrorblob.c index 61250cc0..b5a92756 100644 --- a/hacks/glx/mirrorblob.c +++ b/hacks/glx/mirrorblob.c @@ -19,7 +19,7 @@ * 10-Feb-2004: jon.dowdall@bigpond.com Added motion blur * * The mirrorblob screensaver draws a pulsing blob on the screen. Options - * include adding a background (via screen_to_ximage), texturing the blob, + * include adding a background (via screen_to_texture), texturing the blob, * making the blob semi-transparent and varying the resolution of the blob * tessellation. * @@ -63,24 +63,9 @@ #define DEF_FADE_TIME "5" #define DEFAULTS \ - "*delay: " DEF_DELAY "\n" \ - "*showFPS: " DEF_FPS "\n" \ - "*wire: " DEF_WIRE "\n" \ - "*blend: " DEF_BLEND "\n" \ - "*fog: " DEF_FOG "\n" \ - "*antialias: " DEF_ANTIALIAS "\n" \ - "*walls: " DEF_WALLS "\n" \ - "*colour : " DEF_COLOUR "\n" \ - "*texture: " DEF_TEXTURE "\n" \ - "*offset_texture: " DEF_OFFSET_TEXTURE "\n" \ - "*paint_background: " DEF_PAINT_BACKGROUND "\n" \ - "*x_resolution: " DEF_X_RES "\n" \ - "*y_resolution: " DEF_Y_RES "\n" \ - "*field_points: " DEF_FIELD_POINTS "\n" \ - "*motion_blur: " DEF_MOTION_BLUR "\n" \ - "*incremental: " DEF_INCREMENTAL "\n" \ - "*hold_time: " DEF_HOLD_TIME "\n" \ - "*fade_time: " DEF_FADE_TIME "\n" + "*delay: " DEF_DELAY "\n" \ + "*showFPS: " DEF_FPS "\n" \ + "*useSHM: True \n" # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -336,35 +321,30 @@ reset_projection(int width, int height) /**************************************************************************** * - * Load a texture using the screen_to_ximage function. + * Load a texture using the screen_to_texture function. */ void grab_texture(ModeInfo *mi, int texture_index) { - XImage *ximage; - - ximage = screen_to_ximage (mi->xgwa.screen, mi->window, 0); + Bool mipmap_p = True; + int iw, ih, tw, th; glBindTexture (GL_TEXTURE_2D, textures[texture_index]); - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ximage->width, ximage->height, - 0, GL_RGBA, GL_UNSIGNED_BYTE, ximage->data); + if (! screen_to_texture (mi->xgwa.screen, mi->window, 0, 0, mipmap_p, + NULL, NULL, &iw, &ih, &tw, &th)) + exit(1); - tex_width[texture_index] = (mi->xgwa.width - 1) / (GLfloat)ximage->width; - tex_height[texture_index] = (mi->xgwa.height - 1) / (GLfloat)ximage->height; + tex_width [texture_index] = (GLfloat) iw / tw; + tex_height[texture_index] = -(GLfloat) ih / th; - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + (mipmap_p ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR)); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - free(ximage->data); - ximage->data = 0; - XDestroyImage (ximage); + glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } /****************************************************************************** @@ -1109,16 +1089,16 @@ draw_background (ModeInfo *mi) glBegin (GL_QUADS); - glTexCoord2f (0.0, tex_height[current_texture]); + glTexCoord2f (0.0, 0.0); glVertex2i (0, 0); - glTexCoord2f (0.0, 0.0); + glTexCoord2f (0.0, -tex_height[current_texture]); glVertex2i (0, MI_HEIGHT(mi)); - glTexCoord2f (tex_width[current_texture], 0.0); + glTexCoord2f (tex_width[current_texture], -tex_height[current_texture]); glVertex2i (MI_WIDTH(mi), MI_HEIGHT(mi)); - glTexCoord2f (tex_width[current_texture], tex_height[current_texture]); + glTexCoord2f (tex_width[current_texture], 0.0); glVertex2i (MI_WIDTH(mi), 0); glEnd();