data = createFunctionData (); if (data) { Bool ok = TRUE; int handle = 0; char str[1024]; ok &= addTempHeaderOpToFunctionData (data, "image"); ok &= addTempHeaderOpToFunctionData (data, "tmp"); ok &= addFetchOpToFunctionData (data, "output", NULL, target); ok &= addColorOpToFunctionData (data, "output", "output"); snprintf (str, 1024, "MUL tmp, fragment.position, program.env[%d];" , param); ok &= addDataOpToFunctionData (data, str); snprintf (str, 1024, "TEX image, tmp, texture[%d], %s;", unit, targetString); ok &= addDataOpToFunctionData (data, str); if (!ok) { destroyFunctionData (data); return 0; } handle = createFragmentFunction (s, "reflex", data); rs->function = handle; destroyFunctionData (data); return handle; } return 0; } static void reflexScreenOptionChanged (CompScreen * s, CompOption * opt, ReflexScreenOptions num) { REFLEX_SCREEN (s); switch (num) { case ReflexScreenOptionFile: if (rs->imageLoaded) { finiTexture (s, &rs->image); initTexture (s, &rs->image); } rs->imageLoaded = readImageToTexture (s, &rs->image, reflexGetFile (s), &rs->width, &rs->height); damageScreen (s); break; default: damageScreen (s); break; } } static void reflexDrawWindowTexture (CompWindow * w, CompTexture * texture, const FragmentAttrib * attrib, unsigned int mask) { CompScreen *s = w->screen; REFLEX_SCREEN (s); Bool enabled = (texture == w->texture) ? reflexGetWindow (s) : reflexGetDecoration (s); if (enabled && matchEval (reflexGetMatch (s), w) && rs->imageLoaded && w->screen->fragmentProgram) { FragmentAttrib fa = *attrib; int function; int unit = 0; int param; float tx, ty, dx, mx; mx = w->attrib.x + (w->width / 2); mx /= s->width / 2.0; mx -= 1.0; mx *= -0.065; if (rs->image.target == GL_TEXTURE_2D) { tx = 1.0 / s->width; ty = 1.0 / s->height; dx = mx; } else { tx = 1.0 / s->width * rs->width; ty = 1.0 / s->height * rs->height; dx = mx * rs->width; } unit = allocFragmentTextureUnits (&fa, 1); param = allocFragmentParameters (&fa, 1); function = getReflexFragmentFunction (w->screen, texture, param, unit); if (function) { addFragmentFunction (&fa, function); (*s->activeTexture) (GL_TEXTURE0_ARB + unit); enableTexture (s, &rs->image, COMP_TEXTURE_FILTER_GOOD); (*s->activeTexture) (GL_TEXTURE0_ARB); (*s->programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param, 1.0, 1.0, 0.0f, 0.0f); }