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
/
mirrorblob.c
diff --git
a/hacks/glx/mirrorblob.c
b/hacks/glx/mirrorblob.c
index a2f1ed6ea48d03d7a4fec6b8ec39786e21012f9f..d6fbdc1c8234a643d5655213add3f86b05792e88 100644
(file)
--- a/
hacks/glx/mirrorblob.c
+++ b/
hacks/glx/mirrorblob.c
@@
-191,20
+191,20
@@
ModStruct mirrorblob_description =
typedef struct
{
typedef struct
{
- GL
double
x, y;
+ GL
float
x, y;
} Vector2D;
typedef struct
{
} Vector2D;
typedef struct
{
- GL
double
x, y, z;
+ GL
float
x, y, z;
} Vector3D;
typedef struct
{
} Vector3D;
typedef struct
{
- GL
double
w;
- GL
double
x;
- GL
double
y;
- GL
double
z;
+ GL
float
w;
+ GL
float
x;
+ GL
float
y;
+ GL
float
z;
} Quaternion;
typedef struct
} Quaternion;
typedef struct
@@
-461,9
+461,9
@@
normalise (const Vector3D v)
* Calculate the transform matrix for the given quaternion
*/
static void
* Calculate the transform matrix for the given quaternion
*/
static void
-quaternion_transform (Quaternion q, GL
double
* transform)
+quaternion_transform (Quaternion q, GL
float
* transform)
{
{
- GL
double
x, y, z, w;
+ GL
float
x, y, z, w;
x = q.x;
y = q.y;
z = q.z;
x = q.x;
y = q.y;
z = q.z;
@@
-495,7
+495,7
@@
quaternion_transform (Quaternion q, GLdouble * transform)
* Apply a matrix transform to the given vector
*/
static inline Vector3D
* Apply a matrix transform to the given vector
*/
static inline Vector3D
-vector_transform (Vector3D u, GL
double
* t)
+vector_transform (Vector3D u, GL
float
* t)
{
Vector3D result;
{
Vector3D result;
@@
-516,7
+516,7
@@
partial (Vector3D node1, Vector3D node2, double distance)
{
Vector3D result;
Vector3D rotation_axis;
{
Vector3D result;
Vector3D rotation_axis;
- GL
double
transformation[16];
+ GL
float
transformation[16];
double angle;
Quaternion rotation;
double angle;
Quaternion rotation;
@@
-737,7
+737,7
@@
initialize_gl(ModeInfo *mi, GLsizei width, GLsizei height)
* Initialise the openGL state data.
*/
static void
* Initialise the openGL state data.
*/
static void
-set_blob_gl_state(GL
double
alpha)
+set_blob_gl_state(GL
float
alpha)
{
if (do_antialias)
{
{
if (do_antialias)
{
@@
-776,12
+776,12
@@
set_blob_gl_state(GLdouble alpha)
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* Set the default blob colour to off-white. */
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* Set the default blob colour to off-white. */
- glColor4
d
(0.9, 0.9, 1.0, alpha);
+ glColor4
f
(0.9, 0.9, 1.0, alpha);
}
else
{
glDisable(GL_BLEND);
}
else
{
glDisable(GL_BLEND);
- glColor4
d
(0.9, 0.9, 1.0, 1.0);
+ glColor4
f
(0.9, 0.9, 1.0, 1.0);
}
glEnable(GL_DEPTH_TEST);
}
glEnable(GL_DEPTH_TEST);
@@
-1394,10
+1394,10
@@
draw_vertex(mirrorblobstruct *gp, int index)
}
if (load_textures)
{
}
if (load_textures)
{
- glTexCoord
3dv((GLdouble *) &gp->tex_coords[index]
);
+ glTexCoord
2fv(&gp->tex_coords[index].x
);
}
}
- glNormal3
dv((GLdouble *) &gp->normals[index]
);
- glVertex3
dv((GLdouble *) &gp->dots[index]
);
+ glNormal3
fv(&gp->normals[index].x
);
+ glVertex3
fv(&gp->dots[index].x
);
}
/******************************************************************************
}
/******************************************************************************
@@
-1417,6
+1417,7
@@
draw_blob (mirrorblobstruct *gp)
glTranslatef (0.0, 0.0, -4.0);
gltrackball_rotate (gp->trackball);
glTranslatef (0.0, 0.0, -4.0);
gltrackball_rotate (gp->trackball);
+ glRotatef(current_device_rotation(), 0, 0, 1);
/* glColor4ub (255, 0, 0, 128); */
glBegin(GL_TRIANGLES);
/* glColor4ub (255, 0, 0, 128); */
glBegin(GL_TRIANGLES);
@@
-1435,9
+1436,9
@@
draw_blob (mirrorblobstruct *gp)
if (gp->normals[gp->faces[face].node1].z > 0.0)
{
Vector3D end = gp->dots[gp->faces[face].node1];
if (gp->normals[gp->faces[face].node1].z > 0.0)
{
Vector3D end = gp->dots[gp->faces[face].node1];
- glVertex3dv(
(GLdouble *)
&end);
+ glVertex3dv(&end);
add(&end, scale(gp->normals[gp->faces[face].node1], 0.25));
add(&end, scale(gp->normals[gp->faces[face].node1], 0.25));
- glVertex3dv(
(GLdouble *)
&end);
+ glVertex3dv(&end);
}
}
glEnd();
}
}
glEnd();
@@
-1454,6
+1455,7
@@
static void
draw_background (ModeInfo *mi)
{
mirrorblobstruct *gp = &Mirrorblob[MI_SCREEN(mi)];
draw_background (ModeInfo *mi)
{
mirrorblobstruct *gp = &Mirrorblob[MI_SCREEN(mi)];
+ GLfloat rot = current_device_rotation();
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable (GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable (GL_TEXTURE_2D);
@@
-1467,6
+1469,14
@@
draw_background (ModeInfo *mi)
glPushMatrix();
glLoadIdentity();
glPushMatrix();
glLoadIdentity();
+ glRotatef (rot, 0, 0, 1);
+ if ((rot > 45 && rot < 135) ||
+ (rot < -45 && rot > -135))
+ {
+ GLfloat s = MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi);
+ glScalef (s, 1/s, 1);
+ }
+
glOrtho(0.0, MI_WIDTH(mi), MI_HEIGHT(mi), 0.0, -1000.0, 1000.0);
glBegin (GL_QUADS);
glOrtho(0.0, MI_WIDTH(mi), MI_HEIGHT(mi), 0.0, -1000.0, 1000.0);
glBegin (GL_QUADS);
@@
-1503,13
+1513,13
@@
draw_scene(ModeInfo * mi)
check_gl_error ("draw_scene");
mi->polygon_count = 0;
check_gl_error ("draw_scene");
mi->polygon_count = 0;
- glColor4
d
(1.0, 1.0, 1.0, 1.0);
+ glColor4
f
(1.0, 1.0, 1.0, 1.0);
current_time = double_time();
switch (gp->state)
{
case INITIALISING:
current_time = double_time();
switch (gp->state)
{
case INITIALISING:
- glColor4
d
(0.0, 0.0, 0.0, 1.0);
+ glColor4
f
(0.0, 0.0, 0.0, 1.0);
fade = 1.0;
break;
fade = 1.0;
break;
@@
-1540,7
+1550,7
@@
draw_scene(ModeInfo * mi)
{
glClear(GL_DEPTH_BUFFER_BIT);
glEnable (GL_BLEND);
{
glClear(GL_DEPTH_BUFFER_BIT);
glEnable (GL_BLEND);
- glColor4
d
(1.0, 1.0, 1.0, motion_blur);
+ glColor4
f
(1.0, 1.0, 1.0, motion_blur);
}
else
{
}
else
{
@@
-1557,7
+1567,7
@@
draw_scene(ModeInfo * mi)
glEnable (GL_BLEND);
/* Select the texture to transition to */
glBindTexture (GL_TEXTURE_2D, gp->textures[1 - gp->current_texture]);
glEnable (GL_BLEND);
/* Select the texture to transition to */
glBindTexture (GL_TEXTURE_2D, gp->textures[1 - gp->current_texture]);
- glColor4
d
(1.0, 1.0, 1.0, 1.0 - fade);
+ glColor4
f
(1.0, 1.0, 1.0, 1.0 - fade);
draw_background (mi);
mi->polygon_count++;
draw_background (mi);
mi->polygon_count++;
@@
-1571,7
+1581,7
@@
draw_scene(ModeInfo * mi)
else if (motion_blur > 0.0)
{
glEnable (GL_BLEND);
else if (motion_blur > 0.0)
{
glEnable (GL_BLEND);
- glColor4
d
(0.0, 0.0, 0.0, motion_blur);
+ glColor4
f
(0.0, 0.0, 0.0, motion_blur);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glTranslatef (0.0, 0.0, -4.0);
glRectd (-10.0, -10.0, 10.0, 10.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glTranslatef (0.0, 0.0, -4.0);
glRectd (-10.0, -10.0, 10.0, 10.0);
@@
-1669,7
+1679,7
@@
draw_scene(ModeInfo * mi)
}
else
{
}
else
{
- glColor4
d
(0.9, 0.9, 1.0, (1.0 - fade) * blend);
+ glColor4
f
(0.9, 0.9, 1.0, (1.0 - fade) * blend);
}
draw_blob (gp);
}
draw_blob (gp);