X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fjigglypuff.c;h=8556a5beceeab8e8fbf7b97c54175ca682081983;hb=39809ded547bdbb08207d3e514950425215b4410;hp=a65e99fa94acfd4897688fe27d0b523753833ab3;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;p=xscreensaver diff --git a/hacks/glx/jigglypuff.c b/hacks/glx/jigglypuff.c index a65e99fa..8556a5be 100644 --- a/hacks/glx/jigglypuff.c +++ b/hacks/glx/jigglypuff.c @@ -39,8 +39,9 @@ # define DEFAULTS "*delay: 20000\n" \ "*showFPS: False\n" \ "*wireframe: False\n" \ + "*suppressRotationAnimation: True\n" \ -# define refresh_jigglypuff 0 +# define free_jigglypuff 0 # define release_jigglypuff 0 # include "xlockmore.h" #else @@ -939,13 +940,19 @@ ENTRYPOINT Bool jigglypuff_handle_event(ModeInfo *mi, XEvent *event) ENTRYPOINT void reshape_jigglypuff(ModeInfo *mi, int width, int height) { - GLfloat aspect = (GLfloat)width / (GLfloat)height; - - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-0.5*aspect, 0.5*aspect, -0.5, 0.5, 1, 20); -/* glTranslatef(0, 0, -10);*/ + double h = (GLfloat) height / (GLfloat) width; + int y = 0; + + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport(0, y, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-0.5*(1/h), 0.5*(1/h), -0.5, 0.5, 1, 20); } ENTRYPOINT void draw_jigglypuff(ModeInfo *mi) @@ -960,6 +967,16 @@ ENTRYPOINT void draw_jigglypuff(ModeInfo *mi) glLoadIdentity(); glTranslatef(0,0,-10); + +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, 1/h, 1/h); + } +# endif + glRotatef(js->angle, sin(js->axis), cos(js->axis), -sin(js->axis)); glTranslatef(0, 0, 5); if(!(js->button_down)) { @@ -999,14 +1016,7 @@ ENTRYPOINT void init_jigglypuff(ModeInfo *mi) jigglystruct *js; int subdivs; - if(!jss) { - jss = (jigglystruct*) - calloc(MI_NUM_SCREENS(mi), sizeof(jigglystruct)); - if(!jss) { - fprintf(stderr, "%s: No..memory...must...abort..\n", progname); - exit(1); - } - } + MI_INIT(mi, jss); js = &jss[MI_SCREEN(mi)];