X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fpinion.c;h=389786de62f50990c2c032d4c9fd7a6a82d56797;hb=d5186197bc394e10a4402f7f6d23fbb14103bc50;hp=8ba2ee0ee4d7c37f0edf80a5e9295293cf322f43;hpb=50be9bb40dc60130c99ffa568e6677779904ff70;p=xscreensaver diff --git a/hacks/glx/pinion.c b/hacks/glx/pinion.c index 8ba2ee0e..389786de 100644 --- a/hacks/glx/pinion.c +++ b/hacks/glx/pinion.c @@ -1,4 +1,4 @@ -/* pinion, Copyright (c) 2004-2008 Jamie Zawinski +/* pinion, Copyright (c) 2004-2014 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 @@ -12,9 +12,9 @@ #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 release_pinion 0 @@ -27,7 +27,7 @@ #include "xlockmore.h" #include "normals.h" #include "gltrackball.h" -#include "glxfonts.h" +#include "texfont.h" #include "involute.h" #include @@ -53,9 +53,8 @@ typedef struct { Bool button_down_p; unsigned long mouse_gear_id; - XFontStruct *xfont1, *xfont2, *xfont3; - GLuint font1_dlist, font2_dlist, font3_dlist; - GLuint title_list; + texture_font_data *font1, *font2, *font3; + int draw_tick; GLfloat plane_displacement; /* distance between coaxial gears */ @@ -109,9 +108,9 @@ static void load_fonts (ModeInfo *mi) { pinion_configuration *pp = &pps[MI_SCREEN(mi)]; - load_font (mi->dpy, "titleFont", &pp->xfont1, &pp->font1_dlist); - load_font (mi->dpy, "titleFont2", &pp->xfont2, &pp->font2_dlist); - load_font (mi->dpy, "titleFont3", &pp->xfont3, &pp->font3_dlist); + pp->font1 = load_texture_font (mi->dpy, "titleFont"); + pp->font2 = load_texture_font (mi->dpy, "titleFont2"); + pp->font3 = load_texture_font (mi->dpy, "titleFont3"); } @@ -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,25 +148,21 @@ new_label (ModeInfo *mi) g->tooth_h * MI_HEIGHT(mi)); } - glNewList (pp->title_list, GL_COMPILE); if (*label) { - XFontStruct *f; - GLuint fl; + texture_font_data *fd; if (MI_WIDTH(mi) >= 500 && MI_HEIGHT(mi) >= 375) - f = pp->xfont1, fl = pp->font1_dlist; /* big font */ + fd = pp->font1; else if (MI_WIDTH(mi) >= 350 && MI_HEIGHT(mi) >= 260) - f = pp->xfont2, fl = pp->font2_dlist; /* small font */ + fd = pp->font2; else - f = pp->xfont3, fl = pp->font3_dlist; /* tiny font */ + fd = pp->font3; glColor3f (0.8, 0.8, 0); - print_gl_string (mi->dpy, f, fl, - 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 (); } @@ -313,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); @@ -412,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; @@ -1160,6 +1160,9 @@ static void find_mouse_gear (ModeInfo *mi) { pinion_configuration *pp = &pps[MI_SCREEN(mi)]; + +# ifndef HAVE_JWZGLES + int screen_width = MI_WIDTH (mi); int screen_height = MI_HEIGHT (mi); GLfloat h = (GLfloat) screen_height / (GLfloat) screen_width; @@ -1227,6 +1230,14 @@ find_mouse_gear (ModeInfo *mi) pp->mouse_gear_id = pnames[0]; } } + +#else /* HAVE_JWZGLES */ + /* #### not yet implemented */ + pp->mouse_gear_id = (pp->ngears > 1 ? pp->gears[1]->id : 0); + return; +#endif /* HAVE_JWZGLES */ + + } @@ -1279,39 +1290,10 @@ pinion_handle_event (ModeInfo *mi, XEvent *event) { pinion_configuration *pp = &pps[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && - event->xbutton.button == Button1) - { - pp->button_down_p = True; - gltrackball_start (pp->trackball, - event->xbutton.x, event->xbutton.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; - } - else if (event->xany.type == ButtonRelease && - event->xbutton.button == Button1) - { - pp->button_down_p = False; - return True; - } - else if (event->xany.type == ButtonPress && - (event->xbutton.button == Button4 || - event->xbutton.button == Button5 || - event->xbutton.button == Button6 || - event->xbutton.button == Button7)) - { - gltrackball_mousewheel (pp->trackball, event->xbutton.button, 5, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == MotionNotify && - pp->button_down_p) - { - gltrackball_track (pp->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; - } + if (gltrackball_event_handler (event, pp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &pp->button_down_p)) + return True; else if (event->xany.type == KeyPress) { KeySym keysym; @@ -1332,7 +1314,6 @@ ENTRYPOINT void init_pinion (ModeInfo *mi) { pinion_configuration *pp; - int wire = MI_IS_WIREFRAME(mi); if (!pps) { pps = (pinion_configuration *) @@ -1349,8 +1330,7 @@ init_pinion (ModeInfo *mi) load_fonts (mi); reshape_pinion (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); - - pp->title_list = glGenLists (1); + clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */ pp->ngears = 0; pp->gears_size = 0; @@ -1358,25 +1338,7 @@ init_pinion (ModeInfo *mi) pp->plane_displacement = gear_size * 0.1; - if (!wire) - { - GLfloat pos[4] = {-3.0, 1.0, 1.0, 0.0}; - GLfloat amb[4] = { 0.0, 0.0, 0.0, 1.0}; - GLfloat dif[4] = { 1.0, 1.0, 1.0, 1.0}; - GLfloat spc[4] = { 1.0, 1.0, 1.0, 1.0}; - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - - glLightfv(GL_LIGHT0, GL_POSITION, pos); - glLightfv(GL_LIGHT0, GL_AMBIENT, amb); - glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); - glLightfv(GL_LIGHT0, GL_SPECULAR, spc); - } - - pp->trackball = gltrackball_init (); + pp->trackball = gltrackball_init (False); ffwd (mi); } @@ -1395,6 +1357,27 @@ draw_pinion (ModeInfo *mi) glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(pp->glx_context)); + glPushMatrix(); + glRotatef(current_device_rotation(), 0, 0, 1); + + if (!wire_p) + { + GLfloat pos[4] = {-3.0, 1.0, 1.0, 0.0}; + GLfloat amb[4] = { 0.0, 0.0, 0.0, 1.0}; + GLfloat dif[4] = { 1.0, 1.0, 1.0, 1.0}; + GLfloat spc[4] = { 1.0, 1.0, 1.0, 1.0}; + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glLightfv(GL_LIGHT0, GL_AMBIENT, amb); + glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); + glLightfv(GL_LIGHT0, GL_SPECULAR, spc); + } + if (!pp->button_down_p) { if (!debug_one_gear_p || pp->ngears == 0) @@ -1469,12 +1452,12 @@ 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); glFinish();