rendered paste bodyIndex: snow.c
===================================================================
--- snow.c (revision 4514)
+++ snow.c (working copy)
@@ -1,9 +1,10 @@
/**
*
- * Beryl snow plugin
+ * Beryl Star plugin
*
- * snow.c
+ * stars.c
*
+ * Copyright (c) 2007 Kyle Mallory <kyle.mallory@utah.edu>
* Copyright (c) 2006 Eckhart P. <beryl@cornergraf.net>
* Copyright (c) 2006 Brian Jørgensen <qte@fundanemt.com>
*
@@ -37,76 +38,64 @@
#include <beryl.h>
// ------------------------------------------------------------ CONSTANTS -----------------------------------------------------
-#define MAX_SNOWFLAKES 10000
-
+#define MAX_STARS 10000
+#define GLOW_STAGES 5
// ------------------------------------------------------------ WRAPPERS -----------------------------------------------------
-#define GET_SNOW_DISPLAY(d) \
- ((SnowDisplay *) (d)->privates[displayPrivateIndex].ptr)
+#define GET_STAR_DISPLAY(d) \
+ ((StarDisplay *) (d)->privates[displayPrivateIndex].ptr)
-#define SNOW_DISPLAY(d) \
- SnowDisplay *sd = GET_SNOW_DISPLAY (d)
+#define STAR_DISPLAY(d) \
+ StarDisplay *sd = GET_STAR_DISPLAY (d)
-#define GET_SNOW_SCREEN(s, sd) \
- ((SnowScreen *) (s)->privates[(sd)->screenPrivateIndex].ptr)
+#define GET_STAR_SCREEN(s, sd) \
+ ((StarScreen *) (s)->privates[(sd)->screenPrivateIndex].ptr)
-#define SNOW_SCREEN(s) \
- SnowScreen *ss = GET_SNOW_SCREEN (s, GET_SNOW_DISPLAY (s->display))
+#define STAR_SCREEN(s) \
+ StarScreen *ss = GET_STAR_SCREEN (s, GET_STAR_DISPLAY (s->display))
// ------------------------------------------------------------ OPTIONS -----------------------------------------------------
-#define SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES 0
-#define SNOW_DISPLAY_OPTION_SNOW_SIZE 1
-#define SNOW_DISPLAY_OPTION_SNOW_SPEED 2
-#define SNOW_DISPLAY_OPTION_SCREEN_BOXING 3
-#define SNOW_DISPLAY_OPTION_SCREEN_DEPTH 4
-#define SNOW_DISPLAY_OPTION_INITIATE 5
-#define SNOW_DISPLAY_OPTION_ON_TOP 6
-#define SNOW_DISPLAY_OPTION_USE_BLENDING 7
-#define SNOW_DISPLAY_OPTION_USE_TEXTURES 8
-#define SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY 9
-#define SNOW_DISPLAY_OPTION_SNOW_TEXTURES 10
-#define SNOW_DISPLAY_OPTION_SNOW_DIRECTION 11
-#define SNOW_DISPLAY_OPTION_ROTATION 12
-#define SNOW_DISPLAY_OPTION_NUM 13
+#define STAR_DISPLAY_OPTION_NUM_STARS 0
+#define STAR_DISPLAY_OPTION_STAR_SIZE 1
+#define STAR_DISPLAY_OPTION_STAR_SPEED 2
+#define STAR_DISPLAY_OPTION_SCREEN_BOXING 3
+#define STAR_DISPLAY_OPTION_SCREEN_DEPTH 4
+#define STAR_DISPLAY_OPTION_INITIATE 5
+#define STAR_DISPLAY_OPTION_ON_TOP 6
+#define STAR_DISPLAY_OPTION_USE_BLENDING 7
+#define STAR_DISPLAY_OPTION_USE_TEXTURES 8
+#define STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY 9
+#define STAR_DISPLAY_OPTION_STAR_TEXTURES 10
+#define STAR_DISPLAY_OPTION_NUM 11
-#define NUM_SNOW_DIRECTIONS 4
-#define SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY_DEFAULT 40
-#define SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT 1500.0
-#define SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT 10.0
-#define SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT 85.0
-#define SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT 400.0
-#define SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT 1000.0
-#define SNOW_DISPLAY_OPTION_SNOW_TEXTURES_DEFAULT ""
-#define SNOW_DISPLAY_OPTION_INITIATE_KEY "F3"
-#define SNOW_DISPLAY_OPTION_INITIATE_MOD CompSuperMask
-#define SNOW_DISPLAY_OPTION_ON_TOP_DEFAULT FALSE
-#define SNOW_DISPLAY_OPTION_ROTATION_DEFAULT TRUE
-#define SNOW_DISPLAY_OPTION_USE_BLENDING_DEFAULT TRUE
-#define SNOW_DISPLAY_OPTION_USE_TEXTURES_DEFAULT TRUE
-#define SNOW_DISPLAY_OPTION_DIRECTION_DEFAULT 0
+#define STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY_DEFAULT 40
+#define STAR_DISPLAY_OPTION_NUM_STARS_DEFAULT 300.0
+#define STAR_DISPLAY_OPTION_STAR_SIZE_DEFAULT 2.0
+#define STAR_DISPLAY_OPTION_STAR_SPEED_DEFAULT 5.0
+#define STAR_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT 400.0
+#define STAR_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT 1000.0
+#define STAR_DISPLAY_OPTION_STAR_TEXTURES_DEFAULT ""
+#define STAR_DISPLAY_OPTION_INITIATE_KEY "F5"
+#define STAR_DISPLAY_OPTION_INITIATE_MOD CompSuperMask
+#define STAR_DISPLAY_OPTION_ON_TOP_DEFAULT FALSE
+#define STAR_DISPLAY_OPTION_USE_BLENDING_DEFAULT TRUE
+#define STAR_DISPLAY_OPTION_USE_TEXTURES_DEFAULT TRUE
-static char *snowDirections[] = {
- N_("Top to bottom"),
- N_("Bottom to top"),
- N_("Right to left"),
- N_("Left to right")
-};
-static char *snowTextures[] = {
- IMAGEDIR "/snowflake2.png"
+static char *starTextures[] = {
+ IMAGEDIR "/star1.png"
};
-#define N_SNOW_TEXTURES (sizeof (snowTextures) / sizeof (snowTextures[0]))
+#define N_STAR_TEXTURES (sizeof (starTextures) / sizeof (starTextures[0]))
#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
static int displayPrivateIndex = 0;
-static int numFlakes;
-static int snowRotate;
-static int snowUpdateDelay;
-static float snowSize;
-static float snowSpeed;
+static int numFlies;
+static int starUpdateDelay;
+static float starSize;
+static float starSpeed;
static float boxing;
static float depth;
static Bool onTop;
@@ -115,115 +104,147 @@
static Bool displayListNeedsUpdating;
// ------------------------------------------------------------ STRUCTS -----------------------------------------------------
-typedef struct _SnowDisplay
-{
+typedef struct _StarDisplay {
int screenPrivateIndex;
Bool useBlending;
Bool useTextures;
- int snowTexNFiles;
- CompOptionValue *snowTexFiles;
+ int starsTexNFiles;
+ CompOptionValue *starsTexFiles;
- float snowSize;
+ float starsSize;
Bool displayListNeedsUpdating;
- CompOption opt[SNOW_DISPLAY_OPTION_NUM];
+ CompOption opt[STAR_DISPLAY_OPTION_NUM];
-} SnowDisplay;
+} StarDisplay;
-typedef struct _SnowScreen SnowScreen;
+typedef struct _StarScreen StarScreen;
-typedef struct _SnowTexture
-{
+typedef struct _StarTexture {
CompTexture tex;
unsigned int width;
unsigned int height;
Bool loaded;
GLuint dList;
-} SnowTexture;
+} StarTexture;
-typedef struct _SnowFlake
-{
+typedef struct _Star {
+ // fly position
float x;
float y;
float z;
+
+ // actual fly vector
float xs;
float ys;
float zs;
- float ra; //rotation angle
- float rs; //rotation speed
- SnowTexture *tex;
-} SnowFlake;
+ float lifecycle;
+ float glowAlpha; // alpha, given life from tables
+ StarTexture *tex;
+} Star;
-static void InitiateSnowFlake(SnowScreen * ss, SnowFlake * sf);
-static void setSnowflakeTexture(SnowScreen * ss, SnowFlake * sf);
-static void beginRendering(SnowScreen * ss, CompScreen * s);
-static void setupDisplayList(SnowScreen * ss);
+struct _StarScreen {
+ CompScreen * s;
-static void snowThink(SnowScreen * ss, SnowFlake * sf);
-static void snowMove(SnowFlake * sf);
-
-struct _SnowScreen
-{
- CompScreen *s;
-
Bool active;
CompTimeoutHandle timeoutHandle;
- PaintScreenProc paintScreen;
- DrawWindowProc drawWindow;
- DrawWindowTextureProc drawWindowTexture;
+ PaintScreenProc paintScreen;
+ DrawWindowProc drawWindow;
+ DrawWindowTextureProc drawWindowTexture;
- SnowTexture *snowTex;
- int snowTexturesLoaded;
+ StarTexture * starsTex;
+ int starTexturesLoaded;
GLuint displayList;
- SnowFlake allSnowFlakes[MAX_SNOWFLAKES];
-};
-static void snowThink(SnowScreen * ss, SnowFlake * sf)
-{
- if (sf->y >= ss->s->height + boxing
- || sf->x <= -boxing
- || sf->y >= ss->s->width + boxing
- || sf->z <= -(depth / 500.0) || sf->z >= 1)
+ Star allStars[MAX_STARS];
+} ;
- {
- InitiateSnowFlake(ss, sf);
- }
- snowMove(sf);
+static void InitiateStar(StarScreen *ss, Star *sf);
+static void setStarTexture(StarScreen *ss, Star *sf);
+static void beginRendering(StarScreen *ss, CompScreen *s);
+static void setupDisplayList(StarScreen * ss);
+
+static void starMove(Star *sf);
+static void starThink(StarScreen *ss, Star *sf);
+
+// ------------------------------------------------- HELPER FUNCTIONS ----------------------------------------------------
+
+int GetRand(int min, int max);
+int GetRand(int min, int max)
+{
+ return (rand() % (max - min + 1) + min);
}
-static void snowMove(SnowFlake * sf)
+float mmrand(int min, int max, float divisor);
+float mmrand(int min, int max, float divisor)
{
- float tmp = 1.0f / (100.0f - snowSpeed);
+ return ((float)GetRand(min, max)) / divisor;
+};
- sf->x += (sf->xs * (float)snowUpdateDelay) * tmp;
- sf->y += (sf->ys * (float)snowUpdateDelay) * tmp;
- sf->z += (sf->zs * (float)snowUpdateDelay) * tmp;
- sf->ra += ((float)snowUpdateDelay) / (10.0f - sf->rs);
+float bezierCurve(float p, float time) {
+ float out = p * (time+0.01) * 10;//(a*(i*i*i)) + (3.0*b*(i*i)*h) + (3.0*c*i*(h*h)) + (d*(h*h*h));
+ return out;
}
-static Bool stepSnowPositions(void *sc)
+// ------------------------------------------------- CORE ANIMATION ------------------------------------------------------
+
+static void starMove(Star *sf)
{
- CompScreen *s = sc;
+ float xs = bezierCurve(sf->xs, sf->lifecycle);
+ float ys = bezierCurve(sf->ys, sf->lifecycle);
+ float zs = bezierCurve(sf->zs, sf->lifecycle);
+
+ sf->x += (float)(xs * (double)starUpdateDelay) / (100 - (starSpeed + 0.5));
+ sf->y += (float)(ys * (double)starUpdateDelay) / (100 - (starSpeed + 0.5));
+ sf->z += (float)(zs * (double)starUpdateDelay) / (100 - (starSpeed + 0.5));
+}
- SNOW_SCREEN(s);
+static void starThink(StarScreen *ss, Star *sf)
+{
+ sf->lifecycle += 0.0002;
+
+ //int glowStage = (sf->lifecycle * GLOW_STAGES);
+ sf->glowAlpha = bezierCurve(1., 7. * sf->lifecycle * (double)starUpdateDelay / (100 - (starSpeed + 0.5)));
+ if (sf->glowAlpha > 1.0)
+ sf->glowAlpha = 1.0;
+
+ if ( sf->y <= -boxing
+ || sf->y <= 0
+ || sf->y >= ss->s->height
+ || sf->x <= 0
+ || sf->x >= ss->s->width
+ || sf->z >= 1)
+ {
+ InitiateStar(ss,sf);
+ }
+ starMove(sf);
+}
+
+static Bool stepStarPositions(void *sc)
+{
+ CompScreen * s = sc;
+ STAR_SCREEN(s);
if (!ss->active)
return True;
int i = 0;
-
- SnowFlake *snowFlake = ss->allSnowFlakes;
-
- for (i = 0; i < numFlakes; i++)
- snowThink(ss, snowFlake++);
-
- if (ss->active && !onTop)
+ for (i = 0; i < numFlies; i++)
+ starThink(ss, &ss->allStars[i]);
+ if (ss->active && !onTop)//(ss->lastMsCount > 15)
{
+ // // TODO: I Don't quite know which of the following is easiest on
+ // // CPU/GPU cycles... ought to be the second, but I am no expert.
+ //
+ // //// if (ss->alpha > 0.0) {
+ // // damageScreen(s);
+ // // // XSync(s->display->display, FALSE);
+ // //// }
+ //
CompWindow *w;
-
for (w = s->windows; w; w = w->next)
{
if (w->type & CompWindowTypeDesktopMask)
@@ -237,153 +258,122 @@
return True;
}
-static Bool
-snowToggle(CompDisplay * d, CompAction * action, CompActionState state,
- CompOption * option, int nOption)
+
+static Bool starsToggle (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption)
{
CompScreen *s;
Window xid;
- xid = getIntOptionNamed(option, nOption, "root", 0);
- s = findScreenAtDisplay(d, xid);
+ xid = getIntOptionNamed (option, nOption, "root", 0);
+ s = findScreenAtDisplay (d, xid);
- if (s)
- {
- SNOW_SCREEN(s);
+ STAR_SCREEN (s);
+ if (ss) {
ss->active = !ss->active;
if (!ss->active)
- damageScreen(s);
+ damageScreen(s);
}
return TRUE;
}
-// ------------------------------------------------- HELPER FUNCTIONS ----------------------------------------------------
-
-int GetRand(int min, int max);
-int GetRand(int min, int max)
-{
- return (rand() % (max - min + 1) + min);
-}
-
-float mmrand(int min, int max, float divisor);
-float mmrand(int min, int max, float divisor)
-{
- return ((float)GetRand(min, max)) / divisor;
-};
-
// ------------------------------------------------- RENDERING ----------------------------------------------------
-static void setupDisplayList(SnowScreen * ss)
+ static void
+setupDisplayList(StarScreen *ss)
{
// ----------------- untextured list
- ss->displayList = glGenLists(1);
+ ss->displayList =glGenLists(1);
glNewList(ss->displayList, GL_COMPILE);
- glBegin(GL_QUADS);
+ glBegin (GL_QUADS);
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glVertex3f(0, 0, -0.0);
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glVertex3f(0, snowSize, -0.0);
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glVertex3f(snowSize, snowSize, -0.0);
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glVertex3f(snowSize, 0, -0.0);
+ glColor4f (1.0, 1.0, 1.0, 1.0); glVertex3f (0,0, -0.0);
+ glColor4f (1.0, 1.0, 1.0, 1.0); glVertex3f (0,starSize, -0.0);
+ glColor4f (1.0, 1.0, 1.0, 1.0); glVertex3f (starSize, starSize, -0.0);
+ glColor4f (1.0, 1.0, 1.0, 1.0); glVertex3f (starSize, 0, -0.0);
- glEnd();
+ glEnd ();
glEndList();
}
-static void beginRendering(SnowScreen * ss, CompScreen * s)
+static void
+beginRendering(StarScreen *ss, CompScreen *s)
{
if (useBlending)
- glEnable(GL_BLEND);
+ glEnable (GL_BLEND);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- if (displayListNeedsUpdating)
+ if (displayListNeedsUpdating)
{
setupDisplayList(ss);
displayListNeedsUpdating = FALSE;
}
- glColor4f(1.0, 1.0, 1.0, 1.0);
- if (ss->snowTexturesLoaded && useTextures)
+ glColor4f (1.0, 1.0, 1.0, 1.0);
+ if (ss->starTexturesLoaded && useTextures)
{
int j = 0;
- for (j = 0; j < ss->snowTexturesLoaded; j++)
+ for (j = 0; j < ss->starTexturesLoaded; j++)
{
- enableTexture(ss->s, &ss->snowTex[j].tex,
- COMP_TEXTURE_FILTER_GOOD);
+ enableTexture (ss->s, &ss->starsTex[j].tex, COMP_TEXTURE_FILTER_GOOD);
int i = 0;
- SnowFlake *snowFlake = ss->allSnowFlakes;
-
- for (i = 0; i < numFlakes; i++)
+ for (i = 0; i < numFlies; i++)
{
- if (snowFlake->tex == &ss->snowTex[j])
+ glColor4f (1.0, 1.0, 1.0, ss->allStars[i].glowAlpha);
+ if (ss->allStars[i].tex == &ss->starsTex[j])
{
- glTranslatef(snowFlake->x, snowFlake->y, snowFlake->z);
- if (snowRotate)
- glRotatef(snowFlake->ra, 0, 0, 1);
- glCallList(ss->snowTex[j].dList);
- if (snowRotate)
- glRotatef(-snowFlake->ra, 0, 0, 1);
- glTranslatef(-snowFlake->x, -snowFlake->y, -snowFlake->z);
+ glTranslatef(ss->allStars[i].x, ss->allStars[i].y, ss->allStars[i].z);
+ glCallList(ss->starsTex[j].dList);
+ glTranslatef(-ss->allStars[i].x, -ss->allStars[i].y, -ss->allStars[i].z);
}
- snowFlake++;
}
- disableTexture(ss->s, &ss->snowTex[j].tex);
+ disableTexture (ss->s, &ss->starsTex[j].tex);
}
}
- else if (!ss->snowTexturesLoaded || !useTextures)
+ else if (!ss->starTexturesLoaded || !useTextures)
{
int i = 0;
- SnowFlake *snowFlake = ss->allSnowFlakes;
-
- for (i = 0; i < numFlakes; i++)
+ for (i = 0; i < numFlies; i++)
{
- glTranslatef(snowFlake->x, snowFlake->y, snowFlake->z);
- glRotatef(snowFlake->ra, 0, 0, 1);
+ glColor4f (1.0, 1.0, 1.0, ss->allStars[i].glowAlpha);
+ glTranslatef(ss->allStars[i].x, ss->allStars[i].y, ss->allStars[i].z);
glCallList(ss->displayList);
- glRotatef(-snowFlake->ra, 0, 0, 1);
- glTranslatef(-snowFlake->x, -snowFlake->y, -snowFlake->z);
- snowFlake++;
+ glTranslatef(-ss->allStars[i].x, -ss->allStars[i].y, -ss->allStars[i].z);
}
}
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
if (useBlending)
{
- glDisable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable (GL_BLEND);
+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
}
-
// ------------------------------------------------- FUNCTIONS ----------------------------------------------------
-static Bool
-snowPaintScreen(CompScreen * s,
- const ScreenPaintAttrib * sa,
- const CompTransform * transform,
- Region region, int output, unsigned int mask)
+static Bool starsPaintScreen(CompScreen *s,
+ const ScreenPaintAttrib *sa,
+ const CompTransform *transform,
+ Region region, int output, unsigned int mask)
{
Bool status;
- SNOW_SCREEN(s);
+ STAR_SCREEN(s);
if (!onTop && ss->active)
{
- // This line is essential. Without it the snow will be rendered above (some) other windows.
+ // This line is essential. Without it the stars will be rendered above (some) other windows.
mask |= PAINT_SCREEN_ORDER_BACK_TO_FRONT_MASK;
}
UNWRAP(ss, s, paintScreen);
status = (*s->paintScreen) (s, sa, transform, region, output, mask);
- WRAP(ss, s, paintScreen, snowPaintScreen);
+ WRAP(ss, s, paintScreen, starsPaintScreen);
if (onTop && ss->active)
{
@@ -399,18 +389,19 @@
return status;
}
-static Bool
-snowDrawWindow(CompWindow * w, const CompTransform *transform, const FragmentAttrib *attrib,
- Region region, unsigned int mask)
+static Bool starsDrawWindow (CompWindow *w,
+ const CompTransform *transform,
+ const FragmentAttrib *attrib,
+ Region region, unsigned int mask)
{
int status;;
- SNOW_SCREEN(w->screen);
+ STAR_SCREEN (w->screen);
// First draw Window as usual
- UNWRAP(ss, w->screen, drawWindow);
+ UNWRAP (ss, w->screen, drawWindow);
status = (*w->screen->drawWindow) (w, transform, attrib, region, mask);
- WRAP(ss, w->screen, drawWindow, snowDrawWindow);
+ WRAP (ss, w->screen, drawWindow, starsDrawWindow);
// Check whether this is the Desktop Window
if (w->type & CompWindowTypeDesktopMask && ss->active && !onTop)
@@ -419,193 +410,155 @@
return status;
}
-static void InitiateSnowFlake(SnowScreen * ss, SnowFlake * sf)
+static void InitiateStar(StarScreen *ss, Star *sf)
{
- //TODO: possibly place snowflakes based on FOV, instead of a cube.
- SNOW_DISPLAY(ss->s->display);
- CompOption *o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_DIRECTION];
+ float init;
- if (strcmp(snowDirections[0], o->value.s) == 0)
- {
- sf->x = mmrand(-boxing, ss->s->width + boxing, 1);
- sf->xs = mmrand(-1, 1, 500);
- sf->y = mmrand(-300, 0, 1);
- sf->ys = mmrand(1, 3, 1);
- }
- else if (strcmp(snowDirections[1], o->value.s) == 0)
- {
- sf->x = mmrand(-boxing, ss->s->width + boxing, 1);
- sf->xs = mmrand(-1, 1, 500);
- sf->y = mmrand(ss->s->height, ss->s->height + 300, 1);
- sf->ys = -mmrand(1, 3, 1);
- }
- else if (strcmp(snowDirections[2], o->value.s) == 0)
- {
- sf->x = mmrand(ss->s->width, ss->s->width + 300, 1);
- sf->xs = -mmrand(1, 3, 1);
- sf->y = mmrand(-boxing, ss->s->height + boxing, 1);
- sf->ys = mmrand(-1, 1, 500);
- }
- else if (strcmp(snowDirections[3], o->value.s) == 0)
- {
- sf->x = mmrand(-300, 0, 1);
- sf->xs = mmrand(1, 3, 1);
- sf->y = mmrand(-boxing, ss->s->height + boxing, 1);
- sf->ys = mmrand(-1, 1, 500);
- }
+ // speed of star
+ sf->xs = mmrand(-50000, 50000, 5000);
+ sf->ys = mmrand(-50000, 50000, 5000);
+ sf->zs = mmrand(000, 200, 2000);
+ //TODO: possibly place stars based on FOV, instead of a cube.
+ sf->x = ss->s->width * .5;
+ sf->y = ss->s->height * .5;
sf->z = mmrand(-depth, 0.1, 5000);
- sf->zs = mmrand(-1000, 1000, 500000);
- sf->ra = mmrand(-1000, 1000, 50);
- sf->rs = mmrand(-1000, 1000, 1000);
+ sf->glowAlpha = 0;
+ sf->lifecycle = 0.;
+ init = mmrand(0,100, 1); //init = distance to center of the screen
+
+ sf->x += init * sf->xs;
+ sf->y += init * sf->ys;
}
-static void setSnowflakeTexture(SnowScreen * ss, SnowFlake * sf)
+static void setStarTexture(StarScreen *ss, Star *sf)
{
- if (ss->snowTexturesLoaded)
- sf->tex = &ss->snowTex[rand() % ss->snowTexturesLoaded];
+ if (ss->starTexturesLoaded)
+ sf->tex = &ss->starsTex[rand() % ss->starTexturesLoaded];
}
-static void updateSnowTextures(CompScreen * s)
+static void updateStarTextures(CompScreen *s)
{
- SNOW_SCREEN(s);
- SNOW_DISPLAY(s->display);
+ STAR_SCREEN(s);
+ STAR_DISPLAY(s->display);
int i = 0;
-
- for (i = 0; i < ss->snowTexturesLoaded; i++)
+ for (i = 0; i < ss->starTexturesLoaded; i++)
{
- finiTexture(s, &ss->snowTex[i].tex);
- glDeleteLists(ss->snowTex[i].dList, 1);
+ finiTexture (s, &ss->starsTex[i].tex);
+ glDeleteLists(ss->starsTex[i].dList,1);
}
- if (ss->snowTexturesLoaded)
- free(ss->snowTex);
- ss->snowTexturesLoaded = 0;
+ if (ss->starTexturesLoaded)
+ free(ss->starsTex);
+ ss->starTexturesLoaded = 0;
- ss->snowTex = calloc(1, sizeof(SnowTexture) * sd->snowTexNFiles);
+ ss->starsTex = calloc(1, sizeof(StarTexture) * sd->starsTexNFiles);
int count = 0;
-
- for (i = 0; i < sd->snowTexNFiles; i++)
+ for (i = 0; i < sd->starsTexNFiles; i++)
{
- ss->snowTex[count].loaded =
- readImageToTexture(s, &ss->snowTex[count].tex,
- sd->snowTexFiles[i].s,
- &ss->snowTex[count].width,
- &ss->snowTex[count].height);
- if (!ss->snowTex[count].loaded)
+ ss->starsTex[count].loaded = readImageToTexture (s, &ss->starsTex[count].tex,
+ sd->starsTexFiles[i].s, &ss->starsTex[count].width, &ss->starsTex[count].height);
+ if (!ss->starsTex[count].loaded)
{
- printf("[Snow]: Texture not found : %s\n", sd->snowTexFiles[i].s);
+ printf("[Star]: Texture not found : %s\n", sd->starsTexFiles[i].s);
continue;
}
- printf("[Snow]: Loaded Texture %s\n", sd->snowTexFiles[i].s);
- CompMatrix *mat = &ss->snowTex[count].tex.matrix;
- SnowTexture *sTex = &ss->snowTex[count];
+ printf("[Star]: Loaded Texture %s\n",sd->starsTexFiles[i].s);
+ CompMatrix *mat = &ss->starsTex[count].tex.matrix;
+ StarTexture *sTex = &ss->starsTex[count];
- sTex->dList = glGenLists(1);
+ sTex->dList =glGenLists(1);
glNewList(sTex->dList, GL_COMPILE);
- glBegin(GL_QUADS);
+ glBegin (GL_QUADS);
- glTexCoord2f(COMP_TEX_COORD_X(mat, 0), COMP_TEX_COORD_Y(mat, 0));
- glVertex2f(0, 0);
- glTexCoord2f(COMP_TEX_COORD_X(mat, 0),
- COMP_TEX_COORD_Y(mat, sTex->height));
- glVertex2f(0, snowSize * sTex->height / sTex->width);
- glTexCoord2f(COMP_TEX_COORD_X(mat, sTex->width),
- COMP_TEX_COORD_Y(mat, sTex->height));
- glVertex2f(snowSize, snowSize * sTex->height / sTex->width);
- glTexCoord2f(COMP_TEX_COORD_X(mat, sTex->width),
- COMP_TEX_COORD_Y(mat, 0));
- glVertex2f(snowSize, 0);
+ glTexCoord2f (COMP_TEX_COORD_X(mat, 0), COMP_TEX_COORD_Y(mat, 0));
+ glVertex2f (0,0);
+ glTexCoord2f (COMP_TEX_COORD_X(mat, 0), COMP_TEX_COORD_Y(mat, sTex->height));
+ glVertex2f (0,starSize * sTex->height / sTex->width);
+ glTexCoord2f (COMP_TEX_COORD_X(mat, sTex->width), COMP_TEX_COORD_Y(mat, sTex->height));
+ glVertex2f (starSize,starSize * sTex->height / sTex->width);
+ glTexCoord2f (COMP_TEX_COORD_X(mat, sTex->width), COMP_TEX_COORD_Y(mat, 0));
+ glVertex2f (starSize,0);
- glEnd();
+ glEnd ();
glEndList();
count++;
}
- ss->snowTexturesLoaded = count;
- if (count < sd->snowTexNFiles)
- ss->snowTex = realloc(ss->snowTex, sizeof(SnowTexture) * count);
+ ss->starTexturesLoaded = count;
+ if (count < sd->starsTexNFiles)
+ ss->starsTex = realloc(ss->starsTex, sizeof(StarTexture) * count);
- SnowFlake *snowFlake = ss->allSnowFlakes;
-
- for (i = 0; i < MAX_SNOWFLAKES; i++)
+ for (i = 0; i < MAX_STARS; i++)
{
- setSnowflakeTexture(ss, snowFlake++);
+ setStarTexture(ss, &ss->allStars[i]);
}
}
-static Bool snowInitScreen(CompPlugin * p, CompScreen * s)
+static Bool starsInitScreen(CompPlugin *p, CompScreen *s)
{
- SNOW_DISPLAY(s->display);
+ STAR_DISPLAY(s->display);
- SnowScreen *ss = (SnowScreen *) calloc(1, sizeof(SnowScreen));
-
+ StarScreen *ss = (StarScreen *) calloc(1, sizeof(StarScreen));
ss->s = s;
s->privates[sd->screenPrivateIndex].ptr = ss;
int i = 0;
- SnowFlake *snowFlake = ss->allSnowFlakes;
-
- for (i = 0; i < MAX_SNOWFLAKES; i++)
+ for (i = 0; i < MAX_STARS; i++)
{
- InitiateSnowFlake(ss, snowFlake);
- setSnowflakeTexture(ss, snowFlake);
- snowFlake++;
+ InitiateStar(ss, &ss->allStars[i]);
+ setStarTexture(ss, &ss->allStars[i]);
}
- updateSnowTextures(s);
+ updateStarTextures(s);
setupDisplayList(ss);
ss->active = FALSE;
- addScreenAction(s, &sd->opt[SNOW_DISPLAY_OPTION_INITIATE].value.action);
+ addScreenAction (s, &sd->opt[STAR_DISPLAY_OPTION_INITIATE].value.action);
- WRAP(ss, s, paintScreen, snowPaintScreen);
- WRAP(ss, s, drawWindow, snowDrawWindow);
+ WRAP(ss, s, paintScreen, starsPaintScreen);
+ WRAP(ss, s, drawWindow, starsDrawWindow);
- ss->timeoutHandle = compAddTimeout(snowUpdateDelay, stepSnowPositions, s);
+ ss->timeoutHandle=compAddTimeout(starUpdateDelay,stepStarPositions,s);
return TRUE;
}
-static void snowFiniScreen(CompPlugin * p, CompScreen * s)
+static void starsFiniScreen(CompPlugin *p, CompScreen *s)
{
- SNOW_SCREEN(s);
- SNOW_DISPLAY(s->display);
+ STAR_SCREEN(s);
+ STAR_DISPLAY(s->display);
compRemoveTimeout(ss->timeoutHandle);
int i = 0;
-
- for (i = 0; i < ss->snowTexturesLoaded; i++)
+ for (i = 0; i < ss->starTexturesLoaded; i++)
{
- finiTexture(s, &ss->snowTex[i].tex);
- glDeleteLists(ss->snowTex[i].dList, 1);
+ finiTexture (s, &ss->starsTex[i].tex);
+ glDeleteLists(ss->starsTex[i].dList,1);
}
- if (ss->snowTexturesLoaded)
- free(ss->snowTex);
+ if (ss->starTexturesLoaded)
+ free(ss->starsTex);
//Restore the original function
UNWRAP(ss, s, paintScreen);
UNWRAP(ss, s, drawWindow);
- removeScreenAction(s,
- &sd->opt[SNOW_DISPLAY_OPTION_INITIATE].value.action);
+ removeScreenAction (s, &sd->opt[STAR_DISPLAY_OPTION_INITIATE].value.action);
//Free the pointer
free(ss);
}
-static Bool
-snowSetDisplayOption(CompDisplay * display, char *name,
- CompOptionValue * value)
+static Bool starsSetDisplayOption(CompDisplay *display, char *name, CompOptionValue *value)
{
CompOption *o;
int index;
- SNOW_DISPLAY(display);
+ STAR_DISPLAY(display);
o = compFindOption(sd->opt, NUM_OPTIONS(sd), name, &index);
if (!o)
@@ -613,367 +566,296 @@
switch (index)
{
- case SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES:
- if (compSetFloatOption(o, value))
- {
- numFlakes =
- (int)sd->opt[SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES].value.f;
- return TRUE;
- }
- break;
+ case STAR_DISPLAY_OPTION_NUM_STARS:
+ if (compSetFloatOption (o, value))
+ {
+ numFlies = (int) sd->opt[STAR_DISPLAY_OPTION_NUM_STARS].value.f;
+ return TRUE;
+ }
+ break;
+ case STAR_DISPLAY_OPTION_STAR_SIZE:
+ if (compSetFloatOption (o, value))
+ {
+ starSize = sd->opt[STAR_DISPLAY_OPTION_STAR_SIZE].value.f;
+ displayListNeedsUpdating = TRUE;
+ CompScreen * s=display->screens;
+ updateStarTextures(s);
- case SNOW_DISPLAY_OPTION_SNOW_DIRECTION:
- if (compSetStringOption(o, value))
- {
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_SNOW_SIZE:
- if (compSetFloatOption(o, value))
- {
- snowSize = sd->opt[SNOW_DISPLAY_OPTION_SNOW_SIZE].value.f;
- displayListNeedsUpdating = TRUE;
- CompScreen *s = display->screens;
+ return TRUE;
+ }
+ break;
+ case STAR_DISPLAY_OPTION_STAR_SPEED:
+ if (compSetFloatOption (o, value))
+ {
+ starSpeed = sd->opt[STAR_DISPLAY_OPTION_STAR_SPEED].value.f;
+ return TRUE;
+ }
+ break;
+ case STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY:
+ if (compSetIntOption (o,value))
+ {
+ CompScreen * s = display->screens;
+ STAR_SCREEN(s);
+ starUpdateDelay = sd->opt[STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY].value.i;
+ if (ss->timeoutHandle)
+ compRemoveTimeout(ss->timeoutHandle);
+ ss->timeoutHandle=compAddTimeout(starUpdateDelay,stepStarPositions,s);
+ return TRUE;
+ }
+ case STAR_DISPLAY_OPTION_SCREEN_BOXING:
+ if (compSetFloatOption (o, value))
+ {
+ boxing = sd->opt[STAR_DISPLAY_OPTION_SCREEN_BOXING].value.f;
+ return TRUE;
+ }
+ break;
+ case STAR_DISPLAY_OPTION_SCREEN_DEPTH:
+ if (compSetFloatOption (o, value))
+ {
+ depth = sd->opt[STAR_DISPLAY_OPTION_SCREEN_DEPTH].value.f;
+ return TRUE;
+ }
+ break;
+ // case STAR_DISPLAY_OPTION_MAX_FRAMES:
+ // if (compSetFloatOption (o, value))
+ // return TRUE;
+ // break;
- updateSnowTextures(s);
+ case STAR_DISPLAY_OPTION_STAR_TEXTURES:
+ if (compSetOptionList (o, value))
+ {
+ CompScreen * s=display->screens;
+ sd->starsTexFiles = sd->opt[STAR_DISPLAY_OPTION_STAR_TEXTURES].value.list.value;
+ sd->starsTexNFiles = sd->opt[STAR_DISPLAY_OPTION_STAR_TEXTURES].value.list.nValue;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_SNOW_SPEED:
- if (compSetFloatOption(o, value))
- {
- snowSpeed = sd->opt[SNOW_DISPLAY_OPTION_SNOW_SPEED].value.f;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY:
- if (compSetIntOption(o, value))
- {
- CompScreen *s = display->screens;
+ updateStarTextures(s);
+ return TRUE;
+ }
+ break;
- SNOW_SCREEN(s);
- snowUpdateDelay =
- sd->opt[SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY].value.i;
- if (ss->timeoutHandle)
- compRemoveTimeout(ss->timeoutHandle);
- ss->timeoutHandle =
- compAddTimeout(snowUpdateDelay, stepSnowPositions, s);
- return TRUE;
- }
- case SNOW_DISPLAY_OPTION_SCREEN_BOXING:
- if (compSetFloatOption(o, value))
- {
- boxing = sd->opt[SNOW_DISPLAY_OPTION_SCREEN_BOXING].value.f;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_SCREEN_DEPTH:
- if (compSetFloatOption(o, value))
- {
- depth = sd->opt[SNOW_DISPLAY_OPTION_SCREEN_DEPTH].value.f;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_SNOW_TEXTURES:
- if (compSetOptionList(o, value))
- {
- CompScreen *s = display->screens;
-
- sd->snowTexFiles =
- sd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURES].value.list.
- value;
- sd->snowTexNFiles =
- sd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURES].value.list.
- nValue;
-
- updateSnowTextures(s);
- return TRUE;
- }
- break;
-
- case SNOW_DISPLAY_OPTION_INITIATE:
- if (setDisplayAction(display, o, value))
- return TRUE;
- break;
- case SNOW_DISPLAY_OPTION_ON_TOP:
- if (compSetBoolOption(o, value))
- {
- onTop = sd->opt[SNOW_DISPLAY_OPTION_ON_TOP].value.b;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_ROTATION:
- if (compSetBoolOption(o, value))
- {
- snowRotate = sd->opt[SNOW_DISPLAY_OPTION_ROTATION].value.b;
- return TRUE;
- }
- break;
- case SNOW_DISPLAY_OPTION_USE_BLENDING:
- if (compSetBoolOption(o, value))
- {
- useBlending = sd->opt[SNOW_DISPLAY_OPTION_USE_BLENDING].value.b;
- return TRUE;
- }
- case SNOW_DISPLAY_OPTION_USE_TEXTURES:
- if (compSetBoolOption(o, value))
- {
- useTextures = sd->opt[SNOW_DISPLAY_OPTION_USE_TEXTURES].value.b;
- return TRUE;
- }
- break;
- default:
- break;
+ case STAR_DISPLAY_OPTION_INITIATE:
+ if (setDisplayAction (display, o, value))
+ return TRUE;
+ break;
+ case STAR_DISPLAY_OPTION_ON_TOP:
+ if (compSetBoolOption (o, value))
+ {
+ onTop = sd->opt[STAR_DISPLAY_OPTION_ON_TOP].value.b;
+ return TRUE;
+ }
+ break;
+ case STAR_DISPLAY_OPTION_USE_BLENDING:
+ if (compSetBoolOption (o, value))
+ {
+ useBlending = sd->opt[STAR_DISPLAY_OPTION_USE_BLENDING].value.b;
+ return TRUE;
+ }
+ case STAR_DISPLAY_OPTION_USE_TEXTURES:
+ if (compSetBoolOption (o, value))
+ {
+ useTextures = sd->opt[STAR_DISPLAY_OPTION_USE_TEXTURES].value.b;
+ return TRUE;
+ }
+ break;
+ default:
+ break;
}
return FALSE;
}
-static void snowDisplayInitOptions(SnowDisplay * sd)
+static void starsDisplayInitOptions(StarDisplay * sd)
{
CompOption *o;
- o = &sd->opt[SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES];
- o->advanced = False;
- o->name = "num_snowflakes";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Number of Snowflakes");
- o->longDesc = N_("Number of Snowflakes");
+ o = &sd->opt[STAR_DISPLAY_OPTION_NUM_STARS];
+ o->name = "num_stars";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Number of stars");
+ o->longDesc = N_("Number of stars");
o->type = CompOptionTypeFloat;
- o->value.f = SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT;
+ o->value.f = STAR_DISPLAY_OPTION_NUM_STARS_DEFAULT;
o->rest.f.min = 0;
o->rest.f.max = 10000;
o->rest.f.precision = 1;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_SIZE];
- o->advanced = False;
- o->name = "snow_size";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Size of snowflakes");
- o->longDesc = N_("Size of snowflakes");
+ o = &sd->opt[STAR_DISPLAY_OPTION_STAR_SIZE];
+ o->name = "stars_size";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Size of stars");
+ o->longDesc = N_("Size of stars");
o->type = CompOptionTypeFloat;
- o->value.f = SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT;
+ o->value.f = STAR_DISPLAY_OPTION_STAR_SIZE_DEFAULT;
o->rest.f.min = 0;
- o->rest.f.max = 50;
+ o->rest.f.max = 5;
o->rest.f.precision = 0.1;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_SPEED];
- o->advanced = False;
- o->name = "snow_speed";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Speed of falling snow");
- o->longDesc = N_("Speed of falling snow");
+ o = &sd->opt[STAR_DISPLAY_OPTION_STAR_SPEED];
+ o->name = "stars_speed";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Speed of stars");
+ o->longDesc = N_("Speed of stars");
o->type = CompOptionTypeFloat;
- o->value.f = SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT;
+ o->value.f = STAR_DISPLAY_OPTION_STAR_SPEED_DEFAULT;
o->rest.f.min = 0;
o->rest.f.max = 100;
o->rest.f.precision = 1;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY];
- o->advanced = False;
- o->name = "snow_update_delay";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Update Delay");
- o->longDesc =
- N_
- ("Delay in ms between screen updates. Deacreasing this value may make snow fall more smoothly, but will also increase CPU usage.");
+ o = &sd->opt[STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY];
+ o->name = "stars_update_delay";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Screen Update Delay");
+ o->longDesc = N_("Delay in ms between screen updates");
o->type = CompOptionTypeInt;
- o->value.i = SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY_DEFAULT;
+ o->value.i = STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY_DEFAULT;
o->rest.i.min = 10;
o->rest.i.max = 200;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SCREEN_BOXING];
- o->advanced = False;
+ o = &sd->opt[STAR_DISPLAY_OPTION_SCREEN_BOXING];
o->name = "screen_boxing";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
o->shortDesc = N_("Screen Boxing");
- o->longDesc =
- N_
- ("How far outside the screen resolution snowflakes can be before being removed. Needed because of FOV.");
+ o->longDesc = N_("How far outside the screen resolution stars can be before being removed. Needed because of FOV.");
o->type = CompOptionTypeFloat;
- o->value.f = SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
+ o->value.f = STAR_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
o->rest.f.min = -2000;
o->rest.f.max = 2000;
o->rest.f.precision = 1;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SCREEN_DEPTH];
- o->advanced = False;
+ o = &sd->opt[STAR_DISPLAY_OPTION_SCREEN_DEPTH];
o->name = "screen_depth";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
+ o->group=N_("Settings");
+ o->subGroup=N_("");
+ o->displayHints="";
o->shortDesc = N_("Screen Depth");
- o->longDesc =
- N_
- ("How deep into the screen snowflakes can be drawn before being removed.");
+ o->longDesc = N_("How deep into the screen stars can be drawn before being removed.");
o->type = CompOptionTypeFloat;
- o->value.f = SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
+ o->value.f = STAR_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
o->rest.f.min = 0;
- o->rest.f.max = SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT * 2;
+ o->rest.f.max = STAR_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT * 2;
o->rest.f.precision = 1;
- o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURES];
- o->advanced = False;
- o->name = "snow_textures";
- o->group = N_("Textures");
- o->subGroup = N_("");
- o->displayHints = "file;image;pngonly;";
- o->shortDesc = N_("Snow Textures");
- o->longDesc = N_("Snow textures");
+ o = &sd->opt[STAR_DISPLAY_OPTION_STAR_TEXTURES];
+ o->name = "stars_textures";
+ o->group=N_("Textures");
+ o->subGroup=N_("");
+ o->displayHints="file;image;pngonly;";
+ o->shortDesc = N_("Star Textures");
+ o->longDesc = N_("Star textures");
o->type = CompOptionTypeList;
o->value.list.type = CompOptionTypeString;
- o->value.list.nValue = N_SNOW_TEXTURES;
- o->value.list.value = malloc(sizeof(CompOptionValue) * N_SNOW_TEXTURES);
+ o->value.list.nValue = N_STAR_TEXTURES;
+ o->value.list.value =
+ malloc(sizeof(CompOptionValue) * N_STAR_TEXTURES);
int i = 0;
-
- for (i = 0; i < N_SNOW_TEXTURES; i++)
- o->value.list.value[i].s = strdup(snowTextures[i]);
+ for (i = 0; i < N_STAR_TEXTURES; i++)
+ o->value.list.value[i].s = strdup(starTextures[i]);
o->rest.s.string = 0;
o->rest.s.nString = 0;
- o = &sd->opt[SNOW_DISPLAY_OPTION_INITIATE];
- o->advanced = False;
+ o = &sd->opt[STAR_DISPLAY_OPTION_INITIATE];
o->name = "Initiate";
- o->group = N_("Key Bindings");
- o->subGroup = N_("");
+ o->group = N_("Initiate");
+ o->subGroup = N_("Key Bindings");
o->displayHints = "";
- o->shortDesc = N_("snow toggle key");
- o->longDesc = N_("snow toggle key");
+ o->shortDesc = N_("Stars toggle key");
+ o->longDesc = N_("Stars toggle key");
o->type = CompOptionTypeAction;
- o->value.action.initiate = snowToggle;
+ o->value.action.initiate = starsToggle;
o->value.action.terminate = 0;
o->value.action.bell = FALSE;
o->value.action.type = CompBindingTypeKey;
o->value.action.state = CompActionStateInitKey;
o->value.action.state |= CompActionStateInitButton;
- o->value.action.key.modifiers = SNOW_DISPLAY_OPTION_INITIATE_MOD;
+ o->value.action.key.modifiers = STAR_DISPLAY_OPTION_INITIATE_MOD;
o->value.action.key.keysym =
- XStringToKeysym(SNOW_DISPLAY_OPTION_INITIATE_KEY);
+ XStringToKeysym (STAR_DISPLAY_OPTION_INITIATE_KEY);
- o = &sd->opt[SNOW_DISPLAY_OPTION_ON_TOP];
- o->advanced = False;
- o->name = "snow_over_windows";
+ o = &sd->opt[STAR_DISPLAY_OPTION_ON_TOP];
+ o->name = "stars_over_windows";
o->group = N_("Settings");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Snow over windows.");
- o->longDesc = N_("Snow is drawn above windows.");
+ o->shortDesc = N_("stars over windows");
+ o->longDesc = N_("stars are drawn above windows.");
o->type = CompOptionTypeBool;
- o->value.b = SNOW_DISPLAY_OPTION_ON_TOP_DEFAULT;
+ o->value.b = STAR_DISPLAY_OPTION_ON_TOP_DEFAULT;
- o = &sd->opt[SNOW_DISPLAY_OPTION_ROTATION];
- o->advanced = False;
- o->name = "snow_rotation";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Rotate flakes");
- o->longDesc = N_("Flakes rotate when checked.");
- o->type = CompOptionTypeBool;
- o->value.b = SNOW_DISPLAY_OPTION_ROTATION_DEFAULT;
-
- o = &sd->opt[SNOW_DISPLAY_OPTION_SNOW_DIRECTION];
- o->advanced = False;
- o->name = "snow_direction";
- o->group = N_("Settings");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Snow Direction");
- o->longDesc = N_("Select direction in which the snow should fly.");
- o->type = CompOptionTypeString;
- o->value.s =
- strdup(snowDirections[SNOW_DISPLAY_OPTION_DIRECTION_DEFAULT]);
- o->rest.s.string = snowDirections;
- o->rest.s.nString = NUM_SNOW_DIRECTIONS;
-
- o = &sd->opt[SNOW_DISPLAY_OPTION_USE_BLENDING];
- o->advanced = False;
+ o = &sd->opt[STAR_DISPLAY_OPTION_USE_BLENDING];
o->name = "use_blending";
o->group = N_("Debug");
o->subGroup = N_("");
o->displayHints = "";
o->shortDesc = N_("Enable Blending");
- o->longDesc = N_("Enables alpha blending of snowflakes");
+ o->longDesc = N_("Enables alpha blending of stars");
o->type = CompOptionTypeBool;
- o->value.b = SNOW_DISPLAY_OPTION_USE_BLENDING_DEFAULT;
+ o->value.b = STAR_DISPLAY_OPTION_USE_BLENDING_DEFAULT;
- o = &sd->opt[SNOW_DISPLAY_OPTION_USE_TEXTURES];
- o->advanced = False;
+ o = &sd->opt[STAR_DISPLAY_OPTION_USE_TEXTURES];
o->name = "use_textures";
o->group = N_("Debug");
o->subGroup = N_("");
o->displayHints = "";
o->shortDesc = N_("Enable Textures");
- o->longDesc =
- N_
- ("Enables textured snowflakes. Otherwise color gradients are used.");
+ o->longDesc = N_("Enables textured stars. Otherwise color gradients are used.");
o->type = CompOptionTypeBool;
- o->value.b = SNOW_DISPLAY_OPTION_USE_TEXTURES_DEFAULT;
+ o->value.b = STAR_DISPLAY_OPTION_USE_TEXTURES_DEFAULT;
}
-static CompOption *snowGetDisplayOptions(CompDisplay * display, int *count)
+static CompOption *starsGetDisplayOptions(CompDisplay * display, int *count)
{
- if (display)
- {
- SNOW_DISPLAY(display);
+ if (display) {
+ STAR_DISPLAY(display);
*count = NUM_OPTIONS(sd);
return sd->opt;
}
- else
- {
- SnowDisplay *sd = malloc(sizeof(SnowDisplay));
+ else {
+ StarDisplay *sd = malloc(sizeof(StarDisplay));
+ starsDisplayInitOptions(sd);
- snowDisplayInitOptions(sd);
-
*count = NUM_OPTIONS(sd);
return sd->opt;
}
}
-static Bool snowInitDisplay(CompPlugin * p, CompDisplay * d)
+static Bool starsInitDisplay(CompPlugin * p, CompDisplay * d)
{
- //Generate a snow display
- SnowDisplay *sd = (SnowDisplay *) malloc(sizeof(SnowDisplay));
-
+ //Generate a stars display
+ StarDisplay *sd = (StarDisplay *) malloc(sizeof(StarDisplay));
//Allocate a private index
sd->screenPrivateIndex = allocateScreenPrivateIndex(d);
//Check if its valid
- if (sd->screenPrivateIndex < 0)
- {
+ if (sd->screenPrivateIndex < 0) {
free(sd);
return FALSE;
}
- numFlakes = SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT;
- snowRotate = SNOW_DISPLAY_OPTION_ROTATION_DEFAULT;
- snowSize = SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT;
- snowSpeed = SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT;
- snowUpdateDelay = SNOW_DISPLAY_OPTION_SNOW_UPDATE_DELAY_DEFAULT;
- boxing = SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
- depth = SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
- onTop = SNOW_DISPLAY_OPTION_ON_TOP_DEFAULT;
+ numFlies = STAR_DISPLAY_OPTION_NUM_STARS_DEFAULT;
+ starSize = STAR_DISPLAY_OPTION_STAR_SIZE_DEFAULT;
+ starSpeed = STAR_DISPLAY_OPTION_STAR_SPEED_DEFAULT;
+ starUpdateDelay = STAR_DISPLAY_OPTION_STAR_UPDATE_DELAY_DEFAULT;
+ boxing = STAR_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
+ depth = STAR_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
+ onTop = STAR_DISPLAY_OPTION_ON_TOP_DEFAULT;
displayListNeedsUpdating = FALSE;
- useBlending = SNOW_DISPLAY_OPTION_USE_BLENDING_DEFAULT;
- useTextures = SNOW_DISPLAY_OPTION_USE_TEXTURES_DEFAULT;
- snowDisplayInitOptions(sd);
+ useBlending = STAR_DISPLAY_OPTION_USE_BLENDING_DEFAULT;
+ useTextures = STAR_DISPLAY_OPTION_USE_TEXTURES_DEFAULT;
+ starsDisplayInitOptions(sd);
- sd->snowTexFiles =
- sd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURES].value.list.value;
- sd->snowTexNFiles =
- sd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURES].value.list.nValue;
+ sd->starsTexFiles = sd->opt[STAR_DISPLAY_OPTION_STAR_TEXTURES].value.list.value;
+ sd->starsTexNFiles = sd->opt[STAR_DISPLAY_OPTION_STAR_TEXTURES].value.list.nValue;
//Record the display
d->privates[displayPrivateIndex].ptr = sd;
@@ -981,9 +863,9 @@
return TRUE;
}
-static void snowFiniDisplay(CompPlugin * p, CompDisplay * d)
+static void starsFiniDisplay(CompPlugin * p, CompDisplay * d)
{
- SNOW_DISPLAY(d);
+ STAR_DISPLAY(d);
//Free the private index
freeScreenPrivateIndex(d, sd->screenPrivateIndex);
@@ -991,7 +873,7 @@
free(sd);
}
-static Bool snowInit(CompPlugin * p)
+static Bool starsInit(CompPlugin * p)
{
displayPrivateIndex = allocateDisplayPrivateIndex();
@@ -1001,40 +883,38 @@
return TRUE;
}
-static void snowFini(CompPlugin * p)
+static void starsFini(CompPlugin * p)
{
if (displayPrivateIndex >= 0)
freeDisplayPrivateIndex(displayPrivateIndex);
}
-CompPluginDep snowDeps[] = {
- {CompPluginRuleAfterCategory, "imageformat"}
- ,
+CompPluginDep starDeps[] = {
+ {CompPluginRuleAfterCategory, "imageformat"},
};
-CompPluginVTable snowVTable = {
- "snow",
- N_("Snow"),
- N_("XSnow for Beryl"),
- snowInit,
- snowFini,
- snowInitDisplay,
- snowFiniDisplay,
- snowInitScreen,
- snowFiniScreen,
+CompPluginVTable starsVTable = {
+ "star",
+ N_("Stars"),
+ N_("XStars for Beryl"),
+ starsInit,
+ starsFini,
+ starsInitDisplay,
+ starsFiniDisplay,
+ starsInitScreen,
+ starsFiniScreen,
0,
0,
- snowGetDisplayOptions,
- snowSetDisplayOption,
- 0, /*snowGetScreenOptions */
- 0, /*snowSetScreenOption */
+ starsGetDisplayOptions,
+ starsSetDisplayOption,
+ 0, /*starsGetScreenOptions */
+ 0, /*starsSetScreenOption */
+ starDeps,
+ sizeof(starDeps) / sizeof(starDeps[0]),
0,
- snowDeps,
- sizeof(snowDeps) / sizeof(snowDeps[0]),
0,
- 0,
BERYL_ABI_INFO,
- "beryl-plugins-unsupported",
+ "beryl-plugins-extra",
"misc",
0,
0,
@@ -1043,5 +923,5 @@
CompPluginVTable *getCompPluginInfo(void)
{
- return &snowVTable;
+ return &starsVTable;
}