From c5cf3fefeb7a08ba2c991d2ebfd013b2d0abe525 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Wed, 12 Oct 2011 00:06:15 -0500 Subject: [PATCH] that awkward moment when you forget you can't automatically allocate arrays with variable expressions in C++ --- src/modules/graphics/opengl/Canvas.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 093050dd7..cbd151005 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -287,7 +287,7 @@ namespace opengl love::image::ImageData * Canvas::getImageData(love::image::Image * image) { - GLubyte pixels[4*width*height]; + GLubyte * pixels = new GLubyte[4*width*height]; strategy->bindFBO( fbo ); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); @@ -297,6 +297,8 @@ namespace opengl strategy->bindFBO( 0 ); love::image::ImageData * img = image->newImageData(width, height, (void*)pixels); + + delete[] pixels; return img; }