X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fmirrorblob.c;h=6c721c2a0d5bcdc99c01f9c5c1859dbf15a37383;hb=2d04c4f22466851aedb6ed0f2919d148f726b889;hp=2ff5666a9ac1a8c4d33be1f298ece30146639c25;hpb=e4fa2ac140f7bc56571373a7b7eb585fa4500e38;p=xscreensaver diff --git a/hacks/glx/mirrorblob.c b/hacks/glx/mirrorblob.c index 2ff5666a..6c721c2a 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. * @@ -36,13 +36,6 @@ #include #include -/*- - * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock. - * otherwise caddr_t is not defined correctly - */ - -#include - #ifdef STANDALONE # define PROGCLASS "Screensaver" # define HACK_INIT init_screensaver @@ -87,7 +80,8 @@ "*motion_blur: " DEF_MOTION_BLUR "\n" \ "*incremental: " DEF_INCREMENTAL "\n" \ "*hold_time: " DEF_HOLD_TIME "\n" \ - "*fade_time: " DEF_FADE_TIME "\n" + "*fade_time: " DEF_FADE_TIME "\n" \ + "*useSHM: True \n" # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -343,35 +337,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); } /****************************************************************************** @@ -1055,10 +1044,10 @@ draw_blob (void) glArrayElement(index3); glEnd(); - lower = floorf((x - 0.5) * row_data[y - 1].num_x_points - / (float)row_data[y].num_x_points); - upper = floorf((x + 0.5) * row_data[y - 1].num_x_points - / (float)row_data[y].num_x_points); + lower = ((x - 0.5) * row_data[y - 1].num_x_points + / (float)row_data[y].num_x_points); + upper = ((x + 0.5) * row_data[y - 1].num_x_points + / (float)row_data[y].num_x_points); if (upper > lower) { @@ -1116,16 +1105,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();