diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-14 11:41:23 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-14 11:41:23 -0700 |
commit | 0d3524b29e5e8718f80c51de4975f4c1e838d015 (patch) | |
tree | 0e2a3ad537012e74886c291a55f0d23702435076 /src/library_sdl.js | |
parent | 80d2ed3d9781011fb473b7e034abf4980ca7883e (diff) |
retrieve pixel data from IMG_Load, for maximum compatibility
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r-- | src/library_sdl.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index efcb377a..c1935e5b 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -701,15 +701,20 @@ var LibrarySDL = { // SDL_Image + IMG_Load__deps: ['SDL_LockSurface'], IMG_Load: function(filename) { - // XXX Image load by default creates HWSURFACE, so you must call LockSurface to access - // pixel data from C++! filename = FS.standardizePath(Pointer_stringify(filename)); var raw = preloadedImages[filename]; assert(raw, 'Cannot find preloaded image ' + filename); var surf = SDL.makeSurface(raw.width, raw.height, 0, false, 'load:' + filename); var surfData = SDL.surfaces[surf]; surfData.ctx.drawImage(raw, 0, 0, raw.width, raw.height, 0, 0, raw.width, raw.height); + // XXX SDL does not specify that loaded images must have available pixel data, in fact + // there are cases where you just want to blit them, so you just need the hardware + // accelerated version. However, code everywhere seems to assume that the pixels + // are in fact available, so we retrieve it here. This does add overhead though. + _SDL_LockSurface(surf); + surfData.locked = 0; // The surface is not actually locked in this hack return surf; }, SDL_LoadBMP: 'IMG_Load', |