projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver]
/
hacks
/
glx
/
antspotlight.c
diff --git
a/hacks/glx/antspotlight.c
b/hacks/glx/antspotlight.c
index 87e34c65751374f2988d0ca88f865708a95afc1c..cec2676d9a33b20befbf845b283aeb3b536b45b0 100644
(file)
--- a/
hacks/glx/antspotlight.c
+++ b/
hacks/glx/antspotlight.c
@@
-25,6
+25,20
@@
#include "xlock.h"
#endif
#include "xlock.h"
#endif
+#ifdef HAVE_COCOA
+# include "jwxyz.h"
+#else
+# include <X11/Xlib.h>
+# include <GL/gl.h>
+# include <GL/glu.h>
+#endif
+
+#ifdef HAVE_JWZGLES
+# include "jwzgles.h"
+#endif /* HAVE_JWZGLES */
+
+#include "sphere.h"
+#include "tube.h"
#include "rotator.h"
#include "gltrackball.h"
#include "rotator.h"
#include "gltrackball.h"
@@
-78,7
+92,7
@@
static antspotlightstruct *antspotlight = (antspotlightstruct *) NULL;
#define NUM_SCENES 2
/* draw method for ant */
#define NUM_SCENES 2
/* draw method for ant */
-static Bool draw_ant(antspotlightstruct *mp,
+static Bool draw_ant(
ModeInfo *mi,
antspotlightstruct *mp,
const GLfloat *Material, int mono, int shadow,
float ant_step, Bool (*sphere)(float), Bool (*cone)(float))
{
const GLfloat *Material, int mono, int shadow,
float ant_step, Bool (*sphere)(float), Bool (*cone)(float))
{
@@
-90,7
+104,9
@@
static Bool draw_ant(antspotlightstruct *mp,
float sin2 = sin(ant_step + 2 * Pi / 3);
float sin3 = sin(ant_step + 4 * Pi / 3);
float sin2 = sin(ant_step + 2 * Pi / 3);
float sin3 = sin(ant_step + 4 * Pi / 3);
- glEnable(GL_POLYGON_SMOOTH);
+/* Apparently this is a performance killer on many systems...
+ glEnable(GL_POLYGON_SMOOTH);
+ */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@
-136,17
+152,21
@@
static Bool draw_ant(antspotlightstruct *mp,
glVertex3f(0.00, 0.30, 0.00);
glColor3fv(MaterialGray);
glVertex3f(0.40, 0.70, 0.40);
glVertex3f(0.00, 0.30, 0.00);
glColor3fv(MaterialGray);
glVertex3f(0.40, 0.70, 0.40);
+ mi->polygon_count++;
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.30, 0.00);
glColor3fv(MaterialGray);
glVertex3f(0.40, 0.70, -0.40);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.30, 0.00);
glColor3fv(MaterialGray);
glVertex3f(0.40, 0.70, -0.40);
+ mi->polygon_count++;
glEnd();
if(!shadow) {
glBegin(GL_POINTS);
glColor3fv(mp->mono ? MaterialGray6 : MaterialGray5);
glVertex3f(0.40, 0.70, 0.40);
glEnd();
if(!shadow) {
glBegin(GL_POINTS);
glColor3fv(mp->mono ? MaterialGray6 : MaterialGray5);
glVertex3f(0.40, 0.70, 0.40);
+ mi->polygon_count++;
glVertex3f(0.40, 0.70, -0.40);
glVertex3f(0.40, 0.70, -0.40);
+ mi->polygon_count++;
glEnd();
}
glEnd();
}
@@
-155,8
+175,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.05, 0.18);
glVertex3f(0.35 + 0.05 * cos1, 0.15, 0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.05, 0.18);
glVertex3f(0.35 + 0.05 * cos1, 0.15, 0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos1, 0.25 + 0.1 * sin1, 0.45);
+ mi->polygon_count++;
glEnd();
/* LEFT-CENTER ARM */
glEnd();
/* LEFT-CENTER ARM */
@@
-164,8
+186,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.00, 0.18);
glVertex3f(0.35 + 0.05 * cos2, 0.00, 0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.00, 0.18);
glVertex3f(0.35 + 0.05 * cos2, 0.00, 0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos2, 0.00 + 0.1 * sin2, 0.45);
+ mi->polygon_count++;
glEnd();
/* LEFT-BACK ARM */
glEnd();
/* LEFT-BACK ARM */
@@
-173,8
+197,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, -0.05, 0.18);
glVertex3f(0.35 + 0.05 * cos3, -0.15, 0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, -0.05, 0.18);
glVertex3f(0.35 + 0.05 * cos3, -0.15, 0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 + 0.05 * cos3, -0.25 + 0.1 * sin3, 0.45);
+ mi->polygon_count++;
glEnd();
/* RIGHT-FRONT ARM */
glEnd();
/* RIGHT-FRONT ARM */
@@
-182,8
+208,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.05, -0.18);
glVertex3f(0.35 - 0.05 * sin1, 0.15, -0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.05, -0.18);
glVertex3f(0.35 - 0.05 * sin1, 0.15, -0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
+ mi->polygon_count++;
glEnd();
/* RIGHT-CENTER ARM */
glEnd();
/* RIGHT-CENTER ARM */
@@
-191,8
+219,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.00, -0.18);
glVertex3f(0.35 - 0.05 * sin2, 0.00, -0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, 0.00, -0.18);
glVertex3f(0.35 - 0.05 * sin2, 0.00, -0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
+ mi->polygon_count++;
glEnd();
/* RIGHT-BACK ARM */
glEnd();
/* RIGHT-BACK ARM */
@@
-200,8
+230,10
@@
static Bool draw_ant(antspotlightstruct *mp,
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, -0.05, -0.18);
glVertex3f(0.35 - 0.05 * sin3, -0.15, -0.25);
glColor3fv(mp->mono ? MaterialGray5 : Material);
glVertex3f(0.00, -0.05, -0.18);
glVertex3f(0.35 - 0.05 * sin3, -0.15, -0.25);
+ mi->polygon_count++;
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
glColor3fv(MaterialGray);
glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
+ mi->polygon_count++;
glEnd();
if(!shadow) {
glEnd();
if(!shadow) {
@@
-213,6
+245,7
@@
static Bool draw_ant(antspotlightstruct *mp,
glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
glVertex3f(-0.20 - 0.05 * sin1, 0.25 + 0.1 * cos1, -0.45);
glVertex3f(-0.20 - 0.05 * sin2, 0.00 + 0.1 * cos2, -0.45);
glVertex3f(-0.20 - 0.05 * sin3, -0.25 + 0.1 * cos3, -0.45);
+ mi->polygon_count += 6;
glEnd();
}
glEnd();
}
@@
-224,6
+257,7
@@
static Bool draw_ant(antspotlightstruct *mp,
/* filled sphere */
static Bool mySphere(float radius)
{
/* filled sphere */
static Bool mySphere(float radius)
{
+#if 0
GLUquadricObj *quadObj;
if((quadObj = gluNewQuadric()) == 0)
GLUquadricObj *quadObj;
if((quadObj = gluNewQuadric()) == 0)
@@
-232,13
+266,20
@@
static Bool mySphere(float radius)
gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
gluSphere(quadObj, radius, 16, 16);
gluDeleteQuadric(quadObj);
gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
gluSphere(quadObj, radius, 16, 16);
gluDeleteQuadric(quadObj);
-
+#else
+ glPushMatrix();
+ glScalef (radius, radius, radius);
+ glRotatef (90, 1, 0, 0);
+ unit_sphere (16, 16, False);
+ glPopMatrix();
+#endif
return True;
}
/* silhouette sphere */
static Bool mySphere2(float radius)
{
return True;
}
/* silhouette sphere */
static Bool mySphere2(float radius)
{
+#if 0
GLUquadricObj *quadObj;
if((quadObj = gluNewQuadric()) == 0)
GLUquadricObj *quadObj;
if((quadObj = gluNewQuadric()) == 0)
@@
-246,14
+287,21
@@
static Bool mySphere2(float radius)
gluQuadricDrawStyle(quadObj, (GLenum) GLU_LINE);
gluSphere(quadObj, radius, 16, 8);
gluDeleteQuadric(quadObj);
gluQuadricDrawStyle(quadObj, (GLenum) GLU_LINE);
gluSphere(quadObj, radius, 16, 8);
gluDeleteQuadric(quadObj);
-
+#else
+ /* #### no GLU_LINE */
+ glPushMatrix();
+ glScalef (radius, radius, radius);
+ glRotatef (90, 1, 0, 0);
+ unit_sphere (16, 16, True);
+ glPopMatrix();
+#endif
return True;
}
/* no cone */
static Bool myCone2(float radius) { return True; }
return True;
}
/* no cone */
static Bool myCone2(float radius) { return True; }
-static void draw_board(antspotlightstruct *mp)
+static void draw_board(
ModeInfo *mi,
antspotlightstruct *mp)
{
int i, j;
double cutoff = Pi/3.0;
{
int i, j;
double cutoff = Pi/3.0;
@@
-322,6
+370,7
@@
static void draw_board(antspotlightstruct *mp)
glTexCoord2f(tex[0], tex[1]);
glVertex3f(point[0], point[1], point[2]);
glTexCoord2f(tex[0], tex[1]);
glVertex3f(point[0], point[1], point[2]);
+ mi->polygon_count++;
}
glEnd();
}
glEnd();
@@
-389,7
+438,7
@@
static void reset_ant(antspotlightstruct *mp)
}
/* draw ant composed of skeleton and glass */
}
/* draw ant composed of skeleton and glass */
-static void show_ant(antspotlightstruct *mp)
+static void show_ant(
ModeInfo *mi,
antspotlightstruct *mp)
{
glPushMatrix();
{
glPushMatrix();
@@
-400,14
+449,14
@@
static void show_ant(antspotlightstruct *mp)
glRotatef(90.0, 0.0, 0.0, 1.0);
/* draw skeleton */
glRotatef(90.0, 0.0, 0.0, 1.0);
/* draw skeleton */
- draw_ant(mp, mp->ant->material, mp->mono, 0, mp->ant->step, mySphere2, myCone2);
+ draw_ant(m
i, m
p, mp->ant->material, mp->mono, 0, mp->ant->step, mySphere2, myCone2);
/* draw glass */
if(!mp->wire && !mp->mono) {
glEnable(GL_BLEND);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGrayB);
glColor4fv(MaterialGrayB);
/* draw glass */
if(!mp->wire && !mp->mono) {
glEnable(GL_BLEND);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGrayB);
glColor4fv(MaterialGrayB);
- draw_ant(mp, MaterialGrayB, mp->mono, 0, mp->ant->step, mySphere, myCone2);
+ draw_ant(m
i, m
p, MaterialGrayB, mp->mono, 0, mp->ant->step, mySphere, myCone2);
glDisable(GL_BLEND);
}
glDisable(GL_BLEND);
}
@@
-441,14
+490,14
@@
static void draw_antspotlight_strip(ModeInfo *mi)
if(mp->wire)
;
else
if(mp->wire)
;
else
- draw_board(mp);
+ draw_board(m
i, m
p);
glDisable(GL_LIGHT2);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
/* now modify ant */
glDisable(GL_LIGHT2);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
/* now modify ant */
- show_ant(mp);
+ show_ant(m
i, m
p);
/* near goal, bend path towards next step */
if(distance(mp->ant->position, mp->ant->goal) < 0.2) {
/* near goal, bend path towards next step */
if(distance(mp->ant->position, mp->ant->goal) < 0.2) {
@@
-530,8
+579,7
@@
static const GLfloat spotlight_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
static void pinit(void)
{
glClearDepth(1.0);
static void pinit(void)
{
glClearDepth(1.0);
- glClearColor(0.0, 0.0, 0.0, 1.0);
-
+
/* setup twoside lighting */
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
/* setup twoside lighting */
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
@@
-722,6
+770,8
@@
ENTRYPOINT void draw_antspotlight(ModeInfo * mi)
if(!mp->glx_context)
return;
if(!mp->glx_context)
return;
+ mi->polygon_count = 0;
+
/* Just keep running before the texture has come in. */
/* if (mp->waiting_for_image_p) return; */
/* Just keep running before the texture has come in. */
/* if (mp->waiting_for_image_p) return; */
@@
-730,6
+780,7
@@
ENTRYPOINT void draw_antspotlight(ModeInfo * mi)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
+ glRotatef(current_device_rotation(), 0, 0, 1);
/* position camera */
/* position camera */