X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fcityflow.c;h=2b3bd4fcea33af810fb1c502d169de385e5cc9c1;hb=39809ded547bdbb08207d3e514950425215b4410;hp=acdf3222a9449d7965a74781ca5b52f5320aa911;hpb=d5186197bc394e10a4402f7f6d23fbb14103bc50;p=xscreensaver diff --git a/hacks/glx/cityflow.c b/hacks/glx/cityflow.c index acdf3222..2b3bd4fc 100644 --- a/hacks/glx/cityflow.c +++ b/hacks/glx/cityflow.c @@ -1,4 +1,4 @@ -/* cityflow, Copyright (c) 2014 Jamie Zawinski +/* cityflow, Copyright (c) 2014-2017 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 @@ -14,7 +14,7 @@ "*showFPS: False \n" \ "*wireframe: False \n" \ -# define refresh_cube 0 +# define free_cube 0 # define release_cube 0 #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -99,8 +99,15 @@ ENTRYPOINT void reshape_cube (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 * 2) { /* tiny window: show middle */ + height = width; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport (0, y, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -182,7 +189,7 @@ cube_handle_event (ModeInfo *mi, XEvent *event) { reset_colors (mi); tweak_cubes (mi); - gltrackball_reset (cc->trackball); + gltrackball_reset (cc->trackball, 0, 0); return True; } @@ -290,14 +297,7 @@ init_cube (ModeInfo *mi) int i; cube_configuration *cc; - if (!ccs) { - ccs = (cube_configuration *) - calloc (MI_NUM_SCREENS(mi), sizeof (cube_configuration)); - if (!ccs) { - fprintf(stderr, "%s: out of memory\n", progname); - exit(1); - } - } + MI_INIT (mi, ccs); cc = &ccs[MI_SCREEN(mi)]; @@ -305,7 +305,7 @@ init_cube (ModeInfo *mi) reshape_cube (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } - cc->trackball = gltrackball_init (True); + cc->trackball = gltrackball_init (False); cc->ncolors = 256; cc->colors = (XColor *) calloc(cc->ncolors, sizeof(XColor)); @@ -323,11 +323,12 @@ init_cube (ModeInfo *mi) /* Set the size to roughly cover a 2x2 square on average. */ GLfloat scale = 1.8 / sqrt (cc->ncubes); cube *cube = &cc->cubes[i]; + double th = -(skew ? frand(skew) : 0) * M_PI / 180; + cube->x = (frand(1)-0.5); cube->y = (frand(1)-0.5); cube->z = frand(0.12); - double th = (skew ? frand(skew) : 0) * M_PI / 180; cube->cth = cos(th); cube->sth = sin(th); @@ -396,6 +397,7 @@ draw_cube (ModeInfo *mi) glPushMatrix (); + glRotatef(current_device_rotation(), 0, 0, 1); gltrackball_rotate (cc->trackball); glRotatef (-180, 1, 0, 0); @@ -404,7 +406,6 @@ draw_cube (ModeInfo *mi) glScalef (s, s, s); } glRotatef (-90, 1, 0, 0); - glRotatef(current_device_rotation(), 0, 1, 0); glTranslatef (-0.18, 0, -0.18); glRotatef (37, 1, 0, 0);