X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=hacks%2Fglx%2Fstairs.c;h=7b6fbe2fe2aaf199f097ece2ed42c5dbd2be7722;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=2dd78b873d40f28096c46803896756e347051bca;hpb=4361b69d3178d7fc98d0388f9a223af6c2651aba;p=xscreensaver diff --git a/hacks/glx/stairs.c b/hacks/glx/stairs.c index 2dd78b87..7b6fbe2f 100644 --- a/hacks/glx/stairs.c +++ b/hacks/glx/stairs.c @@ -59,7 +59,6 @@ static const char sccsid[] = "@(#)stairs.c 4.07 97/11/24 xlockmore"; # define DEFAULTS "*delay: 20000 \n" \ "*showFPS: False \n" -# define refresh_stairs 0 # define release_stairs 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -72,8 +71,8 @@ static const char sccsid[] = "@(#)stairs.c 4.07 97/11/24 xlockmore"; #if 0 #include "e_textures.h" #else -#include "xpm-ximage.h" -#include "../images/wood.xpm" +#include "ximage-loader.h" +#include "images/gen/wood_png.h" #endif #include "sphere.h" @@ -85,7 +84,7 @@ ENTRYPOINT ModeSpecOpt stairs_opts = #ifdef USE_MODULES ModStruct stairs_description = {"stairs", "init_stairs", "draw_stairs", NULL, - "draw_stairs", "change_stairs", NULL, &stairs_opts, + "draw_stairs", "change_stairs", "free_stairs", &stairs_opts, 1000, 1, 1, 1, 4, 1.0, "", "Shows Infinite Stairs, an Escher-like scene", 0, NULL}; @@ -321,8 +320,14 @@ ENTRYPOINT void reshape_stairs (ModeInfo * mi, int width, int height) { stairsstruct *sp = &stairs[MI_SCREEN(mi)]; + int y = 0; - glViewport(0, 0, sp->WindW = (GLint) width, sp->WindH = (GLint) height); + if (width > height * 5) { /* tiny window: show middle */ + height = width; + y = -height/2; + } + + glViewport(0, y, sp->WindW = (GLint) width, sp->WindH = (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0); @@ -407,16 +412,11 @@ pinit(ModeInfo *mi) check_gl_error("mipmapping"); #else { - XImage *img = xpm_to_ximage (mi->dpy, - mi->xgwa.visual, - mi->xgwa.colormap, - wood_texture); + XImage *img = image_data_to_ximage (mi->dpy, mi->xgwa.visual, + wood_png, sizeof(wood_png)); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, img->width, img->height, 0, - GL_RGBA, - /* GL_UNSIGNED_BYTE, */ - GL_UNSIGNED_INT_8_8_8_8_REV, - img->data); + GL_RGBA, GL_UNSIGNED_BYTE, img->data); check_gl_error("texture"); XDestroyImage (img); } @@ -432,15 +432,13 @@ pinit(ModeInfo *mi) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); } -static void free_stairs (ModeInfo * mi); - ENTRYPOINT void init_stairs (ModeInfo * mi) { int screen = MI_SCREEN(mi); stairsstruct *sp; - MI_INIT (mi, stairs, free_stairs); + MI_INIT (mi, stairs); sp = &stairs[screen]; sp->step = 0.0; @@ -577,7 +575,7 @@ change_stairs (ModeInfo * mi) } #endif /* !STANDALONE */ -static void +ENTRYPOINT void free_stairs (ModeInfo * mi) { stairsstruct *sp = &stairs[MI_SCREEN(mi)];