Added cfg paths
This commit is contained in:
10
glsl_ext.c
10
glsl_ext.c
@@ -79,7 +79,14 @@ static struct schar directive(struct glsl_ext* ext, char** args,
|
||||
}
|
||||
char* target = args[0];
|
||||
|
||||
char path[strlen(ext->cd) + strlen(target) + 2];
|
||||
/* Handle `:` config specifier */
|
||||
size_t tsz = strlen(target);
|
||||
if (tsz && target[0] == ':' && ext->cfd) {
|
||||
target = &target[1];
|
||||
ext->cd = ext->cfd;
|
||||
}
|
||||
|
||||
char path[strlen(ext->cd) + tsz + 2];
|
||||
snprintf(path, sizeof(path) / sizeof(char), "%s/%s", ext->cd, target);
|
||||
|
||||
int fd = open(path, O_RDONLY);
|
||||
@@ -101,6 +108,7 @@ static struct schar directive(struct glsl_ext* ext, char** args,
|
||||
.source = map,
|
||||
.source_len = st.st_size,
|
||||
.cd = ext->cd,
|
||||
.cfd = ext->cfd,
|
||||
.handlers = ext->handlers
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ struct glsl_ext {
|
||||
const char* source; /* IN: raw data passed via ext_process */
|
||||
size_t source_len; /* IN: raw source len */
|
||||
const char* cd; /* IN: current directory */
|
||||
const char* cfd; /* IN: config directory, if NULL it is assumed to cd */
|
||||
|
||||
/* IN: NULL (where the last element's 'name' member is NULL) terminated
|
||||
array of request handlers */
|
||||
|
||||
13
render.c
13
render.c
@@ -40,6 +40,7 @@
|
||||
static GLuint shaderload(const char* rpath,
|
||||
GLenum type,
|
||||
const char* shader,
|
||||
const char* config,
|
||||
struct request_handler* handlers,
|
||||
int shader_version,
|
||||
bool raw) {
|
||||
@@ -78,6 +79,7 @@ static GLuint shaderload(const char* rpath,
|
||||
.source = raw ? NULL : map,
|
||||
.source_len = raw ? 0 : st.st_size,
|
||||
.cd = shader,
|
||||
.cfd = config,
|
||||
.handlers = handlers,
|
||||
.processed = (char*) (raw ? shader : NULL),
|
||||
.p_len = raw ? s_len : 0
|
||||
@@ -171,8 +173,10 @@ static GLuint shaderlink_f(GLuint* arr) {
|
||||
}
|
||||
|
||||
/* load shaders */
|
||||
#define shaderbuild(shader_path, r, v, ...) shaderbuild_f(shader_path, r, v, (const char*[]) {__VA_ARGS__, 0})
|
||||
#define shaderbuild(shader_path, c, r, v, ...) \
|
||||
shaderbuild_f(shader_path, c, r, v, (const char*[]) {__VA_ARGS__, 0})
|
||||
static GLuint shaderbuild_f(const char* shader_path,
|
||||
const char* config,
|
||||
struct request_handler* handlers,
|
||||
int shader_version,
|
||||
const char** arr) {
|
||||
@@ -188,7 +192,8 @@ static GLuint shaderbuild_f(const char* shader_path,
|
||||
if (path[t] == '.') {
|
||||
if (!strcmp(path + t + 1, "frag") || !strcmp(path + t + 1, "glsl")) {
|
||||
if (!(shaders[i] = shaderload(path, GL_FRAGMENT_SHADER,
|
||||
shader_path, handlers, shader_version, false))) {
|
||||
shader_path, config, handlers,
|
||||
shader_version, false))) {
|
||||
return 0;
|
||||
}
|
||||
} else if (!strcmp(path + t + 1, "vert")) {
|
||||
@@ -208,7 +213,7 @@ static GLuint shaderbuild_f(const char* shader_path,
|
||||
}
|
||||
}
|
||||
/* load builtin vertex shader */
|
||||
shaders[sz] = shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC, handlers, shader_version, true);
|
||||
shaders[sz] = shaderload(NULL, GL_VERTEX_SHADER, VERTEX_SHADER_SRC, NULL, handlers, shader_version, true);
|
||||
fflush(stdout);
|
||||
return shaderlink_f(shaders);
|
||||
}
|
||||
@@ -1000,7 +1005,7 @@ struct renderer* rd_new(const char** paths, const char* entry, const char* force
|
||||
};
|
||||
|
||||
current = s;
|
||||
GLuint id = shaderbuild(shaders, handlers, shader_version, d->d_name);
|
||||
GLuint id = shaderbuild(shaders, data, handlers, shader_version, d->d_name);
|
||||
if (!id) {
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
/* left color offset */
|
||||
#define LCOL_OFF ((screen.x - gl_FragCoord.x) / 3000)
|
||||
/* vertical color step */
|
||||
#define LSTEP (gl_FragCoord.y / 170)
|
||||
#define LSTEP (pos / 170)
|
||||
/* actual color definition */
|
||||
#define COLOR vec4((0.3 + RCOL_OFF) + LSTEP, 0.6 - LSTEP, (0.3 + LCOL_OFF) + LSTEP, 1)
|
||||
/* outline color */
|
||||
#define OUTLINE vec4(0.15, 0.15, 0.15, 1)
|
||||
/* 1 to invert (vertically), 0 otherwise */
|
||||
#define INVERT 0
|
||||
/* How many frames to queue and run through the average function */
|
||||
#request setavgframes 6
|
||||
/* Whether to window frames ran through the average function (new & old frames
|
||||
|
||||
@@ -39,7 +39,7 @@ uniform int audio_sz;
|
||||
with 'setavgwindow'.
|
||||
*/
|
||||
|
||||
#include "../graph.glsl"
|
||||
#include ":graph.glsl"
|
||||
|
||||
#request uniform "audio_l" audio_l
|
||||
#request transform audio_l "window"
|
||||
@@ -57,7 +57,7 @@ uniform sampler1D audio_r;
|
||||
|
||||
out vec4 fragment;
|
||||
|
||||
#include "../util/smooth.glsl"
|
||||
#include ":util/smooth.glsl"
|
||||
|
||||
/* distance from center */
|
||||
#define CDIST (abs((screen.x / 2) - gl_FragCoord.x) / screen.x)
|
||||
@@ -95,7 +95,12 @@ void render_side(in sampler1D tex, float idx) {
|
||||
s *= 1 + BDIST;
|
||||
|
||||
/* and finally set fragment color if we are in range */
|
||||
if (gl_FragCoord.y + 1.5 <= s) {
|
||||
#if INVERT > 0
|
||||
float pos = float(screen.y) - gl_FragCoord.y;
|
||||
#else
|
||||
float pos = gl_FragCoord.y;
|
||||
#endif
|
||||
if (pos + 1.5 <= s) {
|
||||
fragment = COLOR;
|
||||
} else {
|
||||
fragment = vec4(0, 0, 0, 0);
|
||||
|
||||
@@ -8,7 +8,7 @@ uniform ivec2 screen; /* screen dimensions */
|
||||
|
||||
out vec4 fragment; /* output */
|
||||
|
||||
#include "../graph.glsl"
|
||||
#include ":graph.glsl"
|
||||
|
||||
void main() {
|
||||
fragment = texture(tex, vec2(gl_FragCoord.x / screen.x, gl_FragCoord.y / screen.y));
|
||||
@@ -26,7 +26,12 @@ void main() {
|
||||
|
||||
vec4 avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0;
|
||||
if (avg.a > 0){
|
||||
if (fragment.a <= 0 && gl_FragCoord.y != screen.y - 1) {
|
||||
#if INVERT > 0
|
||||
#define EDGE_CHECK (gl_FragCoord.y != 0)
|
||||
#else
|
||||
#define EDGE_CHECK (gl_FragCoord.y != screen.y - 1)
|
||||
#endif
|
||||
if (fragment.a <= 0 && EDGE_CHECK) {
|
||||
/* outline */
|
||||
fragment = OUTLINE;
|
||||
} else if (avg.a < 1 && gl_FragCoord.y != 0) {
|
||||
|
||||
@@ -6,7 +6,7 @@ uniform ivec2 screen;
|
||||
#request uniform "audio_sz" audio_sz
|
||||
uniform int audio_sz;
|
||||
|
||||
#include "../radial.glsl"
|
||||
#include ":radial.glsl"
|
||||
|
||||
#request uniform "audio_l" audio_l
|
||||
#request transform audio_l "window"
|
||||
@@ -23,7 +23,7 @@ uniform sampler1D audio_l;
|
||||
uniform sampler1D audio_r;
|
||||
|
||||
out vec4 fragment;
|
||||
#include "../util/smooth.glsl"
|
||||
#include ":util/smooth.glsl"
|
||||
|
||||
#define TWOPI 6.28318530718
|
||||
#define PI 3.14159265359
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define PI 3.14159265359
|
||||
#endif
|
||||
|
||||
#include "../smooth_parameters.glsl"
|
||||
#include ":smooth_parameters.glsl"
|
||||
|
||||
/* window value t that resides in range [0, sz)*/
|
||||
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / (sz - 1))))
|
||||
|
||||
@@ -11,7 +11,7 @@ uniform sampler1D audio_l;
|
||||
|
||||
out vec4 fragment;
|
||||
|
||||
#include "../wave.glsl"
|
||||
#include ":wave.glsl"
|
||||
|
||||
#define index(offset) ((texture(audio_l, (gl_FragCoord.x + offset) / screen.x).r - 0.5) * AMPLIFY) + 0.5F
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ uniform ivec2 screen; /* screen dimensions */
|
||||
|
||||
out vec4 fragment; /* output */
|
||||
|
||||
#include "../wave.glsl"
|
||||
#include ":wave.glsl"
|
||||
|
||||
void main() {
|
||||
fragment = texture(tex, vec2(gl_FragCoord.x / screen.x, gl_FragCoord.y / screen.y));
|
||||
|
||||
Reference in New Issue
Block a user