Skip to content

Commit

Permalink
Changed screenshot format to PNG.
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Mar 16, 2014
1 parent 2214fba commit 49b31ba
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
*.mpg
*.mkv
*.mp4
gource-*.png
.objs
/gource
/gource.exe
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -4,6 +4,7 @@
* Full screen mode now uses desktop resolution by default.
* Added --start-date, --stop-date 'YYYY-MM-DD hh:mm:ss' options.
* Changed --file-idle-time default value to 0.
* Changed screenshot format to PNG.

0.40:
* Added caption support.
Expand Down
1 change: 1 addition & 0 deletions INSTALL
Expand Up @@ -19,6 +19,7 @@ Gource requires the following libraries to compile (package names may vary):
GLEW (libglew-dev)
GLM >= 0.9.3 (libglm-dev)
Boost Filesystem >= 1.46 (libboost-filesystem-dev)
PNG >= 1.2 (libpng12-dev)

If SDL 2.0 is unavailable you can still use SDL 1.2, but this is deprecated:

Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -26,7 +26,7 @@ gource_SOURCES = \
src/core/shader_common.cpp \
src/core/stringhash.cpp \
src/core/texture.cpp \
src/core/tga.cpp \
src/core/png_writer.cpp \
src/core/timezone.cpp \
src/core/vbo.cpp \
src/core/vectors.cpp \
Expand Down
5 changes: 3 additions & 2 deletions gource.win32.cbp
Expand Up @@ -39,6 +39,7 @@
<Add library="freetype" />
<Add library="libboost_filesystem-mgw46-mt-1_52" />
<Add library="libboost_system-mgw46-mt-1_52" />
<Add library="libpng16.dll.a" />
</Linker>
<Unit filename="data/shaders/bloom.frag" />
<Unit filename="data/shaders/bloom.vert" />
Expand Down Expand Up @@ -69,6 +70,8 @@
<Unit filename="src/core/pi.h" />
<Unit filename="src/core/plane.cpp" />
<Unit filename="src/core/plane.h" />
<Unit filename="src/core/png_writer.cpp" />
<Unit filename="src/core/png_writer.h" />
<Unit filename="src/core/ppm.cpp" />
<Unit filename="src/core/ppm.h" />
<Unit filename="src/core/quadtree.cpp" />
Expand All @@ -91,8 +94,6 @@
<Unit filename="src/core/stringhash.h" />
<Unit filename="src/core/texture.cpp" />
<Unit filename="src/core/texture.h" />
<Unit filename="src/core/tga.cpp" />
<Unit filename="src/core/tga.h" />
<Unit filename="src/core/timezone.cpp" />
<Unit filename="src/core/timezone.h" />
<Unit filename="src/core/vbo.cpp" />
Expand Down
36 changes: 22 additions & 14 deletions src/gource.cpp
Expand Up @@ -16,6 +16,7 @@
*/

#include "gource.h"
#include "core/png_writer.h"

bool gGourceDrawBackground = true;
bool gGourceQuadTreeDebug = false;
Expand Down Expand Up @@ -97,6 +98,8 @@ Gource::Gource(FrameExporter* exporter) {
mousedragged = false;
mouseclicked = false;

take_screenshot = false;

if(gGourceSettings.hide_mouse) {
cursor.showCursor(false);
}
Expand Down Expand Up @@ -663,7 +666,7 @@ void Gource::keyPress(SDL_KeyboardEvent *e) {
if(commitlog==0) return;

if(e->keysym.sym == SDLK_F12) {
screenshot();
take_screenshot = true;
}

if (e->keysym.sym == SDLK_q) {
Expand Down Expand Up @@ -1115,7 +1118,7 @@ void Gource::readLog() {
stop_position_reached = true;
break;
}

commitqueue.push_back(commit);
}

Expand Down Expand Up @@ -2175,23 +2178,23 @@ void Gource::setMessage(const char* str, ...) {
void Gource::screenshot() {

//get next free recording name
char tganame[256];
char pngname[256];
struct stat finfo;
int tgano = 1;
int pngno = 1;

while(tgano < 10000) {
snprintf(tganame, 256, "gource-%04d.tga", tgano);
if(stat(tganame, &finfo) != 0) break;
tgano++;
while(pngno < 10000) {
snprintf(pngname, 256, "gource-%04d.png", pngno);
if(stat(pngname, &finfo) != 0) break;
pngno++;
}

//write tga
std::string filename(tganame);
//write png
std::string filename(pngname);

TGAWriter tga(gGourceSettings.transparent ? 4 : 3);
tga.screenshot(filename);
PNGWriter png(gGourceSettings.transparent ? 4 : 3);
png.screenshot(filename);

setMessage("Wrote screenshot %s", tganame);
setMessage("Wrote screenshot %s", pngname);
}

void Gource::updateVBOs(float dt) {
Expand Down Expand Up @@ -2598,7 +2601,7 @@ void Gource::draw(float t, float dt) {
caption->draw();
}

if(message_timer>0.0f) {
if(!take_screenshot && message_timer>0.0f) {
fontmedium.draw(1, 3, message);
}

Expand Down Expand Up @@ -2699,4 +2702,9 @@ void Gource::draw(float t, float dt) {

mousemoved=false;
mouseclicked=false;

if(take_screenshot) {
screenshot();
take_screenshot = false;
}
}
5 changes: 3 additions & 2 deletions src/gource.h
Expand Up @@ -32,7 +32,6 @@
#include "core/regex.h"
#include "core/ppm.h"
#include "core/mousecursor.h"
#include "core/tga.h"

#include "gource_settings.h"

Expand Down Expand Up @@ -139,6 +138,8 @@ class Gource : public SDLApp {
bool paused;
bool reloaded;

bool take_screenshot;

float max_tick_rate;
int frameskip;
int framecount;
Expand Down Expand Up @@ -259,7 +260,7 @@ class Gource : public SDLApp {
void screenshot();

void changeColours();

void grabMouse(bool grab_mouse);
public:
Gource(FrameExporter* frameExporter = 0);
Expand Down

0 comments on commit 49b31ba

Please sign in to comment.