X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Ffs.cc;h=3db00122e9b70a35d803e1c411dbac75257df323;hp=ae5b31abdcbbe66002fcb8dac31ff95ec02f1783;hb=HEAD;hpb=1c2b18e725db9e066d5dcb11123fc2019aec2ee7 diff --git a/src/fs.cc b/src/fs.cc index ae5b31a..3db0012 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -26,7 +26,8 @@ static int start_child; 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) @@ -51,10 +52,27 @@ 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; @@ -89,6 +107,7 @@ void draw_fs() static const float radius = 0.6; static const float umax = 0.42; static const float max_icon_angle = M_PI * 2.0 * umax; + static const float first_row_y = -row_spacing; int max_ncols = std::max(1, umax * 12); @@ -100,9 +119,11 @@ void draw_fs() 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); + int ncols = std::max(std::min(cur_node->nfiles, max_ncols), 1); int first = start_child % ncols; int col = 0, row = 0; @@ -116,8 +137,11 @@ void draw_fs() } } - // ... and draw them - glLineWidth(5.0); + // draw the directory link lines + glUseProgram(glow_link_sdr); + set_uniform_float(glow_link_sdr, "tsec", time_sec); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + for(int i=0; ichildren[i]; @@ -129,25 +153,50 @@ void draw_fs() Mat4 xform; xform.rotate_y(angle); - xform.translate(0, -0.3, 0); + xform.translate(0, -0.6, 0); - glUseProgram(0); glPushMatrix(); glMultMatrixf(xform[0]); + glDepthMask(0); + + set_uniform_float(glow_link_sdr, "phase", col * 42.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.2, 0, 0.05); + glTexCoord2f(1, 0); + glVertex3f(0.2, 0, 0.05); + glTexCoord2f(1, 1); + glVertex3f(0.2, 0, -10.0); + glTexCoord2f(0, 1); + glVertex3f(-0.2, 0, -10.0); glColor3f(1, 1, 1); glEnd(); glPopMatrix(); - draw_node_name(node, angle, -0.3, radius, false); + glDepthMask(1); + } + + // draw the directory labels + glUseProgram(glow_font_sdr); + col = 0; + for(int i=0; ichildren[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.6, radius * 1.2, false); } - glLineWidth(1.0); - // then draw files + // then draw file icons + glDisable(GL_BLEND); + glUseProgram(0); + glLineWidth(2.0); col = 0; for(int i=0; idraw(node); glPopMatrix(); - draw_node_name(node, angle, row * row_spacing - 0.1, radius, false); + if(++col >= ncols) { + col = 0; + ++row; + } + } + glLineWidth(1.0); + + // then draw the file labels + glUseProgram(chrome_font_sdr); + col = 0; + row = 0; + for(int i=0; ichildren[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 + first_row_y - 0.08, radius, false); if(++col >= ncols) { col = 0; @@ -192,11 +261,11 @@ static void draw_node_name(FSNode *node, float angle, float ypos, float dist, bo const char *name = full ? node->name_lines[i].c_str() : node->short_name.c_str(); glPushMatrix(); Mat4 xform; - xform.translate(-dtx_string_width(name) / 2.0, -line_height * i, 0); + xform.translate(-dtx_string_width(name) / 2.0, -line_height * i - line_height * 0.5, 0); if(node->type == FSTYPE_DIR) { xform.rotate_z(deg_to_rad(90)); xform.rotate_x(deg_to_rad(-90)); - xform.scale(0.0017); + xform.scale(0.0018); } else { xform.scale(0.0012); } @@ -204,8 +273,6 @@ static void draw_node_name(FSNode *node, float angle, float ypos, float dist, bo xform.rotate_y(angle); glMultMatrixf(xform[0]); - glUseProgram(font_sdr); - set_uniform_float(font_sdr, "height", line_height); dtx_string(name); glPopMatrix(); }