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 /tests/OffscreenContext.cc | |
parent | f0772e73bd258f678723e8e040c6cb72285c1d08 (diff) |
Linux compile fixes
Diffstat (limited to 'tests/OffscreenContext.cc')
-rw-r--r-- | tests/OffscreenContext.cc | 8 |
1 files changed, 4 insertions, 4 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; } |