X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fcube21.c;h=542c93699e3953bde0e1b36708b3edd435e8c651;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=1379b4cf9f36b02735a6574950071d73f470b681;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/cube21.c b/hacks/glx/cube21.c index 1379b4cf..542c9369 100644 --- a/hacks/glx/cube21.c +++ b/hacks/glx/cube21.c @@ -26,7 +26,7 @@ /* TODO: * some simple "solve mode" - * use rotator and trackball + * use rotator */ /*- @@ -46,9 +46,10 @@ "*wireframe: False \n" # define refresh_cube21 0 -# define cube21_handle_event 0 #include "xlockmore.h" +#include "gltrackball.h" + #ifdef USE_GL #define DEF_SPIN "True" @@ -57,7 +58,7 @@ #define DEF_RANDOMIZE "True" #define DEF_SPINSPEED "1.0" #define DEF_ROTSPEED "3.0" -#define DEF_WANDERSPEED "1.0" +#define DEF_WANDERSPEED "0.02" #define DEF_WAIT "40.0" #define DEF_CUBESIZE "0.7" #define DEF_COLORMODE "six" @@ -178,6 +179,9 @@ typedef struct { GLfloat texp, texq, posc[6]; GLfloat color_inner[4]; + Bool button_down_p; + trackball_state *trackball; + } cube21_conf; static cube21_conf *cube21 = NULL; @@ -510,6 +514,9 @@ static Bool draw_main(ModeInfo *mi, cube21_conf *cp) else glTranslatef(0, 0, zpos); glScalef(size, size, size); + + gltrackball_rotate (cp->trackball); + glRotatef(cp->xrot, 1.0, 0.0, 0.0); glRotatef(cp->yrot, 0.0, 1.0, 0.0); if(cp->wire) glColor3f(0.7, 0.7, 0.7); @@ -692,6 +699,11 @@ static void init_gl(ModeInfo *mi) tex = False; cp->cmat = False; } + +# ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */ + cp->wire = 0; +# endif + if(cp->wire) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); return; @@ -702,7 +714,6 @@ static void init_gl(ModeInfo *mi) cp->color_inner[0] = cp->color_inner[1] = cp->color_inner[2] = 1.0; glClearDepth(1.0); - glClearColor(0.0, 0.0, 0.0, 1.0); glDrawBuffer(GL_BACK); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glShadeModel(GL_FLAT); @@ -834,6 +845,20 @@ ENTRYPOINT void reshape_cube21(ModeInfo *mi, int width, int height) glClear(GL_COLOR_BUFFER_BIT); } +ENTRYPOINT Bool +cube21_handle_event (ModeInfo *mi, XEvent *event) +{ + cube21_conf *cp = &cube21[MI_SCREEN(mi)]; + + if (gltrackball_event_handler (event, cp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &cp->button_down_p)) + return True; + + return False; +} + + ENTRYPOINT void release_cube21(ModeInfo *mi) { if (cube21 != NULL) { @@ -859,6 +884,8 @@ ENTRYPOINT void init_cube21(ModeInfo *mi) } cp = &cube21[MI_SCREEN(mi)]; + cp->trackball = gltrackball_init (False); + if(!cp->texp) { init_posc(cp); make_texture(cp);