static Bool stepPositions(void *closure) { CompScreen *s = closure; int i, ii, numSnow, numAutumn, numStars, numFf, numBubbles, numTmp; element *ele; Bool onTopOfWindows; E_SCREEN(s); Bool active = FALSE; //THis makes sure nothing happens if all features are off. for (ii = 0; ii <= 4; ii++) { if (eScreen->isActive[ii]) active = TRUE; } if (!active) return TRUE; ele = eScreen->allElements; if (eScreen->isActive[0]) numAutumn = elementsGetNumLeaves (s->display); else numAutumn = 0; if (eScreen->isActive[1]) numFf = elementsGetNumFireflies (s->display); else numFf = 0; if (eScreen->isActive[2]) numSnow = elementsGetNumSnowflakes (s->display); else numSnow = 0; if (eScreen->isActive[3]) numStars = elementsGetNumStars (s->display); else numStars = 0; if (eScreen->isActive[4]) numBubbles = elementsGetNumBubbles (s->display); else numBubbles = 0; numTmp = numAutumn + numFf + numSnow + numStars + numBubbles; onTopOfWindows = elementsGetOverWindows (s->display); for (i = 0; i < numTmp; i++) elementTestCreate(eScreen, ele++); if (active && !onTopOfWindows ) { CompWindow *w; for (w = s->windows; w; w = w->next) { if (w->type & CompWindowTypeDesktopMask) addWindowDamage (w); } } else if (active) damageScreen (s); return TRUE;
static Bool stepPositions(CompScreen *s, int elapsed) { int i, numSnow, numAutumn, numStars, numFf, numBubbles, numTmp; element *ele; Bool onTopOfWindows; Bool active = elementActive(s); E_SCREEN(s); if (!active) return TRUE; ele = eScreen->allElements; if (eScreen->isActive[0]) numAutumn = elementsGetNumLeaves (s->display); else numAutumn = 0; if (eScreen->isActive[1]) numFf = elementsGetNumFireflies (s->display); else numFf = 0; if (eScreen->isActive[2]) numSnow = elementsGetNumSnowflakes (s->display); else numSnow = 0; if (eScreen->isActive[3]) numStars = elementsGetNumStars (s->display); else numStars = 0; if (eScreen->isActive[4]) numBubbles = elementsGetNumBubbles (s->display); else numBubbles = 0; numTmp = numAutumn + numFf + numSnow + numStars + numBubbles; onTopOfWindows = elementsGetOverWindows (s->display); for (i = 0; i < numTmp; i++) elementTestCreate(eScreen, ele++, elapsed); if (active) { CompWindow *w; for (w = s->windows; w; w = w->next) { if (!onTopOfWindows && (w->type & CompWindowTypeDesktopMask)) addWindowDamage (w); else if (onTopOfWindows && isNormalWin(w)) { eScreen->topWindow = w; addWindowDamage (w); } } damageScreen (s); } return TRUE; }
static void updateElementTextures (CompScreen *s, Bool changeTextures) { int i, count = 0; float autumnSize = elementsGetLeafSize(s->display); float ffSize = elementsGetFireflySize(s->display); float snowSize = elementsGetSnowSize(s->display); float starsSize = elementsGetStarsSize(s->display); float bubblesSize = elementsGetBubblesSize(s->display); element *ele; E_SCREEN (s); E_DISPLAY (s->display); int numAutumn, numFf, numSnow, numStars, numBubbles; if (eScreen->isActive[0]) numAutumn = elementsGetNumLeaves (s->display); else numAutumn = 0; if (eScreen->isActive[1]) numFf = elementsGetNumFireflies (s->display); else numFf = 0; if (eScreen->isActive[2]) numSnow = elementsGetNumSnowflakes (s->display); else numSnow = 0; if (eScreen->isActive[3]) numStars = elementsGetNumStars (s->display); else numStars = 0; if (eScreen->isActive[4]) numBubbles = elementsGetNumBubbles (s->display); else numBubbles = 0; ele = eScreen->allElements; if (changeTextures) { for (i = 0; i < eScreen->numElements; i++) { finiTexture (s, &eScreen->textu[i].tex); glDeleteLists (eScreen->textu[i].dList, 1); } if (eScreen->textu) free (eScreen->textu); eScreen->numElements = 0; eScreen->numTexLoaded[0] = 0; eScreen->numTexLoaded[1] = 0; eScreen->numTexLoaded[2] = 0; eScreen->numTexLoaded[3] = 0; eScreen->numTexLoaded[4] = 0; eScreen->textu = calloc (1, sizeof (texture) * (ed->numTex[0] + ed->numTex[1] + ed->numTex[2] + ed->numTex[3] + ed->numTex[4])); } for (i = 0; i < ed->numTex[0]; i++) { CompMatrix *mat; texture *aTex; if (changeTextures) { eScreen->textu[count].loaded = readImageToTexture (s, &eScreen->textu[count].tex, ed->texFiles[0][i].s, &eScreen->textu[count].width, &eScreen->textu[count].height); if (!eScreen->textu[count].loaded) { compLogMessage ("Elements", CompLogLevelWarn, "Texture (Autumn) not found : %s", ed->texFiles[0][i].s); continue; } compLogMessage ("Elements", CompLogLevelInfo, "Loaded Texture (Autumn)%s", ed->texFiles[0][i].s); } mat = &eScreen->textu[count].tex.matrix; aTex = &eScreen->textu[count]; aTex->dList = glGenLists (1); glNewList (aTex->dList, GL_COMPILE); 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, aTex->height)); glVertex2f (0, autumnSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, aTex->height)); glVertex2f (autumnSize, autumnSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, 0)); glVertex2f (autumnSize, 0); glEnd (); glEndList (); count++; } if (changeTextures) eScreen->numTexLoaded[0] = count; for (i = 0; i < ed->numTex[1]; i++) { CompMatrix *mat; texture *aTex; if (changeTextures) { eScreen->textu[count].loaded = readImageToTexture (s, &eScreen->textu[count].tex, ed->texFiles[1][i].s, &eScreen->textu[count].width, &eScreen->textu[count].height); if (!eScreen->textu[count].loaded) { compLogMessage ("Elements", CompLogLevelWarn, "Texture (Firefly) not found : %s", ed->texFiles[1][i].s); continue; } compLogMessage ("Elements", CompLogLevelInfo, "Loaded Texture (Firefly) %s", ed->texFiles[1][i].s); } mat = &eScreen->textu[count].tex.matrix; aTex = &eScreen->textu[count]; aTex->dList = glGenLists (1); glNewList (aTex->dList, GL_COMPILE); 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, aTex->height)); glVertex2f (0, ffSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, aTex->height)); glVertex2f (ffSize, ffSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, 0)); glVertex2f (ffSize, 0); glEnd (); glEndList (); count++; } if (changeTextures) eScreen->numTexLoaded[1] = count - eScreen->numTexLoaded[0]; for (i = 0; i < ed->numTex[2]; i++) { CompMatrix *mat; texture *aTex; if (changeTextures) { eScreen->textu[count].loaded = readImageToTexture (s, &eScreen->textu[count].tex, ed->texFiles[2][i].s, &eScreen->textu[count].width, &eScreen->textu[count].height); if (!eScreen->textu[count].loaded) { compLogMessage ("Elements", CompLogLevelWarn, "Texture (snow) not found : %s", ed->texFiles[2][i].s); continue; } compLogMessage ("Elements", CompLogLevelInfo, "Loaded Texture (snow) %s", ed->texFiles[2][i].s); } mat = &eScreen->textu[count].tex.matrix; aTex = &eScreen->textu[count]; aTex->dList = glGenLists (1); glNewList (aTex->dList, GL_COMPILE); 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, aTex->height)); glVertex2f (0, snowSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, aTex->height)); glVertex2f (snowSize, snowSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, 0)); glVertex2f (snowSize, 0); glEnd (); glEndList (); count++; } if (changeTextures) eScreen->numTexLoaded[2] = count - eScreen->numTexLoaded[0] -eScreen->numTexLoaded[1]; for (i = 0; i < ed->numTex[3]; i++) { CompMatrix *mat; texture *aTex; if (changeTextures) { eScreen->textu[count].loaded = readImageToTexture (s, &eScreen->textu[count].tex, ed->texFiles[3][i].s, &eScreen->textu[count].width, &eScreen->textu[count].height); if (!eScreen->textu[count].loaded) { compLogMessage ("Elements", CompLogLevelWarn, "Texture (stars) not found : %s", ed->texFiles[3][i].s); continue; } compLogMessage ("Elements", CompLogLevelInfo, "Loaded Texture (stars)%s", ed->texFiles[3][i].s); } mat = &eScreen->textu[count].tex.matrix; aTex = &eScreen->textu[count]; aTex->dList = glGenLists (1); glNewList (aTex->dList, GL_COMPILE); 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, aTex->height)); glVertex2f (0, starsSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, aTex->height)); glVertex2f (starsSize, starsSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, 0)); glVertex2f (starsSize, 0); glEnd (); glEndList (); count++; } if (changeTextures) eScreen->numTexLoaded[3] = count - eScreen->numTexLoaded[0] - eScreen->numTexLoaded[1] - eScreen->numTexLoaded[2]; for (i = 0; i < ed->numTex[4]; i++) { CompMatrix *mat; texture *aTex; if (changeTextures) { eScreen->textu[count].loaded = readImageToTexture (s, &eScreen->textu[count].tex, ed->texFiles[4][i].s, &eScreen->textu[count].width, &eScreen->textu[count].height); if (!eScreen->textu[count].loaded) { compLogMessage ("Elements", CompLogLevelWarn, "Texture (bubbles) not found : %s", ed->texFiles[4][i].s); continue; } compLogMessage ("Elements", CompLogLevelInfo, "Loaded Texture (bubbles)%s", ed->texFiles[4][i].s); } mat = &eScreen->textu[count].tex.matrix; aTex = &eScreen->textu[count]; aTex->dList = glGenLists (1); glNewList (aTex->dList, GL_COMPILE); 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, aTex->height)); glVertex2f (0, bubblesSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, aTex->height)); glVertex2f (bubblesSize, bubblesSize * aTex->height / aTex->width); glTexCoord2f (COMP_TEX_COORD_X (mat, aTex->width), COMP_TEX_COORD_Y (mat, 0)); glVertex2f (bubblesSize, 0); glEnd (); glEndList (); count++; } if (changeTextures) { eScreen->numTexLoaded[4] = count - eScreen->numTexLoaded[0] - eScreen->numTexLoaded[1] - eScreen->numTexLoaded[2] - eScreen->numTexLoaded[3]; // if (count < (ed->numTex[0] + ed->numTex[1] + ed->numTex[2] + ed->numTex[3] + ed->numTex[4])) eScreen->textu = realloc (eScreen->textu, sizeof (texture) * count); eScreen->numElements = count; for (i = 0; i < (numAutumn + numFf + numSnow + numStars + numBubbles); i++) setElementTexture (eScreen, ele++); } }
static void beginRendering (CompScreen *s) { int j; E_SCREEN (s); glEnable (GL_BLEND); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (eScreen->needUpdate) { setupDisplayList (eScreen); eScreen->needUpdate = FALSE; } glColor4f (1.0, 1.0, 1.0, 1.0); for (j = 0; j < eScreen->numElements; j++) { element *ele = eScreen->allElements; int i, numAutumn, numFf, numSnow, numStars, numBubbles; if (eScreen->isActive[0]) numAutumn = elementsGetNumLeaves (s->display); else numAutumn = 0; if (eScreen->isActive[1]) numFf = elementsGetNumFireflies (s->display); else numFf = 0; if (eScreen->isActive[2]) numSnow = elementsGetNumSnowflakes (s->display); else numSnow = 0; if (eScreen->isActive[3]) numStars = elementsGetNumStars (s->display); else numStars = 0; if (eScreen->isActive[4]) numBubbles = elementsGetNumBubbles (s->display); else numBubbles = 0; int numTmp = numAutumn + numFf + numSnow + numStars + numBubbles; Bool autumnRotate = elementsGetAutumnRotate (s->display); Bool snowRotate = elementsGetSnowRotate (s->display); Bool ffRotate = elementsGetFirefliesRotate (s->display); Bool starsRotate = elementsGetStarsRotate (s->display); Bool bubblesRotate = elementsGetBubblesRotate (s->display); enableTexture (eScreen->cScreen, &eScreen->textu[j].tex, COMP_TEXTURE_FILTER_GOOD); for (i = 0; i < numTmp; i++) { if (ele->eTex == &eScreen->textu[j]) { glTranslatef (ele->x, ele->y, ele->z); if (autumnRotate && ele->type == 0) glRotatef (ele->rAngle, 0, 0, 1); if (ffRotate && ele->type == 1) glRotatef (ele->rAngle, 0, 0, 1); if (snowRotate && ele->type == 2) glRotatef (ele->rAngle, 0, 0, 1); if (starsRotate && ele->type == 3) glRotatef (ele->rAngle, 0, 0, 1); if (bubblesRotate && ele->type == 4) glRotatef (ele->rAngle, 0, 0, 1); glCallList (eScreen->textu[j].dList); if (autumnRotate && ele->type == 0) glRotatef (-ele->rAngle, 0, 0, 1); if (ffRotate && ele->type == 1) glRotatef (-ele->rAngle, 0, 0, 1); if (snowRotate && ele->type == 2) glRotatef (-ele->rAngle, 0, 0, 1); if (starsRotate && ele->type == 3) glRotatef (-ele->rAngle, 0, 0, 1); if (bubblesRotate && ele->type == 4) glRotatef (-ele->rAngle, 0, 0, 1); glTranslatef (-ele->x, -ele->y, -ele->z); } ele++; } disableTexture (eScreen->cScreen, &eScreen->textu[j].tex); } glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glDisable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); }
static void createAll( CompDisplay *d ) { CompScreen *s; int i, ii, iii, iv ,v, numAutumn, numFf, numSnow, numStars, numBubbles, numTmp; element *ele; for (s = d->screens; s; s = s->next) { E_SCREEN (s); if (eScreen->isActive[0]) numAutumn = elementsGetNumLeaves (s->display); else numAutumn = 0; if (eScreen->isActive[1]) numFf = elementsGetNumFireflies (s->display); else numFf = 0; if (eScreen->isActive[2]) numSnow = elementsGetNumSnowflakes (s->display); else numSnow = 0; if (eScreen->isActive[3]) numStars = elementsGetNumStars (s->display); else numStars = 0; if (eScreen->isActive[4]) numBubbles = elementsGetNumBubbles (s->display); else numBubbles = 0; numTmp = (numAutumn + numFf + numSnow + numStars + numBubbles); eScreen->allElements = ele = realloc (eScreen->allElements, numTmp * sizeof (element)); ele = eScreen->allElements; for (i = 0; i < numAutumn; i++) { ele->type = 0; initiateElement (eScreen, ele); setElementTexture (eScreen, ele); ele++; } for (ii = 0; ii < numFf; ii++) { ele->type = 1; initiateElement (eScreen, ele); setElementTexture (eScreen, ele); ele++; } for (iii = 0; iii < numSnow; iii++) { ele->type = 2; initiateElement (eScreen, ele); setElementTexture (eScreen, ele); ele++; } for (iv = 0; iv < numStars; iv++) { ele->type = 3; initiateElement (eScreen, ele); setElementTexture (eScreen, ele); ele++; } for (v = 0; v < numBubbles; v++) { ele->type = 4; initiateElement (eScreen, ele); setElementTexture (eScreen, ele); ele++; } } }