X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fblocktube.c;h=d4a402e71987ff11a277215d4955ac2d3ee82cbe;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=682b64390e05eb8da7e3e99198e9a511b962c6af;hpb=4361b69d3178d7fc98d0388f9a223af6c2651aba;p=xscreensaver diff --git a/hacks/glx/blocktube.c b/hacks/glx/blocktube.c index 682b6439..d4a402e7 100644 --- a/hacks/glx/blocktube.c +++ b/hacks/glx/blocktube.c @@ -18,9 +18,8 @@ "*showFPS: False \n" \ "*suppressRotationAnimation: True\n" \ -# define refresh_blocktube 0 # define release_blocktube 0 -# define blocktube_handle_event 0 +# define blocktube_handle_event xlockmore_no_events #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -39,10 +38,10 @@ #if defined(USE_XPM) || defined(USE_XPMINC) || defined(STANDALONE) /* USE_XPM & USE_XPMINC in xlock mode ; HAVE_XPM in xscreensaver mode */ -#include "xpm-ximage.h" +#include "ximage-loader.h" #define I_HAVE_XPM -#include "../images/blocktube.xpm" +#include "images/gen/blocktube_png.h" #endif /* HAVE_XPM */ typedef struct { @@ -111,7 +110,7 @@ ENTRYPOINT ModeSpecOpt blocktube_opts = {countof(opts), opts, countof(vars), var #ifdef USE_MODULES ModStruct blocktube_description = {"blocktube", "init_blocktube", "draw_blocktube", (char *)NULL, - "draw_blocktube", "init_blocktube", (char *)NULL, &blocktube_opts, + "draw_blocktube", "init_blocktube", "free_blocktube", &blocktube_opts, 40000, 30, 1, 1, 64, 1.0, "", "A shifting tunnel of reflective blocks", 0, NULL}; #endif /* USE_MODULES */ @@ -125,14 +124,14 @@ static Bool LoadGLTextures(ModeInfo *mi) status = True; glGenTextures(1, &lp->envTexture); glBindTexture(GL_TEXTURE_2D, lp->envTexture); - lp->texti = xpm_to_ximage(MI_DISPLAY(mi), MI_VISUAL(mi), MI_COLORMAP(mi), - blocktube_xpm); + lp->texti = image_data_to_ximage(MI_DISPLAY(mi), MI_VISUAL(mi), + blocktube_png, sizeof(blocktube_png)); if (!lp->texti) { status = False; } else { glPixelStorei(GL_UNPACK_ALIGNMENT,1); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lp->texti->width, lp->texti->height, 0, - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, lp->texti->data); + GL_RGBA, GL_UNSIGNED_BYTE, lp->texti->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); # ifndef HAVE_JWZGLES /* #### Sphere maps unimplemented */ @@ -205,7 +204,6 @@ static void tick(blocktube_configuration *lp) static int cube_vertices(float x, float y, float z, int wire); ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height); -static void free_blocktube (ModeInfo *mi); ENTRYPOINT void init_blocktube (ModeInfo *mi) { @@ -214,7 +212,7 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) blocktube_configuration *lp; int wire = MI_IS_WIREFRAME(mi); - MI_INIT(mi, lps, free_blocktube); + MI_INIT(mi, lps); lp = &lps[MI_SCREEN(mi)]; lp->glx_context = init_GL(mi); @@ -289,7 +287,7 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) glFlush(); } -static void free_blocktube (ModeInfo *mi) +ENTRYPOINT void free_blocktube (ModeInfo *mi) { blocktube_configuration *lp = &lps[MI_SCREEN(mi)]; # if defined ( I_HAVE_XPM ) @@ -308,10 +306,17 @@ ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height) { blocktube_configuration *lp = &lps[MI_SCREEN(mi)]; GLfloat h = (GLfloat) height / (GLfloat) width; + int y = 0; glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context)); - glViewport(0, 0, (GLint) width, (GLint) height); + if (width > height * 5) { /* tiny window: show middle */ + height = width; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport(0, y, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, 1/h, 1.0, 100.0);