-/* cityflow, Copyright (c) 2014 Jamie Zawinski <jwz@jwz.org>
+/* cityflow, Copyright (c) 2014-2017 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
"*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)))
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();
{
reset_colors (mi);
tweak_cubes (mi);
- gltrackball_reset (cc->trackball);
+ gltrackball_reset (cc->trackball, 0, 0);
return True;
}
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)];
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));
/* 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);
glPushMatrix ();
+ glRotatef(current_device_rotation(), 0, 0, 1);
gltrackball_rotate (cc->trackball);
glRotatef (-180, 1, 0, 0);
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);