-/* Sky Tentacles, Copyright (c) 2008 Jamie Zawinski <jwz@jwz.org>
+/* Sky Tentacles, Copyright (c) 2008-2014 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#ifdef USE_GL /* whole file */
+# ifndef HAVE_JWZGLES
+# define HAVE_POLYGONMODE
+# endif
+
#define DEF_SPEED "1.0"
#define DEF_SMOOTH "True"
#define DEF_TEXTURE "True"
t->mi->polygon_count += points/2;
}
-
static void
-draw_tentacle (tentacle *t, Bool front_p)
+draw_tentacle_1 (tentacle *t, Bool front_p, Bool outline_p)
{
tentacles_configuration *tc = &tcs[MI_SCREEN(t->mi)];
int i;
}
+# ifdef HAVE_POLYGONMODE
if (cel_p)
glPolygonMode (GL_FRONT_AND_BACK, (front_p ? GL_FILL : GL_LINE));
+# endif
glPushMatrix();
glTranslatef (t->x, t->y, t->z);
glPopAttrib();
}
- if (!front_p)
+ if (!front_p || outline_p)
glColor4fv (tc->outline_color);
else if (wire)
glColor4fv (t->tentacle_color);
if (j <= indented_points/2 || j >= arg_slices-indented_points/2)
r *= 0.75; /* indent the stripe */
+ if (outline_p)
+ r *= 1.1;
+
ring[j].x = r * ucirc[j].x;
ring[j].y = 0;
ring[j].z = r * ucirc[j].y;
GLfloat ts = j / (double) arg_slices;
- if (!front_p)
+ if (!front_p || outline_p)
glColor4fv (tc->outline_color);
else if (j <= indented_points/2 ||
j >= arg_slices-indented_points/2)
nsuckers = (i % segs_per_sucker) ? 0 : 1;
}
- if (front_p)
+ if (outline_p)
+ {
+ glColor4fv (tc->outline_color);
+ glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
+ tc->outline_color);
+ }
+ else if (front_p)
{
glColor4fv (t->sucker_color);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
scale = t->segments[i].thickness / arg_thickness;
scale *= 0.7 * sucker_size;
+
glScalef (scale, scale, scale * 4);
glTranslatef (0, 0, -0.1); /* embed */
+ if (outline_p)
+ {
+ scale = 1.1;
+ glScalef (scale, scale, scale);
+ }
+
glTranslatef (1, 0, 0); /* left */
draw_sucker (t, front_p);
/* Now draw the end caps.
*/
glLineWidth (tc->line_thickness);
- if (i == 0 || i == t->nsegments-1)
+ if (!outline_p && (i == 0 || i == t->nsegments-1))
{
int j;
GLfloat ctrz = ctr.z + ((i == 0 ? -1 : 1) *
}
+static void
+draw_tentacle (tentacle *t, Bool front_p)
+{
+# ifndef HAVE_POLYGONMODE
+ Bool wire = MI_IS_WIREFRAME (t->mi);
+ if (!wire && cel_p && front_p)
+ {
+ draw_tentacle_1 (t, front_p, True);
+ glClear (GL_DEPTH_BUFFER_BIT);
+ }
+# endif /* HAVE_POLYGONMODE */
+
+ draw_tentacle_1 (t, front_p, False);
+}
+
+
static void
move_tentacle (tentacle *t)
{
{
tentacles_configuration *tc = &tcs[MI_SCREEN(mi)];
- if (event->xany.type == ButtonPress &&
- event->xbutton.button == Button1)
- {
- tc->button_down_p = True;
- gltrackball_start (tc->trackball,
- event->xbutton.x, event->xbutton.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
- }
- else if (event->xany.type == ButtonRelease &&
- event->xbutton.button == Button1)
- {
- tc->button_down_p = False;
- return True;
- }
- else if (event->xany.type == ButtonPress &&
- (event->xbutton.button == Button4 ||
- event->xbutton.button == Button5 ||
- event->xbutton.button == Button6 ||
- event->xbutton.button == Button7))
- {
- gltrackball_mousewheel (tc->trackball, event->xbutton.button, 10,
- !!event->xbutton.state);
- return True;
- }
- else if (event->xany.type == MotionNotify &&
- tc->button_down_p)
- {
- gltrackball_track (tc->trackball,
- event->xmotion.x, event->xmotion.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
- }
+ if (gltrackball_event_handler (event, tc->trackball,
+ MI_WIDTH (mi), MI_HEIGHT (mi),
+ &tc->button_down_p))
+ return True;
else if (event->xany.type == KeyPress)
{
KeySym keysym;
XLookupString (&event->xkey, &c, 1, &keysym, 0);
if (c == ' ')
{
- gltrackball_reset (tc->trackball);
+ gltrackball_reset (tc->trackball, 0, 0);
return True;
}
}
int wire = MI_IS_WIREFRAME(mi);
int i;
- if (!tcs) {
- tcs = (tentacles_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (tentacles_configuration));
- if (!tcs) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT (mi, tcs, NULL);
tc = &tcs[MI_SCREEN(mi)];
glEnable (GL_LIGHT0);
}
- tc->trackball = gltrackball_init ();
+ tc->trackball = gltrackball_init (False);
tc->left_p = !(random() % 5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
-
+ glRotatef(current_device_rotation(), 0, 0, 1);
# if 1
glScalef (3, 3, 3);
# endif
gltrackball_rotate (tc->trackball);
- glRotatef(current_device_rotation(), 0, 0, 1);
mi->polygon_count = 0;