Skip to content

Commit

Permalink
New effect now called 'bloom'
Browse files Browse the repository at this point in the history
--no-bloom turns this off.

Added

--hide-tree
--hide-files

Incase you just want to look at the bloom effect.
  • Loading branch information
acaudwell committed Dec 11, 2009
1 parent 3c95836 commit 760038d
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 91 deletions.
Binary file added data/bloom.tga
Binary file not shown.
4 changes: 2 additions & 2 deletions src/dirnode.cpp
Expand Up @@ -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)) {

Expand All @@ -1060,7 +1060,7 @@ void RDirNode::gourceianBlur(Frustum& frustum, float dt) {

for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) {
RDirNode* node = (*it);
node->gourceianBlur(frustum,dt);
node->drawBloom(frustum,dt);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dirnode.h
Expand Up @@ -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);
Expand Down
163 changes: 77 additions & 86 deletions src/gource.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) {
Expand All @@ -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<std::string,RUser*>::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<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) {
it->second->drawName();
}
Expand Down
7 changes: 6 additions & 1 deletion src/gource.h
Expand Up @@ -99,7 +99,7 @@ class Gource : public SDLApp {
std::string displaydate;
int date_x_offset;

TextureResource* blurtex;
TextureResource* bloomtex;

FXFont font, fontlarge, fontmedium;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 16 additions & 1 deletion src/main.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 760038d

Please sign in to comment.