diff options
author | alon@honor <none@none> | 2010-09-28 20:15:21 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-28 20:15:21 -0700 |
commit | d451428fb3312717c9e6cdf7c58c2e119d160bfb (patch) | |
tree | 75fbbd81ed414f4a178d7599edb44036c1e7600e /demos | |
parent | 8d76adec420ef2abe0d5afe3ec1e72cb1ede76b7 (diff) |
SDL fixes, do not malloc for each frame
Diffstat (limited to 'demos')
-rw-r--r-- | demos/raytrace.js | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/demos/raytrace.js b/demos/raytrace.js index 684cf3b9..1d36c6dd 100644 --- a/demos/raytrace.js +++ b/demos/raytrace.js @@ -288,7 +288,6 @@ _SDL_LockSurface = function (surf) { surfData.image = surfData.ctx.getImageData(0, 0, surfData.width, surfData.height); // Copy pixel data to somewhere accessible to 'C/C++' var num = surfData.image.data.length; - surfData.buffer = _malloc(num); for (var i = 0; i < num; i++) { HEAP[surfData.buffer+i] = surfData.image.data[i]; } @@ -311,8 +310,6 @@ _SDL_UnlockSurface = function (surf) { surfData.ctx.putImageData(surfData.image, 0, 0); // Cleanup surfData.image = null; - _free(surfData.buffer); - surfData.buffer = null; } _SDL_Flip = function (surf) { // We actually do this in Unlock... @@ -332,6 +329,7 @@ _SDL_SetVideoMode = function (width, height, depth, flags, canvas) { canvas: canvas, ctx: canvas.getContext('2d'), surf: surf, + buffer: _malloc(width*height*4), }; return surf; } |