X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstairs.c;h=7fabea1ad32f61af464600e32f1879f7215fd976;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=3216dd37b27c4b14443e2203e14a7c25ca07b1ee;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/stairs.c b/hacks/glx/stairs.c index 3216dd37..7fabea1a 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" @@ -298,6 +304,7 @@ draw_sphere(int pos, int tick) glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialYellow); glDisable (GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); + glFrontFace(GL_CCW); polys += unit_sphere (32, 32, False); glShadeModel(GL_FLAT); glEnable (GL_TEXTURE_2D); @@ -336,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; @@ -386,12 +364,10 @@ stairs_handle_event (ModeInfo *mi, XEvent *event) static void -pinit(void) +pinit(ModeInfo *mi) { - int status; + /* int status; */ glClearDepth(1.0); - glClearColor(0.0, 0.0, 0.0, 1.0); - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, position0); @@ -414,6 +390,7 @@ pinit(void) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +#if 0 clear_gl_error(); status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, WoodTextureWidth, WoodTextureHeight, @@ -427,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); @@ -462,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); @@ -487,6 +481,14 @@ draw_stairs (ModeInfo * mi) glPushMatrix(); + glRotatef(rot, 0, 0, 1); + if ((rot > 45 && rot < 135) || + (rot < -45 && rot > -135)) + { + GLfloat s = MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi); + glScalef (s, 1/s, 1); + } + glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) {