X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.cpp;fp=src%2Fscreen.cpp;h=07d3f947da27e407b67de14269505ff0beea9b73;hp=2764ef7d9283174352ba22fc09c09fc7fb0cf954;hb=aaa65d90ac812f924cbbc39bef7a5f8b6cad2da3;hpb=6ad7439e8ebf969fcd2d3a710a4b16e2b1ee131f diff --git a/src/screen.cpp b/src/screen.cpp index 2764ef7..07d3f94 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -2,6 +2,8 @@ #include "screen.h" #include "SDL_opengl.h" +#include // for access(2) +#include // for access(2) using namespace IPDF; using namespace std; @@ -140,8 +142,7 @@ void Screen::ScreenShot(const char * filename) const unsigned char * pixels = new unsigned char[w*h*4]; if (pixels == NULL) Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4); - glReadBuffer(GL_FRONT); - glPixelStorei(GL_PACK_ALIGNMENT, 1); + for (int y = 0; y < h; ++y) { glReadPixels(0,h-y-1,w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[y*w*4]); @@ -172,6 +173,11 @@ void Screen::ScreenShot(const char * filename) const */ void Screen::RenderBMP(const char * filename) const { + if (access(filename, R_OK) == -1) + { + Error("No such file \"%s\" - Nothing to render - You might have done this deliberately?", filename); + return; + } SDL_Surface * bmp = SDL_LoadBMP(filename); if (bmp == NULL) Fatal("Failed to load BMP from %s - %s", filename, SDL_GetError());