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.40.tar.gz
[xscreensaver]
/
hacks
/
glx
/
tunnel_draw.c
diff --git
a/hacks/glx/tunnel_draw.c
b/hacks/glx/tunnel_draw.c
index c87fea9dd57a875f4989df065180b2c6144d21aa..8a87c7673d5bc142b764802b3adc920595020a0f 100644
(file)
--- a/
hacks/glx/tunnel_draw.c
+++ b/
hacks/glx/tunnel_draw.c
@@
-45,14
+45,15
@@
static const char sccsid[] = "@(#)tunnel_draw.c 5.13 2004/05/25 xlockmore";
#include <math.h>
#ifdef STANDALONE
#include <math.h>
#ifdef STANDALONE
-# ifdef HAVE_COCOA
-# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
-# else
+# ifndef HAVE_JWXYZ
# include <GL/gl.h>
# include <GL/glu.h>
# endif
#endif
# include <GL/gl.h>
# include <GL/glu.h>
# endif
#endif
+#ifdef HAVE_ANDROID
+#include <GLES/gl.h>
+#endif
+
#include "tunnel_draw.h"
#include "tunnel_draw.h"
@@
-114,7
+115,8
@@
struct tunnel_state {
};
/*=================== Vector normalization ==================================*/
};
/*=================== Vector normalization ==================================*/
-static void normalize(cvPoint *V)
+static void
+normalize(cvPoint *V)
{
float d;
{
float d;
@@
-128,7
+130,8
@@
static void normalize(cvPoint *V)
}
/*=================== C = A x B (Vector multiply) ==========================*/
#if 0
}
/*=================== C = A x B (Vector multiply) ==========================*/
#if 0
-static void vect_mult(cvPoint *A, cvPoint *B, cvPoint *C)
+static void
+vect_mult(cvPoint *A, cvPoint *B, cvPoint *C)
{
/* Vector multiply */
C->x = A->y*B->z - A->z*B->y;
{
/* Vector multiply */
C->x = A->y*B->z - A->z*B->y;
@@
-138,7
+141,8
@@
static void vect_mult(cvPoint *A, cvPoint *B, cvPoint *C)
#endif
/* Catmull-Rom Curve calculations */
#endif
/* Catmull-Rom Curve calculations */
-static void cvCatmullRom(cvPoint *p, float t, cvPoint *outp)
+static void
+cvCatmullRom(cvPoint *p, float t, cvPoint *outp)
{
float t2, t3, t1;
{
float t2, t3, t1;
@@
-159,7
+163,8
@@
static void cvCatmullRom(cvPoint *p, float t, cvPoint *outp)
// outp - output point
//==========================================================================
*/
// outp - output point
//==========================================================================
*/
-static void RotateAroundLine(cvPoint *p, cvPoint *pp, cvPoint *pl, float a, cvPoint *outp)
+static void
+RotateAroundLine(cvPoint *p, cvPoint *pp, cvPoint *pl, float a, cvPoint *outp)
{
cvPoint p1, p2;
float l, m, n, ca, sa;
{
cvPoint p1, p2;
float l, m, n, ca, sa;
@@
-186,7
+191,8
@@
static void RotateAroundLine(cvPoint *p, cvPoint *pp, cvPoint *pl, float a, cvPo
/*=================== Load camera and tunnel path ==========================*/
/*=================== Load camera and tunnel path ==========================*/
-static void LoadPath(struct tunnel_state *st)
+static void
+LoadPath(struct tunnel_state *st)
{
float x, y, z;
tnPath *path1=NULL, *path2=NULL;
{
float x, y, z;
tnPath *path1=NULL, *path2=NULL;
@@
-207,6
+213,7
@@
static void LoadPath(struct tunnel_state *st)
}
else
{
}
else
{
+ if (!path1) path1 = st->path;
path2 = (tnPath *)malloc(sizeof(tnPath));
path1->next = path2;
path1 = path2;
path2 = (tnPath *)malloc(sizeof(tnPath));
path1->next = path2;
path1 = path2;
@@
-224,7
+231,7
@@
static void LoadPath(struct tunnel_state *st)
/*=================== Tunnel Initialization ================================*/
struct tunnel_state *
/*=================== Tunnel Initialization ================================*/
struct tunnel_state *
-InitTunnel(void)
+
atunnel_
InitTunnel(void)
{
struct tunnel_state *st = (struct tunnel_state *) calloc (1, sizeof(*st));
LoadPath(st);
{
struct tunnel_state *st = (struct tunnel_state *) calloc (1, sizeof(*st));
LoadPath(st);
@@
-232,11
+239,12
@@
InitTunnel(void)
return st;
}
return st;
}
-void DrawTunnel(struct tunnel_state *st,
+void
+atunnel_DrawTunnel(struct tunnel_state *st,
int do_texture, int do_light, GLuint *textures)
{
tnPath *p, *p1, *cmpos;
int do_texture, int do_light, GLuint *textures)
{
tnPath *p, *p1, *cmpos;
- cvPoint op, p4[4], T, ppp,
ppp1,
op1, op2;
+ cvPoint op, p4[4], T, ppp, op1, op2;
float t;
int i, j, k, flag;
cvPoint points[10];
float t;
int i, j, k, flag;
cvPoint points[10];
@@
-249,7
+257,9
@@
void DrawTunnel(struct tunnel_state *st,
cmpos = st->cam_pos;
/* Get current curve */
cmpos = st->cam_pos;
/* Get current curve */
- if (st->cam_pos->next->next->next)
+ if (st->cam_pos->next &&
+ st->cam_pos->next->next &&
+ st->cam_pos->next->next->next)
{
p1 = st->cam_pos;
for (i=0; i<4; i++)
{
p1 = st->cam_pos;
for (i=0; i<4; i++)
@@
-342,6
+352,7
@@
void DrawTunnel(struct tunnel_state *st,
/* End of tunnel */
st->ModeX = 1.0;
st->ModeXFlag = 0;
/* End of tunnel */
st->ModeX = 1.0;
st->ModeXFlag = 0;
+ glEnd();
return;
}
cvCatmullRom(p4, t, &op);
return;
}
cvCatmullRom(p4, t, &op);
@@
-374,15
+385,12
@@
void DrawTunnel(struct tunnel_state *st,
/* End of tunnel */
st->ModeX = 1.0;
st->ModeXFlag = 0;
/* End of tunnel */
st->ModeX = 1.0;
st->ModeXFlag = 0;
+ glEnd();
return;
}
cvCatmullRom(p4, t, &op1);
return;
}
cvCatmullRom(p4, t, &op1);
- ppp1.x = op1.x;
- ppp1.y = op1.y;
- ppp1.z = op1.z + 0.25;
-
T.x = op1.x - op.x;
T.y = op1.y - op.y;
T.z = op1.z - op.z;
T.x = op1.x - op.x;
T.y = op1.y - op.y;
T.z = op1.z - op.z;
@@
-436,7
+444,8
@@
void DrawTunnel(struct tunnel_state *st,
}
/* =================== Show splash screen =================================== */
}
/* =================== Show splash screen =================================== */
-void SplashScreen(struct tunnel_state *st,
+void
+atunnel_SplashScreen(struct tunnel_state *st,
int do_wire, int do_texture, int do_light)
{
if (st->ModeX > 0)
int do_wire, int do_texture, int do_light)
{
if (st->ModeX > 0)
@@
-494,7
+503,8
@@
void SplashScreen(struct tunnel_state *st,
}
}
}
}
-void FreeTunnel(struct tunnel_state *st)
+void
+atunnel_FreeTunnel(struct tunnel_state *st)
{
free (st);
}
{
free (st);
}