X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstairs.c;h=b300ee13c1126b57c3ea588cb091b1b1616c69d5;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=bbfe5ff4a4aa8210d137b7b0c5970561b4edf698;hpb=50be9bb40dc60130c99ffa568e6677779904ff70;p=xscreensaver diff --git a/hacks/glx/stairs.c b/hacks/glx/stairs.c index bbfe5ff4..b300ee13 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,7 +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_CW); + glFrontFace(GL_CCW); polys += unit_sphere (32, 32, False); glShadeModel(GL_FLAT); glEnable (GL_TEXTURE_2D); @@ -387,12 +393,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); @@ -415,6 +419,7 @@ pinit(void) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +#if 0 clear_gl_error(); status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, WoodTextureWidth, WoodTextureHeight, @@ -428,6 +433,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); @@ -463,7 +484,7 @@ init_stairs (ModeInfo * mi) glDrawBuffer(GL_BACK); if (!glIsList(sp->objects)) sp->objects = glGenLists(1); - pinit(); + pinit(mi); } else { MI_CLEARWINDOW(mi); } @@ -475,6 +496,7 @@ 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); @@ -488,6 +510,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)) {