X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstairs.c;h=91f40ac46a919853c077b3b7b11a33d8ab398dce;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=9381f6fadae7246c78943d50e2e4ef1cb367e78e;hpb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;p=xscreensaver diff --git a/hacks/glx/stairs.c b/hacks/glx/stairs.c index 9381f6fa..91f40ac4 100644 --- a/hacks/glx/stairs.c +++ b/hacks/glx/stairs.c @@ -68,7 +68,13 @@ static const char sccsid[] = "@(#)stairs.c 4.07 97/11/24 xlockmore"; #ifdef USE_GL +#if 0 #include "e_textures.h" +#else +#include "xpm-ximage.h" +#include "../images/wood.xpm" +#endif + #include "sphere.h" #include "gltrackball.h" @@ -337,45 +343,16 @@ stairs_handle_event (ModeInfo *mi, XEvent *event) { stairsstruct *sp = &stairs[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && - event->xbutton.button == Button1) - { - sp->button_down_p = True; - gltrackball_start (sp->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) - { - sp->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 (sp->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == MotionNotify && - sp->button_down_p) - { - gltrackball_track (sp->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; - } + if (gltrackball_event_handler (event, sp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &sp->button_down_p)) + return True; else if (event->xany.type == KeyPress) { KeySym keysym; char c = 0; XLookupString (&event->xkey, &c, 1, &keysym, 0); - if (c == ' ') + if (c == ' ' || c == '\t') { gltrackball_reset (sp->trackball); return True; @@ -387,9 +364,9 @@ stairs_handle_event (ModeInfo *mi, XEvent *event) static void -pinit(void) +pinit(ModeInfo *mi) { - int status; + /* int status; */ glClearDepth(1.0); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); @@ -413,6 +390,7 @@ pinit(void) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +#if 0 clear_gl_error(); status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, WoodTextureWidth, WoodTextureHeight, @@ -426,6 +404,22 @@ pinit(void) exit (1); } check_gl_error("mipmapping"); +#else + { + XImage *img = xpm_to_ximage (mi->dpy, + mi->xgwa.visual, + mi->xgwa.colormap, + wood_texture); + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, + img->width, img->height, 0, + GL_RGBA, + /* GL_UNSIGNED_BYTE, */ + GL_UNSIGNED_INT_8_8_8_8_REV, + img->data); + check_gl_error("texture"); + XDestroyImage (img); + } +#endif glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -461,18 +455,19 @@ init_stairs (ModeInfo * mi) glDrawBuffer(GL_BACK); if (!glIsList(sp->objects)) sp->objects = glGenLists(1); - pinit(); + pinit(mi); } else { MI_CLEARWINDOW(mi); } - sp->trackball = gltrackball_init (); + sp->trackball = gltrackball_init (False); } ENTRYPOINT void draw_stairs (ModeInfo * mi) { stairsstruct *sp = &stairs[MI_SCREEN(mi)]; + GLfloat rot = current_device_rotation(); Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); @@ -486,6 +481,8 @@ draw_stairs (ModeInfo * mi) glPushMatrix(); + glRotatef(rot, 0, 0, 1); + glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) { @@ -494,6 +491,14 @@ draw_stairs (ModeInfo * mi) glScalef(Scale4Iconic * sp->WindH / sp->WindW, Scale4Iconic, Scale4Iconic); } +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); + if (rot != 0 && rot != 180 && rot != -180) + glScalef (1/h, 1/h, 1/h); + } +# endif + gltrackball_rotate (sp->trackball); glTranslatef(0, 0.5, 0);