summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/OffscreenContextAll.hpp7
-rw-r--r--src/OffscreenContextCGL.mm22
-rw-r--r--src/imageutils-macosx.cc5
3 files changed, 10 insertions, 24 deletions
diff --git a/src/OffscreenContextAll.hpp b/src/OffscreenContextAll.hpp
index b0df83d..42563be 100644
--- a/src/OffscreenContextAll.hpp
+++ b/src/OffscreenContextAll.hpp
@@ -1,6 +1,9 @@
// Functions shared by OffscreenContext[platform].cc
// #include this directly after definition of struct OffscreenContext.
+#include <vector>
+#include <ostream>
+
void bind_offscreen_context(OffscreenContext *ctx)
{
if (ctx) fbo_bind(ctx->fbo);
@@ -30,7 +33,7 @@ bool save_framebuffer_common(OffscreenContext *ctx, std::ostream &output)
{
if (!ctx) return false;
int samplesPerPixel = 4; // R, G, B and A
- vector<GLubyte> pixels(ctx->width * ctx->height * samplesPerPixel);
+ std::vector<GLubyte> pixels(ctx->width * ctx->height * samplesPerPixel);
glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]);
// Flip it vertically - images read from OpenGL buffers are upside-down
@@ -56,7 +59,7 @@ OffscreenContext *create_offscreen_context_common(OffscreenContext *ctx)
if (!ctx) return NULL;
GLenum err = glewInit(); // must come after Context creation and before FBO c$
if (GLEW_OK != err) {
- cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
+ std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
return NULL;
}
//cerr << glew_dump(0);
diff --git a/src/OffscreenContextCGL.mm b/src/OffscreenContextCGL.mm
index ab3cc1b..76c5418 100644
--- a/src/OffscreenContextCGL.mm
+++ b/src/OffscreenContextCGL.mm
@@ -21,7 +21,7 @@ struct OffscreenContext
#include "OffscreenContextAll.hpp"
-std::string offscreen_context_getinfo(OffscreenContext *ctx)
+std::string offscreen_context_getinfo(OffscreenContext *)
{
std::stringstream out;
@@ -83,7 +83,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << std::endl;
return NULL;
}
- glew_dump();
+ glew_dump(false);
ctx->fbo = fbo_new();
if (!fbo_init(ctx->fbo, w, h)) {
@@ -109,27 +109,11 @@ bool teardown_offscreen_context(OffscreenContext *ctx)
}
/*!
- Capture framebuffer from OpenGL and write it to the given filename as PNG.
-*/
-bool save_framebuffer(OffscreenContext *ctx, const char *filename)
-{
- std::ofstream fstream(filename,std::ios::out|std::ios::binary);
- if (!fstream.is_open()) {
- PRINTB("Can't open file \"%s\" for writing", filename);
- return false;
- } else {
- save_framebuffer(ctx, fstream);
- fstream.close();
- }
- return true;
-}
-
-/*!
Capture framebuffer from OpenGL and write it to the given ostream
*/
bool save_framebuffer(OffscreenContext *ctx, std::ostream &output)
{
- if (!ctx || !filename) return false;
+ if (!ctx) return false;
// Read pixels from OpenGL
int samplesPerPixel = 4; // R, G, B and A
int rowBytes = samplesPerPixel * ctx->width;
diff --git a/src/imageutils-macosx.cc b/src/imageutils-macosx.cc
index e3a1983..4c7c446 100644
--- a/src/imageutils-macosx.cc
+++ b/src/imageutils-macosx.cc
@@ -1,6 +1,5 @@
#include <ApplicationServices/ApplicationServices.h>
#include <iostream>
-#include <CGDataConsumer.h>
#include "imageutils.h"
#include <assert.h>
@@ -15,13 +14,13 @@ size_t write_bytes_to_ostream (void *info,const void *buffer,size_t count)
try {
output->write( (const char *)buffer, count );
endpos = output->tellp();
- } catch (const std::ios_base::failure& e)
+ } catch (const std::ios_base::failure& e) {
std::cerr << "Error writing to ostream:" << e.what() << "\n";
}
return (endpos-startpos);
}
-CGDataConsumerRef dataconsumer CGDataConsumerCreateWithOstream(std::ostream &output)
+CGDataConsumerRef CGDataConsumerCreateWithOstream(std::ostream &output)
{
dc_callbacks.putBytes = write_bytes_to_ostream;
dc_callbacks.releaseConsumer = NULL; // ostream closed by caller of write_png
contact: Jan Huwald // Impressum