Added signal reloading and legacy makefile support

This commit is contained in:
Jarcode
2019-08-26 20:11:13 -07:00
parent b4cdcb3120
commit 0358143bb7
9 changed files with 10770 additions and 2261 deletions

View File

@@ -1,15 +1,56 @@
.PHONY: all install clean .PHONY: all install clean
# In case these were specified explicitly as options instead of environment variables, export them to child processes
export DESTDIR
export CFLAGS
BUILD_DIR = build
MESON_CONF = $(BUILD_DIR)
# Support assigning standalone/debug builds as the old Makefile did, otherwise complain
ifneq ($(BUILD),debug)
MESON_CONF += --buildtype=release
ifdef BUILD
@echo "WARNING: ignoring build option '$(BUILD)' in compatibility Makefile"
endif
endif
ifeq ($(INSTALL),standalone)
MESON_CONF += -Dstandalone=true
else
ifdef INSTALL
@echo "WARNING: ignoring install option '$(INSTALL)' in compatibility Makefile"
endif
endif
# Store relevant variables that may change depending on the environment or user input
STATE = $(BUILD),$(INSTALL),$(PYTHON),$(CC),$(CFLAGS),$(DESTDIR)
# Only update the file if the contents changed, `make` just looks at the timestamp
$(shell if [[ ! -e build_state ]]; then touch build_state; fi)
$(shell if [ '$(STATE)' != "`cat build_state`" ]; then echo '$(STATE)' > build_state; fi)
ifndef BUILD
@echo ""
@echo "PACKAGE MAINTAINER NOTICE: Configuring release build for compatibility with old makefile."
@echo " If you are a package maintainer consider using meson directly!"
@echo ""
endif
all: ninja all: ninja
build: # Rebuild if the makefile state changes to maintain old behaviour and smooth rebuilds with altered parameters
meson build build: build_state
@rm -rf $(BUILD_DIR)
meson $(BUILD_DIR)
meson configure $(MESON_CONF)
ninja: build ninja: build
ninja -C build ninja -C $(BUILD_DIR)
install: install:
cd build && meson install cd $(BUILD_DIR) && meson install
clean: clean:
rm -rf build rm -rf $(BUILD_DIR)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -73,6 +73,8 @@
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
#endif #endif
static bool reload = false;
/* Copy installed shaders/configuration from the installed location /* Copy installed shaders/configuration from the installed location
(usually /etc/xdg). Modules (folders) will be linked instead of (usually /etc/xdg). Modules (folders) will be linked instead of
copied. */ copied. */
@@ -237,6 +239,14 @@ static void handle_term(int signum) {
} }
} }
static void handle_reload(int signum) {
if (rd->alive) {
puts("\nSIGUSR1 recieved, reloading...");
rd->alive = false;
}
reload = true;
}
#define append_buf(buf, sz_store, ...) \ #define append_buf(buf, sz_store, ...) \
({ \ ({ \
buf = realloc(buf, ++(*sz_store) * sizeof(*buf)); \ buf = realloc(buf, ++(*sz_store) * sizeof(*buf)); \
@@ -261,7 +271,7 @@ int main(int argc, char** argv) {
struct rd_bind* binds = malloc(1); struct rd_bind* binds = malloc(1);
size_t binds_sz = 0; size_t binds_sz = 0;
bool verbose = false, copy_mode = false, desktop = false; bool verbose = false, copy_mode = false, desktop = false, test = false;
int c, idx; int c, idx;
while ((c = getopt_long(argc, argv, opt_str, p_opts, &idx)) != -1) { while ((c = getopt_long(argc, argv, opt_str, p_opts, &idx)) != -1) {
@@ -391,7 +401,7 @@ int main(int argc, char** argv) {
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
case 'T': { case 'T': {
entry = "test_rc.glsl"; entry = "test_rc.glsl";
rd_enable_test_mode(); test = true;
} }
#endif #endif
} }
@@ -413,22 +423,47 @@ int main(int argc, char** argv) {
/* Null terminate array arguments */ /* Null terminate array arguments */
append_buf(requests, &requests_sz, NULL); append_buf(requests, &requests_sz, NULL);
append_buf(binds, &binds_sz, (struct rd_bind) { .name = NULL }); append_buf(binds, &binds_sz, (struct rd_bind) { .name = NULL });
rd = rd_new(system_shader_paths, entry, (const char**) requests,
backend, binds, stdin_type, desktop, verbose);
struct sigaction action = { .sa_handler = handle_term }; const struct sigaction term_action = { .sa_handler = handle_term };
sigaction(SIGTERM, &action, NULL); const struct sigaction reload_action = { .sa_handler = handle_reload };
sigaction(SIGINT, &action, NULL); sigaction(SIGTERM, &term_action, NULL);
sigaction(SIGINT, &term_action, NULL);
sigaction(SIGUSR1, &reload_action, NULL);
float b0[rd->bufsize_request], b1[rd->bufsize_request]; float* b0, * b1, * lb, * rb;
size_t t; size_t t;
struct audio_data audio;
struct audio_impl* impl = NULL;
pthread_t thread;
int return_status;
for (t = 0; t < audio_impls_idx; ++t) {
if (!strcmp(audio_impls[t]->name, audio_impl_name)) {
impl = audio_impls[t];
break;
}
}
if (!impl) {
fprintf(stderr, "The specified audio backend (\"%s\") is not available.\n", audio_impl_name);
exit(EXIT_FAILURE);
}
instantiate:
reload = false;
rd = rd_new(system_shader_paths, entry, (const char**) requests,
backend, binds, stdin_type, desktop, verbose, test);
b0 = malloc(rd->bufsize_request * sizeof(float));
b1 = malloc(rd->bufsize_request * sizeof(float));
lb = malloc(rd->bufsize_request * sizeof(float));
rb = malloc(rd->bufsize_request * sizeof(float));
for (t = 0; t < rd->bufsize_request; ++t) { for (t = 0; t < rd->bufsize_request; ++t) {
b0[t] = 0.0F; b0[t] = 0.0F;
b1[t] = 0.0F; b1[t] = 0.0F;
} }
struct audio_data audio = { audio = (struct audio_data) {
.source = ({ .source = ({
char* src = NULL; char* src = NULL;
if (rd->audio_source_request && strcmp(rd->audio_source_request, "auto") != 0) { if (rd->audio_source_request && strcmp(rd->audio_source_request, "auto") != 0) {
@@ -447,29 +482,12 @@ int main(int argc, char** argv) {
.sample_sz = rd->samplesize_request, .sample_sz = rd->samplesize_request,
.modified = false .modified = false
}; };
struct audio_impl* impl = NULL;
for (size_t t = 0; t < audio_impls_idx; ++t) {
if (!strcmp(audio_impls[t]->name, audio_impl_name)) {
impl = audio_impls[t];
break;
}
}
if (!impl) {
fprintf(stderr, "The specified audio backend (\"%s\") is not available.\n", audio_impl_name);
exit(EXIT_FAILURE);
}
impl->init(&audio); impl->init(&audio);
if (verbose) printf("Using audio source: %s\n", audio.source); if (verbose) printf("Using audio source: %s\n", audio.source);
pthread_t thread;
pthread_create(&thread, NULL, impl->entry, (void*) &audio); pthread_create(&thread, NULL, impl->entry, (void*) &audio);
float lb[rd->bufsize_request], rb[rd->bufsize_request];
while (rd->alive) { while (rd->alive) {
rd_time(rd); /* update timer for this frame */ rd_time(rd); /* update timer for this frame */
@@ -498,13 +516,13 @@ int main(int argc, char** argv) {
nanosleep(&tv, NULL); nanosleep(&tv, NULL);
} }
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (ret && rd_get_test_mode()) if (ret && rd_get_test_mode(rd))
break; break;
#endif #endif
} }
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (rd_get_test_mode()) { if (rd_get_test_mode(rd)) {
if (rd_test_evaluate(rd)) { if (rd_test_evaluate(rd)) {
fprintf(stderr, "Test results did not match expected output\n"); fprintf(stderr, "Test results did not match expected output\n");
fflush(stderr); fflush(stderr);
@@ -514,11 +532,16 @@ int main(int argc, char** argv) {
#endif #endif
audio.terminate = 1; audio.terminate = 1;
int return_status;
if ((return_status = pthread_join(thread, NULL))) { if ((return_status = pthread_join(thread, NULL))) {
fprintf(stderr, "Failed to join with audio thread: %s\n", strerror(return_status)); fprintf(stderr, "Failed to join with audio thread: %s\n", strerror(return_status));
} }
free(audio.source); free(audio.source);
free(b0);
free(b1);
free(lb);
free(rb);
rd_destroy(rd); rd_destroy(rd);
if (reload)
goto instantiate;
} }

View File

@@ -71,7 +71,7 @@ static void* create_and_bind(const char* name, const char* class,
int d, int h, int d, int h,
int x, int y, int x, int y,
int version_major, int version_minor, int version_major, int version_minor,
bool clickthrough) { bool clickthrough, bool offscreen) {
GLFWwindow* w; GLFWwindow* w;
@@ -93,7 +93,10 @@ static void* create_and_bind(const char* name, const char* class,
glfwSetWindowPos(w, x, y); glfwSetWindowPos(w, x, y);
glfwMakeContextCurrent(w); glfwMakeContextCurrent(w);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); if (!glad_instantiated) {
gladLoadGL();
glad_instantiated = true;
}
return w; return w;
} }

View File

@@ -164,8 +164,8 @@ void (*glXDestroyContext) (Display* dpy, GLXContext ctx);
Bool (*glXQueryVersion) (Display* dpy, int* major, int* minor); Bool (*glXQueryVersion) (Display* dpy, int* major, int* minor);
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
GLXPixmap (*glXCreateGLXPixmap) (Display* dpy, XVisualInfo* vis, Pixmap pixmap); GLXPixmap (*glXCreateGLXPixmap) (Display* dpy, XVisualInfo* vis, Pixmap pixmap);
static Pixmap test_pixmap; static Pixmap off_pixmap;
static GLXPixmap test_glxpm; static GLXPixmap off_glxpm;
#endif #endif
extern struct gl_wcb wcb_glx; extern struct gl_wcb wcb_glx;
@@ -180,7 +180,7 @@ struct glxwin {
Window w; Window w;
GLXContext context; GLXContext context;
double time; double time;
bool should_close, should_render, bg_changed, clickthrough; bool should_close, should_render, bg_changed, clickthrough, offscreen;
char override_state; char override_state;
}; };
@@ -342,7 +342,7 @@ static void* create_and_bind(const char* name, const char* class,
int d, int h, int d, int h,
int x, int y, int x, int y,
int version_major, int version_minor, int version_major, int version_minor,
bool clickthrough) { bool clickthrough, bool offscreen) {
struct glxwin* w = malloc(sizeof(struct glxwin)); struct glxwin* w = malloc(sizeof(struct glxwin));
*w = (struct glxwin) { *w = (struct glxwin) {
.override_state = '\0', .override_state = '\0',
@@ -350,7 +350,8 @@ static void* create_and_bind(const char* name, const char* class,
.should_close = false, .should_close = false,
.should_render = true, .should_render = true,
.bg_changed = false, .bg_changed = false,
.clickthrough = false .clickthrough = false,
.offscreen = offscreen
}; };
XVisualInfo* vi; XVisualInfo* vi;
@@ -497,17 +498,21 @@ static void* create_and_bind(const char* name, const char* class,
XSync(display, False); XSync(display, False);
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (rd_get_test_mode()) { if (w->offscreen) {
test_pixmap = XCreatePixmap(display, w->w, d, h, off_pixmap = XCreatePixmap(display, w->w, d, h,
DefaultDepth(display, DefaultScreen(display))); DefaultDepth(display, DefaultScreen(display)));
test_glxpm = glXCreateGLXPixmap(display, vi, test_pixmap); off_glxpm = glXCreateGLXPixmap(display, vi, off_pixmap);
glXMakeCurrent(display, test_glxpm, w->context); glXMakeCurrent(display, off_glxpm, w->context);
} else } else
glXMakeCurrent(display, w->w, w->context); glXMakeCurrent(display, w->w, w->context);
#else #else
glXMakeCurrent(display, w->w, w->context); glXMakeCurrent(display, w->w, w->context);
#endif #endif
gladLoadGL();
if (!glad_instantiated) {
gladLoadGL();
glad_instantiated = true;
}
GLXDrawable drawable = glXGetCurrentDrawable(); GLXDrawable drawable = glXGetCurrentDrawable();
@@ -515,7 +520,7 @@ static void* create_and_bind(const char* name, const char* class,
if (!transparent) if (!transparent)
XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask); XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask);
return w; return w;
} }
@@ -557,7 +562,7 @@ static void set_geometry(struct glxwin* w, int x, int y, int d, int h) {
static void set_visible(struct glxwin* w, bool visible) { static void set_visible(struct glxwin* w, bool visible) {
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (rd_get_test_mode()) if (w->offscreen)
return; return;
#endif #endif
if (visible) { if (visible) {
@@ -576,7 +581,7 @@ static bool should_close (struct glxwin* w) { return w->should_close; }
static bool bg_changed (struct glxwin* w) { return w->bg_changed; } static bool bg_changed (struct glxwin* w) { return w->bg_changed; }
static bool should_render(struct glxwin* w) { static bool should_render(struct glxwin* w) {
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (rd_get_test_mode()) if (w->offscreen)
return true; return true;
#endif #endif
/* For nearly all window managers, windows are 'minimized' by unmapping parent windows. /* For nearly all window managers, windows are 'minimized' by unmapping parent windows.
@@ -590,8 +595,8 @@ static bool should_render(struct glxwin* w) {
static void swap_buffers(struct glxwin* w) { static void swap_buffers(struct glxwin* w) {
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (rd_get_test_mode()) if (w->offscreen)
glXSwapBuffers(display, test_glxpm); glXSwapBuffers(display, off_glxpm);
else else
glXSwapBuffers(display, w->w); glXSwapBuffers(display, w->w);
#else #else

View File

@@ -47,6 +47,7 @@ typeof(bind_types) bind_types = {
#define VERTEX_SHADER_SRC \ #define VERTEX_SHADER_SRC \
"layout(location = 0) in vec3 pos; void main() { gl_Position = vec4(pos.x, pos.y, 0.0F, 1.0F); }" "layout(location = 0) in vec3 pos; void main() { gl_Position = vec4(pos.x, pos.y, 0.0F, 1.0F); }"
bool glad_instantiated = false;
struct gl_wcb* wcbs[2] = {}; struct gl_wcb* wcbs[2] = {};
static size_t wcbs_idx = 0; static size_t wcbs_idx = 0;
@@ -141,30 +142,26 @@ struct gl_data {
int geometry[4]; int geometry[4];
int stdin_type; int stdin_type;
struct rd_bind* binds; struct rd_bind* binds;
GLuint bg_prog, bg_utex, bg_screen;
bool bg_setup;
GLuint sm_utex, sm_usz, sm_uw;
bool sm_setup;
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
struct { struct {
float r, g, b, a; float r, g, b, a;
} test_eval_color; } test_eval_color;
bool debug_verbose; bool debug_verbose;
bool assigned_debug_cb;
bool test_mode;
struct gl_sfbo test_sfbo;
#endif #endif
}; };
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
static bool test_mode = false; bool rd_get_test_mode(struct renderer* r) {
static struct gl_sfbo test_sfbo = { struct gl_data* gl = r->gl;
.name = "test", return gl->test_mode;
.shader = 0,
.indirect = false,
.nativeonly = false,
.binds = NULL,
.binds_sz = 0
};
void rd_enable_test_mode(void) {
test_mode = true;
}
bool rd_get_test_mode(void) {
return test_mode;
} }
#endif #endif
@@ -268,9 +265,14 @@ static GLuint shaderload(const char* rpath,
glShaderSource(s, 1, (const GLchar* const*) &buf, &sl); glShaderSource(s, 1, (const GLchar* const*) &buf, &sl);
switch (glGetError()) { switch (glGetError()) {
case GL_INVALID_VALUE: case GL_INVALID_VALUE:
fprintf(stderr, "invalid value while loading shader source\n");
abort(); //todo: remove
return 0;
case GL_INVALID_OPERATION: case GL_INVALID_OPERATION:
fprintf(stderr, "invalid operation while loading shader source\n"); fprintf(stderr, "invalid operation while loading shader source\n");
abort(); //todo: remove
return 0; return 0;
default: {}
} }
glCompileShader(s); glCompileShader(s);
GLint ret, ilen; GLint ret, ilen;
@@ -366,6 +368,7 @@ static GLuint shaderlink_f(GLuint* arr) {
fprintf(stderr, "shader is already attached, or argument types " fprintf(stderr, "shader is already attached, or argument types "
"were invalid when calling glAttachShader\n"); "were invalid when calling glAttachShader\n");
return 0; return 0;
default: {}
} }
} }
glLinkProgram(p); glLinkProgram(p);
@@ -799,7 +802,8 @@ static struct gl_bind_src* lookup_bind_src(const char* str) {
struct renderer* rd_new(const char** paths, const char* entry, struct renderer* rd_new(const char** paths, const char* entry,
const char** requests, const char* force_backend, const char** requests, const char* force_backend,
struct rd_bind* bindings, int stdin_type, struct rd_bind* bindings, int stdin_type,
bool auto_desktop, bool verbose) { bool auto_desktop, bool verbose,
bool test_mode) {
xwin_wait_for_wm(); xwin_wait_for_wm();
@@ -850,9 +854,21 @@ struct renderer* rd_new(const char** paths, const char* entry,
.clickthrough = false, .clickthrough = false,
.stdin_type = stdin_type, .stdin_type = stdin_type,
.binds = bindings, .binds = bindings,
.bg_setup = false,
.sm_setup = false,
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
.test_eval_color = { 0.0F, 0.0F, 0.0F, 0.0F }, .test_eval_color = { 0.0F, 0.0F, 0.0F, 0.0F },
.debug_verbose = verbose .debug_verbose = verbose,
.assigned_debug_cb = false,
.test_mode = test_mode,
.test_sfbo = {
.name = "test",
.shader = 0,
.indirect = false,
.nativeonly = false,
.binds = NULL,
.binds_sz = 0
}
#endif #endif
}; };
@@ -901,10 +917,9 @@ struct renderer* rd_new(const char** paths, const char* entry,
#ifdef GLAD_DEBUG #ifdef GLAD_DEBUG
if (verbose) printf("Assigning debug callback\n"); if (verbose) printf("Assigning debug callback\n");
static bool assigned_debug_cb = false; if (!gl->assigned_debug_cb) {
if (!assigned_debug_cb) {
glad_set_post_callback(glad_debugcb); glad_set_post_callback(glad_debugcb);
assigned_debug_cb = true; gl->assigned_debug_cb = true;
} }
#endif #endif
@@ -1314,7 +1329,7 @@ struct renderer* rd_new(const char** paths, const char* entry,
gl->w = gl->wcb->create_and_bind(wintitle, "GLava", xwintype, (const char**) xwinstates, xwinstates_sz, gl->w = gl->wcb->create_and_bind(wintitle, "GLava", xwintype, (const char**) xwinstates, xwinstates_sz,
gl->geometry[2], gl->geometry[3], gl->geometry[0], gl->geometry[1], gl->geometry[2], gl->geometry[3], gl->geometry[0], gl->geometry[1],
context_version_major, context_version_minor, gl->clickthrough); context_version_major, context_version_minor, gl->clickthrough, gl->test_mode);
if (!gl->w) abort(); if (!gl->w) abort();
for (size_t t = 0; t < xwinstates_sz; ++t) for (size_t t = 0; t < xwinstates_sz; ++t)
@@ -1470,7 +1485,7 @@ struct renderer* rd_new(const char** paths, const char* entry,
{ {
int w, h; int w, h;
gl->wcb->get_fbsize(gl->w, &w, &h); gl->wcb->get_fbsize(gl->w, &w, &h);
setup_sfbo(&test_sfbo, w, h); setup_sfbo(&gl->test_sfbo, w, h);
} }
#endif #endif
@@ -1621,7 +1636,7 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
} }
} }
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
setup_sfbo(&test_sfbo, ww, wh); setup_sfbo(&gl->test_sfbo, ww, wh);
#endif #endif
} }
@@ -1817,17 +1832,14 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
glBindFramebuffer(GL_FRAMEBUFFER, current->fbo); glBindFramebuffer(GL_FRAMEBUFFER, current->fbo);
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
if (!current->indirect && test_mode) { if (!current->indirect && gl->test_mode) {
glBindFramebuffer(GL_FRAMEBUFFER, test_sfbo.fbo); glBindFramebuffer(GL_FRAMEBUFFER, gl->test_sfbo.fbo);
} }
#endif #endif
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
if (!current->indirect && gl->copy_desktop) { if (!current->indirect && gl->copy_desktop) {
/* Self-contained code for drawing background image */
static GLuint bg_prog, bg_utex, bg_screen;
static bool setup = false;
/* Shader to flip texture and override alpha channel */ /* Shader to flip texture and override alpha channel */
static const char* frag_shader = static const char* frag_shader =
"uniform sampler2D tex;" "\n" "uniform sampler2D tex;" "\n"
@@ -1839,21 +1851,21 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
" screen.y - gl_FragCoord.y), 0);" "\n" " screen.y - gl_FragCoord.y), 0);" "\n"
" fragment.a = 1.0F;" "\n" " fragment.a = 1.0F;" "\n"
"}" "\n"; "}" "\n";
if (!setup) { if (!gl->bg_setup) {
bg_prog = shaderlink(shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC, gl->bg_prog = shaderlink(shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC,
NULL, NULL, NULL, 330, true, NULL, gl), NULL, NULL, NULL, 330, true, NULL, gl),
shaderload(NULL, GL_FRAGMENT_SHADER, frag_shader, shaderload(NULL, GL_FRAGMENT_SHADER, frag_shader,
NULL, NULL, NULL, 330, true, NULL, gl)); NULL, NULL, NULL, 330, true, NULL, gl));
bg_utex = glGetUniformLocation(bg_prog, "tex"); gl->bg_utex = glGetUniformLocation(gl->bg_prog, "tex");
bg_screen = glGetUniformLocation(bg_prog, "screen"); gl->bg_screen = glGetUniformLocation(gl->bg_prog, "screen");
glBindFragDataLocation(bg_prog, 1, "fragment"); glBindFragDataLocation(gl->bg_prog, 1, "fragment");
setup = true; gl->bg_setup = true;
} }
glUseProgram(bg_prog); glUseProgram(gl->bg_prog);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gl->bg_tex); glBindTexture(GL_TEXTURE_2D, gl->bg_tex);
glUniform2i(bg_screen, (GLint) ww, (GLint) wh); glUniform2i(gl->bg_screen, (GLint) ww, (GLint) wh);
glUniform1i(bg_utex, 0); glUniform1i(gl->bg_utex, 0);
/* We need to disable blending, we might read in bogus alpha values due /* We need to disable blending, we might read in bogus alpha values due
to how we obtain the background texture (format is four byte `rgb_`, to how we obtain the background texture (format is four byte `rgb_`,
where the last value is skipped) */ where the last value is skipped) */
@@ -1936,16 +1948,14 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
/* Apply pre-smoothing shader pass if configured */ /* Apply pre-smoothing shader pass if configured */
if (audio && gl->smooth_pass) { if (audio && gl->smooth_pass) {
static bool setup = false;
static GLuint sm_utex, sm_usz, sm_uw;
/* Compile preprocess shader and handle uniform locations */ /* Compile preprocess shader and handle uniform locations */
if (!setup) { if (!gl->sm_setup) {
sm_utex = glGetUniformLocation(gl->sm_prog, "tex"); gl->sm_utex = glGetUniformLocation(gl->sm_prog, "tex");
sm_usz = glGetUniformLocation(gl->sm_prog, "sz"); gl->sm_usz = glGetUniformLocation(gl->sm_prog, "sz");
sm_uw = glGetUniformLocation(gl->sm_prog, "w"); gl->sm_uw = glGetUniformLocation(gl->sm_prog, "w");
glBindFragDataLocation(gl->sm_prog, 1, "fragment"); glBindFragDataLocation(gl->sm_prog, 1, "fragment");
setup = true; gl->sm_setup = true;
} }
/* Allocate and setup our per-bind data, if needed */ /* Allocate and setup our per-bind data, if needed */
@@ -1983,9 +1993,9 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
glUseProgram(gl->sm_prog); glUseProgram(gl->sm_prog);
glActiveTexture(GL_TEXTURE0 + offset); glActiveTexture(GL_TEXTURE0 + offset);
glBindTexture(GL_TEXTURE_1D, tex); glBindTexture(GL_TEXTURE_1D, tex);
glUniform1i(sm_uw, sz); /* target texture width */ glUniform1i(gl->sm_uw, sz); /* target texture width */
glUniform1i(sm_usz, sz); /* source texture width */ glUniform1i(gl->sm_usz, sz); /* source texture width */
glUniform1i(sm_utex, offset); glUniform1i(gl->sm_utex, offset);
if (!gl->premultiply_alpha) glDisable(GL_BLEND); if (!gl->premultiply_alpha) glDisable(GL_BLEND);
glViewport(0, 0, sz, 1); glViewport(0, 0, sz, 1);
drawoverlay(&gl->overlay); drawoverlay(&gl->overlay);

View File

@@ -6,6 +6,7 @@ extern const struct {
const char* n; const char* n;
int i; int i;
} bind_types[]; } bind_types[];
extern bool glad_instantiated;
#define STDIN_TYPE_NONE 0 #define STDIN_TYPE_NONE 0
#define STDIN_TYPE_INT 1 #define STDIN_TYPE_INT 1
@@ -33,15 +34,15 @@ struct rd_bind {
}; };
#ifdef GLAVA_DEBUG #ifdef GLAVA_DEBUG
void rd_enable_test_mode(void); bool rd_get_test_mode (struct renderer*);
bool rd_get_test_mode (void);
bool rd_test_evaluate (struct renderer*); bool rd_test_evaluate (struct renderer*);
#endif #endif
struct renderer* rd_new (const char** paths, const char* entry, struct renderer* rd_new (const char** paths, const char* entry,
const char** requests, const char* force_backend, const char** requests, const char* force_backend,
struct rd_bind* bindings, int stdin_type, struct rd_bind* bindings, int stdin_type,
bool auto_desktop, bool verbose); bool auto_desktop, bool verbose,
bool test_mode);
bool rd_update (struct renderer*, float* lb, float* rb, bool rd_update (struct renderer*, float* lb, float* rb,
size_t bsz, bool modified); size_t bsz, bool modified);
void rd_destroy (struct renderer*); void rd_destroy (struct renderer*);
@@ -59,7 +60,7 @@ struct gl_wcb {
int w, int h, int w, int h,
int x, int y, int x, int y,
int version_major, int version_minor, int version_major, int version_minor,
bool clickthrough); bool clickthrough, bool offscreen);
bool (*should_close) (void* ptr); bool (*should_close) (void* ptr);
bool (*should_render) (void* ptr); bool (*should_render) (void* ptr);
bool (*bg_changed) (void* ptr); bool (*bg_changed) (void* ptr);

View File

@@ -20,7 +20,7 @@ if get_option('buildtype').startswith('debug')
else else
add_project_arguments( add_project_arguments(
'-O2', '-O2',
'-Wstringpop-overflow=0', '-Wstringop-overflow=0',
language: 'c' language: 'c'
) )
if get_option('glad') if get_option('glad')