Permalink
Browse files

Added --transparent to make the background see-through (for screensho…

…ts).

I couldn't see much use for finer control of the alpha channel with
the background-colour option, and also it has to be enabled when the video
mode is selected, so that wouldn't always work.
  • Loading branch information...
1 parent bbb0fb3 commit ad2fa86047dca2c85b201edd8a8ebd3e803a293b @acaudwell committed Mar 30, 2010
Showing with 28 additions and 17 deletions.
  1. +1 −1 ChangeLog
  2. +5 −2 README
  3. +5 −2 data/gource.1
  4. +1 −1 src/core/display.cpp
  5. +8 −0 src/core/settings.cpp
  6. +1 −0 src/core/settings.h
  7. +5 −9 src/gource_settings.cpp
  8. +1 −1 src/gource_settings.h
  9. +1 −1 src/main.cpp
View
@@ -1,6 +1,6 @@
0.27:
- * --background-colour can now be used to set the alpha channel (eg FFFFFF00).
* Added take screenshot button (F12). Screenshots respect the alpha channel.
+ * Added --transparent to make the background see-through (for screenshots).
* Added ini style config file support.
* Added demo mode for showing multiple projects in a loop.
* Added --logo and --background-image options.
View
7 README
@@ -51,6 +51,9 @@ options:
-w, --windowed
Windowed.
+ --transparent
+ Make the background transparent. Only really useful for screenshots.
+
-p, --start-position POSITION
Begin at some position in the log (between 0.0 and 1.0 or 'random').
@@ -81,8 +84,8 @@ options:
-e, --elasticity FLOAT
Elasticity of nodes.
- -b, --background-colour FFFFFF[FF]
- Background colour in hex. Alpha channel optional.
+ -b, --background-colour FFFFFF
+ Background colour in hex.
--background-image IMAGE
Set a background image.
View
@@ -25,6 +25,9 @@ Fullscreen
\fB\-w\fR
Windowed
.TP
+\fB\-\-transparent\fR
+Make the background transparent. Only really useful for screenshots.
+.TP
\fB\-p, \-\-start\-position POSITION\fR
Begin at some position in the log (between 0.0 and 1.0 or 'random').
.TP
@@ -55,8 +58,8 @@ Time in seconds files remain idle before they are removed.
\fB\-e, \-\-elasticity FLOAT\fR
Elasticity of nodes.
.TP
-\fB\-b, \-\-background-colour FFFFFF[FF]\fR
-Background colour in hex. Alpha channel optional.
+\fB\-b, \-\-background-colour FFFFFF\fR
+Background colour in hex.
.TP
\fB\-\-background\-image IMAGE\fR
Set a background image.
View
@@ -43,7 +43,7 @@ SDLAppDisplay::~SDLAppDisplay() {
}
void SDLAppDisplay::setClearColour(vec3f colour) {
- //setClearColour(vec4f(colour,1.0f));
+ setClearColour(vec4f(colour, enable_alpha ? 0.0f : 1.0f));
}
void SDLAppDisplay::setClearColour(vec4f colour) {
View
@@ -31,6 +31,7 @@ SDLAppSettings::SDLAppSettings() {
conf_sections["multi-sampling"] = "display";
conf_sections["output-ppm-stream"] = "display";
conf_sections["output-framerate"] = "display";
+ conf_sections["transparent"] = "display";
//translate args
arg_aliases["f"] = "fullscreen";
@@ -42,16 +43,19 @@ SDLAppSettings::SDLAppSettings() {
arg_types["viewport"] = "string";
arg_types["windowed"] = "bool";
arg_types["fullscreen"] = "bool";
+ arg_types["transparent"] = "bool";
arg_types["multi-sampling"] = "bool";
arg_types["output-ppm-stream"] = "string";
arg_types["output-framerate"] = "int";
+
}
void SDLAppSettings::setDisplayDefaults() {
display_width = 1024;
display_height = 768;
fullscreen = false;
multisample = false;
+ transparent = false;
output_ppm_filename = "";
output_framerate = 60;
@@ -256,6 +260,10 @@ void SDLAppSettings::importDisplaySettings(ConfFile& conffile) {
fullscreen = false;
}
+ if(display_settings->getBool("transparent")) {
+ transparent = true;
+ }
+
if((entry = display_settings->getEntry("output-ppm-stream")) != 0) {
if(!entry->hasValue()) {
View
@@ -38,6 +38,7 @@ class SDLAppSettings {
int display_height;
bool multisample;
bool fullscreen;
+ bool transparent;
std::string output_ppm_filename;
int output_framerate;
View
@@ -37,6 +37,7 @@ void GourceSettings::help() {
printf(" -WIDTHxHEIGHT, --viewport Set viewport size\n");
printf(" -f, --fullscreen Fullscreen\n");
printf(" --multi-sampling Enable multi-sampling\n");
+ printf(" --transparent Make the background transparent\n\n");
printf(" --demo Run in demo mode\n\n");
printf(" -p, --start-position POSITION Begin at some position (0.0-1.0 or 'random')\n");
@@ -255,7 +256,7 @@ void GourceSettings::setGourceDefaults() {
bloom_multiplier = 1.0f;
bloom_intensity = 0.75f;
- background_colour = vec4f(0.1f, 0.1f, 0.1f, 1.0f);
+ background_colour = vec3f(0.1f, 0.1f, 0.1f);
background_image = "";
elasticity = 0.0f;
@@ -542,17 +543,12 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if(!entry->hasValue()) conffile.entryException(entry, "specify background colour (FFFFFF)");
- int r,g,b,a;
+ int r,g,b;
std::string colstring = entry->getString();
- if(colstring.size()==8 && sscanf(colstring.c_str(), "%02x%02x%02x%02x", &r, &g, &b, &a) == 4) {
- background_colour = vec4f(r,g,b,a);
+ if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
+ background_colour = vec3f(r,g,b);
background_colour /= 255.0f;
- if(a==255) background_colour.w = 1.0f;
- } else if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
- background_colour = vec4f(r,g,b,1.0f);
- background_colour /= 255.0f;
- background_colour.w = 1.0f;
} else {
conffile.invalidValueException(entry);
}
View
@@ -78,7 +78,7 @@ class GourceSettings : public SDLAppSettings {
float bloom_multiplier;
float bloom_intensity;
- vec4f background_colour;
+ vec3f background_colour;
std::string background_image;
float elasticity;
View
@@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
}
//background needs alpha channel
- if(gGourceSettings.background_colour.w < 1.0f) {
+ if(gGourceSettings.transparent) {
display.enableAlpha(true);
}

0 comments on commit ad2fa86

Please sign in to comment.