1 /* sballs --- balls spinning like crazy in GL */
3 #if !defined( lint ) && !defined( SABER )
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"
81 #include "../images/sball.xpm"
82 #include "../images/sball-bg.xpm"
83 #else /* !STANDALONE */
84 #include "pixmaps/sball.xpm"
85 #include "pixmaps/sball-bg.xpm"
86 #endif /* !STANDALONE */
89 /* Manage option vars */
90 #define DEF_TEXTURE "True"
91 #define DEF_TRACKMOUSE "False"
92 #define DEF_OBJECT "2"
93 #define DEF_OBJECT_INDX 2
94 static Bool do_texture;
95 static Bool do_trackmouse;
99 static XrmOptionDescRec opts[] = {
100 {(char *) "-texture", (char *) ".sballs.texture", XrmoptionNoArg, (caddr_t) "on"},
101 {(char *) "+texture", (char *) ".sballs.texture", XrmoptionNoArg, (caddr_t) "off"},
102 {(char *) "-trackmouse", (char *) ".sballs.trackmouse", XrmoptionNoArg, (caddr_t) "on"},
103 {(char *) "+trackmouse", (char *) ".sballs.trackmouse", XrmoptionNoArg, (caddr_t) "off"},
104 {(char *) "-object", (char *) ".sballs.object", XrmoptionSepArg, (caddr_t) NULL},
108 static argtype vars[] = {
109 {(caddr_t *) & do_texture, (char *) "texture", (char *) "Texture", (char *) DEF_TEXTURE, t_Bool},
110 {(caddr_t *) & do_trackmouse, (char *) "trackmouse", (char *) "TrackMouse", (char *) DEF_TRACKMOUSE, t_Bool},
111 {(caddr_t *) & object, (char *) "object", (char *) "Object", (char *) DEF_OBJECT, t_Int},
115 static OptionStruct desc[] = {
116 /*{(char *) "-count spheres", (char *) "set number of spheres"},*/
117 /*{(char *) "-cycles speed", (char *) "set ball speed value"},*/
118 {(char *) "-/+texture", (char *) "turn on/off texturing"},
119 {(char *) "-/+trackmouse", (char *) "turn on/off the tracking of the mouse"},
120 {(char *) "-object num", (char *) "number of the 3D object (0 means random)"},
123 ModeSpecOpt sballs_opts =
124 { sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc };
127 ModStruct sballs_description =
128 { "sballs", "init_sballs", "draw_sballs", "release_sballs",
129 "draw_sballs", "change_sballs", (char *) NULL, &sballs_opts,
131 delay,count,cycles,size,ncolors,sat
133 10000, 0, 10, 400, 64, 1.0, "",
134 "balls spinning like crazy in GL", 0, NULL
136 #endif /* USE_MODULES */
138 /* misc types and defines */
139 #define vinit(a,i,j,k) {\
145 typedef vec_t vec3_t[3];
149 /* the mode struct, contains all per screen variables */
151 GLint WIDTH, HEIGHT; /* display dimensions */
152 GLXContext *glx_context;
155 XImage *btexture; /* back texture image bits */
156 XImage *ftexture; /* face texture image bits */
157 GLuint backid; /* back texture id: GL world */
158 GLuint faceid; /* face texture id: GL world */
164 float radius[MAX_BALLS];
168 /* array of sballsstruct indexed by screen number */
169 static sballsstruct *sballs = (sballsstruct *) NULL;
172 static float LightAmbient[]= { 1.0f, 1.0f, 1.0f, 1.0f };
173 static float LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
174 static float LightPosition[]= { 0.0f, 0.0f, 4.0f, 1.0f };
176 /* structure of the polyhedras */
178 const char *longname; /* long name of object */
179 const char *shortname; /* short name of object */
180 int numverts; /* number of vertices */
181 float radius; /* radius */
182 vec3_t v[MAX_BALLS];/* the vertices */
185 static Polyinfo polygons[] =
188 /* 0: objtetra - structure values for tetrahedron */
190 "tetrahedron", "tetra", /* long and short names */
191 4, /* number of vertices */
193 { /* vertices (x,y,z) */
194 /* all points must be within radius 2 of the origin */
204 /* 1: objcube - structure values for cube */
207 "hexahedron", "cube", /* long and short names */
208 8, /* number of vertices, edges, and faces */
210 { /* vertices (x,y,z) */
211 /* all points must be within radius 2 of the origin */
225 /* 2: objocta - structure values for octahedron */
228 "octahedron", "octa", /* long and short names */
229 6, /* number of vertices */
231 { /* vertices (x,y,z) */
232 /* all points must be within radius 2 of the origin */
243 /* 3: objdodec - structure values for dodecahedron */
246 "dodecahedron", "dodeca", /* long and short names */
247 20, /* number of vertices */
249 { /* vertices (x,y,z) */
250 /* all points must be within radius 2 of the origin */
251 {0.000000, 0.500000, 1.000000},
252 {0.000000, -0.500000, 1.000000},
253 {0.000000, -0.500000, -1.000000},
254 {0.000000, 0.500000, -1.000000},
255 {1.000000, 0.000000, 0.500000},
256 {-1.000000, 0.000000, 0.500000},
257 {-1.000000, 0.000000, -0.500000},
258 {1.000000, 0.000000, -0.500000},
259 {0.500000, 1.000000, 0.000000},
260 {-0.500000, 1.000000, 0.000000},
261 {-0.500000, -1.000000, 0.000000},
262 {0.500000, -1.000000, 0.000000},
263 {0.750000, 0.750000, 0.750000},
264 {-0.750000, 0.750000, 0.750000},
265 {-0.750000, -0.750000, 0.750000},
266 {0.750000, -0.750000, 0.750000},
267 {0.750000, -0.750000, -0.750000},
268 {0.750000, 0.750000, -0.750000},
269 {-0.750000, 0.750000, -0.750000},
270 {-0.750000, -0.750000, -0.750000},
274 /* 4: objicosa - structure values for icosahedron */
277 "icosahedron", "icosa", /* long and short names */
278 12, /* number of vertices */
280 { /* vertices (x,y,z) */
281 /* all points must be within radius 2 of the origin */
282 {0.00000000, 0.00000000, -0.95105650},
283 {0.00000000, 0.85065080, -0.42532537},
284 {0.80901698, 0.26286556, -0.42532537},
285 {0.50000000, -0.68819095, -0.42532537},
286 {-0.50000000, -0.68819095, -0.42532537},
287 {-0.80901698, 0.26286556, -0.42532537},
288 {0.50000000, 0.68819095, 0.42532537},
289 {0.80901698, -0.26286556, 0.42532537},
290 {0.00000000, -0.85065080, 0.42532537},
291 {-0.80901698, -0.26286556, 0.42532537},
292 {-0.50000000, 0.68819095, 0.42532537},
293 {0.00000000, 0.00000000, 0.95105650}
297 /* 5: objplane - structure values for plane */
300 "plane", "plane", /* long and short names */
301 4, /* number of vertices */
303 { /* vertices (x,y,z) */
304 /* all points must be within radius 2 of the origin */
314 /* 6: objpyr - structure values for pyramid */
317 "pyramid", "pyramid", /* long and short names */
318 5, /* number of vertices */
320 { /* vertices (x,y,z) */
321 /* all points must be within radius 1 of the origin */
332 /* 7: objstar - structure values for octahedron star (stellated octahedron?) */
334 "star", "star", /* long and short names */
335 8, /* number of vertices */
337 { /* vertices (x,y,z) */
338 /* all points must be within radius 1 of the origin */
358 *-----------------------------------------------------------------------------
359 *-----------------------------------------------------------------------------
361 *-----------------------------------------------------------------------------
362 *-----------------------------------------------------------------------------
365 static void clamp(vec3_t v)
369 for (i = 0; i < 3; i ++)
370 if (v[i] > 360 || v[i] < -360)
374 /* track the mouse in a joystick manner : not perfect but it works */
375 static void trackmouse(ModeInfo * mi)
377 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
378 /* we keep static values (not per screen) for the mouse stuff: in general you have only one mouse :-> */
379 static int max[2] = { 0, 0 };
380 static int min[2] = { 0x7fffffff, 0x7fffffff }, center[2];
385 (void) XQueryPointer(MI_DISPLAY(mi), MI_WINDOW(mi),
386 &r, &c, &rx, &ry, &cx, &cy, &m);
392 center[0] = (max[0] + min[0]) / 2;
398 center[1] = (max[1] + min[1]) / 2;
400 if (fabs(center[0] - (float) cx) > 0.1 * (max[0] - min[0]))
401 sb->rot[0] -= ((center[0] - (float) cx) / (max[0] - min[0]) * 180.0f) / 200.0f;
402 if (fabs(center[1] - (float) cy) > 0.1 * (max[1] - min[1]))
403 sb->rot[1] -= ((center[1] - (float) cy) / (max[1] - min[1]) * 180.0f) / 200.0f;;
406 /* oops: can't get those buttons */
414 /* initialise textures */
415 static void inittextures(ModeInfo * mi)
417 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
419 #if defined( I_HAVE_XPM )
422 glGenTextures(1, &sb->backid);
423 #ifdef HAVE_GLBINDTEXTURE
424 glBindTexture(GL_TEXTURE_2D, sb->backid);
425 #endif /* HAVE_GLBINDTEXTURE */
427 sb->btexture = xpm_to_ximage(MI_DISPLAY(mi),
431 if (!(sb->btexture)) {
432 (void) fprintf(stderr, "Error reading the background texture.\n");
433 glDeleteTextures(1, &sb->backid);
435 sb->faceid = 0; /* default textures */
440 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
442 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
443 sb->btexture->width, sb->btexture->height, 0,
444 GL_RGBA, GL_UNSIGNED_BYTE, sb->btexture->data);
445 check_gl_error("texture");
447 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
448 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
450 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
451 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
453 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
455 glGenTextures(1, &sb->faceid);
456 #ifdef HAVE_GLBINDTEXTURE
457 glBindTexture(GL_TEXTURE_2D, sb->faceid);
458 #endif /* HAVE_GLBINDTEXTURE */
460 sb->ftexture = xpm_to_ximage(MI_DISPLAY(mi),
464 if (!(sb->ftexture)) {
465 (void) fprintf(stderr, "Error reading the face texture.\n");
466 glDeleteTextures(1, &sb->faceid);
471 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
473 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
474 sb->ftexture->width, sb->ftexture->height, 0,
475 GL_RGBA, GL_UNSIGNED_BYTE, sb->ftexture->data);
476 check_gl_error("texture");
478 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
479 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
481 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
482 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
484 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
488 sb->faceid = 0; /* default textures */
491 #else /* !I_HAVE_XPM */
493 sb->faceid = 0; /* default textures */
495 #endif /* !I_HAVE_XPM */
498 static void drawSphere(ModeInfo * mi,int sphere_num)
500 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
501 float x = polygons[object].v[sphere_num][0];
502 float y = polygons[object].v[sphere_num][1];
503 float z = polygons[object].v[sphere_num][2];
506 float radius = sb->radius[sphere_num];
507 double majorStep = (M_PI / numMajor);
508 double minorStep = (2.0 * M_PI / numMinor);
512 glTranslatef(x, y, z);
514 glColor4f(1, 1, 1, 1);
515 for (i = 0; i < numMajor; ++i)
517 double a = i * majorStep;
518 double b = a + majorStep;
519 double r0 = radius * sin(a);
520 double r1 = radius * sin(b);
521 GLfloat z0 = radius * cos(a);
522 GLfloat z1 = radius * cos(b);
524 glBegin(MI_IS_WIREFRAME(mi) ? GL_LINE_STRIP: GL_TRIANGLE_STRIP);
525 for (j = 0; j <= numMinor; ++j)
527 double c = j * minorStep;
531 glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius);
532 glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor);
533 glVertex3f(x * r0, y * r0, z0);
535 glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius);
536 glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor);
537 glVertex3f(x * r1, y * r1, z1);
546 *-----------------------------------------------------------------------------
547 *-----------------------------------------------------------------------------
549 *-----------------------------------------------------------------------------
550 *-----------------------------------------------------------------------------
554 static void Reshape(ModeInfo * mi)
556 void reshape_sballs(ModeInfo * mi, int width, int height)
560 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
561 int size = MI_SIZE(mi);
563 /* Viewport is specified size if size >= MINSIZE && size < screensize */
565 sb->WIDTH = MI_WIDTH(mi);
566 sb->HEIGHT = MI_HEIGHT(mi);
567 } else if (size < MINSIZE) {
569 sb->HEIGHT = MINSIZE;
571 sb->WIDTH = (size > MI_WIDTH(mi)) ? MI_WIDTH(mi) : size;
572 sb->HEIGHT = (size > MI_HEIGHT(mi)) ? MI_HEIGHT(mi) : size;
574 glViewport((MI_WIDTH(mi) - sb->WIDTH) / 2, (MI_HEIGHT(mi) - sb->HEIGHT) / 2, sb->WIDTH, sb->HEIGHT);
575 glMatrixMode(GL_PROJECTION);
577 gluPerspective(55.0, (float)sb->WIDTH / (float) sb->HEIGHT, 1.0, 300.0);
579 glMatrixMode(GL_MODELVIEW);
583 static void Draw(ModeInfo * mi)
585 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
588 if (do_trackmouse && !MI_IS_ICONIC(mi))
591 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
594 glEnable(GL_DEPTH_TEST);
597 glTranslatef (-sb->eye[0], -sb->eye[1], -sb->eye[2]);
599 /* draw background */
602 glEnable(GL_LIGHTING);
603 glEnable(GL_TEXTURE_2D);
605 #ifdef HAVE_GLBINDTEXTURE
606 glBindTexture(GL_TEXTURE_2D, sb->backid);
607 #endif /* HAVE_GLBINDTEXTURE */
613 glBegin(GL_QUAD_STRIP);
614 glNormal3f(0, 0, 1); glTexCoord2f(0,0); glVertex3f(8, 4.1, -4);
615 glNormal3f(0, 0, 1); glTexCoord2f(0,1); glVertex3f(8, -4.1, -4);
616 glNormal3f(0, 0, 1); glTexCoord2f(1,0); glVertex3f(-8, 4.1, -4);
617 glNormal3f(0, 0, 1); glTexCoord2f(1,1); glVertex3f(-8, -4.1, -4);
620 /* rotate the mouse */
621 glRotatef(sb->rot[0], 1.0f, 0.0f, 0.0f);
622 glRotatef(sb->rot[1], 0.0f, 1.0f, 0.0f);
623 glRotatef(sb->rot[2], 0.0f, 0.0f, 1.0f);
625 /* rotate the balls */
626 glRotatef(sb->rotm[0], 1.0f, 0.0f, 0.0f);
627 glRotatef(sb->rotm[1], 0.0f, 1.0f, 0.0f);
628 glRotatef(sb->rotm[2], 0.0f, 0.0f, 1.0f);
630 sb->rotm[0] += sb->speed;
631 sb->rotm[1] += -(sb->speed);
636 #ifdef HAVE_GLBINDTEXTURE
637 glBindTexture(GL_TEXTURE_2D, sb->faceid);
638 #endif /* HAVE_GLBINDTEXTURE */
640 glEnable(GL_LIGHTING);
641 for (sphere=0;sphere<spheres;sphere++)
643 drawSphere(mi,sphere);
646 glDisable(GL_TEXTURE_2D);
647 glDisable(GL_DEPTH_TEST);
648 glDisable(GL_LIGHTING);
650 /* manage framerate display */
651 if (MI_IS_FPS(mi)) do_fps (mi);
656 static void Init(ModeInfo * mi)
658 sballsstruct *sb = &sballs[MI_SCREEN(mi)];
661 /* Default settings */
662 if (MI_IS_WIREFRAME(mi))
668 sb->btexture = (XImage*) NULL;
669 sb->ftexture = (XImage*) NULL;
672 vinit(sb->eye ,0.0f, 0.0f, 6.0f);
673 vinit(sb->rot ,0.0f, 0.0f, 0.0f);
674 vinit(sb->rotm ,0.0f, 0.0f, 0.0f);
675 sb->speed = MI_CYCLES(mi);
677 /* initialise object number */
679 object = NRAND(MAX_OBJ);
680 if ((object == 0) || (object > MAX_OBJ))
681 object = DEF_OBJECT_INDX;
684 /* initialise sphere number */
685 spheres = MI_COUNT(mi);
686 if (MI_COUNT(mi) > polygons[object].numverts)
687 spheres = polygons[object].numverts;
688 if (MI_COUNT(mi) < 1)
689 spheres = polygons[object].numverts;
690 /* initialise sphere radius */
691 for(i=0; i < spheres;i++)
694 sb->radius[i] = ((float) LRAND() / (float) MAXRAND);
695 if (sb->radius[i] < 0.3)
697 if (sb->radius[i] > 0.7)
700 sb->radius[i] = polygons[object].radius;
704 if (MI_IS_DEBUG(mi)) {
705 (void) fprintf(stderr,
706 "%s:\n\tobject=%s\n\tspheres=%d\n\tspeed=%d\n\ttexture=%s\n",
708 polygons[object].shortname,
711 do_texture ? "on" : "off"
715 glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
716 glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
717 glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
720 glClearColor(0, 0, 0, 0);
724 *-----------------------------------------------------------------------------
725 *-----------------------------------------------------------------------------
727 *-----------------------------------------------------------------------------
728 *-----------------------------------------------------------------------------
732 *-----------------------------------------------------------------------------
733 * Initialize sballs. Called each time the window changes.
734 *-----------------------------------------------------------------------------
737 void init_sballs(ModeInfo * mi)
741 if (sballs == NULL) {
742 if ((sballs = (sballsstruct *) calloc(MI_NUM_SCREENS(mi),
743 sizeof(sballsstruct))) == NULL)
746 sb = &sballs[MI_SCREEN(mi)];
748 if ((sb->glx_context = init_GL(mi)) != NULL) {
751 Reshape(mi); /* xlock mode */
753 reshape_sballs(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
755 glDrawBuffer(GL_BACK);
764 *-----------------------------------------------------------------------------
765 * Called by the mainline code periodically to update the display.
766 *-----------------------------------------------------------------------------
768 void draw_sballs(ModeInfo * mi)
770 Display *display = MI_DISPLAY(mi);
771 Window window = MI_WINDOW(mi);
776 sb = &sballs[MI_SCREEN(mi)];
778 MI_IS_DRAWN(mi) = True;
779 if (!sb->glx_context)
782 glXMakeCurrent(display, window, *(sb->glx_context));
785 Reshape(mi); /* xlock mode */
787 reshape_sballs(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
791 glXSwapBuffers(display, window);
796 *-----------------------------------------------------------------------------
797 * The display is being taken away from us. Free up malloc'ed
798 * memory and X resources that we've alloc'ed. Only called
799 * once, we must zap everything for every screen.
800 *-----------------------------------------------------------------------------
803 void release_sballs(ModeInfo * mi)
807 if (sballs != NULL) {
808 for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
809 sballsstruct *sb = &sballs[screen];
812 glDeleteTextures(1,&sb->backid);
813 XDestroyImage(sb->btexture);
817 glDeleteTextures(1,&sb->faceid);
818 XDestroyImage(sb->ftexture);
821 (void) free((void *) sballs);
822 sballs = (sballsstruct *) NULL;
827 void change_sballs(ModeInfo * mi)
833 sb = &sballs[MI_SCREEN(mi)];
835 if (!sb->glx_context)
838 /* initialise object number */
840 object = NRAND(MAX_OBJ);
841 if ((object == 0) || (object > MAX_OBJ))
842 object = DEF_OBJECT_INDX;
845 /* correct sphere number */
846 spheres = MI_COUNT(mi);
847 if (MI_COUNT(mi) > polygons[object].numverts)
848 spheres = polygons[object].numverts;
849 if (MI_COUNT(mi) < 1)
850 spheres = polygons[object].numverts;
852 if (MI_IS_DEBUG(mi)) {
853 (void) fprintf(stderr,
854 "%s:\n\tobject=%s\n\tspheres=%d\n\tspeed=%d\n\ttexture=%s\n",
856 polygons[object].shortname,
859 do_texture ? "on" : "off"
862 glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sb->glx_context));
865 #endif /* MODE_sballs */