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" \
86 # include "xlockmore.h" /* from the xscreensaver distribution */
87 #else /* !STANDALONE */
88 # include "xlock.h" /* from the xlockmore distribution */
89 #endif /* !STANDALONE */
94 # include <X11/Xlib.h>
100 # include "jwzgles.h"
101 #endif /* HAVE_JWZGLES */
105 #if 0 /* Hey, this never actually used the texture at all! */
107 #include "e_textures.h"
109 #include "xpm-ximage.h"
110 #include "../images/wood.xpm"
118 #include "gltrackball.h"
120 #define DEF_SOLIDMOEBIUS "False"
121 #define DEF_DRAWANTS "True"
123 static int solidmoebius;
126 static XrmOptionDescRec opts[] =
128 {"-solidmoebius", ".moebius.solidmoebius", XrmoptionNoArg, "on"},
129 {"+solidmoebius", ".moebius.solidmoebius", XrmoptionNoArg, "off"},
130 {"-ants", ".moebius.drawants", XrmoptionNoArg, "on"},
131 {"+ants", ".moebius.drawants", XrmoptionNoArg, "off"}
133 static argtype vars[] =
135 {&solidmoebius, "solidmoebius", "Solidmoebius", DEF_SOLIDMOEBIUS, t_Bool},
136 {&drawants, "drawants", "Drawants", DEF_DRAWANTS, t_Bool}
139 static OptionStruct desc[] =
141 {"-/+solidmoebius", "select between a SOLID or a NET Moebius Strip"},
142 {"-/+drawants", "turn on/off walking ants"}
145 ENTRYPOINT ModeSpecOpt moebius_opts =
146 {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
149 ModStruct moebius_description =
150 {"moebius", "init_moebius", "draw_moebius", "release_moebius",
151 "draw_moebius", "change_moebius", (char *) NULL, &moebius_opts,
152 1000, 1, 1, 1, 4, 1.0, "",
153 "Shows Moebius Strip II, an Escher-like GL scene with ants", 0, NULL};
157 #define Scale4Window 0.3
158 #define Scale4Iconic 0.4
160 #define sqr(A) ((A)*(A))
166 #define ObjMoebiusStrip 0
170 /*************************************************************************/
175 GLfloat ant_position;
177 GLXContext *glx_context;
179 trackball_state *trackball;
183 static const float front_shininess[] = {60.0};
184 static const float front_specular[] = {0.7, 0.7, 0.7, 1.0};
185 static const float ambient[] = {0.0, 0.0, 0.0, 1.0};
186 static const float diffuse[] = {1.0, 1.0, 1.0, 1.0};
187 static const float position0[] = {1.0, 1.0, 1.0, 0.0};
188 static const float position1[] = {-1.0, -1.0, 1.0, 0.0};
189 static const float lmodel_ambient[] = {0.5, 0.5, 0.5, 1.0};
190 static const float lmodel_twoside[] = {GL_TRUE};
192 static const float MaterialRed[] = {0.7, 0.0, 0.0, 1.0};
193 static const float MaterialGreen[] = {0.1, 0.5, 0.2, 1.0};
194 static const float MaterialBlue[] = {0.0, 0.0, 0.7, 1.0};
195 static const float MaterialCyan[] = {0.2, 0.5, 0.7, 1.0};
196 static const float MaterialYellow[] = {0.7, 0.7, 0.0, 1.0};
197 static const float MaterialMagenta[] = {0.6, 0.2, 0.5, 1.0};
198 static const float MaterialWhite[] = {0.7, 0.7, 0.7, 1.0};
199 static const float MaterialGray[] = {0.2, 0.2, 0.2, 1.0};
200 static const float MaterialGray5[] = {0.5, 0.5, 0.5, 1.0};
201 static const float MaterialGray6[] = {0.6, 0.6, 0.6, 1.0};
202 static const float MaterialGray8[] = {0.8, 0.8, 0.8, 1.0};
204 static moebiusstruct *moebius = (moebiusstruct *) NULL;
209 mySphere(float radius)
212 GLUquadricObj *quadObj;
214 if ((quadObj = gluNewQuadric()) == 0)
216 gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
217 gluSphere(quadObj, radius, 16, 16);
218 gluDeleteQuadric(quadObj);
221 glScalef (radius, radius, radius);
222 unit_sphere (16, 16, False);
232 GLUquadricObj *quadObj;
234 if ((quadObj = gluNewQuadric()) == 0)
236 gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
237 gluCylinder(quadObj, radius, 0, radius * 3, 8, 1);
238 gluDeleteQuadric(quadObj);
243 8, True, True, False);
249 draw_moebius_ant(moebiusstruct * mp, const float *Material, int mono)
251 float cos1 = cos(mp->ant_step);
252 float cos2 = cos(mp->ant_step + 2 * Pi / 3);
253 float cos3 = cos(mp->ant_step + 4 * Pi / 3);
254 float sin1 = sin(mp->ant_step);
255 float sin2 = sin(mp->ant_step + 2 * Pi / 3);
256 float sin3 = sin(mp->ant_step + 4 * Pi / 3);
259 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray5);
261 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Material);
262 glEnable(GL_CULL_FACE);
267 glScalef(1, 1 / 1.3, 1);
268 glTranslatef(0.00, 0.30, 0.00);
272 glTranslatef(-0.05, 0.17, 0.05);
273 glRotatef(-90, 1, 0, 0);
274 glRotatef(-25, 0, 1, 0);
277 glTranslatef(0.00, 0.10, 0.00);
280 glRotatef(25, 0, 1, 0);
281 glRotatef(90, 1, 0, 0);
284 glTranslatef(0.15, -0.65, 0.05);
287 glScalef(1, 1 / 1.3, 1);
289 glDisable(GL_CULL_FACE);
291 glDisable(GL_LIGHTING);
295 glColor3fv(MaterialGray5);
297 glColor3fv(Material);
298 glVertex3f(0.00, 0.30, 0.00);
299 glColor3fv(MaterialGray);
300 glVertex3f(0.40, 0.70, 0.40);
302 glColor3fv(MaterialGray5);
304 glColor3fv(Material);
305 glVertex3f(0.00, 0.30, 0.00);
306 glColor3fv(MaterialGray);
307 glVertex3f(0.40, 0.70, -0.40);
311 glColor3fv(MaterialGray6);
313 glColor3fv(MaterialRed);
314 glVertex3f(0.40, 0.70, 0.40);
315 glVertex3f(0.40, 0.70, -0.40);
319 glBegin(GL_LINE_STRIP);
321 glColor3fv(MaterialGray5);
323 glColor3fv(Material);
324 glVertex3f(0.00, 0.05, 0.18);
325 glVertex3f(0.35 + 0.05 * cos1, 0.15, 0.25);
326 glColor3fv(MaterialGray);
327 glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
330 /* LEFT-CENTER ARM */
331 glBegin(GL_LINE_STRIP);
333 glColor3fv(MaterialGray5);
335 glColor3fv(Material);
336 glVertex3f(0.00, 0.00, 0.18);
337 glVertex3f(0.35 + 0.05 * cos2, 0.00, 0.25);
338 glColor3fv(MaterialGray);
339 glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
343 glBegin(GL_LINE_STRIP);
345 glColor3fv(MaterialGray5);
347 glColor3fv(Material);
348 glVertex3f(0.00, -0.05, 0.18);
349 glVertex3f(0.35 + 0.05 * cos3, -0.15, 0.25);
350 glColor3fv(MaterialGray);
351 glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
354 /* RIGHT-FRONT ARM */
355 glBegin(GL_LINE_STRIP);
357 glColor3fv(MaterialGray5);
359 glColor3fv(Material);
360 glVertex3f(0.00, 0.05, -0.18);
361 glVertex3f(0.35 - 0.05 * sin1, 0.15, -0.25);
362 glColor3fv(MaterialGray);
363 glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
366 /* RIGHT-CENTER ARM */
367 glBegin(GL_LINE_STRIP);
369 glColor3fv(MaterialGray5);
371 glColor3fv(Material);
372 glVertex3f(0.00, 0.00, -0.18);
373 glVertex3f(0.35 - 0.05 * sin2, 0.00, -0.25);
374 glColor3fv(MaterialGray);
375 glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
379 glBegin(GL_LINE_STRIP);
381 glColor3fv(MaterialGray5);
383 glColor3fv(Material);
384 glVertex3f(0.00, -0.05, -0.18);
385 glVertex3f(0.35 - 0.05 * sin3, -0.15, -0.25);
386 glColor3fv(MaterialGray);
387 glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
392 glColor3fv(MaterialGray8);
394 glColor3fv(MaterialMagenta);
395 glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
396 glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
397 glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
398 glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
399 glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
400 glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
403 glEnable(GL_LIGHTING);
410 RotateAaroundU(float Ax, float Ay, float Az,
411 float Ux, float Uy, float Uz,
412 float *Cx, float *Cy, float *Cz,
415 float cosO = cos(Theta);
416 float sinO = sin(Theta);
417 float one_cosO = 1 - cosO;
421 float UxUy = Ux * Uy;
422 float UxUz = Ux * Uz;
423 float UyUz = Uy * Uz;
425 *Cx = (Ux2 + cosO * (1 - Ux2)) * Ax + (UxUy * one_cosO - Uz * sinO) * Ay + (UxUz * one_cosO + Uy * sinO) * Az;
426 *Cy = (UxUy * one_cosO + Uz * sinO) * Ax + (Uy2 + cosO * (1 - Uy2)) * Ay + (UyUz * one_cosO - Ux * sinO) * Az;
427 *Cz = (UxUz * one_cosO - Uy * sinO) * Ax + (UyUz * one_cosO + Ux * sinO) * Ay + (Uz2 + cosO * (1 - Uz2)) * Az;
430 #define MoebiusDivisions 40
431 #define MoebiusTransversals 4
433 draw_moebius_strip(ModeInfo * mi)
437 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
439 int mono = MI_IS_MONO(mi);
444 solidmoebius = True; /* no LINE PolygonMode */
448 glBegin(GL_QUAD_STRIP);
451 while (i < (MoebiusDivisions * 2 + 1)) {
458 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
460 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
462 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
464 RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
465 glNormal3f(Cx, Cy, Cz);
466 RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
467 glVertex3f(cPhi * 3 + Cx, sPhi * 3 + Cy, +Cz);
468 glVertex3f(cPhi * 3 - Cx, sPhi * 3 - Cy, -Cz);
470 Phi += Pi / MoebiusDivisions;
474 for (j = -MoebiusTransversals; j < MoebiusTransversals; j++) {
475 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
476 glBegin(GL_QUAD_STRIP);
479 while (i < (MoebiusDivisions * 2 + 1)) {
484 RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
485 glNormal3f(Cx, Cy, Cz);
486 RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
488 if (j == MoebiusTransversals || mono)
489 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
491 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
493 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
494 glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);
496 if (j == -MoebiusTransversals || mono)
497 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
499 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
501 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
502 glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);
504 Phi += Pi / MoebiusDivisions;
509 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
515 glRotatef(mp->ant_position + 180, 0, 0, 1);
516 glTranslatef(3, 0, 0);
517 glRotatef(mp->ant_position / 2 + 90, 0, 1, 0);
518 glTranslatef(0.28, 0, -0.45);
519 if (!draw_moebius_ant(mp, MaterialYellow, mono))
523 /* DRAW YELLOW ANT */
525 glRotatef(mp->ant_position, 0, 0, 1);
526 glTranslatef(3, 0, 0);
527 glRotatef(mp->ant_position / 2, 0, 1, 0);
528 glTranslatef(0.28, 0, -0.45);
529 if (!draw_moebius_ant(mp, MaterialBlue, mono))
535 glRotatef(-mp->ant_position, 0, 0, 1);
536 glTranslatef(3, 0, 0);
537 glRotatef(-mp->ant_position / 2, 0, 1, 0);
538 glTranslatef(0.28, 0, 0.45);
539 glRotatef(180, 1, 0, 0);
540 if (!draw_moebius_ant(mp, MaterialGreen, mono))
546 glRotatef(-mp->ant_position + 180, 0, 0, 1);
547 glTranslatef(3, 0, 0);
548 glRotatef(-mp->ant_position / 2 + 90, 0, 1, 0);
549 glTranslatef(0.28, 0, 0.45);
550 glRotatef(180, 1, 0, 0);
551 if (!draw_moebius_ant(mp, MaterialCyan, mono))
555 mp->ant_position += 1;
558 #undef MoebiusDivisions
559 #undef MoebiusTransversals
562 reshape_moebius (ModeInfo * mi, int width, int height)
564 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
566 glViewport(0, 0, mp->WindW = (GLint) width, mp->WindH = (GLint) height);
567 glMatrixMode(GL_PROJECTION);
569 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0);
570 glMatrixMode(GL_MODELVIEW);
574 } else if (width >= 512) {
588 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
589 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
590 glLightfv(GL_LIGHT0, GL_POSITION, position0);
591 glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
592 glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
593 glLightfv(GL_LIGHT1, GL_POSITION, position1);
594 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
595 glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
596 glEnable(GL_LIGHTING);
599 glEnable(GL_NORMALIZE);
604 glShadeModel(GL_SMOOTH);
605 glEnable(GL_DEPTH_TEST);
606 glDisable(GL_CULL_FACE);
609 glEnable(GL_TEXTURE_2D);
610 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
614 status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
615 WoodTextureWidth, WoodTextureHeight,
616 GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
619 const char *s = (char *) gluErrorString (status);
620 fprintf (stderr, "%s: error mipmapping %dx%d texture: %s\n",
621 progname, WoodTextureWidth, WoodTextureHeight,
622 (s ? s : "(unknown)"));
625 check_gl_error("mipmapping");
628 XImage *img = xpm_to_ximage (mi->dpy,
632 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
633 img->width, img->height, 0,
635 /* GL_UNSIGNED_BYTE, */
636 GL_UNSIGNED_INT_8_8_8_8_REV,
638 check_gl_error("texture");
643 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
644 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
645 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
646 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
647 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
650 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
651 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
657 release_moebius (ModeInfo * mi)
659 if (moebius != NULL) {
660 (void) free((void *) moebius);
661 moebius = (moebiusstruct *) NULL;
667 moebius_handle_event (ModeInfo *mi, XEvent *event)
669 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
671 if (event->xany.type == ButtonPress &&
672 event->xbutton.button == Button1)
674 mp->button_down_p = True;
675 gltrackball_start (mp->trackball,
676 event->xbutton.x, event->xbutton.y,
677 MI_WIDTH (mi), MI_HEIGHT (mi));
680 else if (event->xany.type == ButtonRelease &&
681 event->xbutton.button == Button1)
683 mp->button_down_p = False;
686 else if (event->xany.type == ButtonPress &&
687 (event->xbutton.button == Button4 ||
688 event->xbutton.button == Button5 ||
689 event->xbutton.button == Button6 ||
690 event->xbutton.button == Button7))
692 gltrackball_mousewheel (mp->trackball, event->xbutton.button, 10,
693 !!event->xbutton.state);
696 else if (event->xany.type == MotionNotify &&
699 gltrackball_track (mp->trackball,
700 event->xmotion.x, event->xmotion.y,
701 MI_WIDTH (mi), MI_HEIGHT (mi));
710 init_moebius (ModeInfo * mi)
714 if (moebius == NULL) {
715 if ((moebius = (moebiusstruct *) calloc(MI_NUM_SCREENS(mi),
716 sizeof (moebiusstruct))) == NULL)
719 mp = &moebius[MI_SCREEN(mi)];
720 mp->step = NRAND(90);
721 mp->ant_position = NRAND(90);
724 double rot_speed = 0.3;
725 mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
726 mp->trackball = gltrackball_init ();
729 if ((mp->glx_context = init_GL(mi)) != NULL) {
731 reshape_moebius(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
732 glDrawBuffer(GL_BACK);
740 draw_moebius (ModeInfo * mi)
744 Display *display = MI_DISPLAY(mi);
745 Window window = MI_WINDOW(mi);
749 mp = &moebius[MI_SCREEN(mi)];
751 MI_IS_DRAWN(mi) = True;
753 if (!mp->glx_context)
756 glXMakeCurrent(display, window, *(mp->glx_context));
758 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
762 glTranslatef(0.0, 0.0, -10.0);
764 /* Do it twice because we don't track the device's orientation. */
765 glRotatef( current_device_rotation(), 0, 0, 1);
766 gltrackball_rotate (mp->trackball);
767 glRotatef(-current_device_rotation(), 0, 0, 1);
769 if (!MI_IS_ICONIC(mi)) {
770 glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window);
772 glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
777 get_rotation (mp->rot, &x, &y, &z, !mp->button_down_p);
778 glRotatef (x * 360, 1.0, 0.0, 0.0);
779 glRotatef (y * 360, 0.0, 1.0, 0.0);
780 glRotatef (z * 360, 0.0, 0.0, 1.0);
784 if (!draw_moebius_strip(mi)) {
791 if (MI_IS_FPS(mi)) do_fps (mi);
794 glXSwapBuffers(display, window);
801 change_moebius (ModeInfo * mi)
803 moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
805 if (!mp->glx_context)
808 glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(mp->glx_context));
811 #endif /* !STANDALONE */
814 XSCREENSAVER_MODULE ("Moebius", moebius)