diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-22 18:37:51 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-22 18:37:51 -0500 |
commit | 92b660065c16e4089ef9fcf419de0ea444566fff (patch) | |
tree | 9bc5bf9b69a463fbad1edf5e30d9cf4ee83fcab6 /src/preamble.js | |
parent | 8ff943af1652f2a0a57977e277dc8e56013a9e7c (diff) |
Make it possible to compile shaders
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js index 103b786d..f19a68f1 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -752,6 +752,25 @@ function intArrayToString(array) { } Module['intArrayToString'] = intArrayToString; +// Write a Javascript array to somewhere in the heap +function writeStringToMemory(string, buffer, dontAddNull) { + var i = 0; + while (i < string.length) { + var chr = string.charCodeAt(i); + if (chr > 0xFF) { +#if ASSERTIONS + assert(false, 'Character code ' + chr + ' (' + string[i] + ') at offset ' + i + ' not in 0x00-0xFF.'); +#endif + chr &= 0xFF; + } + {{{ makeSetValue('buffer', 'i', 'chr', 'i8') }}} + i = i + 1; + } + if (!dontAddNull) { + {{{ makeSetValue('buffer', 'i', '0', 'i8') }}} + } +} + {{{ unSign }}} {{{ reSign }}} |