- Copy base.xml to /usr/share/xscreensaver/config
- Copy the compiled base.c (named "base") to /usr/libexec/xscreensaver
- Add "GL: base -root\n" to programs in .xscreensaver in your home directory.
Last active
September 6, 2018 11:11
-
-
Save pendingchaos/d63035873cd8f4afe3a0 to your computer and use it in GitHub Desktop.
Base XScreensaver hack or screensaver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Compile with: | |
gcc -pedantic -Wall -Wstrict-prototypes -Wnested-externs -Wmissing-prototypes -Wno-overlength-strings -Wdeclaration-after-statement -std=c89 -U__STRICT_ANSI__ -I../../utils -I../ -I../../ -DSTANDALONE -DUSE_GL -DHAVE_CONFIG_H -g base.c ../fps.c fps-gl.c ../../utils/resources.c ../../utils/visual.c ../../utils/visual-gl.c ../../utils/usleep.c ../../utils/yarandom.c ../../utils/hsv.c ../../utils/colors.c ../../utils/async_netdb.c ../../utils/aligned_malloc.c ../../utils/thread_util.c ../../utils/utf8wc.c ../screenhack.c ../xlockmore.c xlock-gl-utils.c texfont.c -o base -lGL -lGLU -lXxf86vm -lpthread -lSM -lICE -lXft -lXt -lX11 -lXmu -lXext -lm `freetype-config --libs --cflags` | |
Assuming the current working directory is <xscreensaver directory>/hacks/glx and base.c is stored there.*/ | |
#define DEFAULTS "*delay: 30000\n"\ | |
"*showFPS: False\n" | |
#include "xlockmore.h" | |
#ifdef USE_GL | |
typedef struct { | |
GLXContext *glx_context; | |
} base_configuration; | |
static base_configuration *confs = NULL; | |
/*static XrmOptionDescRec opts[] = {};*/ | |
/*static argtype vars[] = {};*/ | |
ENTRYPOINT ModeSpecOpt base_opts = {/*sizeof(opts)/sizeof(XrmOptionDescRec), opts,*/ | |
/*sizeof(vars)/sizeof(argtype), vars,*/ | |
0, NULL, | |
0, NULL, | |
NULL}; | |
ENTRYPOINT void reshape_base(ModeInfo *mi, int width, int height) { | |
base_configuration* conf = confs + MI_SCREEN(mi); | |
} | |
ENTRYPOINT void refresh_base(ModeInfo *mi) { | |
base_configuration* conf = confs + MI_SCREEN(mi); | |
} | |
ENTRYPOINT void release_base(ModeInfo *mi) { | |
base_configuration* conf = confs + MI_SCREEN(mi); | |
} | |
ENTRYPOINT Bool base_handle_event(ModeInfo *mi, XEvent *event) { | |
base_configuration* conf = confs + MI_SCREEN(mi); | |
return False; /*The event was not handled*/ | |
} | |
ENTRYPOINT void init_base(ModeInfo *mi) { | |
base_configuration* conf; | |
if (!confs) | |
confs = malloc(MI_NUM_SCREENS(mi)*sizeof(base_configuration)); | |
if (!confs) { | |
fprintf(stderr, "%s: out of memory\n", progname); | |
exit(1); | |
} | |
conf = confs + MI_SCREEN(mi); | |
conf->glx_context = init_GL(mi); | |
reshape_base(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); | |
} | |
ENTRYPOINT void draw_base(ModeInfo *mi) { | |
base_configuration* conf = confs + MI_SCREEN(mi); | |
Display* dpy = MI_DISPLAY(mi); | |
Window window = MI_WINDOW(mi); | |
if (!conf->glx_context) | |
return; | |
glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(conf->glx_context)); | |
glClearColor(1.0f, 0.5f, 0.5f, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT); | |
if (mi->fps_p) | |
do_fps(mi); | |
glFinish(); | |
glXSwapBuffers(dpy, window); | |
} | |
XSCREENSAVER_MODULE("Base", base) | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<screensaver name="base" _label="Base" gl="yes"> | |
<command arg="-root"/> | |
<number id="delay" type="slider" arg="-delay %" | |
_label="Frame rate" _low-label="Low" | |
_high-label="High" low="0" high="100000" | |
default="30000" convert="invert"/> | |
<boolean id="showfps" _label="Show frame rate" arg-set="-fps"/> | |
<xscreensaver-updater/> | |
<_description>A very basic OpenGL screensaver.</_description> | |
</screensaver> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment