diff --git a/data/bloom.tga b/data/bloom.tga new file mode 100644 index 00000000..f7812c39 Binary files /dev/null and b/data/bloom.tga differ diff --git a/src/dirnode.cpp b/src/dirnode.cpp index 1fc8e5ac..dab85a27 100644 --- a/src/dirnode.cpp +++ b/src/dirnode.cpp @@ -1034,7 +1034,7 @@ void RDirNode::drawEdges(float dt) { } } -void RDirNode::gourceianBlur(Frustum& frustum, float dt) { +void RDirNode::drawBloom(Frustum& frustum, float dt) { if(isVisible() && frustum.boundsInFrustum(quadItemBounds)) { @@ -1060,7 +1060,7 @@ void RDirNode::gourceianBlur(Frustum& frustum, float dt) { for(std::list::iterator it = children.begin(); it != children.end(); it++) { RDirNode* node = (*it); - node->gourceianBlur(frustum,dt); + node->drawBloom(frustum,dt); } } diff --git a/src/dirnode.h b/src/dirnode.h index 06544f57..821361d7 100644 --- a/src/dirnode.h +++ b/src/dirnode.h @@ -175,7 +175,7 @@ class RDirNode : public QuadItem { void drawEdges(float dt); void drawEdgeShadows(float dt); - void gourceianBlur(Frustum& frustum, float dt); + void drawBloom(Frustum& frustum, float dt); void drawShadows(Frustum& frustum, float dt); void drawFiles(Frustum& frustum, float dt); diff --git a/src/gource.cpp b/src/gource.cpp index 7967c027..215f52b3 100644 --- a/src/gource.cpp +++ b/src/gource.cpp @@ -19,8 +19,11 @@ float gGourceAutoSkipSeconds = 3.0; bool gGourceFileLoop = false; +bool gGourceHideTree = false; +bool gGourceHideFiles = false; bool gGourceHideUsernames = false; bool gGourceHideDate = false; +bool gGourceNoBloom = false; bool gGourceDisableProgress = false; bool gGourceQuadTreeDebug = false; @@ -163,7 +166,12 @@ void gource_help(std::string error) { printf(" --disable-auto-skip Disable auto skipping\n"); printf(" --disable-progress Disable the progress bar\n\n"); + printf(" --bloom-multiplier Adjust amount of bloom (default: 1.0)\n"); + printf(" --no-bloom Turn off bloom effect\n\n"); + printf(" --hide-users Hide users\n"); + printf(" --hide-tree Hide the tree\n"); + printf(" --hide-files Hide files\n"); printf(" --hide-usernames Hide usernames\n"); printf(" --hide-filenames Hide filenames\n"); printf(" --hide-dirnames Hide directory names\n"); @@ -296,7 +304,7 @@ Gource::Gource(std::string logfile) { font.dropShadow(true); font.roundCoordinates(true); - blurtex = texturemanager.grab("gourceian.tga"); + bloomtex = texturemanager.grab("bloom.tga"); start_position = 0.0; stop_position = 0.0; @@ -1499,78 +1507,9 @@ void Gource::loadingScreen() { void Gource::drawBackground(float dt) { display.setClearColour(background_colour); display.clear(); - - display.mode2D(); -/* - float blur_radius = display.width * 2.0; - - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - glBindTexture(GL_TEXTURE_2D, blurtex->textureid); - - glBlendFunc(GL_ONE, GL_ONE); - - glColor4f(background_colour.x,background_colour.y, background_colour.z, 1.0); - - glPushMatrix(); - - glTranslatef(display.width * 0.25f, display.height * 0.5f, 0.0f); - - glBegin(GL_QUADS); - glTexCoord2f(1.0, 1.0); - glVertex2f(blur_radius,blur_radius); - glTexCoord2f(1.0, 0.0); - glVertex2f(blur_radius,-blur_radius); - glTexCoord2f(0.0, 0.0); - glVertex2f(-blur_radius,-blur_radius); - glTexCoord2f(0.0, 1.0); - glVertex2f(-blur_radius,blur_radius); - glEnd(); - - glTranslatef(display.width * 0.5f, 0.0f, 0.0f); - - glBegin(GL_QUADS); - glTexCoord2f(1.0, 1.0); - glVertex2f(blur_radius,blur_radius); - glTexCoord2f(1.0, 0.0); - glVertex2f(blur_radius,-blur_radius); - glTexCoord2f(0.0, 0.0); - glVertex2f(-blur_radius,-blur_radius); - glTexCoord2f(0.0, 1.0); - glVertex2f(-blur_radius,blur_radius); - glEnd(); - - glPopMatrix(); -*/ } -void Gource::draw(float t, float dt) { - - drawBackground(dt); - - if(draw_loading) { - loadingScreen(); - draw_loading = false; - return; - } - - Frustum frustum(camera); - - trace_time = SDL_GetTicks(); - - mousetrace(frustum,dt); - - trace_time = SDL_GetTicks() - trace_time; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - camera.focus(); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - +void Gource::drawTree(Frustum& frustum, float dt) { draw_tree_time = SDL_GetTicks(); root->calcEdges(); @@ -1590,8 +1529,10 @@ void Gource::draw(float t, float dt) { glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - root->drawEdgeShadows(dt); - root->drawEdges(dt); + if(!gGourceHideTree) { + root->drawEdgeShadows(dt); + root->drawEdges(dt); + } //switch back glMatrixMode(GL_PROJECTION); @@ -1603,13 +1544,6 @@ void Gource::draw(float t, float dt) { glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); - //draw 'gourceian blur' around dirnodes - glBindTexture(GL_TEXTURE_2D, blurtex->textureid); - glBlendFunc (GL_ONE, GL_ONE); - root->gourceianBlur(frustum, dt); - - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //draw shadows if(!gGourceHideUsers) { @@ -1618,7 +1552,9 @@ void Gource::draw(float t, float dt) { } } - root->drawShadows(frustum, dt); + if(!gGourceHideFiles) { + root->drawShadows(frustum, dt); + } //draw actions for(std::map::iterator it = users.begin(); it!=users.end(); it++) { @@ -1627,23 +1563,78 @@ void Gource::draw(float t, float dt) { glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(0.0, 1.0, 0.0, 1.0); - trace_debug ? root->drawSimple(frustum,dt) : root->drawFiles(frustum,dt); + if(!trace_debug) { + if(!gGourceHideFiles) { + root->drawFiles(frustum,dt); + } + } else { + root->drawSimple(frustum,dt); + } draw_tree_time = SDL_GetTicks() - draw_tree_time; +} + +void Gource::drawBloom(Frustum &frustum, float dt) { + if(gGourceNoBloom) return; + + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + //draw 'gourceian blur' around dirnodes + glBindTexture(GL_TEXTURE_2D, bloomtex->textureid); + glBlendFunc (GL_ONE, GL_ONE); + root->drawBloom(frustum, dt); + + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + +void Gource::draw(float t, float dt) { + + display.mode2D(); + + drawBackground(dt); + + if(draw_loading) { + loadingScreen(); + draw_loading = false; + return; + } + + Frustum frustum(camera); + + trace_time = SDL_GetTicks(); + + mousetrace(frustum,dt); + + trace_time = SDL_GetTicks() - trace_time; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + camera.focus(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + //draw tree + drawTree(frustum, dt); + + //draw bloom + drawBloom(frustum, dt); glColor4f(1.0, 1.0, 0.0, 1.0); for(std::map::iterator it = users.begin(); it!=users.end(); it++) { trace_debug ? it->second->drawSimple(dt) : it->second->draw(dt); } - glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); - root->drawNames(font,frustum); + if(!(gGourceHideFiles || gGourceHideFilenames)) { + root->drawNames(font,frustum); + } - if(!gGourceHideUsernames) { + if(!(gGourceHideUsernames || gGourceHideUsers)) { for(std::map::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawName(); } diff --git a/src/gource.h b/src/gource.h index 13bb42cd..c04b3c36 100644 --- a/src/gource.h +++ b/src/gource.h @@ -99,7 +99,7 @@ class Gource : public SDLApp { std::string displaydate; int date_x_offset; - TextureResource* blurtex; + TextureResource* bloomtex; FXFont font, fontlarge, fontmedium; @@ -176,6 +176,8 @@ class Gource : public SDLApp { void loadingScreen(); void drawBackground(float dt); + void drawTree(Frustum &frustum, float dt); + void drawBloom(Frustum &frustum, float dt); public: Gource(std::string logfile); ~Gource(); @@ -204,7 +206,10 @@ class Gource : public SDLApp { extern float gGourceAutoSkipSeconds; extern bool gGourceHideUsernames; +extern bool gGourceNoBloom; extern bool gGourceHideDate; +extern bool gGourceHideFiles; +extern bool gGourceHideTree; extern bool gGourceDisableProgress; extern bool gGourceFileLoop; extern int gGourceMaxFiles; diff --git a/src/main.cpp b/src/main.cpp index 7849031f..c442fcf4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { int height = 768; bool fullscreen=false; bool multisample=false; - vec3f background = vec3f(0.0, 0.0, 0.0); + vec3f background = vec3f(0.1, 0.1, 0.1); int video_framerate = 60; std::string ppm_file_name; @@ -101,11 +101,26 @@ int main(int argc, char *argv[]) { continue; } + if(args == "--no-bloom") { + gGourceNoBloom = true; + continue; + } + if(args == "--hide-users") { gGourceHideUsers = true; continue; } + if(args == "--hide-tree") { + gGourceHideTree = true; + continue; + } + + if(args == "--hide-files") { + gGourceHideFiles = true; + continue; + } + if(args == "--hide-usernames") { gGourceHideUsernames = true; continue;