X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fblinkbox.c;h=f777371162afafa958c84cb8d8ab4c39f8c98742;hb=39809ded547bdbb08207d3e514950425215b4410;hp=b2c6e4bc960f7910a8afd4f4a8f26bdc2a729b61;hpb=f0261d8acab611f3433160e4f07367b870439739;p=xscreensaver diff --git a/hacks/glx/blinkbox.c b/hacks/glx/blinkbox.c index b2c6e4bc..f7773711 100644 --- a/hacks/glx/blinkbox.c +++ b/hacks/glx/blinkbox.c @@ -14,10 +14,11 @@ #define DEFAULTS "*delay: 30000 \n" \ "*wireframe: False \n" \ + "*suppressRotationAnimation: True\n" \ -# define refresh_ball 0 +# define free_ball 0 # define release_ball 0 -# define ball_handle_event 0 +# define ball_handle_event xlockmore_no_events #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -151,7 +152,7 @@ swap_mov(GLfloat *a, GLfloat *b) swap(a,b); j = get_rand(); if (*a < 0) - *a = (j *= -1); + *a = j * -1; else *a = j; } @@ -231,8 +232,15 @@ ENTRYPOINT void reshape_ball (ModeInfo *mi, int width, int height) { GLfloat h = (GLfloat) height / (GLfloat) width; + int y = 0; - glViewport (0, 0, (GLint) width, (GLint) height); + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport (0, y, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective (30.0, 1/h, 1.0, 100.0); @@ -243,6 +251,13 @@ reshape_ball (ModeInfo *mi, int width, int height) 0.0, 0.0, 0.0, 0.0, 2.0, 10.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 } static void @@ -288,11 +303,7 @@ init_ball (ModeInfo *mi) int wire = MI_IS_WIREFRAME(mi); blinkboxstruct *bp; - if(blinkbox == NULL) { - if((blinkbox = (blinkboxstruct *) calloc(MI_NUM_SCREENS(mi), - sizeof (blinkboxstruct))) == NULL) - return; - } + MI_INIT (mi, blinkbox); bp = &blinkbox[MI_SCREEN(mi)]; if ((bp->glx_context = init_GL(mi)) != NULL) { @@ -401,7 +412,6 @@ init_ball (ModeInfo *mi) glEnable(GL_COLOR_MATERIAL); glShadeModel(GL_SMOOTH); - glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL);