X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fpinion.c;h=f6793eb446b01366bc2802965983707c7b9f6601;hb=39809ded547bdbb08207d3e514950425215b4410;hp=45aedfbd26cd9f12eae35a7675f43d2cde6f01c1;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;p=xscreensaver diff --git a/hacks/glx/pinion.c b/hacks/glx/pinion.c index 45aedfbd..f6793eb4 100644 --- a/hacks/glx/pinion.c +++ b/hacks/glx/pinion.c @@ -12,11 +12,11 @@ #define DEFAULTS "*delay: 15000 \n" \ "*showFPS: False \n" \ "*wireframe: False \n" \ - "*titleFont: -*-helvetica-medium-r-normal-*-180-*\n" \ - "*titleFont2: -*-helvetica-medium-r-normal-*-120-*\n" \ - "*titleFont3: -*-helvetica-medium-r-normal-*-80-*\n" \ + "*titleFont: -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" \ + "*titleFont2: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*\n" \ + "*titleFont3: -*-helvetica-medium-r-normal-*-*-80-*-*-*-*-*-*\n" \ -# define refresh_pinion 0 +# define free_pinion 0 # define release_pinion 0 #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -27,7 +27,7 @@ #include "xlockmore.h" #include "normals.h" #include "gltrackball.h" -#include "glxfonts.h" +#include "texfont.h" #include "involute.h" #include @@ -55,7 +55,6 @@ typedef struct { texture_font_data *font1, *font2, *font3; - GLuint title_list; int draw_tick; GLfloat plane_displacement; /* distance between coaxial gears */ @@ -119,7 +118,7 @@ load_fonts (ModeInfo *mi) static void rpm_string (double rpm, char *s); static void -new_label (ModeInfo *mi) +draw_label (ModeInfo *mi) { pinion_configuration *pp = &pps[MI_SCREEN(mi)]; char label[1024]; @@ -149,7 +148,6 @@ new_label (ModeInfo *mi) g->tooth_h * MI_HEIGHT(mi)); } - glNewList (pp->title_list, GL_COMPILE); if (*label) { texture_font_data *fd; @@ -161,12 +159,10 @@ new_label (ModeInfo *mi) fd = pp->font3; glColor3f (0.8, 0.8, 0); - print_gl_string (mi->dpy, fd, - mi->xgwa.width, mi->xgwa.height, - 10, mi->xgwa.height - 10, - label, False); + print_texture_label (mi->dpy, fd, + mi->xgwa.width, mi->xgwa.height, + 1, label); } - glEndList (); } @@ -312,6 +308,10 @@ new_gear (ModeInfo *mi, gear *parent, Bool coaxial_p) /* g->tooth_slope = (parent ? -parent->tooth_slope : 4); */ + if (debug_one_gear_p) + g->tooth_slope = frand(20)-10; + + /* Colorize */ g->color[0] = 0.5 + frand(0.5); @@ -411,7 +411,8 @@ new_gear (ModeInfo *mi, gear *parent, Bool coaxial_p) double pix = g->tooth_h * MI_HEIGHT(mi); /* approx. tooth size in pixels */ if (pix <= 2.5) g->size = INVOLUTE_SMALL; else if (pix <= 3.5) g->size = INVOLUTE_MEDIUM; - else g->size = INVOLUTE_LARGE; + else if (pix <= 25) g->size = INVOLUTE_LARGE; + else g->size = INVOLUTE_HUGE; } g->base_p = !parent; @@ -1232,7 +1233,7 @@ find_mouse_gear (ModeInfo *mi) #else /* HAVE_JWZGLES */ /* #### not yet implemented */ - pp->mouse_gear_id = pp->gears[1]->id; + pp->mouse_gear_id = (pp->ngears > 1 ? pp->gears[1]->id : 0); return; #endif /* HAVE_JWZGLES */ @@ -1245,10 +1246,17 @@ find_mouse_gear (ModeInfo *mi) ENTRYPOINT void reshape_pinion (ModeInfo *mi, int width, int height) { - GLfloat h = (GLfloat) height / (GLfloat) width; pinion_configuration *pp = &pps[MI_SCREEN(mi)]; + 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(); @@ -1314,14 +1322,7 @@ init_pinion (ModeInfo *mi) { pinion_configuration *pp; - if (!pps) { - pps = (pinion_configuration *) - calloc (MI_NUM_SCREENS(mi), sizeof (pinion_configuration)); - if (!pps) { - fprintf(stderr, "%s: out of memory\n", progname); - exit(1); - } - } + MI_INIT (mi, pps); pp = &pps[MI_SCREEN(mi)]; @@ -1331,8 +1332,6 @@ init_pinion (ModeInfo *mi) reshape_pinion (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */ - pp->title_list = glGenLists (1); - pp->ngears = 0; pp->gears_size = 0; pp->gears = 0; @@ -1453,12 +1452,11 @@ draw_pinion (ModeInfo *mi) { pp->draw_tick = 0; find_mouse_gear (mi); - new_label (mi); } } glPopMatrix (); - glCallList (pp->title_list); + draw_label (mi); glPopMatrix (); if (mi->fps_p) do_fps (mi);