Skip to content

Instantly share code, notes, and snippets.

@krkhan
Created May 21, 2021 14:26
Show Gist options
  • Save krkhan/51b82f4fd55112754157fe02cbf375ba to your computer and use it in GitHub Desktop.
Save krkhan/51b82f4fd55112754157fe02cbf375ba to your computer and use it in GitHub Desktop.
switch matrix colors
diff '--color=auto' -Naur xscreensaver-6.00/hacks/glx/glmatrix.c xscreensaver-6.00.patched/hacks/glx/glmatrix.c
--- xscreensaver-6.00/hacks/glx/glmatrix.c 2021-02-07 12:15:42.000000000 -0800
+++ xscreensaver-6.00.patched/hacks/glx/glmatrix.c 2021-05-02 17:21:54.254157186 -0700
@@ -213,6 +213,11 @@
{&do_texture, "texture", "Texture", DEF_TEXTURE, t_Bool},
};
+static unsigned char rgb_red = 0xFF;
+static unsigned char rgb_green = 0x00;
+static unsigned char rgb_blue = 0x00;
+static time_t last_color_switch = 0;
+
ENTRYPOINT ModeSpecOpt matrix_opts = {countof(opts), opts, countof(vars), vars, NULL};
@@ -745,6 +750,10 @@
}
}
+ rgb_red = random() % 255;
+ rgb_green = random() % 255;
+ rgb_blue = random() % 255;
+
/* The pixmap is a color image with no transparency. Set the texture's
alpha to be the green channel, and set the green channel to be 100%.
*/
@@ -769,7 +778,9 @@
unsigned char g = (p >> gpos) & 0xFF;
unsigned char b = (p >> bpos) & 0xFF;
unsigned char a = g;
- g = 0xFF;
+ r = rgb_red;
+ g = rgb_green;
+ b = rgb_blue;
p = (r << rpos) | (g << gpos) | (b << bpos) | (a << apos);
XPutPixel (xi, x, y, p);
}
@@ -978,11 +989,17 @@
matrix_configuration *mp = &mps[MI_SCREEN(mi)];
Display *dpy = MI_DISPLAY(mi);
Window window = MI_WINDOW(mi);
+ time_t now = time ((time_t *) 0);
int i;
if (!mp->glx_context)
return;
+ if (now - last_color_switch > 15) {
+ load_textures (mi, 0);
+ last_color_switch = now;
+ }
+
glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *mp->glx_context);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment