Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:X0F:HSF
xscreensaver
xscreensaver-glmatrix-boost-definition.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xscreensaver-glmatrix-boost-definition.patch of Package xscreensaver
From a990fba1192ee50bfb99942d1a5eaf33c4c6f42e Mon Sep 17 00:00:00 2001 From: v-fox <virtuousfox@gmail.com> Date: Sat, 24 Aug 2024 00:32:43 +0500 Subject: [PATCH] glmatrix: boost definition --- hacks/config/glmatrix.xml | 16 ++++- hacks/glx/glmatrix.c | 147 ++++++++++++++++++++++---------------- hacks/xlockmore.c | 8 ++- 3 files changed, 105 insertions(+), 66 deletions(-) diff --git a/hacks/config/glmatrix.xml b/hacks/config/glmatrix.xml index e05456e..b2204e1 100644 --- a/hacks/config/glmatrix.xml +++ b/hacks/config/glmatrix.xml @@ -13,13 +13,27 @@ <number id="density" type="slider" arg="--density %" _label="Glyph density" _low-label="Sparse" _high-label="Dense" - low="0" high="100" default="20"/> + low="0" high="200" default="20"/> <number id="speed" type="slider" arg="--speed %" _label="Glyph speed" _low-label="Slow" _high-label="Fast" low="0.1" high="8.0" default="1.0" convert="ratio"/> + <!-- this fucking thing just does not want to work: + <number id="gsize" type="slider" arg="-\-gsize %" + _label="Grid size" _low-label="Small" _high-label="Big" + low="70" high="512" default="224"/> + + <number id="gdepth" type="slider" arg="-\-gdepth %" + _label="Grid depth" _low-label="Shallow" _high-label="Deep" + low="35" high="512" default="192"/> + + <number id="wsize" type="slider" arg="-\-wsize %" + _label="Wave size" _low-label="Small" _high-label="Big" + low="22" high="128" default="48"/> + --> + <select id="mode"> <option id="matrix" _label="Matrix encoding"/> <option id="binary" _label="Binary encoding" arg-set="--mode binary"/> diff --git a/hacks/glx/glmatrix.c b/hacks/glx/glmatrix.c index 1c85a07..afec7dd 100644 --- a/hacks/glx/glmatrix.c +++ b/hacks/glx/glmatrix.c @@ -43,7 +43,14 @@ #define DEF_MODE "Matrix" #define DEF_COLOR "Green" #define DEF_TIMEFMT " %l%M%p " - +/* this fucking thing just does not want to work: */ +#define DEF_GRID_SIZE 224 /* width and height of the arena in 70-512 range */ +#define DEF_GRID_DEPTH 192 /* depth of the arena in 35-512 range */ +#define DEF_WAVE_SIZE 48 /* periodicity of color (brightness) waves in 22-128 range */ +#define GRID_SIZE_MAX DEF_GRID_SIZE /* should be 512 */ +#define GRID_DEPTH_MAX DEF_GRID_DEPTH /* should be 512 */ +#define WAVE_SIZE_MAX DEF_WAVE_SIZE /* should be 128 */ +#define SPLASH_RATIO 0.8 /* ratio of grid_depth where chars hit the screen */ #define CHAR_COLS 16 #define CHAR_ROWS 13 @@ -93,11 +100,6 @@ static const unsigned char char_map[256] = { /* #define DEBUG */ -#define GRID_SIZE 70 /* width and height of the arena */ -#define GRID_DEPTH 35 /* depth of the arena */ -#define WAVE_SIZE 22 /* periodicity of color (brightness) waves */ -#define SPLASH_RATIO 0.7 /* ratio of GRID_DEPTH where chars hit the screen */ - static const struct { GLfloat x, y; } nice_views[] = { { 0, 0 }, { 0, -20 }, /* this is a list of viewer rotations that look nice. */ @@ -118,7 +120,6 @@ static const struct { GLfloat x, y; } nice_views[] = { { 0, 0 }, }; - typedef struct { GLfloat x, y, z; /* position of strip */ GLfloat dx, dy, dz; /* velocity of strip */ @@ -129,12 +130,12 @@ typedef struct { GLfloat spinner_y; /* where on the strip the bottom glyph is */ GLfloat spinner_speed; /* how fast the bottom glyph drops */ - int glyphs[GRID_SIZE]; /* the other glyphs on the strip, which will be + int glyphs[GRID_SIZE_MAX]; /* the other glyphs on the strip, which will be revealed by the dropping spinner. 0 means no glyph; negative means "spinner". If non-zero, real value is abs(G)-1. */ - Bool highlight[GRID_SIZE]; + Bool highlight[GRID_SIZE_MAX]; /* some glyphs may be highlighted */ int spin_speed; /* Rotate all spinners every this-many frames */ @@ -165,7 +166,7 @@ typedef struct { int track_tick; int real_char_rows; - GLfloat brightness_ramp[WAVE_SIZE]; + GLfloat brightness_ramp[WAVE_SIZE_MAX]; } matrix_configuration; @@ -173,6 +174,9 @@ static matrix_configuration *mps = NULL; static GLfloat speed; static GLfloat density; +static int grid_size = DEF_GRID_SIZE; +static int grid_depth = DEF_GRID_DEPTH; +static int wave_size = DEF_WAVE_SIZE; static Bool do_clock; static char *timefmt; static Bool do_fog; @@ -182,6 +186,13 @@ static Bool do_texture; static char *mode_str; static char *color_str; +/* + this fucking thing just does not want to work: + { "-gsize", ".gsize", XrmoptionSepArg, 0 }, + { "-gdepth", ".gdepth", XrmoptionSepArg, 0 }, + { "-wsize", ".wsize", XrmoptionSepArg, 0 }, +*/ + static XrmOptionDescRec opts[] = { { "-speed", ".speed", XrmoptionSepArg, 0 }, { "-density", ".density", XrmoptionSepArg, 0 }, @@ -206,6 +217,13 @@ static XrmOptionDescRec opts[] = { {"+texture", ".texture", XrmoptionNoArg, "False" }, }; +/* + this fucking thing just does not want to work: + {&grid_size, "gsize", "GridSize", DEF_GRID_SIZE, t_Int}, + {&grid_depth, "gdepth", "GridDepth", DEF_GRID_DEPTH, t_Int}, + {&wave_size, "wsize", "WaveSize", DEF_WAVE_SIZE, t_Int}, +*/ + static argtype vars[] = { {&mode_str, "mode", "Mode", DEF_MODE, t_String}, {&color_str, "color", "Color", DEF_COLOR, t_String}, @@ -221,7 +239,6 @@ static argtype vars[] = { ENTRYPOINT ModeSpecOpt matrix_opts = {countof(opts), opts, countof(vars), vars, NULL}; - /* Re-randomize the state of one strip. */ static void @@ -232,9 +249,9 @@ reset_strip (ModeInfo *mi, strip *s) Bool time_displayed_p = False; /* never display time twice in one strip */ memset (s, 0, sizeof(*s)); - s->x = (GLfloat) (frand(GRID_SIZE) - (GRID_SIZE/2)); - s->y = (GLfloat) (GRID_SIZE/2 + BELLRAND(0.5)); /* shift top slightly */ - s->z = (GLfloat) (GRID_DEPTH * 0.2) - frand (GRID_DEPTH * 0.7); + s->x = (GLfloat) (frand(grid_size) - (grid_size/2)); + s->y = (GLfloat) (grid_size/2 + BELLRAND(0.5)); /* shift top slightly */ + s->z = (GLfloat) (grid_depth * 0.2) - frand (grid_depth * 0.7); s->spinner_y = 0; s->dx = 0; @@ -251,11 +268,11 @@ reset_strip (ModeInfo *mi, strip *s) s->wave_speed = (int) BELLRAND(3.0 / speed) + 1; s->wave_tick = 0; - for (i = 0; i < GRID_SIZE; i++) + for (i = 0; i < grid_size; i++) if (do_clock && !time_displayed_p && - (i < GRID_SIZE-5) && /* display approx. once per 5 strips */ - !(random() % ((GRID_SIZE-5)*5))) + (i < grid_size-5) && /* display approx. once per 5 strips */ + !(random() % ((grid_size-5)*5))) { int j; char text[80]; @@ -264,7 +281,7 @@ reset_strip (ModeInfo *mi, strip *s) strftime (text, sizeof(text)-1, timefmt, tm); /* render time into the strip */ - for (j = 0; j < strlen(text) && i < GRID_SIZE; j++, i++) + for (j = 0; j < strlen(text) && i < grid_size; j++, i++) { s->glyphs[i] = char_map [((unsigned char *) text)[j]] + 1; s->highlight[i] = True; @@ -303,14 +320,14 @@ tick_strip (ModeInfo *mi, strip *s) s->y += s->dy; s->z += s->dz; - if (s->z > GRID_DEPTH * SPLASH_RATIO) /* splashed into screen */ + if (s->z > grid_depth * SPLASH_RATIO) /* splashed into screen */ { reset_strip (mi, s); return; } s->spinner_y += s->spinner_speed; - if (s->spinner_y >= GRID_SIZE) + if (s->spinner_y >= grid_size) { if (s->erasing_p) { @@ -331,7 +348,7 @@ tick_strip (ModeInfo *mi, strip *s) { s->spin_tick = 0; s->spinner_glyph = - (mp->glyph_map[(random() % mp->nglyphs)] + 1); - for (i = 0; i < GRID_SIZE; i++) + for (i = 0; i < grid_size; i++) if (s->glyphs[i] < 0) { s->glyphs[i] = -(mp->glyph_map[(random() % mp->nglyphs)] + 1); @@ -346,7 +363,7 @@ tick_strip (ModeInfo *mi, strip *s) { s->wave_tick = 0; s->wave_position++; - if (s->wave_position >= WAVE_SIZE) + if (s->wave_position >= wave_size) s->wave_position = 0; } } @@ -371,7 +388,7 @@ draw_glyph (ModeInfo *mi, int glyph, Bool highlight, if (glyph < 0) glyph = -glyph; if (spinner_p) - brightness *= 1.5; + brightness *= 2.25; if (!do_texture) { @@ -390,7 +407,7 @@ draw_glyph (ModeInfo *mi, int glyph, Bool highlight, if (do_fog) { GLfloat depth; - depth = (z / GRID_DEPTH) + 0.5; /* z ratio from back/front */ + depth = (z / grid_depth) + 0.5; /* z ratio from back/front */ depth = 0.2 + (depth * 0.8); /* scale to range [0.2 - 1.0] */ brightness *= depth; /* so no row goes all black. */ } @@ -400,10 +417,16 @@ draw_glyph (ModeInfo *mi, int glyph, Bool highlight, GLfloat r, g, b, a; if (highlight) - brightness *= 2; + brightness *= 3; if (!do_texture && !spinner_p) - r = b = 0, g = 1; + { + if (!color_str || !*color_str || !strcasecmp(color_str, "g") || + !strcasecmp (color_str, "green")) + r = b = 0, g = 1; + else + g = b = 0, r = 1; + } else r = g = b = 1; @@ -413,14 +436,14 @@ draw_glyph (ModeInfo *mi, int glyph, Bool highlight, and is about to splash into the screen and vanish) then start fading it out, proportional to how close to the glass it is. */ - if (z > GRID_DEPTH/2) + if (z > grid_depth/2) { - GLfloat ratio = ((z - GRID_DEPTH/2) / - ((GRID_DEPTH * SPLASH_RATIO) - GRID_DEPTH/2)); - int i = ratio * WAVE_SIZE; + GLfloat ratio = ((z - grid_depth/2) / + ((grid_depth * SPLASH_RATIO) - grid_depth/2)); + int i = ratio * wave_size; if (i < 0) i = 0; - else if (i >= WAVE_SIZE) i = WAVE_SIZE-1; + else if (i >= wave_size) i = wave_size-1; a *= mp->brightness_ramp[i]; } @@ -457,7 +480,7 @@ draw_strip (ModeInfo *mi, strip *s) { matrix_configuration *mp = &mps[MI_SCREEN(mi)]; int i; - for (i = 0; i < GRID_SIZE; i++) + for (i = 0; i < grid_size; i++) { int g = s->glyphs[i]; Bool below_p = (s->spinner_y >= i); @@ -469,11 +492,11 @@ draw_strip (ModeInfo *mi, strip *s) { GLfloat brightness; if (!do_waves) - brightness = 1.0; + brightness = 1.25; else { - int j = WAVE_SIZE - ((i + (GRID_SIZE - s->wave_position)) - % WAVE_SIZE); + int j = wave_size - ((i + (grid_size - s->wave_position)) + % wave_size); brightness = mp->brightness_ramp[j]; } @@ -913,9 +936,9 @@ init_matrix (ModeInfo *mi) load_textures (mi, flip_p); /* to scale coverage-percent to strips, this number looks about right... */ - mp->nstrips = (int) (density * 2.2); + mp->nstrips = (int) (density * 4.0); if (mp->nstrips < 1) mp->nstrips = 1; - else if (mp->nstrips > 2000) mp->nstrips = 2000; + else if (mp->nstrips > 4096) mp->nstrips = 4096; mp->strips = calloc (mp->nstrips, sizeof(strip)); @@ -930,15 +953,15 @@ init_matrix (ModeInfo *mi) As these die off at random speeds and are re-created, we'll get a more consistent density. */ s->erasing_p = True; - s->spinner_y = frand(GRID_SIZE); + s->spinner_y = frand(grid_size); memset (s->glyphs, 0, sizeof(s->glyphs)); /* no visible glyphs */ } /* Compute the brightness ramp. */ - for (i = 0; i < WAVE_SIZE; i++) + for (i = 0; i < wave_size; i++) { - GLfloat j = ((WAVE_SIZE - i) / (GLfloat) (WAVE_SIZE - 1)); + GLfloat j = ((wave_size - i) / (GLfloat) (wave_size - 1)); j *= (M_PI / 2); /* j ranges from 0.0 - PI/2 */ j = sin (j); /* j ranges from 0.0 - 1.0 */ j = 0.2 + (j * 0.8); /* j ranges from 0.2 - 1.0 */ @@ -965,36 +988,36 @@ draw_grid (ModeInfo *mi) glColor3f(1, 1, 1); glBegin(GL_LINES); - glVertex3f(-GRID_SIZE, 0, 0); glVertex3f(GRID_SIZE, 0, 0); - glVertex3f(0, -GRID_SIZE, 0); glVertex3f(0, GRID_SIZE, 0); + glVertex3f(-grid_size, 0, 0); glVertex3f(grid_size, 0, 0); + glVertex3f(0, -grid_size, 0); glVertex3f(0, grid_size, 0); glEnd(); glBegin(GL_LINE_LOOP); - glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, 0); - glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, 0); - glVertex3f( GRID_SIZE/2, GRID_SIZE/2, 0); - glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, 0); + glVertex3f(-grid_size/2, -grid_size/2, 0); + glVertex3f(-grid_size/2, grid_size/2, 0); + glVertex3f( grid_size/2, grid_size/2, 0); + glVertex3f( grid_size/2, -grid_size/2, 0); glEnd(); glBegin(GL_LINE_LOOP); - glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2); + glVertex3f(-grid_size/2, grid_size/2, -grid_depth/2); + glVertex3f(-grid_size/2, grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, grid_size/2, -grid_depth/2); glEnd(); glBegin(GL_LINE_LOOP); - glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2); + glVertex3f(-grid_size/2, -grid_size/2, -grid_depth/2); + glVertex3f(-grid_size/2, -grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, -grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, -grid_size/2, -grid_depth/2); glEnd(); glBegin(GL_LINES); - glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f(-GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f(-GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, GRID_SIZE/2, -GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, -GRID_SIZE/2, GRID_DEPTH/2); - glVertex3f( GRID_SIZE/2, GRID_SIZE/2, GRID_DEPTH/2); + glVertex3f(-grid_size/2, -grid_size/2, -grid_depth/2); + glVertex3f(-grid_size/2, grid_size/2, -grid_depth/2); + glVertex3f(-grid_size/2, -grid_size/2, grid_depth/2); + glVertex3f(-grid_size/2, grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, -grid_size/2, -grid_depth/2); + glVertex3f( grid_size/2, grid_size/2, -grid_depth/2); + glVertex3f( grid_size/2, -grid_size/2, grid_depth/2); + glVertex3f( grid_size/2, grid_size/2, grid_depth/2); glEnd(); glPopMatrix(); if (!MI_IS_WIREFRAME(mi)) diff --git a/hacks/xlockmore.c b/hacks/xlockmore.c index 2b513dd..b5729a3 100644 --- a/hacks/xlockmore.c +++ b/hacks/xlockmore.c @@ -25,6 +25,7 @@ #include <assert.h> #include <float.h> +#include <stdint.h> #define MAX_COLORS (1L<<13) @@ -156,7 +157,7 @@ xlockmore_setup (struct xscreensaver_function_table *xsft, void *arg) */ i = 0; - new_defaults = (char **) calloc (1, xlockmore_opts->numvarsdesc * 10 + 1000); + new_defaults = (char **) calloc (1, xlockmore_opts->numvarsdesc * 10 + 1536); /* Put on the PROGCLASS.background/foreground resources. */ s = (char *) malloc(50); @@ -191,8 +192,9 @@ xlockmore_setup (struct xscreensaver_function_table *xsft, void *arg) const char *def = xlockmore_opts->vars[j].def; if (!def) abort(); - if (!*def) abort(); - if (strlen(def) > 1000) abort(); + // this thing blows-up addition of new params for incomprehensible reason + //if (!*def) abort(); + if (strlen(def) > 2048) abort(); s = (char *) malloc (strlen (xlockmore_opts->vars[j].name) + strlen (def) + 10); -- 2.46.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor