Added signal reloading and legacy makefile support
This commit is contained in:
51
Makefile
51
Makefile
@@ -1,15 +1,56 @@
|
||||
.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
|
||||
|
||||
build:
|
||||
meson build
|
||||
# Rebuild if the makefile state changes to maintain old behaviour and smooth rebuilds with altered parameters
|
||||
build: build_state
|
||||
@rm -rf $(BUILD_DIR)
|
||||
meson $(BUILD_DIR)
|
||||
meson configure $(MESON_CONF)
|
||||
|
||||
ninja: build
|
||||
ninja -C build
|
||||
ninja -C $(BUILD_DIR)
|
||||
|
||||
install:
|
||||
cd build && meson install
|
||||
cd $(BUILD_DIR) && meson install
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
9503
glava/glad.c
9503
glava/glad.c
File diff suppressed because it is too large
Load Diff
3239
glava/glad.h
3239
glava/glad.h
File diff suppressed because it is too large
Load Diff
@@ -73,6 +73,8 @@
|
||||
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
|
||||
#endif
|
||||
|
||||
static bool reload = false;
|
||||
|
||||
/* Copy installed shaders/configuration from the installed location
|
||||
(usually /etc/xdg). Modules (folders) will be linked instead of
|
||||
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, ...) \
|
||||
({ \
|
||||
buf = realloc(buf, ++(*sz_store) * sizeof(*buf)); \
|
||||
@@ -261,7 +271,7 @@ int main(int argc, char** argv) {
|
||||
struct rd_bind* binds = malloc(1);
|
||||
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;
|
||||
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
|
||||
case 'T': {
|
||||
entry = "test_rc.glsl";
|
||||
rd_enable_test_mode();
|
||||
test = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -413,22 +423,47 @@ int main(int argc, char** argv) {
|
||||
/* Null terminate array arguments */
|
||||
append_buf(requests, &requests_sz, 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 };
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
const struct sigaction term_action = { .sa_handler = handle_term };
|
||||
const struct sigaction reload_action = { .sa_handler = handle_reload };
|
||||
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;
|
||||
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) {
|
||||
b0[t] = 0.0F;
|
||||
b1[t] = 0.0F;
|
||||
}
|
||||
|
||||
struct audio_data audio = {
|
||||
audio = (struct audio_data) {
|
||||
.source = ({
|
||||
char* src = NULL;
|
||||
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,
|
||||
.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);
|
||||
|
||||
if (verbose) printf("Using audio source: %s\n", audio.source);
|
||||
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, impl->entry, (void*) &audio);
|
||||
|
||||
float lb[rd->bufsize_request], rb[rd->bufsize_request];
|
||||
while (rd->alive) {
|
||||
|
||||
rd_time(rd); /* update timer for this frame */
|
||||
@@ -498,13 +516,13 @@ int main(int argc, char** argv) {
|
||||
nanosleep(&tv, NULL);
|
||||
}
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (ret && rd_get_test_mode())
|
||||
if (ret && rd_get_test_mode(rd))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (rd_get_test_mode()) {
|
||||
if (rd_get_test_mode(rd)) {
|
||||
if (rd_test_evaluate(rd)) {
|
||||
fprintf(stderr, "Test results did not match expected output\n");
|
||||
fflush(stderr);
|
||||
@@ -514,11 +532,16 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
|
||||
audio.terminate = 1;
|
||||
int return_status;
|
||||
if ((return_status = pthread_join(thread, NULL))) {
|
||||
fprintf(stderr, "Failed to join with audio thread: %s\n", strerror(return_status));
|
||||
}
|
||||
|
||||
free(audio.source);
|
||||
free(b0);
|
||||
free(b1);
|
||||
free(lb);
|
||||
free(rb);
|
||||
rd_destroy(rd);
|
||||
if (reload)
|
||||
goto instantiate;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
int d, int h,
|
||||
int x, int y,
|
||||
int version_major, int version_minor,
|
||||
bool clickthrough) {
|
||||
bool clickthrough, bool offscreen) {
|
||||
|
||||
GLFWwindow* w;
|
||||
|
||||
@@ -93,7 +93,10 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
glfwSetWindowPos(w, x, y);
|
||||
glfwMakeContextCurrent(w);
|
||||
|
||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
if (!glad_instantiated) {
|
||||
gladLoadGL();
|
||||
glad_instantiated = true;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@ void (*glXDestroyContext) (Display* dpy, GLXContext ctx);
|
||||
Bool (*glXQueryVersion) (Display* dpy, int* major, int* minor);
|
||||
#ifdef GLAVA_DEBUG
|
||||
GLXPixmap (*glXCreateGLXPixmap) (Display* dpy, XVisualInfo* vis, Pixmap pixmap);
|
||||
static Pixmap test_pixmap;
|
||||
static GLXPixmap test_glxpm;
|
||||
static Pixmap off_pixmap;
|
||||
static GLXPixmap off_glxpm;
|
||||
#endif
|
||||
|
||||
extern struct gl_wcb wcb_glx;
|
||||
@@ -180,7 +180,7 @@ struct glxwin {
|
||||
Window w;
|
||||
GLXContext context;
|
||||
double time;
|
||||
bool should_close, should_render, bg_changed, clickthrough;
|
||||
bool should_close, should_render, bg_changed, clickthrough, offscreen;
|
||||
char override_state;
|
||||
};
|
||||
|
||||
@@ -342,7 +342,7 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
int d, int h,
|
||||
int x, int y,
|
||||
int version_major, int version_minor,
|
||||
bool clickthrough) {
|
||||
bool clickthrough, bool offscreen) {
|
||||
struct glxwin* w = malloc(sizeof(struct glxwin));
|
||||
*w = (struct glxwin) {
|
||||
.override_state = '\0',
|
||||
@@ -350,7 +350,8 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
.should_close = false,
|
||||
.should_render = true,
|
||||
.bg_changed = false,
|
||||
.clickthrough = false
|
||||
.clickthrough = false,
|
||||
.offscreen = offscreen
|
||||
};
|
||||
|
||||
XVisualInfo* vi;
|
||||
@@ -497,17 +498,21 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
XSync(display, False);
|
||||
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (rd_get_test_mode()) {
|
||||
test_pixmap = XCreatePixmap(display, w->w, d, h,
|
||||
if (w->offscreen) {
|
||||
off_pixmap = XCreatePixmap(display, w->w, d, h,
|
||||
DefaultDepth(display, DefaultScreen(display)));
|
||||
test_glxpm = glXCreateGLXPixmap(display, vi, test_pixmap);
|
||||
glXMakeCurrent(display, test_glxpm, w->context);
|
||||
off_glxpm = glXCreateGLXPixmap(display, vi, off_pixmap);
|
||||
glXMakeCurrent(display, off_glxpm, w->context);
|
||||
} else
|
||||
glXMakeCurrent(display, w->w, w->context);
|
||||
#else
|
||||
glXMakeCurrent(display, w->w, w->context);
|
||||
#endif
|
||||
gladLoadGL();
|
||||
|
||||
if (!glad_instantiated) {
|
||||
gladLoadGL();
|
||||
glad_instantiated = true;
|
||||
}
|
||||
|
||||
GLXDrawable drawable = glXGetCurrentDrawable();
|
||||
|
||||
@@ -515,7 +520,7 @@ static void* create_and_bind(const char* name, const char* class,
|
||||
|
||||
if (!transparent)
|
||||
XSelectInput(display, DefaultRootWindow(display), PropertyChangeMask);
|
||||
|
||||
|
||||
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) {
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (rd_get_test_mode())
|
||||
if (w->offscreen)
|
||||
return;
|
||||
#endif
|
||||
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 should_render(struct glxwin* w) {
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (rd_get_test_mode())
|
||||
if (w->offscreen)
|
||||
return true;
|
||||
#endif
|
||||
/* 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) {
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (rd_get_test_mode())
|
||||
glXSwapBuffers(display, test_glxpm);
|
||||
if (w->offscreen)
|
||||
glXSwapBuffers(display, off_glxpm);
|
||||
else
|
||||
glXSwapBuffers(display, w->w);
|
||||
#else
|
||||
|
||||
102
glava/render.c
102
glava/render.c
@@ -47,6 +47,7 @@ typeof(bind_types) bind_types = {
|
||||
#define VERTEX_SHADER_SRC \
|
||||
"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] = {};
|
||||
static size_t wcbs_idx = 0;
|
||||
|
||||
@@ -141,30 +142,26 @@ struct gl_data {
|
||||
int geometry[4];
|
||||
int stdin_type;
|
||||
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
|
||||
struct {
|
||||
float r, g, b, a;
|
||||
} test_eval_color;
|
||||
bool debug_verbose;
|
||||
bool assigned_debug_cb;
|
||||
bool test_mode;
|
||||
struct gl_sfbo test_sfbo;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef GLAVA_DEBUG
|
||||
static bool test_mode = false;
|
||||
static struct gl_sfbo test_sfbo = {
|
||||
.name = "test",
|
||||
.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;
|
||||
bool rd_get_test_mode(struct renderer* r) {
|
||||
struct gl_data* gl = r->gl;
|
||||
return gl->test_mode;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -268,9 +265,14 @@ static GLuint shaderload(const char* rpath,
|
||||
glShaderSource(s, 1, (const GLchar* const*) &buf, &sl);
|
||||
switch (glGetError()) {
|
||||
case GL_INVALID_VALUE:
|
||||
fprintf(stderr, "invalid value while loading shader source\n");
|
||||
abort(); //todo: remove
|
||||
return 0;
|
||||
case GL_INVALID_OPERATION:
|
||||
fprintf(stderr, "invalid operation while loading shader source\n");
|
||||
abort(); //todo: remove
|
||||
return 0;
|
||||
default: {}
|
||||
}
|
||||
glCompileShader(s);
|
||||
GLint ret, ilen;
|
||||
@@ -366,6 +368,7 @@ static GLuint shaderlink_f(GLuint* arr) {
|
||||
fprintf(stderr, "shader is already attached, or argument types "
|
||||
"were invalid when calling glAttachShader\n");
|
||||
return 0;
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
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,
|
||||
const char** requests, const char* force_backend,
|
||||
struct rd_bind* bindings, int stdin_type,
|
||||
bool auto_desktop, bool verbose) {
|
||||
bool auto_desktop, bool verbose,
|
||||
bool test_mode) {
|
||||
|
||||
xwin_wait_for_wm();
|
||||
|
||||
@@ -850,9 +854,21 @@ struct renderer* rd_new(const char** paths, const char* entry,
|
||||
.clickthrough = false,
|
||||
.stdin_type = stdin_type,
|
||||
.binds = bindings,
|
||||
.bg_setup = false,
|
||||
.sm_setup = false,
|
||||
#ifdef GLAVA_DEBUG
|
||||
.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
|
||||
};
|
||||
|
||||
@@ -901,10 +917,9 @@ struct renderer* rd_new(const char** paths, const char* entry,
|
||||
|
||||
#ifdef GLAD_DEBUG
|
||||
if (verbose) printf("Assigning debug callback\n");
|
||||
static bool assigned_debug_cb = false;
|
||||
if (!assigned_debug_cb) {
|
||||
if (!gl->assigned_debug_cb) {
|
||||
glad_set_post_callback(glad_debugcb);
|
||||
assigned_debug_cb = true;
|
||||
gl->assigned_debug_cb = true;
|
||||
}
|
||||
#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->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();
|
||||
|
||||
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;
|
||||
gl->wcb->get_fbsize(gl->w, &w, &h);
|
||||
setup_sfbo(&test_sfbo, w, h);
|
||||
setup_sfbo(&gl->test_sfbo, w, h);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1621,7 +1636,7 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
|
||||
}
|
||||
}
|
||||
#ifdef GLAVA_DEBUG
|
||||
setup_sfbo(&test_sfbo, ww, wh);
|
||||
setup_sfbo(&gl->test_sfbo, ww, wh);
|
||||
#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);
|
||||
|
||||
#ifdef GLAVA_DEBUG
|
||||
if (!current->indirect && test_mode) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, test_sfbo.fbo);
|
||||
if (!current->indirect && gl->test_mode) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, gl->test_sfbo.fbo);
|
||||
}
|
||||
#endif
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
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 */
|
||||
static const char* frag_shader =
|
||||
"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"
|
||||
" fragment.a = 1.0F;" "\n"
|
||||
"}" "\n";
|
||||
if (!setup) {
|
||||
bg_prog = shaderlink(shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC,
|
||||
if (!gl->bg_setup) {
|
||||
gl->bg_prog = shaderlink(shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC,
|
||||
NULL, NULL, NULL, 330, true, NULL, gl),
|
||||
shaderload(NULL, GL_FRAGMENT_SHADER, frag_shader,
|
||||
NULL, NULL, NULL, 330, true, NULL, gl));
|
||||
bg_utex = glGetUniformLocation(bg_prog, "tex");
|
||||
bg_screen = glGetUniformLocation(bg_prog, "screen");
|
||||
glBindFragDataLocation(bg_prog, 1, "fragment");
|
||||
setup = true;
|
||||
gl->bg_utex = glGetUniformLocation(gl->bg_prog, "tex");
|
||||
gl->bg_screen = glGetUniformLocation(gl->bg_prog, "screen");
|
||||
glBindFragDataLocation(gl->bg_prog, 1, "fragment");
|
||||
gl->bg_setup = true;
|
||||
}
|
||||
glUseProgram(bg_prog);
|
||||
glUseProgram(gl->bg_prog);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, gl->bg_tex);
|
||||
glUniform2i(bg_screen, (GLint) ww, (GLint) wh);
|
||||
glUniform1i(bg_utex, 0);
|
||||
glUniform2i(gl->bg_screen, (GLint) ww, (GLint) wh);
|
||||
glUniform1i(gl->bg_utex, 0);
|
||||
/* 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_`,
|
||||
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 */
|
||||
if (audio && gl->smooth_pass) {
|
||||
static bool setup = false;
|
||||
static GLuint sm_utex, sm_usz, sm_uw;
|
||||
|
||||
/* Compile preprocess shader and handle uniform locations */
|
||||
if (!setup) {
|
||||
sm_utex = glGetUniformLocation(gl->sm_prog, "tex");
|
||||
sm_usz = glGetUniformLocation(gl->sm_prog, "sz");
|
||||
sm_uw = glGetUniformLocation(gl->sm_prog, "w");
|
||||
if (!gl->sm_setup) {
|
||||
gl->sm_utex = glGetUniformLocation(gl->sm_prog, "tex");
|
||||
gl->sm_usz = glGetUniformLocation(gl->sm_prog, "sz");
|
||||
gl->sm_uw = glGetUniformLocation(gl->sm_prog, "w");
|
||||
glBindFragDataLocation(gl->sm_prog, 1, "fragment");
|
||||
setup = true;
|
||||
gl->sm_setup = true;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
glActiveTexture(GL_TEXTURE0 + offset);
|
||||
glBindTexture(GL_TEXTURE_1D, tex);
|
||||
glUniform1i(sm_uw, sz); /* target texture width */
|
||||
glUniform1i(sm_usz, sz); /* source texture width */
|
||||
glUniform1i(sm_utex, offset);
|
||||
glUniform1i(gl->sm_uw, sz); /* target texture width */
|
||||
glUniform1i(gl->sm_usz, sz); /* source texture width */
|
||||
glUniform1i(gl->sm_utex, offset);
|
||||
if (!gl->premultiply_alpha) glDisable(GL_BLEND);
|
||||
glViewport(0, 0, sz, 1);
|
||||
drawoverlay(&gl->overlay);
|
||||
|
||||
@@ -6,6 +6,7 @@ extern const struct {
|
||||
const char* n;
|
||||
int i;
|
||||
} bind_types[];
|
||||
extern bool glad_instantiated;
|
||||
|
||||
#define STDIN_TYPE_NONE 0
|
||||
#define STDIN_TYPE_INT 1
|
||||
@@ -33,15 +34,15 @@ struct rd_bind {
|
||||
};
|
||||
|
||||
#ifdef GLAVA_DEBUG
|
||||
void rd_enable_test_mode(void);
|
||||
bool rd_get_test_mode (void);
|
||||
bool rd_get_test_mode (struct renderer*);
|
||||
bool rd_test_evaluate (struct renderer*);
|
||||
#endif
|
||||
|
||||
struct renderer* rd_new (const char** paths, const char* entry,
|
||||
const char** requests, const char* force_backend,
|
||||
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,
|
||||
size_t bsz, bool modified);
|
||||
void rd_destroy (struct renderer*);
|
||||
@@ -59,7 +60,7 @@ struct gl_wcb {
|
||||
int w, int h,
|
||||
int x, int y,
|
||||
int version_major, int version_minor,
|
||||
bool clickthrough);
|
||||
bool clickthrough, bool offscreen);
|
||||
bool (*should_close) (void* ptr);
|
||||
bool (*should_render) (void* ptr);
|
||||
bool (*bg_changed) (void* ptr);
|
||||
|
||||
@@ -20,7 +20,7 @@ if get_option('buildtype').startswith('debug')
|
||||
else
|
||||
add_project_arguments(
|
||||
'-O2',
|
||||
'-Wstringpop-overflow=0',
|
||||
'-Wstringop-overflow=0',
|
||||
language: 'c'
|
||||
)
|
||||
if get_option('glad')
|
||||
|
||||
Reference in New Issue
Block a user