1 /* -*- Mode: C; tab-width: 4 -*- */
2 /* moebius --- Moebius Strip II, an Escher-like GL scene with ants. */
5 static const char sccsid[] = "@(#)moebius.c 5.01 2001/03/01 xlockmore";
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation for any purpose and without fee is hereby granted,
11 * provided that the above copyright notice appear in all copies and that
12 * both that copyright notice and this permission notice appear in
13 * supporting documentation.
15 * This file is provided AS IS with no warranties of any kind. The author
16 * shall have no liability with respect to the infringement of copyrights,
17 * trade secrets or any patents by this file or any part thereof. In no
18 * event will the author be liable for any lost revenue or profits or
19 * other special, indirect and consequential damages.
21 * The RotateAroundU() routine was adapted from the book
22 * "Computer Graphics Principles and Practice
23 * Foley - vanDam - Feiner - Hughes
24 * Second Edition" Pag. 227, exercise 5.15.
26 * This mode shows some interesting scenes that are impossible OR very
27 * wierd to build in the real universe. Much of the scenes are inspirated
28 * on Mauritz Cornelis Escher's works which derivated the mode's name.
29 * M.C. Escher (1898-1972) was a dutch artist and many people prefer to
30 * say he was a mathematician.
32 * Thanks goes to Brian Paul for making it possible and inexpensive to use
35 * Since I'm not a native English speaker, my apologies for any grammatical
38 * My e-mail address is
39 * mfvianna@centroin.com.br
41 * Marcelo F. Vianna (Jun-01-1997)
44 * 05-Apr-2002: Removed all gllist uses (fix some bug with nvidia driver)
45 * 01-Mar-2001: backported from xscreensaver by lassauge@mail.dotcom.fr
46 * Feb-2001: Made motion and rotation be smoother Jamie Zawinski
48 * 01-Nov-2000: Allocation checks
49 * 01-Jan-1998: Mode separated from escher and renamed
50 * 08-Jun-1997: New scene implemented: "Impossible Cage" based in a M.C.
51 * Escher's painting with the same name (quite similar). The
52 * first GL mode to use texture mapping.
53 * The "Impossible Cage" scene doesn't use DEPTH BUFFER, the
54 * wood planks are drawn consistently using GL_CULL_FACE, and
55 * the painter's algorithm is used to sort the planks.
57 * 07-Jun-1997: Speed ups in Moebius Strip using GL_CULL_FACE.
59 * 03-Jun-1997: Initial Release (Only one scene: "Moebius Strip")
60 * The Moebius Strip scene was inspirated in a M.C. Escher's
61 * painting named Moebius Strip II in wich ants walk across a
62 * Moebius Strip path, sometimes meeting each other and sometimes
63 * being in "opposite faces" (note that the moebius strip has
64 * only one face and one edge).
69 * Texture mapping is only available on RGBA contexts, Mono and color index
70 * visuals DO NOT support texture mapping in OpenGL.
72 * BUT Mesa do implements RGBA contexts in pseudo color visuals, so texture
73 * mapping shuld work on PseudoColor, DirectColor, TrueColor using Mesa. Mono
74 * is not officially supported for both OpenGL and Mesa, but seems to not crash
77 * In real OpenGL, PseudoColor DO NOT support texture map (as far as I know).
82 # define refresh_moebius 0
83 # define DEFAULTS "*delay: 20000 \n" \
84 "*showFPS: False \n" \
85 "*suppressRotationAnimation: True\n" \
87 # include "xlockmore.h" /* from the xscreensaver distribution */
88 #else /* !STANDALONE */
89 # include "xlock.h" /* from the xlockmore distribution */
90 #endif /* !STANDALONE */
95 # include <X11/Xlib.h>
101 # include "jwzgles.h"
102 #endif /* HAVE_JWZGLES */
106 #if 0 /* Hey, this never actually used the texture at all! */
108 #include "e_textures.h"
110 #include "xpm-ximage.h"
111 #include "../images/wood.xpm"
119 #include "gltrackball.h"
121 #define DEF_SOLIDMOEBIUS "False"
122 #define DEF_DRAWANTS "True"
124 static int solidmoebius;
127 static XrmOptionDescRec opts[] =
129 {"-solidmoebius", ".moebius.solidmoebius", XrmoptionNoArg, "on"},
130 {"+solidmoebius", ".moebius.solidmoebius", XrmoptionNoArg, "off"},
131 {"-ants", ".moebius.drawants", XrmoptionNoArg, "on"},
132 {"+ants", ".moebius.drawants", XrmoptionNoArg, "off"}
134 static argtype vars[] =
136 {&solidmoebius, "solidmoebius", "Solidmoebius", DEF_SOLIDMOEBIUS, t_Bool},
137 {&drawants, "drawants", "Drawants", DEF_DRAWANTS, t_Bool}
140 static OptionStruct desc[] =
142 {"-/+solidmoebius", "select between a SOLID or a NET Moebius Strip"},
143 {"-/+drawants", "turn on/off walking ants"}
146 ENTRYPOINT ModeSpecOpt moebius_opts =
147 {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
150 ModStruct moebius_description =
151 {"moebius", "init_moebius", "draw_moebius", "release_moebius",
152 "draw_moebius", "change_moebius", (char *) NULL, &moebius_opts,
153 1000, 1, 1, 1, 4, 1.0, "",
154 "Shows Moebius Strip II, an Escher-like GL scene with ants", 0, NULL};
158 #define Scale4Window 0.3
159 #define Scale4Iconic 0.4
161 #define sqr(A) ((A)*(A))
167 #define ObjMoebiusStrip 0
171 /*************************************************************************/
176 GLfloat ant_position;
178 GLXContext *glx_context;
180 trackball_state *trackball;
184 static const float front_shininess[] = {60.0};
185 static const float front_specular[] = {0.7, 0.7, 0.7, 1.0};
186 static const float ambient[] = {0.0, 0.0, 0.0, 1.0};
187 static const float diffuse[] = {1.0, 1.0, 1.0, 1.0};
188 static const float position0[] = {1.0, 1.0, 1.0, 0.0};
189 static const float position1[] = {-1.0, -1.0, 1.0, 0.0};
190 static const float lmodel_ambient[] = {0.5, 0.5, 0.5, 1.0};
191 static const float lmodel_twoside[] = {GL_TRUE};
193 static const float MaterialRed[] = {0.7, 0.0, 0.0, 1.0};
194 static const float MaterialGreen[] = {0.1, 0.5, 0.2, 1.0};
195 static const float MaterialBlue[] = {0.0, 0.0, 0.7, 1.0};
196 static const float MaterialCyan[] = {0.2, 0.5, 0.7, 1.0};
197 static const float MaterialYellow[] = {0.7, 0.7, 0.0, 1.0};
198 static const float MaterialMagenta[] = {0.6, 0.2, 0.5, 1.0};
199 static const float MaterialWhite[] = {0.7, 0.7, 0.7, 1.0};
200 static const float MaterialGray[] = {0.2, 0.2, 0.2, 1.0};
201 static const float MaterialGray5[] = {0.5, 0.5, 0.5, 1.0};
202 static const float MaterialGray6[] = {0.6, 0.6, 0.6, 1.0};
203 static const float MaterialGray8[] = {0.8, 0.8, 0.8, 1.0};
205 static moebiusstruct *moebius = (moebiusstruct *) NULL;
210 mySphere(float radius)
213 GLUquadricObj *quadObj;
215 if ((quadObj = gluNewQuadric()) == 0)
217 gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
218 gluSphere(quadObj, radius, 16, 16);
219 gluDeleteQuadric(quadObj);
222 glScalef (radius, radius, radius);
223 unit_sphere (16, 16, False);
233 GLUquadricObj *quadObj;
235 if ((quadObj = gluNewQuadric()) == 0)
237 gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
238 gluCylinder(quadObj, radius, 0, radius * 3, 8, 1);
239 gluDeleteQuadric(quadObj);
244 8, True, True, False);
250 draw_moebius_ant(moebiusstruct * mp, const float *Material, int mono)
252 float cos1 = cos(mp->ant_step);
253 float cos2 = cos(mp->ant_step + 2 * Pi / 3);
254 float cos3 = cos(mp->ant_step + 4 * Pi / 3);
255 float sin1 = sin(mp->ant_step);
256 float sin2 = sin(mp->ant_step + 2 * Pi / 3);
257 float sin3 = sin(mp->ant_step + 4 * Pi / 3);
260 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray5);
262 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Material);
263 glEnable(GL_CULL_FACE);
268 glScalef(1, 1 / 1.3, 1);
269 glTranslatef(0.00, 0.30, 0.00);
273 glTranslatef(-0.05, 0.17, 0.05);
274 glRotatef(-90, 1, 0, 0);
275 glRotatef(-25, 0, 1, 0);
278 glTranslatef(0.00, 0.10, 0.00);
281 glRotatef(25, 0, 1, 0);
282 glRotatef(90, 1, 0, 0);
285 glTranslatef(0.15, -0.65, 0.05);
288 glScalef(1, 1 / 1.3, 1);
290 glDisable(GL_CULL_FACE);
292 glDisable(GL_LIGHTING);
296 glColor3fv(MaterialGray5);
298 glColor3fv(Material);
299 glVertex3f(0.00, 0.30, 0.00);
300 glColor3fv(MaterialGray);
301 glVertex3f(0.40, 0.70, 0.40);
303 glColor3fv(MaterialGray5);
305 glColor3fv(Material);
306 glVertex3f(0.00, 0.30, 0.00);
307 glColor3fv(MaterialGray);
308 glVertex3f(0.40, 0.70, -0.40);
312 glColor3fv(MaterialGray6);
314 glColor3fv(MaterialRed);
315 glVertex3f(0.40, 0.70, 0.40);
316 glVertex3f(0.40, 0.70, -0.40);
320 glBegin(GL_LINE_STRIP);
322 glColor3fv(MaterialGray5);
324 glColor3fv(Material);
325 glVertex3f(0.00, 0.05, 0.18);
326 glVertex3f(0.35 + 0.05 * cos1, 0.15, 0.25);
327 glColor3fv(MaterialGray);
328 glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
331 /* LEFT-CENTER ARM */
332 glBegin(GL_LINE_STRIP);
334 glColor3fv(MaterialGray5);
336 glColor3fv(Material);
337 glVertex3f(0.00, 0.00, 0.18);
338 glVertex3f(0.35 + 0.05 * cos2, 0.00, 0.25);
339 glColor3fv(MaterialGray);
340 glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
344 glBegin(GL_LINE_STRIP);
346 glColor3fv(MaterialGray5);
348 glColor3fv(Material);
349 glVertex3f(0.00, -0.05, 0.18);
350 glVertex3f(0.35 + 0.05 * cos3, -0.15, 0.25);
351 glColor3fv(MaterialGray);
352 glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
355 /* RIGHT-FRONT ARM */
356 glBegin(GL_LINE_STRIP);
358 glColor3fv(MaterialGray5);
360 glColor3fv(Material);
361 glVertex3f(0.00, 0.05, -0.18);
362 glVertex3f(0.35 - 0.05 * sin1, 0.15, -0.25);
363 glColor3fv(MaterialGray);
364 glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
367 /* RIGHT-CENTER ARM */
368 glBegin(GL_LINE_STRIP);
370 glColor3fv(MaterialGray5);
372 glColor3fv(Material);
373 glVertex3f(0.00, 0.00, -0.18);
374 glVertex3f(0.35 - 0.05 * sin2, 0.00, -0.25);
375 glColor3fv(MaterialGray);
376 glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
380 glBegin(GL_LINE_STRIP);
382 glColor3fv(MaterialGray5);
384 glColor3fv(Material);
385 glVertex3f(0.00, -0.05, -0.18);
386 glVertex3f(0.35 - 0.05 * sin3, -0.15, -0.25);
387 glColor3fv(MaterialGray);
388 glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
393 glColor3fv(MaterialGray8);
395 glColor3fv(MaterialMagenta);
396 glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
397 glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
398 glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
399 glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
400 glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
401 glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
404 glEnable(GL_LIGHTING);
411 RotateAaroundU(float Ax, float Ay, float Az,
412 float Ux, float Uy, float Uz,
413 float *Cx, float *Cy, float *Cz,
416 float cosO = cos(Theta);
417 float sinO = sin(Theta);
418 float one_cosO = 1 - cosO;
422 float UxUy = Ux * Uy;
423 float UxUz = Ux * Uz;
424 float UyUz = Uy * Uz;
426 *Cx = (Ux2 + cosO * (1 - Ux2)) * Ax + (UxUy * one_cosO - Uz * sinO) * Ay + (UxUz * one_cosO + Uy * sinO) * Az;
427 *Cy = (UxUy * one_cosO + Uz * sinO) * Ax + (Uy2 + cosO * (1 - Uy2)) * Ay + (UyUz * one_cosO - Ux * sinO) * Az;
428 *Cz = (UxUz * one_cosO - Uy * sinO) * Ax + (UyUz * one_cosO + Ux * sinO) * Ay + (Uz2 + cosO * (1 - Uz2)) * Az;
431 #define MoebiusDivisions 40
432 #define MoebiusTransversals 4
434 draw_moebius_strip(ModeInfo * mi)
438 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
440 int mono = MI_IS_MONO(mi);
444 #ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
449 glBegin(GL_QUAD_STRIP);
452 while (i < (MoebiusDivisions * 2 + 1)) {
459 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
461 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
463 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
465 RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
466 glNormal3f(Cx, Cy, Cz);
467 RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
468 glVertex3f(cPhi * 3 + Cx, sPhi * 3 + Cy, +Cz);
469 glVertex3f(cPhi * 3 - Cx, sPhi * 3 - Cy, -Cz);
471 Phi += Pi / MoebiusDivisions;
475 for (j = -MoebiusTransversals; j < MoebiusTransversals; j++) {
476 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
477 glBegin(GL_QUAD_STRIP);
480 while (i < (MoebiusDivisions * 2 + 1)) {
485 RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
486 glNormal3f(Cx, Cy, Cz);
487 RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
489 if (j == MoebiusTransversals || mono)
490 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
492 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
494 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
495 glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);
497 if (j == -MoebiusTransversals || mono)
498 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
500 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
502 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
503 glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);
505 Phi += Pi / MoebiusDivisions;
510 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
516 glRotatef(mp->ant_position + 180, 0, 0, 1);
517 glTranslatef(3, 0, 0);
518 glRotatef(mp->ant_position / 2 + 90, 0, 1, 0);
519 glTranslatef(0.28, 0, -0.45);
520 if (!draw_moebius_ant(mp, MaterialYellow, mono))
524 /* DRAW YELLOW ANT */
526 glRotatef(mp->ant_position, 0, 0, 1);
527 glTranslatef(3, 0, 0);
528 glRotatef(mp->ant_position / 2, 0, 1, 0);
529 glTranslatef(0.28, 0, -0.45);
530 if (!draw_moebius_ant(mp, MaterialBlue, mono))
536 glRotatef(-mp->ant_position, 0, 0, 1);
537 glTranslatef(3, 0, 0);
538 glRotatef(-mp->ant_position / 2, 0, 1, 0);
539 glTranslatef(0.28, 0, 0.45);
540 glRotatef(180, 1, 0, 0);
541 if (!draw_moebius_ant(mp, MaterialGreen, mono))
547 glRotatef(-mp->ant_position + 180, 0, 0, 1);
548 glTranslatef(3, 0, 0);
549 glRotatef(-mp->ant_position / 2 + 90, 0, 1, 0);
550 glTranslatef(0.28, 0, 0.45);
551 glRotatef(180, 1, 0, 0);
552 if (!draw_moebius_ant(mp, MaterialCyan, mono))
556 mp->ant_position += 1;
559 #undef MoebiusDivisions
560 #undef MoebiusTransversals
563 reshape_moebius (ModeInfo * mi, int width, int height)
565 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
567 glViewport(0, 0, mp->WindW = (GLint) width, mp->WindH = (GLint) height);
568 glMatrixMode(GL_PROJECTION);
570 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0);
571 glMatrixMode(GL_MODELVIEW);
575 } else if (width >= 512) {
589 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
590 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
591 glLightfv(GL_LIGHT0, GL_POSITION, position0);
592 glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
593 glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
594 glLightfv(GL_LIGHT1, GL_POSITION, position1);
595 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
596 glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
597 glEnable(GL_LIGHTING);
600 glEnable(GL_NORMALIZE);
605 glShadeModel(GL_SMOOTH);
606 glEnable(GL_DEPTH_TEST);
607 glDisable(GL_CULL_FACE);
610 glEnable(GL_TEXTURE_2D);
611 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
615 status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
616 WoodTextureWidth, WoodTextureHeight,
617 GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
620 const char *s = (char *) gluErrorString (status);
621 fprintf (stderr, "%s: error mipmapping %dx%d texture: %s\n",
622 progname, WoodTextureWidth, WoodTextureHeight,
623 (s ? s : "(unknown)"));
626 check_gl_error("mipmapping");
629 XImage *img = xpm_to_ximage (mi->dpy,
633 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
634 img->width, img->height, 0,
636 /* GL_UNSIGNED_BYTE, */
637 GL_UNSIGNED_INT_8_8_8_8_REV,
639 check_gl_error("texture");
644 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
645 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
646 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
647 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
648 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
651 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
652 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
658 release_moebius (ModeInfo * mi)
660 if (moebius != NULL) {
661 (void) free((void *) moebius);
662 moebius = (moebiusstruct *) NULL;
668 moebius_handle_event (ModeInfo *mi, XEvent *event)
670 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
672 if (gltrackball_event_handler (event, mp->trackball,
673 MI_WIDTH (mi), MI_HEIGHT (mi),
682 init_moebius (ModeInfo * mi)
686 if (moebius == NULL) {
687 if ((moebius = (moebiusstruct *) calloc(MI_NUM_SCREENS(mi),
688 sizeof (moebiusstruct))) == NULL)
691 mp = &moebius[MI_SCREEN(mi)];
692 mp->step = NRAND(90);
693 mp->ant_position = NRAND(90);
696 double rot_speed = 0.3;
697 mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
698 mp->trackball = gltrackball_init (True);
701 if ((mp->glx_context = init_GL(mi)) != NULL) {
703 reshape_moebius(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
704 glDrawBuffer(GL_BACK);
712 draw_moebius (ModeInfo * mi)
716 Display *display = MI_DISPLAY(mi);
717 Window window = MI_WINDOW(mi);
721 mp = &moebius[MI_SCREEN(mi)];
723 MI_IS_DRAWN(mi) = True;
725 if (!mp->glx_context)
728 glXMakeCurrent(display, window, *(mp->glx_context));
730 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
735 glTranslatef(0.0, 0.0, -10.0);
737 gltrackball_rotate (mp->trackball);
739 if (!MI_IS_ICONIC(mi)) {
740 glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window);
742 glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
745 # ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */
747 GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
748 int o = (int) current_device_rotation();
749 if (o != 0 && o != 180 && o != -180) {
750 glScalef (1/h, h, 1); /* #### not quite right */
759 get_rotation (mp->rot, &x, &y, &z, !mp->button_down_p);
760 glRotatef (x * 360, 1.0, 0.0, 0.0);
761 glRotatef (y * 360, 0.0, 1.0, 0.0);
762 glRotatef (z * 360, 0.0, 0.0, 1.0);
766 if (!draw_moebius_strip(mi)) {
773 if (MI_IS_FPS(mi)) do_fps (mi);
776 glXSwapBuffers(display, window);
783 change_moebius (ModeInfo * mi)
785 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
787 if (!mp->glx_context)
790 glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(mp->glx_context));
793 #endif /* !STANDALONE */
796 XSCREENSAVER_MODULE ("Moebius", moebius)