X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fspheremonics.c;h=9cefbf3dbb322b196c9cb8d446b1ff85edf38877;hb=39809ded547bdbb08207d3e514950425215b4410;hp=0da7b0c77c49e94aba190178a8e3618fc9d84db3;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/glx/spheremonics.c b/hacks/glx/spheremonics.c index 0da7b0c7..9cefbf3d 100644 --- a/hacks/glx/spheremonics.c +++ b/hacks/glx/spheremonics.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2002-2012 Jamie Zawinski +/* xscreensaver, Copyright (c) 2002-2014 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -63,15 +63,16 @@ #define DEFAULTS "*delay: 30000 \n" \ "*showFPS: False \n" \ "*wireframe: False \n" \ - "*labelfont: -*-helvetica-medium-r-normal-*-180-*\n" + "*suppressRotationAnimation: True\n" \ + "*labelfont: -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" -# define refresh_spheremonics 0 +# define free_spheremonics 0 # define release_spheremonics 0 #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) #include "xlockmore.h" -#include "glxfonts.h" +#include "texfont.h" #include "normals.h" #include "colors.h" #include "rotator.h" @@ -111,12 +112,7 @@ typedef struct { int mesher; int polys1, polys2; /* polygon counts */ -# ifdef HAVE_GLBITMAP - XFontStruct *font; - GLuint font_list; -# else texture_font_data *font_data; -# endif int change_tick; int done_once; @@ -170,8 +166,15 @@ ENTRYPOINT void reshape_spheremonics (ModeInfo *mi, int width, int height) { GLfloat 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, 0, (GLint) width, (GLint) height); + glViewport (0, y, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -183,6 +186,14 @@ reshape_spheremonics (ModeInfo *mi, int width, int height) 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, 1/h, 1/h); + } + +# endif glClear(GL_COLOR_BUFFER_BIT); } @@ -691,14 +702,7 @@ init_spheremonics (ModeInfo *mi) { spheremonics_configuration *cc; - if (!ccs) { - ccs = (spheremonics_configuration *) - calloc (MI_NUM_SCREENS(mi), sizeof (spheremonics_configuration)); - if (!ccs) { - fprintf(stderr, "%s: out of memory\n", progname); - exit(1); - } - } + MI_INIT (mi, ccs); cc = &ccs[MI_SCREEN(mi)]; @@ -735,7 +739,7 @@ init_spheremonics (ModeInfo *mi) 1.0, do_wander ? wander_speed : 0, (spinx && spiny && spinz)); - cc->trackball = gltrackball_init (); + cc->trackball = gltrackball_init (True); } cc->tracer = -1; @@ -743,11 +747,7 @@ init_spheremonics (ModeInfo *mi) cc->resolution = res; -# ifdef HAVE_GLBITMAP - load_font (mi->dpy, "labelfont", &cc->font, &cc->font_list); -# else /* !HAVE_GLBITMAP */ - cc->font_data = load_texture_font (mi->dpy, "labelFont"); -# endif /* !HAVE_GLBITMAP */ + cc->font_data = load_texture_font (mi->dpy, "labelfont"); cc->dlist = glGenLists(1); cc->dlist2 = glGenLists(1); @@ -772,49 +772,13 @@ spheremonics_handle_event (ModeInfo *mi, XEvent *event) { spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && - event->xbutton.button == Button1) - { - cc->button_down_p = True; - gltrackball_start (cc->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) - { - cc->button_down_p = False; - 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 (cc->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == KeyPress) - { - KeySym keysym; - char c = 0; - XLookupString (&event->xkey, &c, 1, &keysym, 0); - - if (c == ' ' || c == '\t' || c == '\r' || c == '\n') - { - cc->change_tick = duration; - return True; - } - } - else if (event->xany.type == MotionNotify && - cc->button_down_p) + if (gltrackball_event_handler (event, cc->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &cc->button_down_p)) + return True; + else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) { - gltrackball_track (cc->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); + cc->change_tick = duration; return True; } @@ -851,10 +815,7 @@ draw_spheremonics (ModeInfo *mi) (y - 0.5) * 6, (z - 0.5) * 8); - /* Do it twice because we don't track the device's orientation. */ - glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (cc->trackball); - glRotatef(-current_device_rotation(), 0, 0, 1); get_rotation (cc->rot, &x, &y, &z, !cc->button_down_p); glRotatef (x * 360, 1.0, 0.0, 0.0); @@ -893,15 +854,9 @@ draw_spheremonics (ModeInfo *mi) cc->m[4], cc->m[5], cc->m[6], cc->m[7]); glColor3f(1.0, 1.0, 0.0); - print_gl_string (mi->dpy, -# ifdef HAVE_GLBITMAP - cc->font, cc->font_list, -# else /* !HAVE_GLBITMAP */ - cc->font_data, -# endif /* !HAVE_GLBITMAP */ - mi->xgwa.width, mi->xgwa.height, - 10, mi->xgwa.height - 10, - buf, False); + print_texture_label (mi->dpy, cc->font_data, + mi->xgwa.width, mi->xgwa.height, + 1, buf); } if (!static_parms)