X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fjigglypuff.c;h=8556a5beceeab8e8fbf7b97c54175ca682081983;hb=39809ded547bdbb08207d3e514950425215b4410;hp=63b832947e63328a2143ff1ddf4857de0f2602f7;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/glx/jigglypuff.c b/hacks/glx/jigglypuff.c index 63b83294..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 @@ -286,10 +287,12 @@ static inline void vector_scale(vector v, coord s) v[2] *= s; } +/* static inline coord dot(vector v1, vector v2) { return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; } +*/ static inline void cross(vector v1, vector v2, vector v) { @@ -872,11 +875,11 @@ static int parse_color(jigglystruct *js) static void randomize_parameters(jigglystruct *js) { do_tetrahedron = random() & 1; -# ifndef HAVE_JWZGLES +# ifndef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */ js->do_wireframe = !(random() & 3); # endif js->color_style = random() % 5; -# ifdef HAVE_JWZGLES /* SPHERE_MAP unimplemented */ +# ifdef HAVE_JWZGLES /* #### SPHERE_MAP unimplemented */ while (js->color_style == COLOR_STYLE_CHROME) js->color_style = random() % 5;; # endif @@ -927,45 +930,29 @@ ENTRYPOINT Bool jigglypuff_handle_event(ModeInfo *mi, XEvent *event) { jigglystruct *js = &jss[MI_SCREEN(mi)]; - if(event->xany.type == ButtonPress && - event->xbutton.button == Button1) { - js->button_down = 1; - gltrackball_start(js->trackball, event->xbutton.x, event->xbutton.y, - MI_WIDTH(mi), MI_HEIGHT(mi)); - return True; - } - else if(event->xany.type == ButtonRelease && - event->xbutton.button == Button1) { - js->button_down = 0; - return True; - } - else if (event->xany.type == ButtonPress && - (event->xbutton.button == Button4 || - event->xbutton.button == Button5 || - event->xbutton.button == Button6 || - event->xbutton.button == Button7)) - { - gltrackball_mousewheel (js->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if(event->xany.type == MotionNotify && js->button_down) { - gltrackball_track(js->trackball, event->xmotion.x, event->xmotion.y, - MI_WIDTH(mi), MI_HEIGHT(mi)); - return True; - } + if (gltrackball_event_handler (event, js->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &js->button_down)) + return True; + return False; } 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) @@ -980,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)) { @@ -991,10 +988,7 @@ ENTRYPOINT void draw_jigglypuff(ModeInfo *mi) } } - /* Do it twice because we don't track the device's orientation. */ - glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate(js->trackball); - glRotatef(-current_device_rotation(), 0, 0, 1); if(js->color_style == COLOR_STYLE_CYCLE) { int i; @@ -1022,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)]; @@ -1074,7 +1061,7 @@ ENTRYPOINT void init_jigglypuff(ModeInfo *mi) else { MI_CLEARWINDOW(mi); } - js->trackball = gltrackball_init(); + js->trackball = gltrackball_init(True); /* _DEBUG("distance : %f\nhold : %f\nspherify : %f\ndamping : %f\ndfact : %f\n", js->stable_distance, js->hold_strength, js->spherify_strength, js->damping_velocity, js->damping_factor);