Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use TGAWriter.

  • Loading branch information...
commit f6b29a71c8476103887468a2ea0c4884fe4ce4e8 1 parent 92d5f62
@acaudwell authored
Showing with 4 additions and 27 deletions.
  1. +3 −27 src/gource.cpp
  2. +1 −0  src/gource.h
View
30 src/gource.cpp
@@ -2005,17 +2005,6 @@ void Gource::setMessage(const char* str, ...) {
void Gource::screenshot() {
- char* screenbuff = new char[display.width * display.height * 4];
-
- glReadPixels(0, 0, display.width, display.height,
- GL_RGBA, GL_UNSIGNED_BYTE, screenbuff);
-
- const char tga_header[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- short width = display.width;
- short height = display.height;
- char bitsperpixel = 32;
- char imagedescriptor = 8;
-
//get next free recording name
char tganame[256];
struct stat finfo;
@@ -2030,22 +2019,9 @@ void Gource::screenshot() {
//write tga
std::string filename(tganame);
- std::ofstream tga;
- tga.open(filename.c_str(), std::ios::out | std::ios::binary );
-
- if(!tga.is_open()) return;
-
- tga.write(tga_header, 12);
- tga.write((char*)&width, sizeof(short));
- tga.write((char*)&height, sizeof(short));
- tga.write(&bitsperpixel, 1);
- tga.write(&imagedescriptor, 1);
-
- tga.write(screenbuff, display.width * display.height * 4);
- tga.close();
-
- delete[] screenbuff;
-
+ TGAWriter tga(gGourceSettings.transparent ? 4 : 3);
+ tga.screenshot(filename);
+
setMessage("Wrote screenshot %s", tganame);
}
View
1  src/gource.h
@@ -35,6 +35,7 @@
#include "core/regex.h"
#include "core/ppm.h"
#include "core/mousecursor.h"
+#include "core/tga.h"
#include "gource_settings.h"
Please sign in to comment.
Something went wrong with that request. Please try again.