diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-29 00:35:24 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-29 00:35:24 (GMT) |
commit | c6e5e84eec401096451f14e9e853e33c3aa88853 (patch) | |
tree | 24ad24f81516b5447d0fb26779a5000171e2b833 | |
parent | f0772e73bd258f678723e8e040c6cb72285c1d08 (diff) |
Linux compile fixes
-rw-r--r-- | tests/OffscreenContext.cc | 8 | ||||
-rw-r--r-- | tests/imageutils-lodepng.cc | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc index 6f2104f..36adc15 100644 --- a/tests/OffscreenContext.cc +++ b/tests/OffscreenContext.cc @@ -142,24 +142,24 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { - SDL_GL_SwapBuffers(); // show image + SDL_GL_SwapBuffers(); // show image - int samplesPerPixel = 4; // R, G, B and A + int samplesPerPixel = 4; // R, G, B and A GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Flip it vertically - images read from OpenGL buffers are upside-down + int rowBytes = samplesPerPixel * ctx->width; unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); if (!flippedBuffer) { std::cout << "Unable to allocate flipped buffer for corrected image."; return 1; } - flip_image(bufferData, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); + flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); bool writeok = write_png(filename, flippedBuffer, ctx->width, ctx->height); free(flippedBuffer); - free(bufferData); return writeok; } diff --git a/tests/imageutils-lodepng.cc b/tests/imageutils-lodepng.cc index 98c48de..8636fa4 100644 --- a/tests/imageutils-lodepng.cc +++ b/tests/imageutils-lodepng.cc @@ -1,4 +1,5 @@ #include "lodepng.h" +#include <stdio.h> bool write_png(const char *filename, unsigned char *pixels, int width, int height) { @@ -6,7 +7,7 @@ bool write_png(const char *filename, unsigned char *pixels, int width, int heigh //LodePNG_Text_add(&encoder.infoPng.text, "Comment", "Created with LodePNG"); size_t dataout_size = -1; - GLubyte *dataout = (GLubyte*)malloc(width*height*4); + unsigned char *dataout = (unsigned char *)malloc(width*height*4); LodePNG_encode(&dataout, &dataout_size, pixels, width, height, LCT_RGBA, 8); //LodePNG_saveFile(dataout, dataout_size, "blah2.png"); FILE *f = fopen(filename, "w"); |