Permalink
Browse files

Implemented --logo and --background-image options.

  • Loading branch information...
1 parent c7f9536 commit 5156be30c7ee9b84911cd51bb4ba7e85e88351e0 @acaudwell committed Mar 22, 2010
Showing with 200 additions and 56 deletions.
  1. +15 −15 README
  2. +15 −15 data/gource.1
  3. +18 −8 src/core/settings.cpp
  4. +4 −0 src/core/settings.h
  5. +8 −5 src/core/texture.cpp
  6. +4 −3 src/core/texture.h
  7. +75 −0 src/gource.cpp
  8. +2 −0 src/gource.h
  9. +49 −5 src/gource_settings.cpp
  10. +4 −0 src/gource_settings.h
  11. +4 −3 src/main.cpp
  12. +2 −2 src/user.cpp
View
@@ -81,31 +81,31 @@ options:
-e, --elasticity FLOAT
Elasticity of nodes.
- -b, --background FFFFFF
+ -b, --background-colour FFFFFF
Background colour in hex.
+ --background-image IMAGE
+ Set a background image.
+
+ --logo IMAGE
+ Logo to display in the foreground.
+
+ --logo-offset XxY
+ Offset position of the logo.
+
--date-format FORMAT
Specify display date string (strftime format).
- --log-format FORMAT
+ --log-command VCS
+ Show the log command used by gource (git,cvs,hg,bzr)
+
+ --log-format VCS
Specify format of the log being read (git,cvs,hg,bzr,custom).
- Required when reading STDIN.
+ Required when reading from STDIN.
--git-branch
Get the git log of a branch other than the current one.
- --git-log-command
- Print the git log command used by gource.
-
- --hg-log-command
- Print the hg log (Mercurial) command used by gource.
-
- --bzr-log-command
- Print the bzr log (Bazaar) command used by gource.
-
- --cvs-exp-command
- Print the cvs-exp.pl log command used by gource.
-
--follow-user USER
Have the camera automatically follow a particular user.
View
@@ -55,29 +55,29 @@ Time in seconds files remain idle before they are removed.
\fB\-e, \-\-elasticity FLOAT\fR
Elasticity of nodes.
.TP
-\fB\-b, \-\-background FFFFFF\fR
+\fB\-b, \-\-background-colour FFFFFF\fR
Background colour in hex.
.TP
-\fB\-\-date\-format FORMAT\fR
-Specify display date string (strftime format).
+\fB\-\-background\-image IMAGE\fR
+Set a background image.
.TP
-\fB\-\-log\-format FORMAT\fR
-Specify format of the log being read (git,cvs,hg,bzr,custom). Required when reading STDIN.
+\fB\-\-logo IMAGE\fR
+Logo to display in the foreground.
.TP
-\fB\-\-git\-branch\fR
-Get the git log of a branch other than the current one.
+\fB\-\-logo\-offset XxY\fR
+Offset position of the logo.
.TP
-\fB\-\-git\-log\-command\fR
-Print the git log command used by \fIgource\fR.
+\fB\-\-date\-format FORMAT\fR
+Specify display date string (strftime format).
.TP
-\fB\-\-hg\-log\-command\fR
-Print the hg log command (Mercurial) used by \fIgource\fR.
+\fB\-\-log\-command VCS\fR
+Show the log command used by gource (git,cvs,hg,bzr).
.TP
-\fB\-\-bzr\-log\-command\fR
-Print the bzr log command (Bazaar) used by \fIgource\fR.
+\fB\-\-log\-format VCS\fR
+Specify format of the log being read (git,cvs,hg,bzr,custom). Required when reading from STDIN.
.TP
-\fB\-\-cvs\-exp\-command\fR
-Print the cvs-exp.pl log command used by \fIgource\fR.
+\fB\-\-git\-branch\fR
+Get the git log of a branch other than the current one.
.TP
\fB\-\-follow\-user USER\fR
Have the camera automatically follow a particular user.
View
@@ -17,6 +17,8 @@
#include "settings.h"
+Regex SDLAppSettings_rect_regex("^([0-9.]+)x([0-9.]+)$");
+
SDLAppSettings::SDLAppSettings() {
setDisplayDefaults();
@@ -51,6 +53,19 @@ void SDLAppSettings::setDisplayDefaults() {
output_framerate = 60;
}
+bool SDLAppSettings::parseRectangle(const std::string& value, int* x, int* y) {
+
+ std::vector<std::string> matches;
+
+ if(SDLAppSettings_rect_regex.match(value, &matches)) {
+ if(x!=0) *x = atoi(matches[0].c_str());
+ if(y!=0) *y = atoi(matches[1].c_str());
+ return true;
+ }
+
+ return false;
+}
+
void SDLAppSettings::parseArgs(int argc, char *argv[], ConfFile& conffile, std::vector<std::string>* files) {
std::vector<std::string> arguments;
@@ -97,15 +112,10 @@ void SDLAppSettings::parseArgs(const std::vector<std::string>& arguments, ConfFi
std::string displayarg = args;
- size_t x = displayarg.rfind("x");
-
- if(x != std::string::npos && x != 0 && x != displayarg.size()-1) {
- std::string widthstr = displayarg.substr(0, x);
- std::string heightstr = displayarg.substr(x+1);
-
- int width = atoi(widthstr.c_str());
- int height = atoi(heightstr.c_str());
+ int width = 0;
+ int height = 0;
+ if(parseRectangle(displayarg, &width, &height)) {
if(width>0 && height>0) {
ConfSection* display_settings = conffile.getSection("display");
View
@@ -18,6 +18,8 @@
#ifndef SDLAPP_SETTINGS_H
#define SDLAPP_SETTINGS_H
+#include "regex.h"
+
#include "conffile.h"
class SDLAppSettings {
@@ -29,6 +31,8 @@ class SDLAppSettings {
std::map<std::string, std::string> conf_sections;
virtual void commandLineOption(const std::string& name, const std::string& value) {}
+
+ bool parseRectangle(const std::string& value, int* x=0, int* y=0);
public:
int display_width;
int display_height;
View
@@ -34,24 +34,27 @@ TextureManager texturemanager;
TextureManager::TextureManager() : ResourceManager() {
}
-TextureResource* TextureManager::grab(std::string name, int mipmaps, int clamp, int trilinear, bool external_file) {
- //debugLog("grabing %s\n", name.c_str());
+TextureResource* TextureManager::grabFile(std::string name, bool mipmaps, bool clamp, bool trilinear) {
+ return grab(name, mipmaps, clamp, trilinear, true);
+}
+
+TextureResource* TextureManager::grab(std::string name, bool mipmaps, bool clamp, bool trilinear, bool external_file) {
+
Resource* r = resources[name];
if(r==0) {
- //debugLog("%s not found. creating resource...\n", name.c_str());
-
r = new TextureResource(name, mipmaps, clamp, trilinear, external_file);
resources[name] = r;
}
r->addref();
+
return (TextureResource*)r;
}
// texture resource
-TextureResource::TextureResource(std::string file, int mipmaps, int clamp, int trilinear, bool external_file) : Resource(file) {
+TextureResource::TextureResource(std::string file, bool mipmaps, bool clamp, bool trilinear, bool external_file) : Resource(file) {
//if doesnt have an absolute path, look in resource dir
if(!external_file && !(file.size() > 2 && file[1] == ':') && !(file.size() > 1 && file[0] == '/')) {
View
@@ -40,18 +40,19 @@ class TextureException : public ResourceException {
class TextureResource : public Resource {
int colourFormat(SDL_Surface* surface);
- void loadTexture(std::string file, int mipmaps, int clamp, int trilinear, bool external_file);
+ void loadTexture(std::string file, bool mipmaps, bool clamp, bool trilinear, bool external_file);
public:
int w, h;
GLuint textureid;
- TextureResource(std::string name, int mipmaps, int clamp, int trilinear, bool external_file);
+ TextureResource(std::string name, bool mipmaps, bool clamp, bool trilinear, bool external_file);
~TextureResource();
};
class TextureManager : public ResourceManager {
public:
TextureManager();
- TextureResource* grab(std::string file, int mipmaps=1, int clamp=1, int trilinear=0, bool external_file = false);
+ TextureResource* grabFile(std::string name, bool mipmaps=true, bool clamp=true, bool trilinear=false);
+ TextureResource* grab(std::string file, bool mipmaps=true, bool clamp=true, bool trilinear=false, bool external_file = false);
};
extern TextureManager texturemanager;
View
@@ -44,6 +44,19 @@ Gource::Gource(std::string logfile) {
bloomtex = texturemanager.grab("bloom.tga");
beamtex = texturemanager.grab("beam.png");
+ logotex = 0;
+ backgroundtex = 0;
+
+ //load logo
+ if(gGourceSettings.logo.size() > 0) {
+ logotex = texturemanager.grabFile(gGourceSettings.logo);
+ }
+
+ //load background image
+ if(gGourceSettings.background_image.size() > 0) {
+ backgroundtex = texturemanager.grabFile(gGourceSettings.background_image);
+ }
+
stop_position_reached=false;
paused = false;
@@ -1481,6 +1494,36 @@ void Gource::drawBackground(float dt) {
display.setClearColour(gGourceSettings.background_colour);
display.clear();
+
+ if(backgroundtex!=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, backgroundtex->textureid);
+
+ glPushMatrix();
+
+ glTranslatef(display.width/2 - backgroundtex->w/2, display.height/2 - backgroundtex->h/2, 0.0f);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0f,0.0f);
+ glVertex2i(0, 0);
+
+ glTexCoord2f(1.0f,0.0f);
+ glVertex2i(backgroundtex->w, 0);
+
+ glTexCoord2f(1.0f,1.0f);
+ glVertex2i(backgroundtex->w, backgroundtex->h);
+
+ glTexCoord2f(0.0f,1.0f);
+ glVertex2i(0, backgroundtex->h);
+ glEnd();
+
+ glPopMatrix();
+ }
}
void Gource::drawTree(Frustum& frustum, float dt) {
@@ -1673,6 +1716,38 @@ void Gource::draw(float t, float dt) {
fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate);
}
+ 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;
View
@@ -98,6 +98,8 @@ class Gource : public SDLApp {
TextureResource* bloomtex;
TextureResource* beamtex;
+ TextureResource* logotex;
+ TextureResource* backgroundtex;
FXFont font, fontlarge, fontmedium;
Oops, something went wrong. Retry.

0 comments on commit 5156be3

Please sign in to comment.