aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_sdl.js7
-rw-r--r--tests/hello_world_sdl.cpp4
2 files changed, 6 insertions, 5 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;
}
diff --git a/tests/hello_world_sdl.cpp b/tests/hello_world_sdl.cpp
index 35aec303..b6401995 100644
--- a/tests/hello_world_sdl.cpp
+++ b/tests/hello_world_sdl.cpp
@@ -14,13 +14,13 @@ int main() {
*((char*)screen->pixels + i*256*4 + j*4 + 0) = i;
*((char*)screen->pixels + i*256*4 + j*4 + 1) = j;
*((char*)screen->pixels + i*256*4 + j*4 + 2) = 255-i;
- *((char*)screen->pixels + i*256*4 + j*4 + 3) = 255;
+ *((char*)screen->pixels + i*256*4 + j*4 + 3) = (i+j)%255; // actually ignored, since this is to the screen
}
}
if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
SDL_Flip(screen);
- printf("you should see a colored cube.\n");
+ printf("you should see a smoothly-colored square - no sharp lines but the square borders!\n");
printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: |<cheez></cheez>|\nanother line.\n");
SDL_Quit();