aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Ronsse <sronsse@gmail.com>2014-06-28 08:30:36 -0700
committerSebastien Ronsse <sronsse@gmail.com>2014-06-28 13:07:27 -0700
commit1e23dd2a5eb20fbe305b6569dfb0c38a5033ba66 (patch)
treef86fafb8dfaec6dc44fb3e45a388c29668d4362f
parent190ed2145098b6ab1278127cc1e8d331fc4aa998 (diff)
add SDL_GetRGB and SDL_GetRGBA
-rw-r--r--src/library_sdl.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 7e61cbbb..eef1368d 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1841,6 +1841,35 @@ var LibrarySDL = {
return r&0xff|(g&0xff)<<8|(b&0xff)<<16|(a&0xff)<<24;
},
+ SDL_GetRGB: function(pixel, fmt, r, g, b) {
+ // Canvas screens are always RGBA. We assume the machine is little-endian.
+ if (r) {
+ {{{ makeSetValue('r', '0', 'pixel&0xff', 'i8') }}};
+ }
+ if (g) {
+ {{{ makeSetValue('g', '0', '(pixel>>8)&0xff', 'i8') }}};
+ }
+ if (b) {
+ {{{ makeSetValue('b', '0', '(pixel>>16)&0xff', 'i8') }}};
+ }
+ },
+
+ SDL_GetRGBA: function(pixel, fmt, r, g, b, a) {
+ // Canvas screens are always RGBA. We assume the machine is little-endian.
+ if (r) {
+ {{{ makeSetValue('r', '0', 'pixel&0xff', 'i8') }}};
+ }
+ if (g) {
+ {{{ makeSetValue('g', '0', '(pixel>>8)&0xff', 'i8') }}};
+ }
+ if (b) {
+ {{{ makeSetValue('b', '0', '(pixel>>16)&0xff', 'i8') }}};
+ }
+ if (a) {
+ {{{ makeSetValue('a', '0', '(pixel>>24)&0xff', 'i8') }}};
+ }
+ },
+
SDL_GetAppState: function() {
var state = 0;