X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fspheremonics.c;h=efef9f8826cdd9f42bc83eaa224a71aa6ed62e99;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=f3a03f2b62655c9d27d53d97a2520f3b8fb377fd;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/spheremonics.c b/hacks/glx/spheremonics.c index f3a03f2b..efef9f88 100644 --- a/hacks/glx/spheremonics.c +++ b/hacks/glx/spheremonics.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2002-2008 Jamie Zawinski +/* xscreensaver, Copyright (c) 2002-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 @@ -111,8 +111,8 @@ typedef struct { int mesher; int polys1, polys2; /* polygon counts */ - XFontStruct *font; - GLuint font_list; + texture_font_data *font_data; + int change_tick; int done_once; @@ -221,6 +221,14 @@ gl_init (ModeInfo *mi) glDisable(GL_CULL_FACE); glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, True); } + + if (smooth_p) + { + glEnable (GL_LINE_SMOOTH); + glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); + } } @@ -302,23 +310,25 @@ draw_circle (ModeInfo *mi, Bool teeth_p) static void draw_bounding_box (ModeInfo *mi) { - spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)]; + /* spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)]; */ static const GLfloat c1[4] = { 0.2, 0.2, 0.6, 1.0 }; static const GLfloat c2[4] = { 1.0, 0.0, 0.0, 1.0 }; int wire = MI_IS_WIREFRAME(mi); - GLfloat x1 = cc->bbox[0].x; - GLfloat y1 = cc->bbox[0].y; - GLfloat z1 = cc->bbox[0].z; - GLfloat x2 = cc->bbox[1].x; - GLfloat y2 = cc->bbox[1].y; - GLfloat z2 = cc->bbox[1].z; + GLfloat x1,y1,z1,x2,y2,z2; -#if 1 +# if 0 + x1 = cc->bbox[0].x; + y1 = cc->bbox[0].y; + z1 = cc->bbox[0].z; + x2 = cc->bbox[1].x; + y2 = cc->bbox[1].y; + z2 = cc->bbox[1].z; +# else x1 = y1 = z1 = -0.5; x2 = y2 = z2 = 0.5; -#endif +# endif if (do_bbox && !wire) { @@ -359,13 +369,10 @@ draw_bounding_box (ModeInfo *mi) glDisable(GL_CULL_FACE); } - glPushAttrib (GL_LIGHTING); - glDisable (GL_LIGHTING); - - glColor3f (c2[0], c2[1], c2[2]); - if (do_grid) { + glDisable (GL_LIGHTING); + glColor3f (c2[0], c2[1], c2[2]); glPushMatrix(); glBegin(GL_LINES); glVertex3f(0, -0.66, 0); @@ -380,6 +387,7 @@ draw_bounding_box (ModeInfo *mi) } else { +#if 0 glBegin(GL_LINES); if (x1 > 0) x1 = 0; if (x2 < 0) x2 = 0; if (y1 > 0) y1 = 0; if (y2 < 0) y2 = 0; @@ -388,9 +396,8 @@ draw_bounding_box (ModeInfo *mi) glVertex3f(0 , y1, 0); glVertex3f(0, y2, 0); glVertex3f(0, 0, z1); glVertex3f(0, 0, z2); glEnd(); +#endif } - - glPopAttrib(); } @@ -422,7 +429,6 @@ do_tracer (ModeInfo *mi) { static const GLfloat c[4] = { 0.6, 0.5, 1.0, 1.0 }; - glPushAttrib (GL_LIGHTING); glDisable (GL_LIGHTING); glPushMatrix(); @@ -434,7 +440,7 @@ do_tracer (ModeInfo *mi) draw_circle (mi, False); glPopMatrix(); - glPopAttrib(); + if (! MI_IS_WIREFRAME(mi)) glEnable (GL_LIGHTING); } cc->tracer += 5; @@ -664,13 +670,10 @@ generate_spheremonics (ModeInfo *mi) glEndList(); glNewList(cc->dlist2, GL_COMPILE); - glPushAttrib (GL_LIGHTING); - glDisable (GL_LIGHTING); glPushMatrix(); glScalef (1.05, 1.05, 1.05); cc->polys2 = unit_spheremonics (mi, cc->resolution, 2, cc->m, cc->colors); glPopMatrix(); - glPopAttrib(); glEndList(); } } @@ -690,8 +693,6 @@ init_spheremonics (ModeInfo *mi) fprintf(stderr, "%s: out of memory\n", progname); exit(1); } - - cc = &ccs[MI_SCREEN(mi)]; } cc = &ccs[MI_SCREEN(mi)]; @@ -701,14 +702,6 @@ init_spheremonics (ModeInfo *mi) reshape_spheremonics (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } - if (smooth_p) - { - glEnable (GL_LINE_SMOOTH); - glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable (GL_BLEND); - } - { Bool spinx=False, spiny=False, spinz=False; double spin_speed = 1.0; @@ -737,7 +730,7 @@ init_spheremonics (ModeInfo *mi) 1.0, do_wander ? wander_speed : 0, (spinx && spiny && spinz)); - cc->trackball = gltrackball_init (); + cc->trackball = gltrackball_init (True); } cc->tracer = -1; @@ -745,7 +738,7 @@ init_spheremonics (ModeInfo *mi) cc->resolution = res; - load_font (mi->dpy, "labelfont", &cc->font, &cc->font_list); + cc->font_data = load_texture_font (mi->dpy, "labelfont"); cc->dlist = glGenLists(1); cc->dlist2 = glGenLists(1); @@ -770,49 +763,13 @@ spheremonics_handle_event (ModeInfo *mi, XEvent *event) { spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && - event->xbutton.button == Button1) - { - cc->button_down_p = True; - gltrackball_start (cc->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) - { - cc->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 (cc->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == KeyPress) - { - KeySym keysym; - char c = 0; - XLookupString (&event->xkey, &c, 1, &keysym, 0); - - if (c == ' ' || c == '\t' || c == '\r' || c == '\n') - { - cc->change_tick = duration; - return True; - } - } - else if (event->xany.type == MotionNotify && - cc->button_down_p) + if (gltrackball_event_handler (event, cc->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &cc->button_down_p)) + return True; + else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) { - gltrackball_track (cc->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); + cc->change_tick = duration; return True; } @@ -832,6 +789,8 @@ draw_spheremonics (ModeInfo *mi) glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(cc->glx_context)); + gl_init(mi); + glShadeModel(GL_SMOOTH); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -863,8 +822,9 @@ draw_spheremonics (ModeInfo *mi) glCallList (cc->dlist); mi->polygon_count += cc->polys1; - if (cc->mesher >= 0 /* || mouse_p */) + if (cc->mesher >= 0 /* || cc->button_down_p */) { + glDisable (GL_LIGHTING); glCallList (cc->dlist2); mi->polygon_count += cc->polys2; if (cc->mesher >= 0) @@ -885,7 +845,7 @@ draw_spheremonics (ModeInfo *mi) cc->m[4], cc->m[5], cc->m[6], cc->m[7]); glColor3f(1.0, 1.0, 0.0); - print_gl_string (mi->dpy, cc->font, cc->font_list, + print_gl_string (mi->dpy, cc->font_data, mi->xgwa.width, mi->xgwa.height, 10, mi->xgwa.height - 10, buf, False);