--- /dev/null
+uniform sampler2D tex;
+uniform float smoothness;
+uniform float height;
+uniform vec2 pix_sz;
+
+varying vec2 local_pt;
+
+void gradcurves(float t, out float over, out float under);
+
+#define HALF_PI 1.570796326794897
+
+void main()
+{
+ vec2 uv = gl_TexCoord[0].st;
+ float dist = texture2D(tex, uv).a;
+
+ float dfdu = texture2D(tex, uv + vec2(pix_sz.x, 0.0)).a - dist;
+ float dfdv = texture2D(tex, uv + vec2(0.0, pix_sz.y)).a - dist;
+ vec2 grad = normalize(vec2(dfdu, dfdv));
+
+ float glyph = smoothstep(0.47 - smoothness, 0.47 + smoothness, dist);
+ float outline = smoothstep(0.54 - smoothness, 0.54 + smoothness, dist);
+
+ // --- face gradients ---
+ float t = local_pt.y / height;
+
+ float c_over, c_under;
+ float tlow = min(2.0 * t, 1.0);
+ gradcurves(tlow, c_over, c_under);
+ vec3 color_low = vec3(c_over, c_under, c_over);
+
+ float thigh = max(2.0 * t - 1.0, 0.0);
+ gradcurves(thigh, c_over, c_under);
+ vec3 color_high = vec3(c_under, c_under, c_over);
+
+ vec3 color = mix(color_low, color_high, step(0.5, t));
+
+ // --- bevel gradients ---
+ float bv_shade = mod(1.0 * dot(grad, normalize(vec2(0.1, 1.0))) * 0.5 + 0.5, 1.0);
+
+ gradcurves(1.0 - bv_shade, c_over, c_under);
+ vec3 bv_col = vec3(c_under, c_under, c_over);
+
+ gl_FragColor.rgb = mix(bv_col, color, outline);
+ gl_FragColor.a = glyph;
+}
+
+void gradcurves(float t, out float over, out float under)
+{
+ over = cos(t * HALF_PI);
+ under = cos(t * HALF_PI + HALF_PI) + 1.0;
+}
--- /dev/null
+varying vec2 local_pt;
+
+void main()
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ local_pt = gl_Vertex.xy;
+}
+++ /dev/null
-uniform sampler2D tex;
-uniform float smoothness;
-uniform float height;
-
-varying vec2 local_pt;
-
-void gradcurves(float t, out float over, out float under);
-
-#define HALF_PI 1.570796326794897
-
-void main()
-{
- const vec2 pix_sz = vec2(1.0 / 512.0, 1.0 / 256.0); // TODO: uniform
-
- vec2 uv = gl_TexCoord[0].st;
- float dist = texture2D(tex, uv).a;
-
- float dfdu = texture2D(tex, uv + vec2(pix_sz.x, 0.0)).a - dist;
- float dfdv = texture2D(tex, uv + vec2(0.0, pix_sz.y)).a - dist;
- vec2 grad = normalize(vec2(dfdu, dfdv));
-
- float glyph = smoothstep(0.47 - smoothness, 0.47 + smoothness, dist);
- float outline = smoothstep(0.54 - smoothness, 0.54 + smoothness, dist);
-
- // --- face gradients ---
- float t = local_pt.y / height;
-
- float c_over, c_under;
- float tlow = min(2.0 * t, 1.0);
- gradcurves(tlow, c_over, c_under);
- vec3 color_low = vec3(c_over, c_under, c_over);
-
- float thigh = max(2.0 * t - 1.0, 0.0);
- gradcurves(thigh, c_over, c_under);
- vec3 color_high = vec3(c_under, c_under, c_over);
-
- vec3 color = mix(color_low, color_high, step(0.5, t));
-
- // --- bevel gradients ---
- float bv_shade = mod(1.0 * dot(grad, normalize(vec2(0.1, 1.0))) * 0.5 + 0.5, 1.0);
-
- gradcurves(1.0 - bv_shade, c_over, c_under);
- vec3 bv_col = vec3(c_under, c_under, c_over);
-
- gl_FragColor.rgb = mix(bv_col, color, outline);
- gl_FragColor.a = glyph;
-}
-
-void gradcurves(float t, out float over, out float under)
-{
- over = cos(t * HALF_PI);
- under = cos(t * HALF_PI + HALF_PI) + 1.0;
-}
-varying vec2 local_pt;
-
void main()
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
- local_pt = gl_Vertex.xy;
}
--- /dev/null
+void main()
+{
+ const vec3 color = vec3(0.2, 0.4, 1.0);
+
+ vec2 uv = gl_TexCoord[0].st;
+ vec2 pt = uv * vec2(2.0) - vec2(1.0);
+
+ float d_horiz = abs(pt.x);
+ float d_vert = max(abs(pt.y), 0.0);
+
+ float beam_sharpness = 80.0 * min(uv.y + 0.3, 1.0);
+ float beam_intensity = 6.0 * (1.0 - uv.y);
+
+ float glow_u = pow(1.0 - smoothstep(0.0, 1.0, d_horiz), beam_sharpness) * beam_intensity;
+ float glow_v = 1.0 - smoothstep(0.8, 1.0, d_vert);
+
+ float glow = glow_u * glow_v;
+
+ gl_FragColor.rgb = color * glow;// + vec3(0.0, 1.0, 0.0) * step(0.99, max(abs(pt.x), abs(pt.y)));
+ gl_FragColor.a = 1.0;
+}
--- /dev/null
+void main()
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
--- /dev/null
+uniform sampler2D tex;
+uniform float smoothness;
+uniform float height;
+uniform vec2 pix_sz;
+
+varying vec2 local_pt;
+
+void main()
+{
+ const vec3 color = vec3(0.2, 0.4, 1.0);
+
+ vec2 uv = gl_TexCoord[0].st;
+ float dist = texture2D(tex, uv).a;
+
+ float glyph = smoothstep(0.5 - smoothness, 0.5 + smoothness, dist);
+
+ gl_FragColor.rgb = color * ((dist - 0.5 - smoothness) * 45.0);
+ gl_FragColor.a = glyph;
+}
static dtx_font *fat_font;
#define FAT_FONT_SZ 32
-static unsigned int font_sdr;
+static unsigned int glow_link_sdr;
+static unsigned int chrome_font_sdr, glow_font_sdr;
bool init_fs(const char *path)
}
dtx_use_font(fat_font, FAT_FONT_SZ);
- if(!(font_sdr = create_program_load("sdr/dfont.v.glsl", "sdr/dfont.p.glsl"))) {
+ struct dtx_glyphmap *fat_gmap = dtx_get_glyphmap(fat_font, 0);
+ Vec2 pixsz;
+ pixsz.x = 1.0 / dtx_get_glyphmap_width(fat_gmap);
+ pixsz.y = 1.0 / dtx_get_glyphmap_height(fat_gmap);
+
+ if(!(chrome_font_sdr = create_program_load("sdr/chrome_font.v.glsl", "sdr/chrome_font.p.glsl"))) {
+ return false;
+ }
+ set_uniform_float(chrome_font_sdr, "height", dtx_line_height());
+ set_uniform_float(chrome_font_sdr, "smoothness", 0.01);
+ set_uniform_float2(chrome_font_sdr, "pix_sz", pixsz.x, pixsz.y);
+
+ if(!(glow_font_sdr = create_program_load("sdr/dfont.v.glsl", "sdr/glow_font.p.glsl"))) {
+ return false;
+ }
+ set_uniform_float(glow_font_sdr, "smoothness", 0.01);
+ set_uniform_float2(glow_font_sdr, "pix_sz", pixsz.x, pixsz.y);
+
+ if(!(glow_link_sdr = create_program_load("sdr/glink.v.glsl", "sdr/glink.p.glsl"))) {
return false;
}
- set_uniform_float(font_sdr, "smoothness", 0.01);
if(!(cur_node = get_fsnode(path))) {
return false;
rot_xform.rotate(0, 0, time_sec * 0.5);
glDisable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
int nchildren = (int)cur_node->children.size();
int ncols = std::min(cur_node->nfiles, max_ncols);
}
}
- // ... and draw them
- glLineWidth(5.0);
+ // draw the directory link lines
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
for(int i=0; i<nchildren; i++) {
FSNode *node = cur_node->children[i];
xform.rotate_y(angle);
xform.translate(0, -0.3, 0);
- glUseProgram(0);
+ glUseProgram(glow_link_sdr);
glPushMatrix();
glMultMatrixf(xform[0]);
+ glDepthMask(0);
- glBegin(GL_LINES);
+ glBegin(GL_QUADS);
glColor3f(0.2, 0.3, 0.8);
- glVertex3f(0, 0, -0.3);
- glVertex3f(0, 0, -2);
+ glTexCoord2f(0, 0);
+ glVertex3f(-0.25, 0, 0.05);
+ glTexCoord2f(1, 0);
+ glVertex3f(0.25, 0, 0.05);
+ glTexCoord2f(1, 1);
+ glVertex3f(0.25, 0, -2.0);
+ glTexCoord2f(0, 1);
+ glVertex3f(-0.25, 0, -2.0);
glColor3f(1, 1, 1);
glEnd();
glPopMatrix();
+ glDepthMask(1);
+ }
+
+ // draw the directory labels
+ glUseProgram(glow_font_sdr);
+ col = 0;
+ for(int i=0; i<nchildren; i++) {
+ FSNode *node = cur_node->children[i];
+
+ if(node->type != FSTYPE_DIR) {
+ continue;
+ }
+
+ float angle = (float)col++ / (float)(num_dirs - 1) * max_icon_angle - max_icon_angle * 0.5;
+
draw_node_name(node, angle, -0.3, radius, false);
}
- glLineWidth(1.0);
- // then draw files
+ // then draw file icons
+ glDisable(GL_BLEND);
+ glUseProgram(0);
col = 0;
for(int i=0; i<nchildren; i++) {
int idx = (i + first) % nchildren;
continue;
}
- glUseProgram(0);
-
float angle = icon_angle(col, ncols, max_icon_angle);
Mat4 xform = rot_xform;
iconrend->draw(node);
glPopMatrix();
+ if(++col >= ncols) {
+ col = 0;
+ ++row;
+ }
+ }
+
+ // then draw the file labels
+ glUseProgram(chrome_font_sdr);
+ col = 0;
+ row = 0;
+ for(int i=0; i<nchildren; i++) {
+ int idx = (i + first) % nchildren;
+ FSNode *node = cur_node->children[idx];
+
+ if(node->type == FSTYPE_DIR) {
+ ++num_dirs;
+ continue;
+ }
+
+ float angle = icon_angle(col, ncols, max_icon_angle);
+
draw_node_name(node, angle, row * row_spacing - 0.1, radius, false);
if(++col >= ncols) {
xform.rotate_y(angle);
glMultMatrixf(xform[0]);
- glUseProgram(font_sdr);
- set_uniform_float(font_sdr, "height", line_height);
dtx_string(name);
glPopMatrix();
}