1 /* flyingtoasters, Copyright (c) 2003, 2004 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
11 * Draws 3D flying toasters, and toast. Inspired by the ancient
12 * Berkeley Systems / After Dark hack, but now updated to the wide
13 * wonderful workd of OpenGL and 3D!
15 * Code by jwz; object models by Baconmonkey.
17 * The original After Dark flying toasters, with the fluffy white wings,
18 * were a trademark of Berkeley Systems. Berkeley Systems ceased to exist
19 * some time in 1998, having been gobbled up by Sierra Online, who were
20 * subsequently gobbled up by Flipside and/or Vivendi (it's hard to tell
21 * exactly what happened when.)
23 * I doubt anyone even cares any more, but if they do, hopefully this homage,
24 * with the space-age 3D jet-plane toasters, will be considered different
25 * enough that whoever still owns the trademark to the fluffy-winged 2D
26 * bitmapped toasters won't get all huffy at us.
29 #include <X11/Intrinsic.h>
31 extern XtAppContext app;
33 #define PROGCLASS "FlyingToasters"
34 #define HACK_INIT init_toasters
35 #define HACK_DRAW draw_toasters
36 #define HACK_RESHAPE reshape_toasters
37 #define HACK_HANDLE_EVENT toaster_handle_event
38 #define EVENT_MASK PointerMotionMask
39 #define sws_opts xlockmore_opts
41 #define DEF_SPEED "1.0"
42 #define DEF_NTOASTERS "20"
43 #define DEF_NSLICES "25"
44 #define DEF_TEXTURE "True"
46 #define DEFAULTS "*delay: 30000 \n" \
47 "*showFPS: False \n" \
48 "*wireframe: False \n" \
49 "*speed: " DEF_SPEED " \n" \
50 "*ntoasters: " DEF_NTOASTERS "\n" \
51 "*nslices: " DEF_NSLICES "\n" \
52 "*texture: " DEF_TEXTURE "\n" \
57 #define countof(x) (sizeof((x))/sizeof((*x)))
60 #define BELLRAND(n) ((frand((n)) + frand((n)) + frand((n))) / 3)
62 #include "xlockmore.h"
63 #include "gltrackball.h"
64 #include "xpm-ximage.h"
67 #include "../images/chromesphere.xpm"
68 #include "../images/toast.xpm"
70 #ifdef USE_GL /* whole file */
78 *toaster, *toaster_base, *toaster_handle, *toaster_handle2, *toaster_jet,
79 *toaster_knob, *toaster_slots, *toaster_wing, *toast, *toast2;
81 struct gllist **all_objs[] = {
82 &toaster, &toaster_base, &toaster_handle, &toaster_handle2, &toaster_jet,
83 &toaster_knob, &toaster_slots, &toaster_wing, &toast, &toast2
86 #define BASE_TOASTER 0
95 #define TOAST_BITTEN 9
98 #define GRID_DEPTH 500
101 static struct { GLfloat x, y; } nice_views[] = {
104 { 12, 28 }, /* this is a list of viewer rotations that look nice. */
105 { 12, -28 }, /* every now and then we switch to a new one. */
106 {-10, -28 }, /* (but we only use the first two at start-up.) */
120 int toast_type; /* 0, 1 */
121 GLfloat handle_pos; /* 0.0 - 1.0 */
122 GLfloat knob_pos; /* degrees */
123 int loaded; /* 2 bits */
127 GLXContext *glx_context;
128 trackball_state *user_trackball;
131 int last_view, target_view;
132 GLfloat view_x, view_y;
133 int view_steps, view_tick;
134 Bool auto_tracking_p;
137 GLuint chrome_texture;
138 GLuint toast_texture;
143 } toaster_configuration;
145 static toaster_configuration *bps = NULL;
147 static GLfloat speed;
148 static int ntoasters;
150 static int do_texture;
152 static XrmOptionDescRec opts[] = {
153 { "-speed", ".speed", XrmoptionSepArg, 0 },
154 { "-ntoasters", ".ntoasters", XrmoptionSepArg, 0 },
155 { "-nslices", ".nslices", XrmoptionSepArg, 0 },
156 {"-texture", ".texture", XrmoptionNoArg, "True" },
157 {"+texture", ".texture", XrmoptionNoArg, "False" },
160 static argtype vars[] = {
161 {&speed, "speed", "Speed", DEF_SPEED, t_Float},
162 {&ntoasters, "ntoasters", "Count", DEF_NTOASTERS, t_Int},
163 {&nslices, "nslices", "Count", DEF_NSLICES, t_Int},
164 {&do_texture, "texture", "Texture", DEF_TEXTURE, t_Bool},
167 ModeSpecOpt sws_opts = {countof(opts), opts, countof(vars), vars, NULL};
171 reset_floater (ModeInfo *mi, floater *f)
173 /* toaster_configuration *bp = &bps[MI_SCREEN(mi)]; */
175 GLfloat n = GRID_SIZE/2.0;
176 GLfloat n2 = GRID_DEPTH/2.0;
177 GLfloat delta = GRID_SIZE * speed / 200.0;
183 f->dz += BELLRAND(delta) - delta/3;
185 if (! (random() % 5)) {
186 f->dx += (BELLRAND(delta*2) - delta);
187 f->dy += (BELLRAND(delta*2) - delta);
190 if (! (random() % 40)) f->dz *= 10; /* occasional speedy one */
192 f->x = frand(n) - n/2;
193 f->y = frand(n) - n/2;
194 f->z = -n2 - frand(delta * 4);
199 f->knob_pos = frand(180) - 90;
200 f->handle_pos = ((random() & 1) ? 0.0 : 1.0);
202 if (f->handle_pos > 0.8 && (! (random() % 5)))
203 f->loaded = (random() & 3); /* let's toast! */
207 if (! (random() % 10))
208 f->toast_type = 1; /* toast_bitten */
214 tick_floater (ModeInfo *mi, floater *f)
216 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
218 GLfloat n1 = GRID_DEPTH/2.0;
219 GLfloat n2 = GRID_SIZE*4;
221 if (bp->button_down_p) return;
227 if (! (random() % 50000)) /* sudden gust of gravity */
230 if (f->x < -n2 || f->x > n2 ||
231 f->y < -n2 || f->y > n2 ||
233 reset_floater (mi, f);
238 auto_track_init (ModeInfo *mi)
240 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
241 bp->last_view = (random() % 2);
242 bp->target_view = bp->last_view + 2;
243 bp->view_x = nice_views[bp->last_view].x;
244 bp->view_y = nice_views[bp->last_view].y;
245 bp->view_steps = 100;
247 bp->auto_tracking_p = True;
252 auto_track (ModeInfo *mi)
254 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
256 if (bp->button_down_p)
259 /* if we're not moving, maybe start moving. Otherwise, do nothing. */
260 if (! bp->auto_tracking_p)
263 if (++tick < 200/speed) return;
265 if (! (random() % 5))
266 bp->auto_tracking_p = True;
273 GLfloat ox = nice_views[bp->last_view].x;
274 GLfloat oy = nice_views[bp->last_view].y;
275 GLfloat tx = nice_views[bp->target_view].x;
276 GLfloat ty = nice_views[bp->target_view].y;
278 /* move from A to B with sinusoidal deltas, so that it doesn't jerk
280 GLfloat th = sin ((M_PI / 2) * (double) bp->view_tick / bp->view_steps);
282 bp->view_x = (ox + ((tx - ox) * th));
283 bp->view_y = (oy + ((ty - oy) * th));
286 if (bp->view_tick >= bp->view_steps)
289 bp->view_steps = (350.0 / speed);
290 bp->last_view = bp->target_view;
291 bp->target_view = (random() % (countof(nice_views) - 2)) + 2;
292 bp->auto_tracking_p = False;
298 /* Window management, etc
301 reshape_toasters (ModeInfo *mi, int width, int height)
303 GLfloat h = (GLfloat) height / (GLfloat) width;
305 glViewport (0, 0, (GLint) width, (GLint) height);
307 glMatrixMode(GL_PROJECTION);
309 gluPerspective (40.0, 1/h, 1.0, 250);
311 glMatrixMode(GL_MODELVIEW);
313 gluLookAt( 0.0, 2.0, 30.0,
317 glClear(GL_COLOR_BUFFER_BIT);
322 toaster_handle_event (ModeInfo *mi, XEvent *event)
324 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
326 if (event->xany.type == ButtonPress &&
327 event->xbutton.button & Button1)
329 bp->button_down_p = True;
330 gltrackball_start (bp->user_trackball,
331 event->xbutton.x, event->xbutton.y,
332 MI_WIDTH (mi), MI_HEIGHT (mi));
335 else if (event->xany.type == ButtonRelease &&
336 event->xbutton.button & Button1)
338 bp->button_down_p = False;
341 else if (event->xany.type == MotionNotify &&
344 gltrackball_track (bp->user_trackball,
345 event->xmotion.x, event->xmotion.y,
346 MI_WIDTH (mi), MI_HEIGHT (mi));
355 load_textures (ModeInfo *mi)
357 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
360 xi = xpm_to_ximage (mi->dpy, mi->xgwa.visual, mi->xgwa.colormap,
364 glGenTextures (1, &bp->chrome_texture);
365 glBindTexture (GL_TEXTURE_2D, bp->chrome_texture);
366 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
367 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
368 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
369 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
370 xi->width, xi->height, 0,
372 /* GL_UNSIGNED_BYTE, */
373 GL_UNSIGNED_INT_8_8_8_8_REV,
375 check_gl_error("texture");
377 xi = xpm_to_ximage (mi->dpy, mi->xgwa.visual, mi->xgwa.colormap,
380 glGenTextures (1, &bp->toast_texture);
381 glBindTexture (GL_TEXTURE_2D, bp->toast_texture);
382 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
383 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
384 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
385 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
386 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
387 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
388 xi->width, xi->height, 0,
390 /* GL_UNSIGNED_BYTE, */
391 GL_UNSIGNED_INT_8_8_8_8_REV,
393 check_gl_error("texture");
395 glEnable(GL_TEXTURE_GEN_S);
396 glEnable(GL_TEXTURE_GEN_T);
397 glEnable(GL_TEXTURE_2D);
402 init_toasters (ModeInfo *mi)
404 toaster_configuration *bp;
405 int wire = MI_IS_WIREFRAME(mi);
409 bps = (toaster_configuration *)
410 calloc (MI_NUM_SCREENS(mi), sizeof (toaster_configuration));
412 fprintf(stderr, "%s: out of memory\n", progname);
416 bp = &bps[MI_SCREEN(mi)];
419 bp = &bps[MI_SCREEN(mi)];
421 bp->glx_context = init_GL(mi);
423 reshape_toasters (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
425 glShadeModel(GL_SMOOTH);
427 glEnable(GL_DEPTH_TEST);
428 glEnable(GL_NORMALIZE);
429 glEnable(GL_CULL_FACE);
433 GLfloat pos[4] = {0.4, 0.2, 0.4, 0.0};
434 /* GLfloat amb[4] = {0.0, 0.0, 0.0, 1.0};*/
435 GLfloat amb[4] = {0.2, 0.2, 0.2, 1.0};
436 GLfloat dif[4] = {1.0, 1.0, 1.0, 1.0};
437 GLfloat spc[4] = {1.0, 1.0, 1.0, 1.0};
439 glEnable(GL_LIGHTING);
441 glEnable(GL_DEPTH_TEST);
442 glEnable(GL_CULL_FACE);
444 glLightfv(GL_LIGHT0, GL_POSITION, pos);
445 glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
446 glLightfv(GL_LIGHT0, GL_DIFFUSE, dif);
447 glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
450 if (!wire && do_texture)
453 bp->user_trackball = gltrackball_init ();
454 auto_track_init (mi);
456 bp->dlists = (GLuint *) calloc (countof(all_objs)+1, sizeof(GLuint));
457 for (i = 0; i < countof(all_objs); i++)
458 bp->dlists[i] = glGenLists (1);
460 for (i = 0; i < countof(all_objs); i++)
462 struct gllist *gll = *all_objs[i];
464 gll->primitive = GL_LINE_LOOP;
466 glNewList (bp->dlists[i], GL_COMPILE);
468 glMatrixMode(GL_MODELVIEW);
470 glMatrixMode(GL_TEXTURE);
472 glMatrixMode(GL_MODELVIEW);
474 glRotatef (-90, 1, 0, 0);
475 glRotatef (180, 0, 0, 1);
478 glBindTexture (GL_TEXTURE_2D, 0);
480 if (i == BASE_TOASTER)
482 GLfloat color[4] = {1.00, 1.00, 1.00, 1.00};
483 GLfloat spec[4] = {1.00, 1.00, 1.00, 1.0};
484 GLfloat shiny = 20.0;
485 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
486 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
487 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
489 glBindTexture (GL_TEXTURE_2D, bp->chrome_texture);
490 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
491 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
493 else if (i == TOAST || i == TOAST_BITTEN)
495 GLfloat color[4] = {0.80, 0.80, 0.00, 1.0};
496 GLfloat spec[4] = {0.00, 0.00, 0.00, 1.0};
498 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
499 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
500 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
502 glBindTexture (GL_TEXTURE_2D, bp->toast_texture);
503 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
504 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
506 glMatrixMode(GL_TEXTURE);
507 glTranslatef(0.5, 0.5, 0);
508 glMatrixMode(GL_MODELVIEW);
510 else if (i == SLOTS || i == HANDLE_SLOT)
512 GLfloat color[4] = {0.30, 0.30, 0.40, 1.0};
513 GLfloat spec[4] = {0.40, 0.40, 0.70, 1.0};
514 GLfloat shiny = 128.0;
515 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
516 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
517 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
519 else if (i == HANDLE)
521 GLfloat color[4] = {0.80, 0.10, 0.10, 1.0};
522 GLfloat spec[4] = {1.00, 1.00, 1.00, 1.0};
523 GLfloat shiny = 20.0;
524 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
525 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
526 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
530 GLfloat color[4] = {0.80, 0.10, 0.10, 1.0};
531 GLfloat spec[4] = {0.00, 0.00, 0.00, 1.0};
533 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
534 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
535 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
537 else if (i == JET || i == JET_WING)
539 GLfloat color[4] = {0.70, 0.70, 0.70, 1.0};
540 GLfloat spec[4] = {1.00, 1.00, 1.00, 1.0};
541 GLfloat shiny = 20.0;
542 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
543 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
544 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
548 GLfloat color[4] = {0.50, 0.50, 0.50, 1.0};
549 GLfloat spec[4] = {1.00, 1.00, 1.00, 1.0};
550 GLfloat shiny = 20.0;
551 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
552 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
553 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
557 GLfloat color[4] = {1.00, 1.00, 1.00, 1.00};
558 GLfloat spec[4] = {1.00, 1.00, 1.00, 1.0};
559 GLfloat shiny = 128.0;
560 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
561 glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
562 glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny);
567 glMatrixMode(GL_TEXTURE);
569 glMatrixMode(GL_MODELVIEW);
575 bp->nfloaters = ntoasters + nslices;
576 bp->floaters = (floater *) calloc (bp->nfloaters, sizeof (floater));
578 for (i = 0; i < bp->nfloaters; i++)
580 floater *f = &bp->floaters[i];
581 /* arrange the list so that half the toasters are in front of bread,
582 and half are behind. */
583 f->toaster_p = ((i < ntoasters / 2) ||
584 (i >= (nslices + (ntoasters / 2))));
585 reset_floater (mi, f);
587 /* Position the first generation randomly, but make sure they aren't
588 on screen yet (until we rotate the view into position.)
591 GLfloat min = -GRID_DEPTH/2;
592 GLfloat max = GRID_DEPTH/3.5;
593 f->z = frand (max - min) + min;
600 draw_origin (ModeInfo *mi)
603 /* toaster_configuration *bp = &bps[MI_SCREEN(mi)];*/
605 if (!MI_IS_WIREFRAME(mi)) glDisable(GL_LIGHTING);
606 if (!MI_IS_WIREFRAME(mi) && do_texture) glDisable(GL_TEXTURE_2D);
611 glVertex3f(-1, 0, 0); glVertex3f(1, 0, 0);
612 glVertex3f(0, -1, 0); glVertex3f(0, 1, 0);
613 glVertex3f(0, 0, -1); glVertex3f(0, 0, 1);
617 if (!MI_IS_WIREFRAME(mi)) glEnable(GL_LIGHTING);
618 if (!MI_IS_WIREFRAME(mi) && do_texture) glEnable(GL_TEXTURE_2D);
624 draw_grid (ModeInfo *mi)
627 /* toaster_configuration *bp = &bps[MI_SCREEN(mi)];*/
629 if (!MI_IS_WIREFRAME(mi)) glDisable(GL_LIGHTING);
630 if (!MI_IS_WIREFRAME(mi) && do_texture) glDisable(GL_TEXTURE_2D);
632 glBegin(GL_LINE_LOOP);
633 glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, 0);
634 glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, 0);
635 glVertex3f( GRID_SIZE/2, GRID_SIZE/2, 0);
636 glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, 0);
638 glBegin(GL_LINE_LOOP);
639 glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2);
640 glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2);
641 glVertex3f( GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2);
642 glVertex3f( GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2);
644 glBegin(GL_LINE_LOOP);
645 glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2);
646 glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2);
647 glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2);
648 glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2);
651 glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2);
652 glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2);
653 glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2);
654 glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2);
655 glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2);
656 glVertex3f( GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2);
657 glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2);
658 glVertex3f( GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2);
662 if (!MI_IS_WIREFRAME(mi)) glEnable(GL_LIGHTING);
663 if (!MI_IS_WIREFRAME(mi) && do_texture) glEnable(GL_TEXTURE_2D);
669 draw_floater (ModeInfo *mi, floater *f)
671 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
677 glTranslatef (f->x, f->y, f->z);
681 glRotatef (180, 0, 1, 0);
682 glCallList (bp->dlists[BASE_TOASTER]);
683 mi->polygon_count += (*all_objs[BASE_TOASTER])->points / 3;
687 glTranslatef(0, 1.01, 0);
688 n = 0.91; glScalef(n,n,n);
689 glCallList (bp->dlists[SLOTS]);
690 mi->polygon_count += (*all_objs[SLOTS])->points / 3;
694 glRotatef (180, 0, 1, 0);
695 glTranslatef(0, -0.4, -2.38);
696 n = 0.33; glScalef(n,n,n);
697 glCallList (bp->dlists[HANDLE_SLOT]);
698 mi->polygon_count += (*all_objs[HANDLE_SLOT])->points / 3;
702 glTranslatef(0, -1.1, 3);
703 n = 0.3; glScalef (n,n,n);
704 glTranslatef(0, f->handle_pos * 4.8, 0);
705 glCallList (bp->dlists[HANDLE]);
706 mi->polygon_count += (*all_objs[HANDLE])->points / 3;
710 glRotatef (180, 0, 1, 0);
711 glTranslatef(0, -1.1, -3); /* where the handle is */
712 glTranslatef (1, -0.4, 0); /* down and to the left */
713 n = 0.08; glScalef (n,n,n);
714 glRotatef (f->knob_pos, 0, 0, 1);
715 glCallList (bp->dlists[KNOB]);
716 mi->polygon_count += (*all_objs[KNOB])->points / 3;
720 glRotatef (180, 0, 1, 0);
721 glTranslatef (0, -2.3, 0);
722 glCallList (bp->dlists[BASE]);
723 mi->polygon_count += (*all_objs[BASE])->points / 3;
727 glTranslatef(-4.8, 0, 0);
728 glCallList (bp->dlists[JET_WING]);
729 mi->polygon_count += (*all_objs[JET_WING])->points / 3;
730 glScalef (0.5, 0.5, 0.5);
731 glTranslatef (-2, -1, 0);
732 glCallList (bp->dlists[JET]);
733 mi->polygon_count += (*all_objs[JET])->points / 3;
737 glTranslatef(4.8, 0, 0);
740 glCallList (bp->dlists[JET_WING]);
741 mi->polygon_count += (*all_objs[JET_WING])->points / 3;
742 glScalef (0.5, 0.5, 0.5);
743 glTranslatef (-2, -1, 0);
744 glCallList (bp->dlists[JET]);
745 mi->polygon_count += (*all_objs[JET])->points / 3;
752 glTranslatef(0, 1.01, 0);
753 n = 0.91; glScalef(n,n,n);
754 glRotatef (90, 0, 0, 1);
755 glRotatef (90, 0, 1, 0);
756 glTranslatef(0, 0, -0.95);
757 glTranslatef(0, 0.72, 0);
760 glCallList (bp->dlists[TOAST]);
761 mi->polygon_count += (*all_objs[TOAST])->points / 3;
763 glTranslatef(0, -1.46, 0);
766 glCallList (bp->dlists[TOAST]);
767 mi->polygon_count += (*all_objs[TOAST])->points / 3;
774 glScalef (0.7, 0.7, 0.7);
775 if (f->toast_type == 0)
777 glCallList (bp->dlists[TOAST]);
778 mi->polygon_count += (*all_objs[TOAST])->points / 3;
782 glCallList (bp->dlists[TOAST_BITTEN]);
783 mi->polygon_count += (*all_objs[TOAST_BITTEN])->points / 3;
793 draw_toasters (ModeInfo *mi)
795 toaster_configuration *bp = &bps[MI_SCREEN(mi)];
796 Display *dpy = MI_DISPLAY(mi);
797 Window window = MI_WINDOW(mi);
800 if (!bp->glx_context)
803 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
806 glRotatef(bp->view_x, 1, 0, 0);
807 glRotatef(bp->view_y, 0, 1, 0);
808 gltrackball_rotate (bp->user_trackball);
820 F.dx = F.dy = F.dz = 0;
823 if (!MI_IS_WIREFRAME(mi)) glDisable(GL_LIGHTING);
824 if (!MI_IS_WIREFRAME(mi) && do_texture) glDisable(GL_TEXTURE_2D);
826 glVertex3f(-10, 0, 0); glVertex3f(10, 0, 0);
827 glVertex3f(0, -10, 0); glVertex3f(0, 10, 0);
828 glVertex3f(0, 0, -10); glVertex3f(0, 0, 10);
830 if (!MI_IS_WIREFRAME(mi)) glEnable(GL_LIGHTING);
831 if (!MI_IS_WIREFRAME(mi) && do_texture) glEnable(GL_TEXTURE_2D);
833 draw_floater (mi, &F);
835 if (mi->fps_p) do_fps (mi);
837 glXSwapBuffers(dpy, window);
842 glScalef (0.5, 0.5, 0.5);
844 glTranslatef (0, 0, -GRID_DEPTH/2.5);
847 mi->polygon_count = 0;
848 for (i = 0; i < bp->nfloaters; i++)
850 floater *f = &bp->floaters[i];
851 draw_floater (mi, f);
852 tick_floater (mi, f);
858 if (mi->fps_p) do_fps (mi);
861 glXSwapBuffers(dpy, window);