Browse Source

that awkward moment when you forget you can't automatically allocate arrays with variable expressions in C++

Bill Meltsner 14 years ago
parent
commit
c5cf3fefeb
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/modules/graphics/opengl/Canvas.cpp

+ 3 - 1
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;
 	}