aboutsummaryrefslogtreecommitdiff
path: root/src/library_sdl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-03-27 16:21:44 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-03-27 16:21:44 -0700
commitf0afec555ecd538f92068495d64ddc027e237a77 (patch)
tree750de7fcb35695fe46a7357abae5d1a28a523642 /src/library_sdl.js
parentf88f3af21789291021d54fbf1fe51d2f107e6267 (diff)
fix two bugs with rendering pixel data to SDL: flip R and B to match native behavior, and ignore alpha when rendering to the screen as also done in native behavior
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r--src/library_sdl.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 548f3b0d..b72e239b 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -460,13 +460,14 @@ mergeInto(LibraryManager.library, {
assert(buffer % 4 == 0, 'Invalid buffer offset: ' + buffer);
var src = buffer >> 2;
var dst = 0;
+ var isScreen = surf == SDL.screen;
while (dst < num) {
// TODO: access underlying data buffer and write in 32-bit chunks or more
var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
- data[dst] = val & 0xff;
+ data[dst+2] = val & 0xff;
data[dst+1] = (val >> 8) & 0xff;
- data[dst+2] = (val >> 16) & 0xff;
- data[dst+3] = (val >> 24) & 0xff;
+ data[dst ] = (val >> 16) & 0xff;
+ data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
src++;
dst += 4;
}