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(); if(!gGourceSettings.hide_mouse && cursor.isVisible()) { mousetrace(frustum,dt); } trace_time = SDL_GetTicks() - trace_time; glMatrixMode(GL_PROJECTION); glLoadIdentity(); camera.focus(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //draw tree drawTree(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); //draw bloom drawBloom(frustum, dt); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); name_calc_time = SDL_GetTicks(); root->calcScreenPos(); name_calc_time = SDL_GetTicks() - name_calc_time; name_draw_time = SDL_GetTicks(); //switch to 2D, preserve current state display.push2D(); root->drawNames(font,frustum); //switch back display.pop2D(); name_draw_time = SDL_GetTicks() - name_draw_time; if(!(gGourceSettings.hide_usernames || gGourceSettings.hide_users)) { for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawName(); } } //draw selected item names again so they are over the top if(selectedUser !=0) selectedUser->drawName(); if(selectedFile !=0) { display.push2D(); selectedFile->drawName(); display.pop2D(); } if(debug) { glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); track_users ? user_bounds.draw() : dir_bounds.draw(); } if(gGourceQuadTreeDebug) { glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glLineWidth(1.0); dirNodeTree->outline(); glColor4f(0.0f, 1.0f, 1.0f, 1.0f); userTree->outline(); } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); display.mode2D(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); vec3f campos = camera.getPos(); if(logotex!=0) { glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(GL_TEXTURE_2D, logotex->textureid); vec2f logopos = vec2f(display.width, display.height) - vec2f(logotex->w, logotex->h) - gGourceSettings.logo_offset; glPushMatrix(); glTranslatef(logopos.x, logopos.y, 0.0); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex2i(0, 0); glTexCoord2f(1.0f,0.0f); glVertex2i(logotex->w, 0); glTexCoord2f(1.0f,1.0f); glVertex2i(logotex->w, logotex->h); glTexCoord2f(0.0f,1.0f); glVertex2i(0, logotex->h); glEnd(); glPopMatrix(); } if(splash>0.0f) { int logowidth = fontlarge.getWidth("Gource"); int logoheight = 100; int cwidth = font.getWidth("Software Version Control Visualization"); int awidth = font.getWidth("(C) 2009 Andrew Caudwell"); vec2f corner(display.width/2 - logowidth/2 - 30.0f, display.height/2 - 40); glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.5f, 1.0f, splash * 0.015f); glBegin(GL_QUADS); glVertex2f(0.0f, corner.y); glVertex2f(0.0f, corner.y + logoheight); glVertex2f(display.width, corner.y + logoheight); glVertex2f(display.width, corner.y); glEnd(); glEnable(GL_TEXTURE_2D); glColor4f(1.0,1.0,1.0,1.0); fontlarge.draw(display.width/2 - logowidth/2,display.height/2 - 30, "Gource"); font.draw(display.width/2 - cwidth/2,display.height/2 + 10, "Software Version Control Visualization"); font.draw(display.width/2 - awidth/2,display.height/2 + 30, "(C) 2009 Andrew Caudwell"); } // text using the specified font goes here glColor4f(gGourceSettings.font_colour.x, gGourceSettings.font_colour.y, gGourceSettings.font_colour.z, 1.0f); if(!gGourceSettings.hide_date) { fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate); } if(gGourceSettings.title.size()>0) { fontmedium.alignTop(false); fontmedium.draw(10, display.height - 10, gGourceSettings.title); fontmedium.alignTop(true); } if(message_timer>0.0f) { fontmedium.draw(1, 3, message); } // end text glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if(debug) { font.print(1,20, "FPS: %.2f", fps); font.print(1,40,"Days Per Second: %.2f", gGourceSettings.days_per_second); font.print(1,60,"Time Scale: %.2f", time_scale); font.print(1,80,"Users: %d", users.size()); font.print(1,100,"Files: %d", files.size()); font.print(1,120,"Dirs: %d", gGourceDirMap.size()); font.print(1,140,"Log Position: %.4f", commitlog->getPercent()); font.print(1,160,"Camera: (%.2f, %.2f, %.2f)", campos.x, campos.y, campos.z); font.print(1,180,"Gravity: %.2f", gGourceForceGravity); font.print(1,200,"Update Tree: %u ms", update_dir_tree_time); font.print(1,220,"Draw Tree: %u ms", draw_tree_time); font.print(1,240,"Mouse Trace: %u ms", trace_time); font.print(1,260,"Logic Time: %u ms", logic_time); font.print(1,280,"Draw Time: %u ms (Names: Calc Time = %u ms, Draw Time = %u ms)", SDL_GetTicks() - draw_time, name_calc_time, name_draw_time); font.print(1,300,"File Inner Loops: %d", gGourceFileInnerLoops); font.print(1,320,"User Inner Loops: %d", gGourceUserInnerLoops); font.print(1,340,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops, dirNodeTree->item_count, dirNodeTree->node_count); if(selectedUser != 0) { } if(selectedFile != 0) { font.print(1,360,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(), selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount()); } } glDisable(GL_TEXTURE_2D); if(canSeek()) slider.draw(dt); mousemoved=false; mouseclicked=false; }
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); 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); //draw bloom drawBloom(frustum, dt); root->drawNames(font,frustum); if(!(gGourceHideUsernames || gGourceHideUsers)) { for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawName(); } } //draw selected item names again so they are over the top if(selectedUser !=0) selectedUser->drawName(); if(selectedFile !=0) { vec2f dirpos = selectedFile->getDir()->getPos(); glPushMatrix(); glTranslatef(dirpos.x, dirpos.y, 0.0); selectedFile->drawName(); glPopMatrix(); } if(debug) { glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); track_users ? user_bounds.draw() : dir_bounds.draw(); } if(gGourceQuadTreeDebug) { glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glLineWidth(1.0); dirNodeTree->outline(); glColor4f(0.0f, 1.0f, 1.0f, 1.0f); userTree->outline(); } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); display.mode2D(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); vec3f campos = camera.getPos(); if(!gGourceHideDate) { fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate); } if(splash>0.0f) { int logowidth = fontlarge.getWidth("Gource"); int logoheight = 100; int cwidth = font.getWidth("Software Version Control Visualization"); int awidth = font.getWidth("(C) 2009 Andrew Caudwell"); vec2f corner(display.width/2 - logowidth/2 - 30.0f, display.height/2 - 40); glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.5f, 1.0f, splash * 0.015f); glBegin(GL_QUADS); glVertex2f(0.0f, corner.y); glVertex2f(0.0f, corner.y + logoheight); glVertex2f(display.width, corner.y + logoheight); glVertex2f(display.width, corner.y); glEnd(); glEnable(GL_TEXTURE_2D); glColor4f(1.0,1.0,1.0,1.0); fontlarge.draw(display.width/2 - logowidth/2,display.height/2 - 30, "Gource"); font.draw(display.width/2 - cwidth/2,display.height/2 + 10, "Software Version Control Visualization"); font.draw(display.width/2 - awidth/2,display.height/2 + 30, "(C) 2009 Andrew Caudwell"); } if(debug) { font.print(0,20, "FPS: %.2f", fps); font.print(0,40,"Time Scale: %.2f", time_scale); font.print(0,60,"Users: %d", users.size()); font.print(0,80,"Files: %d", files.size()); font.print(0,100,"Dirs: %d", gGourceDirMap.size()); font.print(0,120,"Log Position: %.2f", commitlog->getPercent()); font.print(0,140,"Camera: (%.2f, %.2f, %.2f)", campos.x, campos.y, campos.z); font.print(0,160,"Gravity: %.2f", gGourceForceGravity); font.print(0,180,"Update Tree: %u ms", update_dir_tree_time); font.print(0,200,"Draw Tree: %u ms", draw_tree_time); font.print(0,220,"Mouse Trace: %u ms", trace_time); font.print(0,240,"Logic Time: %u ms", logic_time); font.print(0,260,"Draw Time: %u ms", SDL_GetTicks() - draw_time); font.print(0,280,"File Inner Loops: %d", gGourceFileInnerLoops); font.print(0,300,"User Inner Loops: %d", gGourceUserInnerLoops); font.print(0,320,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops, dirNodeTree->item_count, dirNodeTree->node_count); if(selectedUser != 0) { } if(selectedFile != 0) { font.print(0,360,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(), selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount()); } } glDisable(GL_TEXTURE_2D); if(canSeek()) slider.draw(dt); mousemoved=false; mouseclicked=false; }
void Gource::draw(float t, float dt) { dt = std::min<float>(dt, gGourceMaxDelta * time_scale); display.setClearColour(background_colour); display.clear(); if(draw_loading) { loadingScreen(); draw_loading = false; return; } //camera tracking if(track_users && (selectedFile !=0 || selectedUser !=0)) { Bounds2D focusbounds; vec3f camerapos = camera.getPos(); if(selectedUser !=0) focusbounds.update(selectedUser->getPos()); if(selectedFile !=0) focusbounds.update(selectedFile->getAbsolutePos()); camera.adjust(focusbounds); } else { if(track_users && idle_time==0) camera.adjust(user_bounds); else camera.adjust(dir_bounds); } camera.logic(dt); 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_time = SDL_GetTicks(); root->calcEdges(); //switch to 2d glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, display.width, display.height, 0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); //draw edges root->drawEdgeShadows(dt); root->drawEdges(dt); //switch back glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); //draw shadows if(!gGourceHideUsers) { for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawShadow(dt); } } root->drawShadows(frustum, dt); //draw actions for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawActions(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); draw_tree_time = SDL_GetTicks() - draw_tree_time; 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(!gGourceHideUsernames) { for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawName(); } } //draw selected item names again so they are over the top if(selectedUser !=0) selectedUser->drawName(); if(selectedFile !=0) { vec2f dirpos = selectedFile->getDir()->getPos(); glPushMatrix(); glTranslatef(dirpos.x, dirpos.y, 0.0); selectedFile->drawName(); glPopMatrix(); } if(debug) { glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); track_users ? user_bounds.draw() : dir_bounds.draw(); } if(gGourceQuadTreeDebug) { glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glLineWidth(1.0); dirNodeTree->outline(); glColor4f(0.0f, 1.0f, 1.0f, 1.0f); userTree->outline(); } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); display.mode2D(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); vec3f campos = camera.getPos(); float width = static_cast<float>(display.width); float height = static_cast<float>(display.height); float half_width = width/2.0f; float half_height = height/2.0f; if(!gGourceHideDate) { fontmedium.draw(half_width - date_x_offset, 20.0f, displaydate); } if(splash>0.0f) { float logowidth = fontlarge.getWidth("Gource"); float logoheight = 100.0f; float cwidth = font.getWidth("Software Version Control Visualization"); float awidth = font.getWidth("(C) 2009 Andrew Caudwell"); vec2f corner(half_width - logowidth/2.0f - 30.0f, half_height - 40.0f); glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.5f, 1.0f, splash * 0.015f); glBegin(GL_QUADS); glVertex2f(0.0f, corner.y); glVertex2f(0.0f, corner.y + logoheight); glVertex2f(width, corner.y + logoheight); glVertex2f(width, corner.y); glEnd(); glEnable(GL_TEXTURE_2D); glColor4f(1.0f,1.0f,1.0f,1.0f); fontlarge.draw(half_width - logowidth/2.0f,half_height - 30.0f, "Gource"); font.draw(half_width - cwidth/2.0f,half_height + 10.0f, "Software Version Control Visualization"); font.draw(half_width - awidth/2.0f,half_height + 30.0f, "(C) 2009 Andrew Caudwell"); } if(debug) { font.print(0,20, "FPS: %.2f", fps); font.print(0,60,"Users: %d", users.size()); font.print(0,80,"Files: %d", files.size()); font.print(0,100,"Dirs: %d", gGourceDirMap.size()); font.print(0,120,"Log Position: %.2f", commitlog->getPercent()); font.print(0,140,"Camera: (%.2f, %.2f, %.2f)", campos.x, campos.y, campos.z); font.print(0,160,"Gravity: %.2f", gGourceForceGravity); font.print(0,180,"Update Tree: %u ms", update_dir_tree_time); font.print(0,200,"Draw Tree: %u ms", draw_tree_time); font.print(0,220,"Mouse Trace: %u ms", trace_time); font.print(0,240,"Logic Time: %u ms", logic_time); font.print(0,260,"Draw Time: %u ms", SDL_GetTicks() - draw_time); font.print(0,280,"File Inner Loops: %d", gGourceFileInnerLoops); font.print(0,300,"User Inner Loops: %d", gGourceUserInnerLoops); font.print(0,320,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops, dirNodeTree->item_count, dirNodeTree->node_count); if(selectedUser != 0) { } if(selectedFile != 0) { font.print(0.0f,360.0f,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(), selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount()); } } glDisable(GL_TEXTURE_2D); if(canSeek()) slider.draw(dt); mousemoved=false; mouseclicked=false; }