static Bool loadImages (CompScreen *s) { MAG_SCREEN (s); if (!s->multiTexCoord2f) return FALSE; ms->overlay.loaded = readImageToTexture (s, &ms->overlay.tex, magGetOverlay (s), &ms->overlay.width, &ms->overlay.height); if (!ms->overlay.loaded) { compLogMessage ("mag", CompLogLevelWarn, "Could not load magnifier overlay image \"%s\"!", magGetOverlay (s)); return FALSE; } ms->mask.loaded = readImageToTexture (s, &ms->mask.tex, magGetMask (s), &ms->mask.width, &ms->mask.height); if (!ms->mask.loaded) { compLogMessage ("mag", CompLogLevelWarn, "Could not load magnifier mask image \"%s\"!", magGetOverlay (s)); ms->overlay.loaded = FALSE; finiTexture (s, &ms->overlay.tex); initTexture (s, &ms->overlay.tex); return FALSE; } if (ms->overlay.width != ms->mask.width || ms->overlay.height != ms->mask.height) { compLogMessage ("mag", CompLogLevelWarn, "Image dimensions do not match!"); ms->overlay.loaded = FALSE; finiTexture (s, &ms->overlay.tex); initTexture (s, &ms->overlay.tex); ms->mask.loaded = FALSE; finiTexture (s, &ms->mask.tex); initTexture (s, &ms->mask.tex); return FALSE; } return TRUE; }
static void updateSnowTextures (CompScreen *s) { int i, count = 0; float snowSize = starGetSnowSize(s->display); int numFlakes = starGetNumSnowflakes(s->display); SnowFlake *snowFlake; SNOW_SCREEN (s); SNOW_DISPLAY (s->display); snowFlake = ss->allSnowFlakes; for (i = 0; i < ss->snowTexturesLoaded; i++) { finiTexture (s, &ss->snowTex[i].tex); glDeleteLists (ss->snowTex[i].dList, 1); } if (ss->snowTex) free (ss->snowTex); ss->snowTexturesLoaded = 0; ss->snowTex = calloc (1, sizeof (SnowTexture) * sd->snowTexNFiles); for (i = 0; i < sd->snowTexNFiles; i++) { CompMatrix *mat; SnowTexture *sTex; 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) { compLogMessage ("snow", CompLogLevelWarn, "Texture not found : %s", sd->snowTexFiles[i].s); continue; } compLogMessage ("snow", CompLogLevelInfo, "Loaded Texture %s", sd->snowTexFiles[i].s); mat = &ss->snowTex[count].tex.matrix; sTex = &ss->snowTex[count]; sTex->dList = glGenLists (1); glNewList (sTex->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, 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); glEnd (); glEndList (); count++; } ss->snowTexturesLoaded = count; if (count < sd->snowTexNFiles) ss->snowTex = realloc (ss->snowTex, sizeof (SnowTexture) * count); for (i = 0; i < numFlakes; i++) setSnowflakeTexture (ss, snowFlake++); }
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++); } }
void updateScreenBackground (CompScreen *screen, CompTexture *texture) { Display *dpy = screen->display->display; Atom pixmapAtom, actualType; int actualFormat, i, status; unsigned int width = 1, height = 1, depth = 0; unsigned long nItems; unsigned long bytesAfter; unsigned char *prop; Pixmap pixmap = 0; pixmapAtom = XInternAtom (dpy, "PIXMAP", FALSE); for (i = 0; pixmap == 0 && i < 2; i++) { status = XGetWindowProperty (dpy, screen->root, screen->display->xBackgroundAtom[i], 0, 4, FALSE, AnyPropertyType, &actualType, &actualFormat, &nItems, &bytesAfter, &prop); if (status == Success && nItems && prop) { if (actualType == pixmapAtom && actualFormat == 32 && nItems == 1) { Pixmap p; memcpy (&p, prop, 4); if (p) { unsigned int ui; int i; Window w; if (XGetGeometry (dpy, p, &w, &i, &i, &width, &height, &ui, &depth)) { if (depth == screen->attrib.depth) pixmap = p; } } } XFree (prop); } } if (!testMode && pixmap) { if (pixmap == texture->pixmap) return; finiTexture (screen, texture); initTexture (screen, texture); if (!bindPixmapToTexture (screen, texture, pixmap, width, height, depth)) { fprintf (stderr, "%s: Couldn't bind background pixmap 0x%x to " "texture\n", programName, (int) pixmap); } } else { finiTexture (screen, texture); initTexture (screen, texture); } if (!texture->name) readImageToTexture (screen, texture, backgroundImage, &width, &height); if (texture->target == GL_TEXTURE_2D) { glBindTexture (texture->target, texture->name); glTexParameteri (texture->target, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture (texture->target, 0); } }
static void updateSnowTextures (CompScreen *s) { const BananaValue * option_snow_size = bananaGetOption (bananaIndex, "snow_size", -1); const BananaValue * option_num_snowflakes = bananaGetOption (bananaIndex, "num_snowflakes", -1); const BananaValue * option_snow_textures = bananaGetOption (bananaIndex, "snow_textures", -1); int i, count = 0; float snowSize = option_snow_size->f; int numFlakes = option_num_snowflakes->i; SnowFlake *snowFlake; SNOW_SCREEN (s); snowFlake = ss->allSnowFlakes; for (i = 0; i < ss->snowTexturesLoaded; i++) { finiTexture (s, &ss->snowTex[i].tex); glDeleteLists (ss->snowTex[i].dList, 1); } if (ss->snowTex) free (ss->snowTex); ss->snowTexturesLoaded = 0; ss->snowTex = calloc (1, sizeof (SnowTexture) * option_snow_textures->list.nItem); for (i = 0; i < option_snow_textures->list.nItem; i++) { CompMatrix *mat; SnowTexture *sTex; ss->snowTex[count].loaded = readImageToTexture (s, &ss->snowTex[count].tex, option_snow_textures->list.item[i].s, &ss->snowTex[count].width, &ss->snowTex[count].height); if (!ss->snowTex[count].loaded) { compLogMessage ("snow", CompLogLevelWarn, "Texture not found : %s", option_snow_textures->list.item[i].s); continue; } compLogMessage ("snow", CompLogLevelInfo, "Loaded Texture %s", option_snow_textures->list.item[i].s); mat = &ss->snowTex[count].tex.matrix; sTex = &ss->snowTex[count]; sTex->dList = glGenLists (1); glNewList (sTex->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, 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); glEnd (); glEndList (); count++; } ss->snowTexturesLoaded = count; if (count < option_snow_textures->list.nItem) ss->snowTex = realloc (ss->snowTex, sizeof (SnowTexture) * count); for (i = 0; i < numFlakes; i++) setSnowflakeTexture (ss, snowFlake++); }