diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-26 05:52:06 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-26 05:52:06 (GMT) |
commit | 544a8e5b799f5dd0a35d650c00db10074104650a (patch) | |
tree | 0651f5efa1422aaf166a303c1210a92b23850681 /src/OffscreenContext.h | |
parent | 395628cb4ef7f8559c667af22fb273e21e4a5ad8 (diff) |
refactor to reduce duplicate code
Diffstat (limited to 'src/OffscreenContext.h')
-rw-r--r-- | src/OffscreenContext.h | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/src/OffscreenContext.h b/src/OffscreenContext.h index 3494898..a32ea2c 100644 --- a/src/OffscreenContext.h +++ b/src/OffscreenContext.h @@ -4,31 +4,12 @@ #include <iostream> #include <fstream> #include <string> +#include "fbo.h" struct OffscreenContext *create_offscreen_context(int w, int h); bool teardown_offscreen_context(OffscreenContext *ctx); +bool save_framebuffer(OffscreenContext *ctx, const char * filename); bool save_framebuffer(OffscreenContext *ctx, std::ostream &output); std::string offscreen_context_getinfo(OffscreenContext *ctx); -void bind_offscreen_context(OffscreenContext *ctx) -{ - if (ctx) fbo_bind(ctx->fbo); -} - -/* - Capture framebuffer from OpenGL and write it to the given filename as PNG. -*/ -inline bool save_framebuffer(OffscreenContext *ctx, const char *filename) -{ - std::ofstream fstream(filename); - if (!fstream.is_open()) { - std::cerr << "Can't open file " << filename << " for writing"; - return false; - } else { - save_framebuffer(ctx, fstream); - fstream.close(); - } - return true; -} - #endif |