X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fboxed.c;h=136d468ebceebbf88548e49cee0ac68156403a91;hb=39809ded547bdbb08207d3e514950425215b4410;hp=4e16f09e2ec5b6477ef551cea8523ef7fd0a8092;hpb=88cfe534a698a0562e81345957a50714af1453bc;p=xscreensaver diff --git a/hacks/glx/boxed.c b/hacks/glx/boxed.c index 4e16f09e..136d468e 100644 --- a/hacks/glx/boxed.c +++ b/hacks/glx/boxed.c @@ -45,8 +45,8 @@ static const char sccsid[] = "@(#)boxed.c 0.9 01/09/26 xlockmore"; "*showFPS: False \n" \ "*wireframe: False \n" -# define refresh_boxed 0 -# define boxed_handle_event 0 +# define release_boxed 0 +# define boxed_handle_event xlockmore_no_events # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -97,8 +97,8 @@ ENTRYPOINT ModeSpecOpt boxed_opts = {countof(opts), opts, countof(vars), vars, N #ifdef USE_MODULES ModStruct boxed_description = { - "boxed", "init_boxed", "draw_boxed", "release_boxed", - "draw_boxed", "init_boxed", NULL, &boxed_opts, + "boxed", "init_boxed", "draw_boxed", NULL, + "draw_boxed", "init_boxed", "free_boxed", &boxed_opts, 1000, 1, 2, 1, 4, 1.0, "", "Shows GL's boxed balls", 0, NULL}; @@ -1029,7 +1029,15 @@ static void draw(ModeInfo * mi) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); - glRotatef(current_device_rotation(), 0, 0, 1); +# 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); + glRotatef(o, 0, 0, 1); + } +# endif gp->tic += 0.01f; gp->camtic += 0.01f + 0.01f * sin(gp->tic * speed); @@ -1161,8 +1169,15 @@ static void draw(ModeInfo * mi) ENTRYPOINT void reshape_boxed(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(); gluPerspective(50.0,1/h,2.0,1000.0); @@ -1283,9 +1298,7 @@ init_boxed(ModeInfo * mi) /* Boolean rgba, doublebuffer, cmap_installed; */ boxedstruct *gp; - if (boxed == NULL) { - if ((boxed = (boxedstruct *) calloc(MI_NUM_SCREENS(mi),sizeof (boxedstruct))) == NULL) return; - } + MI_INIT(mi, boxed); gp = &boxed[screen]; gp->window = MI_WINDOW(mi); @@ -1326,37 +1339,27 @@ draw_boxed(ModeInfo * mi) } ENTRYPOINT void -release_boxed(ModeInfo * mi) +free_boxed(ModeInfo * mi) { + boxedstruct *gp = &boxed[MI_SCREEN(mi)]; int i; + + if (gp->glx_context) { + /* Display lists MUST be freed while their glXContext is current. */ + glXMakeCurrent(MI_DISPLAY(mi), gp->window, *(gp->glx_context)); - if (boxed != NULL) { - int screen; - - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { - boxedstruct *gp = &boxed[screen]; - - if (gp->glx_context) { - /* Display lists MUST be freed while their glXContext is current. */ - glXMakeCurrent(MI_DISPLAY(mi), gp->window, *(gp->glx_context)); - - if (glIsList(gp->listobjects)) - glDeleteLists(gp->listobjects, 3); - - for (i=0;ibman.num_balls;i++) { - if (gp->bman.balls[i].bounced) freetris(&gp->tman[i]); - } - free (gp->bman.balls); - free (gp->tman); - free (gp->tex1); - - - } + if (glIsList(gp->listobjects)) + glDeleteLists(gp->listobjects, 3); + + for (i=0;ibman.num_balls;i++) { + if (gp->bman.balls[i].bounced) freetris(&gp->tman[i]); } - (void) free((void *) boxed); - boxed = NULL; + free (gp->bman.balls); + free (gp->tman); + free (gp->tex1); + + } - FreeAllGL(mi); }