summaryrefslogtreecommitdiff
path: root/snowglobe.c
diff options
context:
space:
mode:
Diffstat (limited to 'snowglobe.c')
-rw-r--r--snowglobe.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/snowglobe.c b/snowglobe.c
index 873eb2a..442a26b 100644
--- a/snowglobe.c
+++ b/snowglobe.c
@@ -86,7 +86,6 @@ initSnowglobe (CompScreen *s)
{
SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
as->water = NULL;
as->ground = NULL;
@@ -95,7 +94,7 @@ initSnowglobe (CompScreen *s)
as->snow = calloc(as->numSnowflakes, sizeof(snowflakeRec));
- initializeWorldVariables(s->hsize, cs->distance);
+ initializeWorldVariables(s);
int i;
for (i=0; i< as->numSnowflakes; i++)
@@ -115,9 +114,7 @@ initSnowglobe (CompScreen *s)
}
- waterHeight = 50000;
-
- speedFactor = snowglobeGetSpeedFactor(s);
+ as->waterHeight = 50000;
as->snowflakeDisplayList = glGenLists(1);
glNewList(as->snowflakeDisplayList, GL_COMPILE);
@@ -126,14 +123,18 @@ initSnowglobe (CompScreen *s)
}
void
-initializeWorldVariables(int hs, float perpDistCentreToWall)
-{ //precalculate some values
+initializeWorldVariables(CompScreen *s)
+{
+ SNOWGLOBE_SCREEN (s);
+ CUBE_SCREEN (s);
+
+ as->speedFactor = snowglobeGetSpeedFactor(s);
- hSize = hs;
- q = (float) hSize;
+ as->hsize = s->hsize * cs->nOutput;
- distance = perpDistCentreToWall;
- radius = perpDistCentreToWall/sin(PI*(0.5-1/q));
+ as->arcAngle = 360.0f / as->hsize;
+ as->radius = cs->distance/sinf(0.5*(PI-as->arcAngle*toRadians));
+ as->distance = cs->distance;
}
static void
@@ -168,7 +169,8 @@ snowglobeSpeedFactorOptionChange (CompScreen *s,
CompOption *opt,
SnowglobeScreenOptions num)
{
- speedFactor = snowglobeGetSpeedFactor(s);
+ SNOWGLOBE_SCREEN (s);
+ as->speedFactor = snowglobeGetSpeedFactor(s);
}
static void
@@ -199,9 +201,9 @@ snowglobePaintInside (CompScreen *s,
int i;
- waterHeight = 50000;
+ as->waterHeight = 50000;
- if (hSize!=s->hsize) updateSnowglobe (s);
+ if (as->hsize!=s->hsize) updateSnowglobe (s);
static const float mat_shininess[] = { 60.0 };
@@ -357,7 +359,6 @@ snowglobePreparePaintScreen (CompScreen *s,
{
SNOWGLOBE_SCREEN (s);
- renderGround = snowglobeGetShowGround(s);
int i;
for (i = 0; i < as->numSnowflakes; i++)