X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Frubik.c;h=bccacc7c134b891d691414a2409b1e8056dab9fb;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=f41985866b83f422b08b222d3c29911a717dd29f;hpb=50be9bb40dc60130c99ffa568e6677779904ff70;p=xscreensaver diff --git a/hacks/glx/rubik.c b/hacks/glx/rubik.c index f4198586..bccacc7c 100644 --- a/hacks/glx/rubik.c +++ b/hacks/glx/rubik.c @@ -111,13 +111,14 @@ static const char sccsid[] = "@(#)rubik.c 5.01 2001/03/01 xlockmore"; "*cycles: 20 \n" \ "*size: -6 \n" # define refresh_rubik 0 -# define rubik_handle_event 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ # include "vis.h" #endif /* !STANDALONE */ +#include "gltrackball.h" + #ifdef MODE_rubik #define DEF_SIZEX "0" @@ -372,6 +373,8 @@ typedef struct { GLfloat rotatestep; GLfloat PX, PY, VX, VY; GLXContext *glx_context; + Bool button_down_p; + trackball_state *trackball; } rubikstruct; static const float front_shininess[] = {60.0}; @@ -1816,11 +1819,29 @@ reshape_rubik(ModeInfo * mi, int width, int height) } +ENTRYPOINT Bool +rubik_handle_event (ModeInfo *mi, XEvent *event) +{ + rubikstruct *rp = &rubik[MI_SCREEN(mi)]; + + if (gltrackball_event_handler (event, rp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &rp->button_down_p)) + return True; + else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + rp->done = 1; + return True; + } + + return False; +} + + static Bool pinit(ModeInfo * mi) { glClearDepth(1.0); - glClearColor(0.0, 0.0, 0.0, 1.0); glColor3f(1.0, 1.0, 1.0); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); @@ -1898,6 +1919,8 @@ init_rubik(ModeInfo * mi) rp->PX = ((float) LRAND() / (float) MAXRAND) * 2.0 - 1.0; rp->PY = ((float) LRAND() / (float) MAXRAND) * 2.0 - 1.0; + rp->trackball = gltrackball_init (True); + if ((rp->glx_context = init_GL(mi)) != NULL) { reshape_rubik(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); @@ -1984,6 +2007,8 @@ draw_rubik(ModeInfo * mi) glScalef(Scale4Iconic * rp->WindH / rp->WindW, Scale4Iconic, Scale4Iconic); } + gltrackball_rotate (rp->trackball); + glRotatef(rp->step * 100, 1, 0, 0); glRotatef(rp->step * 95, 0, 1, 0); glRotatef(rp->step * 90, 0, 0, 1);