X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fcubicgrid.c;h=400af7437f27eb6a2641ae39fdc58b05847b4e35;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=a7238b8244054d995c95adbfb210e8afdbc09195;hpb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;p=xscreensaver diff --git a/hacks/glx/cubicgrid.c b/hacks/glx/cubicgrid.c index a7238b82..400af743 100644 --- a/hacks/glx/cubicgrid.c +++ b/hacks/glx/cubicgrid.c @@ -30,7 +30,7 @@ #define DEF_SPEED "1.0" #define DEF_DIV "30" -#define DEF_SIZE "20.0" +#define DEF_ZOOM "20" #define DEF_BIGDOTS "True" #undef countof @@ -48,7 +48,7 @@ static Bool bigdots; static argtype vars[] = { { &speed, "speed", "Speed", DEF_SPEED, t_Float }, - { &size, "zoom", "Zoom", DEF_SIZE, t_Float }, + { &size, "zoom", "Zoom", DEF_ZOOM, t_Float }, { &ticks, "ticks", "Ticks", DEF_DIV, t_Int }, { &bigdots, "bigdots", "BigDots", DEF_BIGDOTS, t_Bool }, }; @@ -80,6 +80,7 @@ typedef struct { rotator *rot; trackball_state *trackball; Bool button_down_p; + int npoints; } cubicgrid_conf; static cubicgrid_conf *cubicgrid = NULL; @@ -140,7 +141,12 @@ static Bool draw_main(cubicgrid_conf *cp) glTranslatef(0, 0, zpos); glScalef(size/ticks, size/ticks, size/ticks); + + /* Do it twice because we don't track the device's orientation. */ + glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (cp->trackball); + glRotatef(-current_device_rotation(), 0, 0, 1); + get_rotation (cp->rot, &x, &y, &z, !cp->button_down_p); glRotatef (x * 360, 1.0, 0.0, 0.0); glRotatef (y * 360, 0.0, 1.0, 0.0); @@ -148,7 +154,6 @@ static Bool draw_main(cubicgrid_conf *cp) glTranslatef(-ticks/2.0, -ticks/2.0, -ticks/2.0); glCallList(cp->list); - return True; } @@ -158,7 +163,6 @@ static void init_gl(ModeInfo *mi) int x, y, z; float tf = ticks; - glClearColor(0.0, 0.0, 0.0, 1.0); glDrawBuffer(GL_BACK); if(bigdots) { glPointSize(2.0); @@ -175,6 +179,7 @@ static void init_gl(ModeInfo *mi) for(y = 0; y < ticks; y++) { for(z = 0; z < ticks; z++) { glVertex3f(x, y, z); + cp->npoints++; } } } @@ -188,6 +193,7 @@ static void init_gl(ModeInfo *mi) for(z = 0; z < ticks; z++) { glColor3f(x/tf, y/tf, z/tf); glVertex3f(x, y, z); + cp->npoints++; } } } @@ -267,6 +273,7 @@ ENTRYPOINT void draw_cubicgrid(ModeInfo * mi) release_cubicgrid(mi); return; } + mi->polygon_count = cp->npoints; if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window);