1 /* sballs --- balls spinning like crazy in GL */
4 static const char sccsid[] = "@(#)sballs.c 5.02 2001/03/10 xlockmore";
7 /* Copyright (c) E. Lassauge, 2001. */
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation for any purpose and without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and that
13 * both that copyright notice and this permission notice appear in
14 * supporting documentation.
16 * This file is provided AS IS with no warranties of any kind. The author
17 * shall have no liability with respect to the infringement of copyrights,
18 * trade secrets or any patents by this file or any part thereof. In no
19 * event will the author be liable for any lost revenue or profits or
20 * other special, indirect and consequential damages.
22 * The original code for this mode was written by
23 * Mustata Bogdan (LoneRunner) <lonerunner@planetquake.com>
24 * and can be found at http://www.cfxweb.net/lonerunner/
26 * Eric Lassauge (November-07-2000) <lassauge@mail.dotcom.fr>
27 * http://lassauge.free.fr/linux.html
31 * E.Lassauge - 03-Oct-2001:
32 * - minor bugfixes - get ready for xscreensaver
33 * E.Lassauge - 09-Mar-2001:
34 * - get rid of my framerate options to use showfps
35 * E.Lassauge - 28-Nov-2000:
36 * - add handling of polyhedrons (like in ico)
37 * - modified release part to add freeing of GL objects
38 * E.Lassauge - 14-Nov-2000:
39 * - use new common xpm_to_ximage function
43 #ifdef STANDALONE /* xscreensaver mode */
44 #define PROGCLASS "Sballs"
45 #define HACK_INIT init_sballs
46 #define HACK_DRAW draw_sballs
47 #define HACK_RESHAPE reshape_sballs
48 #define sballs_opts xlockmore_opts
49 #define DEFAULTS "*delay: 10000 \n" \
53 "*trackmouse: False \n" \
54 "*showFPS: False \n" \
55 "*wireframe: False \n" \
59 #include "xlockmore.h" /* from the xscreensaver distribution */
60 #else /* !STANDALONE */
61 #include "xlock.h" /* from the xlockmore distribution */
63 #endif /* !STANDALONE */
67 #define MINSIZE 32 /* minimal viewport size */
68 #define FRAME 50 /* frame count interval */
69 #define MAX_OBJ 8 /* number of 3D objects */
75 #if defined( USE_XPM ) || defined( USE_XPMINC ) || defined( HAVE_XPM )
76 /* USE_XPM & USE_XPMINC in xlock mode ; HAVE_XPM in xscreensaver mode */
77 # include "xpm-ximage.h"
83 __extension__ /* don't warn about "string length is greater than the length
84 ISO C89 compilers are required to support" when including
85 the following XPM file... */
87 # include "../images/sball.xpm"
91 # include "../images/sball-bg.xpm"
92 # else /* !STANDALONE */
93 # include "pixmaps/sball.xpm"
94 # include "pixmaps/sball-bg.xpm"
95 # endif /* !STANDALONE */
98 /* Manage option vars */
99 #define DEF_TEXTURE "True"
100 #define DEF_TRACKMOUSE "False"
101 #define DEF_OBJECT "2"
102 #define DEF_OBJECT_INDX 2
103 static Bool do_texture;
104 static Bool do_trackmouse;
108 static XrmOptionDescRec opts[] = {
109 {(char *) "-texture", (char *) ".sballs.texture", XrmoptionNoArg, (caddr_t) "on"},
110 {(char *) "+texture", (char *) ".sballs.texture", XrmoptionNoArg, (caddr_t) "off"},
111 {(char *) "-trackmouse", (char *) ".sballs.trackmouse", XrmoptionNoArg, (caddr_t) "on"},
112 {(char *) "+trackmouse", (char *) ".sballs.trackmouse", XrmoptionNoArg, (caddr_t) "off"},
113 {(char *) "-object", (char *) ".sballs.object", XrmoptionSepArg, (caddr_t) NULL},
117 static argtype vars[] = {
118 {&do_texture, "texture", "Texture", DEF_TEXTURE, t_Bool},
119 {&do_trackmouse, "trackmouse", "TrackMouse", DEF_TRACKMOUSE, t_Bool},
120 {&object, "object", "Object", DEF_OBJECT, t_Int},
124 static OptionStruct desc[] = {
125 /*{(char *) "-count spheres", (char *) "set number of spheres"},*/
126 /*{(char *) "-cycles speed", (char *) "set ball speed value"},*/
127 {(char *) "-/+texture", (char *) "turn on/off texturing"},
128 {(char *) "-/+trackmouse", (char *) "turn on/off the tracking of the mouse"},
129 {(char *) "-object num", (char *) "number of the 3D object (0 means random)"},
132 ModeSpecOpt sballs_opts =
133 { sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc };
136 ModStruct sballs_description =
137 { "sballs", "init_sballs", "draw_sballs", "release_sballs",
138 "draw_sballs", "change_sballs", (char *) NULL, &sballs_opts,
140 delay,count,cycles,size,ncolors,sat
142 10000, 0, 10, 400, 64, 1.0, "",
143 "balls spinning like crazy in GL", 0, NULL
145 #endif /* USE_MODULES */
147 /* misc types and defines */
148 #define vinit(a,i,j,k) {\
154 typedef vec_t vec3_t[3];
158 /* the mode struct, contains all per screen variables */
160 GLint WIDTH, HEIGHT; /* display dimensions */
161 GLXContext *glx_context;
164 XImage *btexture; /* back texture image bits */
165 XImage *ftexture; /* face texture image bits */
166 GLuint backid; /* back texture id: GL world */
167 GLuint faceid; /* face texture id: GL world */
173 float radius[MAX_BALLS];
177 /* array of sballsstruct indexed by screen number */
178 static sballsstruct *sballs = (sballsstruct *) NULL;
181 static float LightAmbient[]= { 1.0f, 1.0f, 1.0f, 1.0f };
182 static float LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
183 static float LightPosition[]= { 0.0f, 0.0f, 4.0f, 1.0f };
185 /* structure of the polyhedras */
187 const char *longname; /* long name of object */
188 const char *shortname; /* short name of object */
189 int numverts; /* number of vertices */
190 float radius; /* radius */
191 vec3_t v[MAX_BALLS];/* the vertices */
194 static Polyinfo polygons[] =
197 /* 0: objtetra - structure values for tetrahedron */
199 "tetrahedron", "tetra", /* long and short names */
200 4, /* number of vertices */
202 { /* vertices (x,y,z) */
203 /* all points must be within radius 2 of the origin */
213 /* 1: objcube - structure values for cube */
216 "hexahedron", "cube", /* long and short names */
217 8, /* number of vertices, edges, and faces */
219 { /* vertices (x,y,z) */
220 /* all points must be within radius 2 of the origin */
234 /* 2: objocta - structure values for octahedron */
237 "octahedron", "octa", /* long and short names */
238 6, /* number of vertices */
240 { /* vertices (x,y,z) */
241 /* all points must be within radius 2 of the origin */
252 /* 3: objdodec - structure values for dodecahedron */
255 "dodecahedron", "dodeca", /* long and short names */
256 20, /* number of vertices */
258 { /* vertices (x,y,z) */
259 /* all points must be within radius 2 of the origin */
260 {0.000000, 0.500000, 1.000000},
261 {0.000000, -0.500000, 1.000000},
262 {0.000000, -0.500000, -1.000000},
263 {0.000000, 0.500000, -1.000000},
264 {1.000000, 0.000000, 0.500000},
265 {-1.000000, 0.000000, 0.500000},
266 {-1.000000, 0.000000, -0.500000},
267 {1.000000, 0.000000, -0.500000},
268 {0.500000, 1.000000, 0.000000},
269 {-0.500000, 1.000000, 0.000000},
270 {-0.500000, -1.000000, 0.000000},
271 {0.500000, -1.000000, 0.000000},
272 {0.750000, 0.750000, 0.750000},
273 {-0.750000, 0.750000, 0.750000},
274 {-0.750000, -0.750000, 0.750000},
275 {0.750000, -0.750000, 0.750000},
276 {0.750000, -0.750000, -0.750000},
277 {0.750000, 0.750000, -0.750000},
278 {-0.750000, 0.750000, -0.750000},
279 {-0.750000, -0.750000, -0.750000},
283 /* 4: objicosa - structure values for icosahedron */
286 "icosahedron", "icosa", /* long and short names */
287 12, /* number of vertices */
289 { /* vertices (x,y,z) */
290 /* all points must be within radius 2 of the origin */
291 {0.00000000, 0.00000000, -0.95105650},
292 {0.00000000, 0.85065080, -0.42532537},
293 {0.80901698, 0.26286556, -0.42532537},
294 {0.50000000, -0.68819095, -0.42532537},
295 {-0.50000000, -0.68819095, -0.42532537},
296 {-0.80901698, 0.26286556, -0.42532537},
297 {0.50000000, 0.68819095, 0.42532537},
298 {0.80901698, -0.26286556, 0.42532537},
299 {0.00000000, -0.85065080, 0.42532537},
300 {-0.80901698, -0.26286556, 0.42532537},
301 {-0.50000000, 0.68819095, 0.42532537},
302 {0.00000000, 0.00000000, 0.95105650}
306 /* 5: objplane - structure values for plane */
309 "plane", "plane", /* long and short names */
310 4, /* number of vertices */
312 { /* vertices (x,y,z) */
313 /* all points must be within radius 2 of the origin */
323 /* 6: objpyr - structure values for pyramid */
326 "pyramid", "pyramid", /* long and short names */
327 5, /* number of vertices */
329 { /* vertices (x,y,z) */
330 /* all points must be within radius 1 of the origin */
341 /* 7: objstar - structure values for octahedron star (stellated octahedron?) */
343 "star", "star", /* long and short names */
344 8, /* number of vertices */
346 { /* vertices (x,y,z) */
347 /* all points must be within radius 1 of the origin */
367 *-----------------------------------------------------------------------------
368 *-----------------------------------------------------------------------------
370 *-----------------------------------------------------------------------------
371 *-----------------------------------------------------------------------------
374 static void clamp(vec3_t v)
378 for (i = 0; i < 3; i ++)
379 if (v[i] > 360 || v[i] < -360)
383 /* track the mouse in a joystick manner : not perfect but it works */
384 static void trackmouse(ModeInfo * mi)
386 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
387 /* we keep static values (not per screen) for the mouse stuff: in general you have only one mouse :-> */
388 static int max[2] = { 0, 0 };
389 static int min[2] = { 0x7fffffff, 0x7fffffff }, center[2];
394 (void) XQueryPointer(MI_DISPLAY(mi), MI_WINDOW(mi),
395 &r, &c, &rx, &ry, &cx, &cy, &m);
401 center[0] = (max[0] + min[0]) / 2;
407 center[1] = (max[1] + min[1]) / 2;
409 if (fabs(center[0] - (float) cx) > 0.1 * (max[0] - min[0]))
410 sb->rot[0] -= ((center[0] - (float) cx) / (max[0] - min[0]) * 180.0f) / 200.0f;
411 if (fabs(center[1] - (float) cy) > 0.1 * (max[1] - min[1]))
412 sb->rot[1] -= ((center[1] - (float) cy) / (max[1] - min[1]) * 180.0f) / 200.0f;;
415 /* oops: can't get those buttons */
423 /* initialise textures */
424 static void inittextures(ModeInfo * mi)
426 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
428 #if defined( I_HAVE_XPM )
431 glGenTextures(1, &sb->backid);
432 #ifdef HAVE_GLBINDTEXTURE
433 glBindTexture(GL_TEXTURE_2D, sb->backid);
434 #endif /* HAVE_GLBINDTEXTURE */
436 sb->btexture = xpm_to_ximage(MI_DISPLAY(mi),
440 if (!(sb->btexture)) {
441 (void) fprintf(stderr, "Error reading the background texture.\n");
442 glDeleteTextures(1, &sb->backid);
444 sb->faceid = 0; /* default textures */
449 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
451 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
452 sb->btexture->width, sb->btexture->height, 0,
454 /* GL_UNSIGNED_BYTE, */
455 GL_UNSIGNED_INT_8_8_8_8_REV,
457 check_gl_error("texture");
459 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
460 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
462 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
463 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
465 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
467 glGenTextures(1, &sb->faceid);
468 #ifdef HAVE_GLBINDTEXTURE
469 glBindTexture(GL_TEXTURE_2D, sb->faceid);
470 #endif /* HAVE_GLBINDTEXTURE */
472 sb->ftexture = xpm_to_ximage(MI_DISPLAY(mi),
476 if (!(sb->ftexture)) {
477 (void) fprintf(stderr, "Error reading the face texture.\n");
478 glDeleteTextures(1, &sb->faceid);
483 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
485 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
486 sb->ftexture->width, sb->ftexture->height, 0,
488 /* GL_UNSIGNED_BYTE, */
489 GL_UNSIGNED_INT_8_8_8_8_REV,
491 check_gl_error("texture");
493 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
494 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
496 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
497 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
499 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
503 sb->faceid = 0; /* default textures */
506 #else /* !I_HAVE_XPM */
508 sb->faceid = 0; /* default textures */
510 #endif /* !I_HAVE_XPM */
513 static void drawSphere(ModeInfo * mi,int sphere_num)
515 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
516 float x = polygons[object].v[sphere_num][0];
517 float y = polygons[object].v[sphere_num][1];
518 float z = polygons[object].v[sphere_num][2];
521 float radius = sb->radius[sphere_num];
522 double majorStep = (M_PI / numMajor);
523 double minorStep = (2.0 * M_PI / numMinor);
527 glTranslatef(x, y, z);
529 glColor4f(1, 1, 1, 1);
530 for (i = 0; i < numMajor; ++i)
532 double a = i * majorStep;
533 double b = a + majorStep;
534 double r0 = radius * sin(a);
535 double r1 = radius * sin(b);
536 GLfloat z0 = radius * cos(a);
537 GLfloat z1 = radius * cos(b);
539 glBegin(MI_IS_WIREFRAME(mi) ? GL_LINE_STRIP: GL_TRIANGLE_STRIP);
540 for (j = 0; j <= numMinor; ++j)
542 double c = j * minorStep;
546 glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius);
547 glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor);
548 glVertex3f(x * r0, y * r0, z0);
550 glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius);
551 glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor);
552 glVertex3f(x * r1, y * r1, z1);
561 *-----------------------------------------------------------------------------
562 *-----------------------------------------------------------------------------
564 *-----------------------------------------------------------------------------
565 *-----------------------------------------------------------------------------
569 static void Reshape(ModeInfo * mi)
571 void reshape_sballs(ModeInfo * mi, int width, int height)
575 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
576 int size = MI_SIZE(mi);
578 /* Viewport is specified size if size >= MINSIZE && size < screensize */
580 sb->WIDTH = MI_WIDTH(mi);
581 sb->HEIGHT = MI_HEIGHT(mi);
582 } else if (size < MINSIZE) {
584 sb->HEIGHT = MINSIZE;
586 sb->WIDTH = (size > MI_WIDTH(mi)) ? MI_WIDTH(mi) : size;
587 sb->HEIGHT = (size > MI_HEIGHT(mi)) ? MI_HEIGHT(mi) : size;
589 glViewport((MI_WIDTH(mi) - sb->WIDTH) / 2, (MI_HEIGHT(mi) - sb->HEIGHT) / 2, sb->WIDTH, sb->HEIGHT);
590 glMatrixMode(GL_PROJECTION);
592 gluPerspective(55.0, (float)sb->WIDTH / (float) sb->HEIGHT, 1.0, 300.0);
594 glMatrixMode(GL_MODELVIEW);
598 static void Draw(ModeInfo * mi)
600 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
603 if (do_trackmouse && !MI_IS_ICONIC(mi))
606 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
609 glEnable(GL_DEPTH_TEST);
612 glTranslatef (-sb->eye[0], -sb->eye[1], -sb->eye[2]);
614 /* draw background */
617 glEnable(GL_LIGHTING);
618 glEnable(GL_TEXTURE_2D);
620 #ifdef HAVE_GLBINDTEXTURE
621 glBindTexture(GL_TEXTURE_2D, sb->backid);
622 #endif /* HAVE_GLBINDTEXTURE */
628 glBegin(GL_QUAD_STRIP);
629 glNormal3f(0, 0, 1); glTexCoord2f(0,0); glVertex3f(8, 4.1, -4);
630 glNormal3f(0, 0, 1); glTexCoord2f(0,1); glVertex3f(8, -4.1, -4);
631 glNormal3f(0, 0, 1); glTexCoord2f(1,0); glVertex3f(-8, 4.1, -4);
632 glNormal3f(0, 0, 1); glTexCoord2f(1,1); glVertex3f(-8, -4.1, -4);
635 /* rotate the mouse */
636 glRotatef(sb->rot[0], 1.0f, 0.0f, 0.0f);
637 glRotatef(sb->rot[1], 0.0f, 1.0f, 0.0f);
638 glRotatef(sb->rot[2], 0.0f, 0.0f, 1.0f);
640 /* rotate the balls */
641 glRotatef(sb->rotm[0], 1.0f, 0.0f, 0.0f);
642 glRotatef(sb->rotm[1], 0.0f, 1.0f, 0.0f);
643 glRotatef(sb->rotm[2], 0.0f, 0.0f, 1.0f);
645 sb->rotm[0] += sb->speed;
646 sb->rotm[1] += -(sb->speed);
651 #ifdef HAVE_GLBINDTEXTURE
652 glBindTexture(GL_TEXTURE_2D, sb->faceid);
653 #endif /* HAVE_GLBINDTEXTURE */
655 glEnable(GL_LIGHTING);
656 for (sphere=0;sphere<spheres;sphere++)
658 drawSphere(mi,sphere);
661 glDisable(GL_TEXTURE_2D);
662 glDisable(GL_DEPTH_TEST);
663 glDisable(GL_LIGHTING);
665 /* manage framerate display */
666 if (MI_IS_FPS(mi)) do_fps (mi);
671 static void Init(ModeInfo * mi)
673 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
676 /* Default settings */
677 if (MI_IS_WIREFRAME(mi))
683 sb->btexture = (XImage*) NULL;
684 sb->ftexture = (XImage*) NULL;
687 vinit(sb->eye ,0.0f, 0.0f, 6.0f);
688 vinit(sb->rot ,0.0f, 0.0f, 0.0f);
689 vinit(sb->rotm ,0.0f, 0.0f, 0.0f);
690 sb->speed = MI_CYCLES(mi);
692 /* initialise object number */
694 object = NRAND(MAX_OBJ);
695 if ((object == 0) || (object > MAX_OBJ))
696 object = DEF_OBJECT_INDX;
699 /* initialise sphere number */
700 spheres = MI_COUNT(mi);
701 if (MI_COUNT(mi) > polygons[object].numverts)
702 spheres = polygons[object].numverts;
703 if (MI_COUNT(mi) < 1)
704 spheres = polygons[object].numverts;
705 /* initialise sphere radius */
706 for(i=0; i < spheres;i++)
709 sb->radius[i] = ((float) LRAND() / (float) MAXRAND);
710 if (sb->radius[i] < 0.3)
712 if (sb->radius[i] > 0.7)
715 sb->radius[i] = polygons[object].radius;
719 if (MI_IS_DEBUG(mi)) {
720 (void) fprintf(stderr,
721 "%s:\n\tobject=%s\n\tspheres=%d\n\tspeed=%d\n\ttexture=%s\n",
723 polygons[object].shortname,
726 do_texture ? "on" : "off"
730 glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
731 glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
732 glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
735 glClearColor(0, 0, 0, 0);
739 *-----------------------------------------------------------------------------
740 *-----------------------------------------------------------------------------
742 *-----------------------------------------------------------------------------
743 *-----------------------------------------------------------------------------
747 *-----------------------------------------------------------------------------
748 * Initialize sballs. Called each time the window changes.
749 *-----------------------------------------------------------------------------
752 void init_sballs(ModeInfo * mi)
756 if (sballs == NULL) {
757 if ((sballs = (sballsstruct *) calloc(MI_NUM_SCREENS(mi),
758 sizeof(sballsstruct))) == NULL)
761 sb = &sballs[MI_SCREEN(mi)];
763 if ((sb->glx_context = init_GL(mi)) != NULL) {
766 Reshape(mi); /* xlock mode */
768 reshape_sballs(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
770 glDrawBuffer(GL_BACK);
779 *-----------------------------------------------------------------------------
780 * Called by the mainline code periodically to update the display.
781 *-----------------------------------------------------------------------------
783 void draw_sballs(ModeInfo * mi)
785 Display *display = MI_DISPLAY(mi);
786 Window window = MI_WINDOW(mi);
791 sb = &sballs[MI_SCREEN(mi)];
793 MI_IS_DRAWN(mi) = True;
794 if (!sb->glx_context)
797 glXMakeCurrent(display, window, *(sb->glx_context));
800 Reshape(mi); /* xlock mode */
802 reshape_sballs(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
806 glXSwapBuffers(display, window);
811 *-----------------------------------------------------------------------------
812 * The display is being taken away from us. Free up malloc'ed
813 * memory and X resources that we've alloc'ed. Only called
814 * once, we must zap everything for every screen.
815 *-----------------------------------------------------------------------------
818 void release_sballs(ModeInfo * mi)
822 if (sballs != NULL) {
823 for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
824 sballsstruct *sb = &sballs[screen];
827 glDeleteTextures(1,&sb->backid);
828 XDestroyImage(sb->btexture);
832 glDeleteTextures(1,&sb->faceid);
833 XDestroyImage(sb->ftexture);
836 (void) free((void *) sballs);
837 sballs = (sballsstruct *) NULL;
842 void change_sballs(ModeInfo * mi)
848 sb = &sballs[MI_SCREEN(mi)];
850 if (!sb->glx_context)
853 /* initialise object number */
855 object = NRAND(MAX_OBJ);
856 if ((object == 0) || (object > MAX_OBJ))
857 object = DEF_OBJECT_INDX;
860 /* correct sphere number */
861 spheres = MI_COUNT(mi);
862 if (MI_COUNT(mi) > polygons[object].numverts)
863 spheres = polygons[object].numverts;
864 if (MI_COUNT(mi) < 1)
865 spheres = polygons[object].numverts;
867 if (MI_IS_DEBUG(mi)) {
868 (void) fprintf(stderr,
869 "%s:\n\tobject=%s\n\tspheres=%d\n\tspeed=%d\n\ttexture=%s\n",
871 polygons[object].shortname,
874 do_texture ? "on" : "off"
877 glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sb->glx_context));
880 #endif /* MODE_sballs */