diff options
117 files changed, 17558 insertions, 963 deletions
@@ -20,3 +20,5 @@ under the licensing terms detailed in LICENSE. * David Benjamin <davidben@mit.edu> * Pierre Renaux <pierre@talansoft.com> * Brian Anderson <banderson@mozilla.com> +* Jon Bardin <diclophis@gmail.com> +* Jukka Jylänki <jujjyl@gmail.com> diff --git a/em-config b/em-config new file mode 100755 index 00000000..dee399ed --- /dev/null +++ b/em-config @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +''' +This is a helper tool which is designed to make it possible +for other apps to read emscripten's configuration variables +in a unified way. Usage: + + em-config VAR_NAME + +This tool prints the value of the variable to stdout if one +is found, or exits with 1 if the variable does not exist. +''' + +import os, sys, re +from tools import shared + +if len(sys.argv) != 2 or \ + not re.match(r"^[\w\W_][\w\W_\d]*$", sys.argv[1]) or \ + not (sys.argv[1] in dir(shared)): + print 'Usage: em-config VAR_NAME' + exit(1) + +print eval('shared.' + sys.argv[1]) + @@ -272,6 +272,10 @@ Options that are modified or new in %s include: --js-library <lib> A JavaScript library to use in addition to those in Emscripten's src/library_* + -v Turns on verbose output. This will pass + -v to Clang, and also enable EMCC_DEBUG + to details emcc's operations + The target file, if specified (-o <target>), defines what will be generated: @@ -293,6 +297,9 @@ the source of emcc (search for 'os.environ'). ''' % (this, this, this) exit(0) +elif len(sys.argv) == 2 and sys.argv[1] == '-v': # -v with no inputs + print 'emcc (Emscripten GCC-like replacement) 2.0' + exit(subprocess.call([shared.CLANG, '-v'])) # If this is a configure-type thing, do not compile to JavaScript, instead use clang # to compile to a native binary (using our headers, so things make sense later) @@ -513,6 +520,10 @@ try: elif newargs[i] == '--ignore-dynamic-linking': ignore_dynamic_linking = True newargs[i] = '' + elif newargs[i] == '-v': + shared.COMPILER_OPTS += ['-v'] + DEBUG = 1 + newargs[i] = '' elif newargs[i].startswith('--shell-file'): check_bad_eq(newargs[i]) shell_path = newargs[i+1] @@ -700,17 +711,18 @@ try: else: assert not has_dash_c, 'fatal error: cannot specify -o with -c with multiple files' + str(sys.argv) # We have a specified target (-o <target>), which is not JavaScript or HTML, and - # we have multiple files: Link them TODO: llvm link-time opts? - ld_args = temp_files + ['-b', specified_target] - #[arg.split('-Wl,')[1] for arg in filter(lambda arg: arg.startswith('-Wl,'), sys.argv)] - if DEBUG: print >> sys.stderr, 'emcc: link: ' + str(ld_args) - execute([shared.LLVM_LD, '-disable-opt'] + ld_args) + # we have multiple files: Link them + if DEBUG: print >> sys.stderr, 'emcc: link: ' + str(temp_files) + shared.Building.link(temp_files, specified_target) exit(0) ## Continue on to create JavaScript if DEBUG: print >> sys.stderr, 'emcc: will generate JavaScript' + if final_suffix == 'html': + shared.Settings.GENERATING_HTML = 1 + extra_files_to_link = [] if not LEAVE_INPUTS_RAW and not AUTODEBUG: @@ -722,9 +734,9 @@ try: # dlmalloc def create_dlmalloc(): if DEBUG: print >> sys.stderr, 'emcc: building dlmalloc for cache' - execute(['python', shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr) + execute(shared.ENV_PREFIX + ['python', shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr) # we include the libc++ new stuff here, so that the common case of using just new/delete is quick to link - execute(['python', shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr) + execute(shared.ENV_PREFIX + ['python', shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr) shared.Building.link([in_temp('dlmalloc.o'), in_temp('new.o')], in_temp('dlmalloc_full.o')) return in_temp('dlmalloc_full.o') def fix_dlmalloc(): @@ -846,7 +858,7 @@ try: if AUTODEBUG: if DEBUG: print >> sys.stderr, 'emcc: autodebug' - execute(['python', shared.AUTODEBUGGER, final, final + '.ad.ll']) + execute(shared.ENV_PREFIX + ['python', shared.AUTODEBUGGER, final, final + '.ad.ll']) final += '.ad.ll' if DEBUG: save_intermediate('autodebug', 'll') @@ -900,7 +912,8 @@ try: partial_dirs = [] for file_ in data_files: dirname = os.path.dirname(file_['name']) - if dirname != '' and dirname != '/': + dirname = dirname.lstrip('/') # absolute paths start with '/', remove that + if dirname != '': parts = dirname.split('/') for i in range(len(parts)): partial = '/'.join(parts[:i+1]) @@ -979,14 +992,23 @@ try: var b = new Blob([byteArray.buffer], { type: '%(mimetype)s' }); var url = URLObject.createObjectURL(b); // XXX we never revoke this! var audio = new Audio(); + audio.removedDependency = false; audio['oncanplaythrough'] = function() { // XXX string for closure audio['oncanplaythrough'] = null; preloadedAudios['%(filename)s'] = audio; - removeRunDependency(); + if (!audio.removedDependency) { + removeRunDependency(); + audio.removedDependency = true; + } }; audio.onerror = function(event) { - console.log('Audio %(filename)s could not be decoded'); + if (!audio.removedDependency) { + console.log('Audio %(filename)s could not be decoded or timed out trying to decode'); + removeRunDependency(); + audio.removedDependency = true; + } }; + setTimeout(audio.onerror, 2000); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang) audio.src = url; } else { preloadedAudios['%(filename)s'] = new Audio(); // empty shim @@ -1106,18 +1128,16 @@ try: flush_js_optimizer_queue() - # eliminator if DEBUG: print >> sys.stderr, 'emcc: running variable eliminator' final = shared.Building.eliminator(final) if DEBUG: save_intermediate('eliminator') - # js optimizer pre-pass js_optimizer_queue += ['simplifyExpressionsPre'] if shared.Settings.RELOOP: js_optimizer_queue += ['optimizeShiftsAggressive'] # aggressive shifts optimization requires loops, it breaks on switches - flush_js_optimizer_queue() - final = shared.Building.eliminator(final) # aggressive shifts optimization introduces some new variables, remove ones that we can - if DEBUG: save_intermediate('eliminator') + flush_js_optimizer_queue() + final = shared.Building.eliminator(final) # aggressive shifts optimization introduces some new variables, remove ones that we can + if DEBUG: save_intermediate('eliminator') if closure: flush_js_optimizer_queue() @@ -1127,7 +1147,6 @@ try: if DEBUG: save_intermediate('closure') if opt_level >= 1: - # js optimizer post-pass if DEBUG: print >> sys.stderr, 'emcc: running post-closure post-opts' js_optimizer_queue += ['simplifyExpressionsPost'] diff --git a/emscripten.py b/emscripten.py index 45c9f418..044d6cd9 100755 --- a/emscripten.py +++ b/emscripten.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python ''' You should normally never use this! Use emcc instead. diff --git a/settings.py b/settings.py index 48eaa9ab..844042ad 100644 --- a/settings.py +++ b/settings.py @@ -10,7 +10,7 @@ NODE_JS = 'node' SPIDERMONKEY_ENGINE = [os.path.expanduser('~/Dev/mozilla-central/js/src/js'), '-m', '-n'] V8_ENGINE = os.path.expanduser('~/Dev/v8/d8') -TEMP_DIR = '/tmp' +TEMP_DIR = '/tmp' # You will need to modify this on Windows ######################################################################################################## diff --git a/src/analyzer.js b/src/analyzer.js index 8ded86f1..4bf2255e 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -9,7 +9,7 @@ var VAR_NATIVIZED = 'nativized'; var VAR_EMULATED = 'emulated'; var ENTRY_IDENT = toNiceIdent('%0'); -var ENTRY_IDENTS = set(toNiceIdent('%0'), toNiceIdent('%1')); +var ENTRY_IDENT_IDS = set(0, 1); // XXX function recomputeLines(func) { func.lines = func.labels.map(function(label) { return label.lines }).reduce(concatenator, []); @@ -544,6 +544,10 @@ function analyzer(data, sidePass) { params: [(signed && j + whole > sourceElements.length) ? signedKeepAlive : null], type: 'i32', }; + if (j == 0 && isUnsignedOp(value.op) && sourceBits < 32) { + // zext sign correction + result.ident = makeSignOp(result.ident, 'i' + sourceBits, 'un', 1, 1); + } if (fraction != 0) { var other = { intertype: 'value', @@ -1176,7 +1180,9 @@ function analyzer(data, sidePass) { func.labelIdsInverse = {}; func.labelIds[toNiceIdent('%0')] = 0; func.labelIdsInverse[0] = toNiceIdent('%0'); - func.labelIdCounter = 1; + func.labelIds[toNiceIdent('%1')] = 1; + func.labelIdsInverse[1] = toNiceIdent('%1'); + func.labelIdCounter = 2; func.labels.forEach(function(label) { func.labelIds[label.ident] = func.labelIdCounter++; func.labelIdsInverse[func.labelIdCounter-1] = label.ident; @@ -1202,6 +1208,7 @@ function analyzer(data, sidePass) { if (phi.intertype == 'phi') { for (var i = 0; i < phi.params.length; i++) { phi.params[i].label = func.labelIds[phi.params[i].label]; + if (!phi.params[i].label) warn('phi refers to nonexistent label on line ' + phi.lineNum); } } }); @@ -1217,9 +1224,10 @@ function analyzer(data, sidePass) { // So we need to handle that in a special way here. function getActualLabelId(labelId) { if (func.labelsDict[labelId]) return labelId; - if (labelId in ENTRY_IDENTS) { - assert(func.labelsDict[ENTRY_IDENT]); - return ENTRY_IDENT; + if (labelId in ENTRY_IDENT_IDS) { + labelId = func.labelIds[ENTRY_IDENT]; + assert(func.labelsDict[labelId]); + return labelId; } return null; } @@ -1270,88 +1278,44 @@ function analyzer(data, sidePass) { recomputeLines(func); } - if (!MICRO_OPTS) { - // 'Emulate' phis, by doing an if where the phi appears in the .ll. For this - // we need __lastLabel__. - func.needsLastLabel = false; - func.labels.forEach(function(label) { - var phis = []; - label.lines.forEach(function(phi) { - if (phi.intertype == 'phi') { - for (var i = 0; i < phi.params.length; i++) { - var sourceLabelId = getActualLabelId(phi.params[i].label); - if (sourceLabelId) { - var sourceLabel = func.labelsDict[sourceLabelId]; - var lastLine = sourceLabel.lines.slice(-1)[0]; - assert(lastLine.intertype in LLVM.PHI_REACHERS, 'Only some can lead to labels with phis:' + [func.ident, label.ident, lastLine.intertype]); - lastLine.currLabelId = sourceLabelId; - } - } - phis.push(phi); - func.needsLastLabel = true; - } - }); + // Properly implement phis, by pushing them back into the branch + // that leads to here. We will only have the |var| definition in this location. - if (phis.length >= 2) { - // Multiple phis have the semantics that they all occur 'in parallel', i.e., changes to - // a variable that is the result of a phi should *not* affect the other results. We must - // therefore be careful! - phis[phis.length-1].postSet = '; /* post-phi: */'; - for (var i = 0; i < phis.length-1; i++) { - var ident = phis[i].assignTo; - var phid = ident+'$phi' - phis[phis.length-1].postSet += ident + '=' + phid + ';'; - phis[i].assignTo = phid; - func.variables[phid] = { - ident: phid, - type: func.variables[ident].type, - origin: func.variables[ident].origin, - lineNum: func.variables[ident].lineNum, - uses: 1, - impl: VAR_EMULATED - }; - } - } - }); - } else { - // MICRO_OPTS == 1: Properly implement phis, by pushing them back into the branch - // that leads to here. We will only have the |var| definition in this location. - - // First, push phis back - func.labels.forEach(function(label) { - label.lines.forEach(function(phi) { - if (phi.intertype == 'phi') { - for (var i = 0; i < phi.params.length; i++) { - var param = phi.params[i]; - var sourceLabelId = getActualLabelId(param.label); - if (sourceLabelId) { - var sourceLabel = func.labelsDict[sourceLabelId]; - var lastLine = sourceLabel.lines.slice(-1)[0]; - assert(lastLine.intertype in LLVM.PHI_REACHERS, 'Only some can lead to labels with phis:' + [func.ident, label.ident, lastLine.intertype]); - if (!lastLine.phi) { - lastLine.phi = true; - assert(!lastLine.dependent); - lastLine.dependent = { - intertype: 'phiassigns', - params: [] - }; + // First, push phis back + func.labels.forEach(function(label) { + label.lines.forEach(function(phi) { + if (phi.intertype == 'phi') { + for (var i = 0; i < phi.params.length; i++) { + var param = phi.params[i]; + if (!param.label) warn('phi refers to nonexistent label on line ' + phi.lineNum); + var sourceLabelId = getActualLabelId(param.label); + if (sourceLabelId) { + var sourceLabel = func.labelsDict[sourceLabelId]; + var lastLine = sourceLabel.lines.slice(-1)[0]; + assert(lastLine.intertype in LLVM.PHI_REACHERS, 'Only some can lead to labels with phis:' + [func.ident, label.ident, lastLine.intertype]); + if (!lastLine.phi) { + lastLine.phi = true; + assert(!lastLine.dependent); + lastLine.dependent = { + intertype: 'phiassigns', + params: [] }; - lastLine.dependent.params.push({ - intertype: 'phiassign', - ident: phi.assignTo, - value: param.value, - targetLabel: label.ident - }); - } + }; + lastLine.dependent.params.push({ + intertype: 'phiassign', + ident: phi.assignTo, + value: param.value, + targetLabel: label.ident + }); } - // The assign to phi is now just a var - phi.intertype = 'var'; - phi.ident = phi.assignTo; - phi.assignTo = null; } - }); + // The assign to phi is now just a var + phi.intertype = 'var'; + phi.ident = phi.assignTo; + phi.assignTo = null; + } }); - } + }); }); this.forwardItem(item, 'StackAnalyzer'); } diff --git a/src/compiler.js b/src/compiler.js index 4442e38e..89da32d5 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -146,6 +146,8 @@ if (PGO) { // by default, correct everything during PGO EXPORTED_FUNCTIONS = set(EXPORTED_FUNCTIONS); EXPORTED_GLOBALS = set(EXPORTED_GLOBALS); +RUNTIME_DEBUG = LIBRARY_DEBUG || GL_DEBUG; + // Settings sanity checks assert(!(USE_TYPED_ARRAYS === 2 && QUANTUM_SIZE !== 4), 'For USE_TYPED_ARRAYS == 2, must have normal QUANTUM_SIZE of 4'); diff --git a/src/experimental/stringCache.diff b/src/experimental/stringCache.diff new file mode 100644 index 00000000..26cbc68c --- /dev/null +++ b/src/experimental/stringCache.diff @@ -0,0 +1,147 @@ +diff --git a/src/library_gl.js b/src/library_gl.js +index 7471578..9228964 100644 +--- a/src/library_gl.js ++++ b/src/library_gl.js +@@ -1256,28 +1256,28 @@ var LibraryGL = { + + setClientAttribute: function(name, size, type, stride, pointer) { + var attrib = this.clientAttributes[GL.immediate.ATTRIBUTE_BY_NAME[name]]; + attrib.size = size; + attrib.type = type; + attrib.stride = stride; + attrib.pointer = pointer; +- attrib.name = name + size; ++ attrib.name = Runtime.getStringConcat(name, size); + }, + + // Renderers + addRendererComponent: function(component) { + if (this.rendererComponents[component]) return; + this.rendererComponents[component] = 1; +- this.renderer += component; ++ this.renderer = Runtime.getStringConcat(this.renderer, component); + }, + + setRenderer: function(renderer) { + var name = renderer; + if (GL.currProgram && renderer[0] != 'U') { +- name = 'UD' + GL.currProgram + '|' + renderer; // user-defined program renderer ++ name = Runtime.getStringConcat(Runtime.getStringConcat('UD', GL.currProgram), Runtime.getStringConcat('|', renderer)); // user-defined program renderer + } + this.renderer = name; + if (this.renderers[name]) return this.renderers[name]; + this.renderers[name] = this.createRenderer(renderer); + return this.renderers[name]; + }, + +@@ -1300,15 +1300,18 @@ var LibraryGL = { + } + vertexSize += size * 4; // XXX assuming float + } else if (which == 'N') { + vertexSize += 4; // 1 char, + alignment + } else if (which == 'C') { + vertexSize += 4; // Up to 4 chars, + alignment + } else { +- console.log('Warning: Ignoring renderer attribute ' + which); ++#if ASSERTIONS ++ console.log('Warning: Ignoring renderer attribute'); ++ console.log(which); ++#endif + size = parseInt(renderer[i+1]); + vertexSize += size * 4; // XXX assuming float + } + } + assert(positionSize > 0); + // TODO: verify vertexSize is equal to the stride in enabled client arrays + var useCurrProgram = !!GL.currProgram; +@@ -1465,30 +1468,30 @@ var LibraryGL = { + var renderer = '', bytes = 0; + for (var i = 0; i < attributes.length; i++) { + var attribute = attributes[i]; + if (!attribute) break; + attribute.offset = attribute.pointer - start; + if (attribute.offset > bytes) { // ensure we start where we should + assert((attribute.offset - bytes)%4 == 0); // XXX assuming 4-alignment +- renderer += '?' + ((attribute.offset - bytes)/4); ++ renderer = Runtime.getStringConcat(renderer, Runtime.getStringConcat('?', ((attribute.offset - bytes)/4))); + bytes += attribute.offset - bytes; + } +- renderer += attribute.name; ++ renderer = Runtime.getStringConcat(renderer, attribute.name); + bytes += attribute.size * GL.immediate.byteSizeByType[attribute.type]; + if (bytes % 4 != 0) bytes += 4 - (bytes % 4); // XXX assuming 4-alignment + #if ASSERTIONS + assert(0 <= attribute.offset && attribute.offset < stride); // must all be in the same buffer + #endif + } + + assert(stride == 0 || bytes <= stride); + + if (bytes < stride) { // ensure the size is that of the stride + assert((stride - bytes)%4 == 0); // assuming float +- renderer += '?' + ((stride-bytes)/4); ++ renderer = Runtime.getStringConcat(renderer, Runtime.getStringConcat('?', ((stride-bytes)/4))); + bytes = stride; + } + + bytes *= count; + if (!GL.currArrayBuffer) { + GL.immediate.vertexData = {{{ makeHEAPView('F32', 'start', 'start + bytes') }}}; // XXX assuming float + } +@@ -1671,15 +1674,15 @@ var LibraryGL = { + }, + + glVertexPointer__deps: ['$GLEmulation'], // if any pointers are used, glVertexPointer must be, and if it is, then we need emulation + glVertexPointer: function(size, type, stride, pointer) { + GL.immediate.setClientAttribute('V', size, type, stride, pointer); + }, + glTexCoordPointer: function(size, type, stride, pointer) { +- GL.immediate.setClientAttribute('T' + GL.immediate.clientActiveTexture, size, type, stride, pointer); ++ GL.immediate.setClientAttribute(Runtime.getStringConcat('T', GL.immediate.clientActiveTexture), size, type, stride, pointer); + }, + glNormalPointer: function(type, stride, pointer) { + GL.immediate.setClientAttribute('N', 1, type, stride, pointer); + }, + glColorPointer: function(size, type, stride, pointer) { + GL.immediate.setClientAttribute('C', size, type, stride, pointer); + }, +diff --git a/src/runtime.js b/src/runtime.js +index 6a251c4..012a66d 100644 +--- a/src/runtime.js ++++ b/src/runtime.js +@@ -319,25 +319,34 @@ var Runtime = { + if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {}; + if (!Runtime.warnOnce.shown[text]) { + Runtime.warnOnce.shown[text] = 1; + Module.printErr(text); + } + }, + ++ // Cache for JS function wrappers for C functions in FUNCTION_TABLE + funcWrappers: {}, +- + getFuncWrapper: function(func) { + if (!Runtime.funcWrappers[func]) { + Runtime.funcWrappers[func] = function() { + FUNCTION_TABLE[func].apply(null, arguments); + }; + } + return Runtime.funcWrappers[func]; + }, + ++ // Cache for small recurring strings generated by concatenating other ++ // strings, use this to avoid needless allocation and collection ++ stringCache: {}, ++ getStringConcat: function(a, b) { ++ var cacheItem = Runtime.stringCache[a]; ++ if (!cacheItem) cacheItem = Runtime.stringCache[a] = {}; ++ return cacheItem[b] || (cacheItem[b] = a + b); ++ }, ++ + #if RUNTIME_DEBUG + debug: true, // Switch to false at runtime to disable logging at the right times + + printObjectList: [], + + prettyPrint: function(arg) { + if (typeof arg == 'undefined') return '!UNDEFINED!'; diff --git a/src/intertyper.js b/src/intertyper.js index 0f9ce659..354ec19c 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -350,6 +350,10 @@ function intertyper(data, sidePass, baseLineNums) { return 'FuncHeader'; if (tokensLength >= 1 && token0Text == '}') return 'FuncEnd'; + if (token0Text == 'module' && token1Text == 'asm') { + warn('Ignoring module asm: ' + item.tokens[2].text); + return '/dev/null'; + } } if (tokensLength >= 3 && (token0Text == 'call' || token1Text == 'call')) return 'Call'; diff --git a/src/jsifier.js b/src/jsifier.js index 904517e1..b3c2af1d 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -73,6 +73,9 @@ function JSify(data, functionsOnly, givenFunctions) { } else { libFuncsToInclude = ['memcpy', 'memset', 'malloc', 'free']; } + if (GENERATING_HTML) { + libFuncsToInclude.push('$Browser'); + } libFuncsToInclude.forEach(function(ident) { data.functionStubs.push({ intertype: 'functionStub', @@ -408,8 +411,8 @@ function JSify(data, functionsOnly, givenFunctions) { // name the function; overwrite if it's already named snippet = snippet.replace(/function(?:\s+([^(]+))?\s*\(/, 'function _' + ident + '('); if (LIBRARY_DEBUG) { - snippet = snippet.replace('{', '{ var ret = (function() {Module.printErr("[library call:' + ident + ': " + Array.prototype.slice.call(arguments) + "]"); '); - snippet = snippet.substr(0, snippet.length-1) + '}).apply(this, arguments); Module.printErr(" [ return:" + ret); return ret; }'; + snippet = snippet.replace('{', '{ var ret = (function() { if (Runtime.debug) Module.printErr("[library call:' + ident + ': " + Array.prototype.slice.call(arguments).map(Runtime.prettyPrint) + "]"); '); + snippet = snippet.substr(0, snippet.length-1) + '}).apply(this, arguments); if (Runtime.debug && typeof ret !== "undefined") Module.printErr(" [ return:" + Runtime.prettyPrint(ret)); return ret; }'; } } @@ -432,7 +435,7 @@ function JSify(data, functionsOnly, givenFunctions) { } else { ident = '_' + ident; } - var text = (deps ? '\n' + deps.map(addFromLibrary).join('\n') : ''); + var text = (deps ? '\n' + deps.map(addFromLibrary).filter(function(x) { return x != '' }).join('\n') : ''); text += isFunction ? snippet : 'var ' + ident + '=' + snippet + ';'; if (ident in EXPORTED_FUNCTIONS) { text += '\nModule["' + ident + '"] = ' + ident + ';'; @@ -450,6 +453,9 @@ function JSify(data, functionsOnly, givenFunctions) { item.JS = addFromLibrary(shortident); } else { item.JS = 'var ' + item.ident + '; // stub for ' + item.ident; + if (WARN_ON_UNDEFINED_SYMBOLS) { + warn('Unresolved symbol: ' + item.ident); + } } return ret; } @@ -555,9 +561,6 @@ function JSify(data, functionsOnly, givenFunctions) { if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */'; func.JS += ' var __label__;\n'; } - if (func.needsLastLabel) { - func.JS += ' var __lastLabel__ = null;\n'; - } // Walk function blocks and generate JS function walkBlock(block, indent) { @@ -748,7 +751,7 @@ function JSify(data, functionsOnly, givenFunctions) { makeFuncLineActor('noop', function(item) { return ';'; }); - makeFuncLineActor('var', function(item) { // assigns into phis become simple vars when MICRO_OPTS + makeFuncLineActor('var', function(item) { // assigns into phis become simple vars return 'var ' + item.ident + ';'; }); makeFuncLineActor('store', function(item) { @@ -789,11 +792,8 @@ function JSify(data, functionsOnly, givenFunctions) { return label; } - function makeBranch(label, lastLabel, labelIsVariable) { + function makeBranch(label, lastLabel, labelIsVariable) { // lastLabel is deprecated var pre = ''; - if (!MICRO_OPTS && lastLabel) { - pre = '__lastLabel__ = ' + getLabelId(lastLabel) + '; '; - } if (label[0] == 'B') { assert(!labelIsVariable, 'Cannot handle branches to variables with special branching options'); var parts = label.split('|'); @@ -1030,7 +1030,16 @@ function JSify(data, functionsOnly, givenFunctions) { makeFuncLineActor('extractvalue', function(item) { assert(item.indexes.length == 1); // TODO: use getelementptr parsing stuff, for depth. For now, we assume that LLVM aggregates are flat, // and we emulate them using simple JS objects { f1: , f2: , } etc., for speed - return item.ident + '.f' + item.indexes[0][0].text; + var index = item.indexes[0][0].text; + var valueType = Types.types[item.type].fields[index]; + if (USE_TYPED_ARRAYS != 2 || valueType != 'i64') { + return item.ident + '.f' + index; + } else { + var assignTo = item.assignTo; + item.assignTo = null; + return 'var ' + assignTo + '$0 = ' + item.ident + '.f' + index + '[0];' + + 'var ' + assignTo + '$1 = ' + item.ident + '.f' + index + '[1];'; + } }); makeFuncLineActor('insertvalue', function(item) { assert(item.indexes.length == 1); // TODO: see extractvalue @@ -1052,20 +1061,6 @@ function JSify(data, functionsOnly, givenFunctions) { return RuntimeGenerator.stackAlloc(getFastValue(calcAllocatedSize(item.allocatedType), '*', item.allocatedNum)); } }); - makeFuncLineActor('phi', function(item) { - var params = item.params; - assert(!MICRO_OPTS); - function makeOne(i) { - if (i === params.length-1) { - return finalizeLLVMParameter(params[i].value); - } - return '__lastLabel__ == ' + getLabelId(params[i].label) + ' ? ' + - finalizeLLVMParameter(params[i].value) + ' : (' + makeOne(i+1) + ')'; - } - var ret = makeOne(0); - if (item.postSet) ret += item.postSet; - return ret; - }); makeFuncLineActor('mathop', processMathop); diff --git a/src/library.js b/src/library.js index c491f078..2472e701 100644 --- a/src/library.js +++ b/src/library.js @@ -90,18 +90,18 @@ LibraryManager.library = { #if FS_LOG var inputPath = path; function log() { - print('FS.analyzePath("' + inputPath + '", ' + - dontResolveLastLink + ', ' + - linksVisited + ') => {' + - 'isRoot: ' + ret.isRoot + ', ' + - 'exists: ' + ret.exists + ', ' + - 'error: ' + ret.error + ', ' + - 'name: "' + ret.name + '", ' + - 'path: "' + ret.path + '", ' + - 'object: ' + ret.object + ', ' + - 'parentExists: ' + ret.parentExists + ', ' + - 'parentPath: "' + ret.parentPath + '", ' + - 'parentObject: ' + ret.parentObject + '}'); + Module['print']('FS.analyzePath("' + inputPath + '", ' + + dontResolveLastLink + ', ' + + linksVisited + ') => {' + + 'isRoot: ' + ret.isRoot + ', ' + + 'exists: ' + ret.exists + ', ' + + 'error: ' + ret.error + ', ' + + 'name: "' + ret.name + '", ' + + 'path: "' + ret.path + '", ' + + 'object: ' + ret.object + ', ' + + 'parentExists: ' + ret.parentExists + ', ' + + 'parentPath: "' + ret.parentPath + '", ' + + 'parentObject: ' + ret.parentObject + '}'); } #endif path = FS.absolutePath(path); @@ -177,11 +177,11 @@ LibraryManager.library = { // Creates a file system record: file, link, device or folder. createObject: function(parent, name, properties, canRead, canWrite) { #if FS_LOG - print('FS.createObject("' + parent + '", ' + - '"' + name + '", ' + - JSON.stringify(properties) + ', ' + - canRead + ', ' + - canWrite + ')'); + Module['print']('FS.createObject("' + parent + '", ' + + '"' + name + '", ' + + JSON.stringify(properties) + ', ' + + canRead + ', ' + + canWrite + ')'); #endif if (!parent) parent = '/'; if (typeof parent === 'string') parent = FS.findObject(parent); @@ -257,11 +257,20 @@ LibraryManager.library = { var properties = {isDevice: false, contents: data}; return FS.createFile(parent, name, properties, canRead, canWrite); }, - // Creates a file record for lazy-loading from a URL. + // Creates a file record for lazy-loading from a URL. XXX This requires a synchronous + // XHR, which is not possible in browsers except in a web worker! Use preloading, + // either --preload-file in emcc or FS.createPreloadedFile createLazyFile: function(parent, name, url, canRead, canWrite) { var properties = {isDevice: false, url: url}; return FS.createFile(parent, name, properties, canRead, canWrite); }, + // Preloads a file asynchronously. You can call this before run, for example in + // preRun. run will be delayed until this file arrives and is set up. + createPreloadedFile: function(parent, name, url, canRead, canWrite) { + Browser.asyncLoad(url, function(data) { + FS.createDataFile(parent, name, data, canRead, canWrite); + }); + }, // Creates a link to a sepcific local path. createLink: function(parent, name, target, canRead, canWrite) { var properties = {isDevice: false, link: target}; @@ -340,6 +349,7 @@ LibraryManager.library = { typeof window.prompt == 'function') { // Browser. result = window.prompt('Input: '); + if (result === null) result = String.fromCharCode(0); // cancel ==> EOF } else if (typeof readline == 'function') { // Command line. result = readline(); @@ -371,8 +381,10 @@ LibraryManager.library = { if (!error.printer) error.printer = Module['print']; if (!error.buffer) error.buffer = []; - // Create the temporary folder. - FS.createFolder('/', 'tmp', true, true); + // Create the temporary folder, if not already created + try { + FS.createFolder('/', 'tmp', true, true); + } catch(e) {} // Create the I/O devices. var devFolder = FS.createFolder('/', 'dev', true, true); @@ -1867,7 +1879,7 @@ LibraryManager.library = { #if CATCH_EXIT_CODE throw new ExitStatus(); -#else +#else throw 'exit(' + status + ') called, at ' + new Error().stack; #endif }, @@ -2217,6 +2229,9 @@ LibraryManager.library = { if (!self.called) { STATICTOP = alignMemoryPage(STATICTOP); // make sure we start out aligned self.called = true; +#if GC_SUPPORT + _sbrk.DYNAMIC_START = STATICTOP; +#endif } var ret = STATICTOP; if (bytes != 0) Runtime.staticAlloc(bytes); @@ -2242,6 +2257,15 @@ LibraryManager.library = { // TODO: Document. _scanString__deps: ['_isFloat'], _scanString: function(format, get, unget, varargs) { + if (!__scanString.whiteSpace) { + __scanString.whiteSpace = {}; + __scanString.whiteSpace[' '.charCodeAt(0)] = 1; + __scanString.whiteSpace['\t'.charCodeAt(0)] = 1; + __scanString.whiteSpace['\n'.charCodeAt(0)] = 1; + __scanString.whiteSpace[' '] = 1; + __scanString.whiteSpace['\t'] = 1; + __scanString.whiteSpace['\n'] = 1; + } // Supports %x, %4x, %d.%d, %s, %f, %lf. // TODO: Support all format specifiers. format = Pointer_stringify(format); @@ -2249,6 +2273,7 @@ LibraryManager.library = { var argsi = 0; var fields = 0; var argIndex = 0; + var next; for (var formatIndex = 0; formatIndex < format.length; formatIndex++) { if (next <= 0) return fields; var next = get(); @@ -2264,11 +2289,14 @@ LibraryManager.library = { if (formatIndex != maxSpecifierStart) { max_ = parseInt(format.slice(maxSpecifierStart, formatIndex), 10); } - // TODO: Handle type size modifier. var long_ = false; + var half = false; if (format[formatIndex] == 'l') { long_ = true; formatIndex++; + } else if (format[formatIndex] == 'h') { + half = true; + formatIndex++; } var type = format[formatIndex]; formatIndex++; @@ -2288,13 +2316,18 @@ LibraryManager.library = { buffer.pop(); unget(); } + unget(); + next = get(); } else { + var first = true; while ((curr < max_ || isNaN(max_)) && next > 0) { - if ((type === 'd' && next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0)) || - (type === 'x' && (next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0) || - next >= 'a'.charCodeAt(0) && next <= 'f'.charCodeAt(0) || - next >= 'A'.charCodeAt(0) && next <= 'F'.charCodeAt(0))) || - (type === 's' && (next != ' '.charCodeAt(0) && next != '\t'.charCodeAt(0) && next != '\n'.charCodeAt(0))) && + if (!(next in __scanString.whiteSpace) && // stop on whitespace + (type == 's' || + ((type === 'd' || type == 'u') && ((next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0)) || + (first && next == '-'.charCodeAt(0)))) || + (type === 'x' && (next >= '0'.charCodeAt(0) && next <= '9'.charCodeAt(0) || + next >= 'a'.charCodeAt(0) && next <= 'f'.charCodeAt(0) || + next >= 'A'.charCodeAt(0) && next <= 'F'.charCodeAt(0)))) && (formatIndex >= format.length || next !== format[formatIndex].charCodeAt(0))) { // Stop when we read something that is coming up buffer.push(String.fromCharCode(next)); next = get(); @@ -2302,6 +2335,7 @@ LibraryManager.library = { } else { break; } + first = false; } } if (buffer.length === 0) return 0; // Failure. @@ -2309,8 +2343,12 @@ LibraryManager.library = { var argPtr = {{{ makeGetValue('varargs', 'argIndex', 'void*') }}}; argIndex += Runtime.getNativeFieldSize('void*'); switch (type) { - case 'd': - {{{ makeSetValue('argPtr', 0, 'parseInt(text, 10)', 'i32') }}} + case 'd': case 'u': + if (half) { + {{{ makeSetValue('argPtr', 0, 'parseInt(text, 10)', 'i16') }}}; + } else { + {{{ makeSetValue('argPtr', 0, 'parseInt(text, 10)', 'i32') }}}; + } break; case 'x': {{{ makeSetValue('argPtr', 0, 'parseInt(text, 16)', 'i32') }}} @@ -2330,6 +2368,12 @@ LibraryManager.library = { break; } fields++; + } else if (format[formatIndex] in __scanString.whiteSpace) { + while (next in __scanString.whiteSpace) { + next = get(); + if (next <= 0) return fields; // End of input. + } + unget(); } else { // Not a specifier. if (format[formatIndex].charCodeAt(0) !== next) { @@ -3480,6 +3524,9 @@ LibraryManager.library = { return ret * multiplier; }, + strtod_l: 'strtod', // no locale support yet + strtold: 'strtod', // XXX add real support for long double + strtold_l: 'strtold', // no locale support yet _parseInt__deps: ['isspace', '__setErrNo', '$ERRNO_CODES'], _parseInt: function(str, endptr, base, min, max, bits, unsign) { @@ -3956,19 +4003,35 @@ LibraryManager.library = { }, strspn: function(pstr, pset) { - var str = String_copy(pstr, true); - var set = String_copy(pset); - var i = 0; - while (set.indexOf(str[i]) != -1) i++; // Must halt, as 0 is in str but not set - return i; + var str = pstr, set, strcurr, setcurr; + while (1) { + strcurr = {{{ makeGetValue('str', '0', 'i8') }}}; + if (!strcurr) return str - pstr; + set = pset; + while (1) { + setcurr = {{{ makeGetValue('set', '0', 'i8') }}}; + if (!setcurr || setcurr == strcurr) break; + set++; + } + if (!setcurr) return str - pstr; + str++; + } }, strcspn: function(pstr, pset) { - var str = String_copy(pstr, true); - var set = String_copy(pset, true); - var i = 0; - while (set.indexOf(str[i]) == -1) i++; // Must halt, as 0 is in both - return i; + var str = pstr, set, strcurr, setcurr; + while (1) { + strcurr = {{{ makeGetValue('str', '0', 'i8') }}}; + if (!strcurr) return str - pstr; + set = pset; + while (1) { + setcurr = {{{ makeGetValue('set', '0', 'i8') }}}; + if (!setcurr || setcurr == strcurr) break; + set++; + } + if (setcurr) return str - pstr; + str++; + } }, strcpy: function(pdest, psrc) { @@ -4394,6 +4457,21 @@ LibraryManager.library = { */ }, + llvm_bswap_i16: function(x) { + x = unSign(x, 32); + var bytes = []; + bytes[0] = x & 255; + x >>= 8; + bytes[1] = x & 255; + x >>= 8; + var ret = 0; + ret <<= 8; + ret += bytes[0]; + ret <<= 8; + ret += bytes[1]; + return ret; + }, + llvm_bswap_i32: function(x) { x = unSign(x, 32); var bytes = []; @@ -4408,7 +4486,7 @@ LibraryManager.library = { } return ret; }, - + llvm_ctlz_i32: function(x) { for (var i=0; i<32; i++) { if ( (x & (1 << (31-i))) != 0 ) { @@ -4672,6 +4750,24 @@ LibraryManager.library = { }; }, + llvm_uadd_with_overflow_i64__deps: [function() { preciseI64MathUsed = 1 }], + llvm_uadd_with_overflow_i64: function(xl, xh, yl, yh) { + i64Math.add(xl, xh, yl, yh); + return { + f0: i64Math.result, + f1: 0 // XXX Need to hack support for this in long.js + }; + }, + + llvm_umul_with_overflow_i64__deps: [function() { preciseI64MathUsed = 1 }], + llvm_umul_with_overflow_i64: function(xl, xh, yl, yh) { + i64Math.mul(xl, xh, yl, yh); + return { + f0: i64Math.result, + f1: 0 // XXX Need to hack support for this in long.js + }; + }, + llvm_stacksave: function() { var self = _llvm_stacksave; if (!self.LLVM_SAVEDSTACKS) { @@ -4711,6 +4807,11 @@ LibraryManager.library = { llvm_lifetime_start: function() {}, llvm_lifetime_end: function() {}, + llvm_invariant_start: function() {}, + llvm_invariant_end: function() {}, + + llvm_objectsize_i32: function() { return -1 }, // TODO: support this + // ========================================================================== // math.h // ========================================================================== @@ -4935,7 +5036,7 @@ LibraryManager.library = { if (isNaN(x)) return {{{ cDefine('FP_NAN') }}}; if (!isFinite(x)) return {{{ cDefine('FP_INFINITE') }}}; if (x == 0) return {{{ cDefine('FP_ZERO') }}}; - // FP_SUBNORMAL..? + // FP_SUBNORMAL..? return {{{ cDefine('FP_NORMAL') }}}; }, __fpclassifyd: '__fpclassifyf', diff --git a/src/library_browser.js b/src/library_browser.js index 299e8a72..d49c4103 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -3,31 +3,17 @@ // Utilities for browser environments mergeInto(LibraryManager.library, { - emscripten_set_main_loop: function(func, fps) { - fps = fps || 60; // TODO: use requestAnimationFrame - _emscripten_set_main_loop.cancel = false; - var jsFunc = FUNCTION_TABLE[func]; - function doOne() { - if (_emscripten_set_main_loop.cancel) return; - jsFunc(); - setTimeout(doOne, 1000/fps); // doing this each time means that on exception, we stop - } - setTimeout(doOne, 1000/fps); - }, - - emscripten_cancel_main_loop: function(func) { - _emscripten_set_main_loop.cancel = true; - }, - - emscripten_async_call: function(func, millis) { - // TODO: cache these to avoid generating garbage - setTimeout(function() { - FUNCTION_TABLE[func](); - }, millis); - }, - + $Browser__postset: 'Module["requestFullScreen"] = function() { Browser.requestFullScreen() };\n', // export requestFullScreen $Browser: { - createContext: function(canvas, useWebGL) { + mainLoop: { + scheduler: null, + shouldPause: false, + paused: false + }, + pointerLock: false, + moduleContextCreatedCallbacks: [], + + createContext: function(canvas, useWebGL, setInModule) { #if !USE_TYPED_ARRAYS if (useWebGL) { Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); @@ -46,57 +32,19 @@ mergeInto(LibraryManager.library, { // Useful to debug native webgl apps: var Module = { printErr: function(x) { console.log(x) } }; var tempCtx = ctx; var wrapper = {}; - wrapper.objectMap = new WeakMap(); - wrapper.objectCounter = 1; for (var prop in tempCtx) { (function(prop) { switch (typeof tempCtx[prop]) { case 'function': { wrapper[prop] = function() { - var printArgs = Array.prototype.slice.call(arguments).map(function(arg) { - if (typeof arg == 'undefined') return '!UNDEFINED!'; - if (!arg) return arg; - if (wrapper.objectMap[arg]) return '<' + arg + '|' + wrapper.objectMap[arg] + '>'; - if (arg.toString() == '[object HTMLImageElement]') { - return arg + '\n\n'; - } - if (arg.byteLength) { - return '{' + Array.prototype.slice.call(arg, 0, Math.min(arg.length, 40)) + '}'; // Useful for correct arrays, less so for compiled arrays, see the code below for that - var buf = new ArrayBuffer(32); - var i8buf = new Int8Array(buf); - var i16buf = new Int16Array(buf); - var f32buf = new Float32Array(buf); - switch(arg.toString()) { - case '[object Uint8Array]': - i8buf.set(arg.subarray(0, 32)); - break; - case '[object Float32Array]': - f32buf.set(arg.subarray(0, 5)); - break; - case '[object Uint16Array]': - i16buf.set(arg.subarray(0, 16)); - break; - default: - alert('unknown array for debugging: ' + arg); - throw 'see alert'; - } - var ret = '{' + arg.byteLength + ':\n'; - var arr = Array.prototype.slice.call(i8buf); - ret += 'i8:' + arr.toString().replace(/,/g, ',') + '\n'; - arr = Array.prototype.slice.call(f32buf, 0, 8); - ret += 'f32:' + arr.toString().replace(/,/g, ',') + '}'; - return ret; - } - return arg; - }); - console.log('[gl_f:' + prop + ':' + printArgs + ']'); + if (GL.debug) { + var printArgs = Array.prototype.slice.call(arguments).map(Runtime.prettyPrint); + console.log('[gl_f:' + prop + ':' + printArgs + ']'); + } var ret = tempCtx[prop].apply(tempCtx, arguments); - var printRet = ret; - if (typeof ret == 'object') { - wrapper.objectMap[ret] = wrapper.objectCounter++; - printRet = '<' + ret + '|' + wrapper.objectMap[ret] + '>'; + if (GL.debug && typeof ret != 'undefined') { + console.log('[ gl:' + prop + ':return:' + Runtime.prettyPrint(ret) + ']'); } - if (typeof printRet != 'undefined') console.log('[ gl:' + prop + ':return:' + printRet + ']'); return ret; } break; @@ -107,7 +55,9 @@ mergeInto(LibraryManager.library, { return tempCtx[prop]; }); wrapper.__defineSetter__(prop, function(value) { - console.log('[gl_s:' + prop + ':' + value + ']'); + if (GL.debug) { + console.log('[gl_s:' + prop + ':' + value + ']'); + } tempCtx[prop] = value; }); break; @@ -119,50 +69,200 @@ mergeInto(LibraryManager.library, { #endif // Set the background of the WebGL canvas to black canvas.style.backgroundColor = "black"; + + // Warn on context loss + canvas.addEventListener('webglcontextlost', function(event) { + alert('WebGL context lost. You will need to reload the page.'); + }, false); + } + if (setInModule) { + Module.ctx = ctx; + Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() }); } return ctx; }, - // Given binary data for an image, in a format like PNG or JPG, we convert it - // to flat pixel data. We do so using the browser's native code. - // This is deprecated, it is preferred to load binary files, createObjectURL, etc., - // see the sdl_* tests. - /*decodeImage: function(pixels, format) { - function encodeBase64(data) { - var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - var PAD = '='; - var ret = ''; - var leftchar = 0; - var leftbits = 0; - for (var i = 0; i < data.length; i++) { - leftchar = (leftchar << 8) | data[i]; - leftbits += 8; - while (leftbits >= 6) { - var curr = (leftchar >> (leftbits-6)) & 0x3f; - leftbits -= 6; - ret += BASE[curr]; - } - } - if (leftbits == 2) { - ret += BASE[(leftchar&3) << 4]; - ret += PAD + PAD; - } else if (leftbits == 4) { - ret += BASE[(leftchar&0xf) << 2]; - ret += PAD; + requestFullScreen: function() { + var canvas = Module.canvas; + function fullScreenChange() { + if (document['webkitFullScreenElement'] === canvas || + document['mozFullScreenElement'] === canvas || + document['fullScreenElement'] === canvas) { + canvas.requestPointerLock = canvas['requestPointerLock'] || + canvas['mozRequestPointerLock'] || + canvas['webkitRequestPointerLock']; + canvas.requestPointerLock(); } - return ret; } - var image = new Image(); - image.src = 'data:image/' + format + ';base64,' + encodeBase64(pixels); - assert(image.complete, 'Image could not be decoded'); // page reload might fix it, decoding is async... need .onload handler... - var canvas = document.createElement('canvas'); - canvas.width = image.width; - canvas.height = image.height; - var ctx = canvas.getContext('2d'); - ctx.drawImage(image, 0, 0); - var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - return imageData; - },*/ + + document.addEventListener('fullscreenchange', fullScreenChange, false); + document.addEventListener('mozfullscreenchange', fullScreenChange, false); + document.addEventListener('webkitfullscreenchange', fullScreenChange, false); + + function pointerLockChange() { + Browser.pointerLock = document['pointerLockElement'] === canvas || + document['mozPointerLockElement'] === canvas || + document['webkitPointerLockElement'] === canvas; + } + + document.addEventListener('pointerlockchange', pointerLockChange, false); + document.addEventListener('mozpointerlockchange', pointerLockChange, false); + document.addEventListener('webkitpointerlockchange', pointerLockChange, false); + + canvas.requestFullScreen = canvas['requestFullScreen'] || + canvas['mozRequestFullScreen'] || + (canvas['webkitRequestFullScreen'] ? function() { canvas['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null); + canvas.requestFullScreen(); + }, + + requestAnimationFrame: function(func) { + if (!window.requestAnimationFrame) { + window.requestAnimationFrame = window['requestAnimationFrame'] || + window['mozRequestAnimationFrame'] || + window['webkitRequestAnimationFrame'] || + window['msRequestAnimationFrame'] || + window['oRequestAnimationFrame'] || + window['setTimeout']; + } + window.requestAnimationFrame(func); + }, + + getMovementX: function(delta, event) { + if (!Browser.pointerLock) return delta; + return event['movementX'] || + event['mozMovementX'] || + event['webkitMovementX'] || + 0; // delta; + }, + + getMovementY: function(delta, event) { + if (!Browser.pointerLock) return delta; + return event['movementY'] || + event['mozMovementY'] || + event['webkitMovementY'] || + 0; // delta; + }, + + asyncLoad: function(url, callback) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + xhr.onload = function() { + var arrayBuffer = xhr.response; + assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).'); + callback(new Uint8Array(arrayBuffer)); + removeRunDependency(); + }; + xhr.onerror = function(event) { + assert(arrayBuffer, 'Loading data file "' + url + '" failed.'); + }; + xhr.send(null); + addRunDependency(); + } + }, + + emscripten_async_run_script__deps: ['emscripten_run_script'], + emscripten_async_run_script: function(script, millis) { + Module['noExitRuntime'] = true; + + // TODO: cache these to avoid generating garbage + setTimeout(function() { + _emscripten_run_script(script); + }, millis); + }, + + emscripten_set_main_loop: function(func, fps) { + Module['noExitRuntime'] = true; + + var jsFunc = FUNCTION_TABLE[func]; + var wrapper = function() { + if (Browser.mainLoop.shouldPause) { + // catch pauses from non-main loop sources + Browser.mainLoop.paused = true; + Browser.mainLoop.shouldPause = false; + return; + } + jsFunc(); + if (Browser.mainLoop.shouldPause) { + // catch pauses from the main loop itself + Browser.mainLoop.paused = true; + Browser.mainLoop.shouldPause = false; + return; + } + Browser.mainLoop.scheduler(); + } + if (fps && fps > 0) { + Browser.mainLoop.scheduler = function() { + setTimeout(wrapper, 1000/fps); // doing this each time means that on exception, we stop + } + } else { + Browser.mainLoop.scheduler = function() { + Browser.requestAnimationFrame(wrapper); + } + } + Browser.mainLoop.scheduler(); + }, + + emscripten_cancel_main_loop: function(func) { + Browser.mainLoop.scheduler = null; + Browser.mainLoop.shouldPause = true; + }, + + emscripten_pause_main_loop: function(func) { + Browser.mainLoop.shouldPause = true; + }, + + emscripten_resume_main_loop: function(func) { + if (Browser.mainLoop.paused) { + Browser.mainLoop.paused = false; + Browser.mainLoop.scheduler(); + } + Browser.mainLoop.shouldPause = false; + }, + + emscripten_async_call: function(func, millis) { + Module['noExitRuntime'] = true; + + var asyncCall = Runtime.getFuncWrapper(func); + if (millis >= 0) { + setTimeout(asyncCall, millis); + } else { + Browser.requestAnimationFrame(asyncCall); + } + }, + + emscripten_hide_mouse: function() { + var styleSheet = document.styleSheets[0]; + var rules = styleSheet.cssRules; + for (var i = 0; i < rules.length; i++) { + if (rules[i].cssText.substr(0, 5) == 'canvas') { + styleSheet.deleteRule(i); + i--; + } + } + styleSheet.insertRule('canvas.emscripten { border: 1px solid black; cursor: none; }', 0); + }, + + emscripten_get_now: function() { + if (window['performance'] && window['performance']['now']) { + return window['performance']['now'](); + } else { + return Date.now(); + } } }); +/* Useful stuff for browser debugging + +function slowLog(label, text) { + if (!slowLog.labels) slowLog.labels = {}; + if (!slowLog.labels[label]) slowLog.labels[label] = 0; + var now = Date.now(); + if (now - slowLog.labels[label] > 1000) { + Module.print(label + ': ' + text); + slowLog.labels[label] = now; + } +} + +*/ + diff --git a/src/library_gc.js b/src/library_gc.js new file mode 100644 index 00000000..ccf6656d --- /dev/null +++ b/src/library_gc.js @@ -0,0 +1,165 @@ + +if (GC_SUPPORT) { + var LibraryGC = { + $GC__deps: ['sbrk'], + $GC: { + ALLOCATIONS_TO_GC: 1*1024*1024, + + sizes: {}, // if in this map, then a live allocated object. this is iterable + scannables: {}, + finalizers: {}, + finalizerArgs: {}, + + totalAllocations: 0, // bytes of all currently active objects + recentAllocations: 0, // bytes allocated since last gc. ignores free()s + + init: function() { + assert(!GC.initted); + GC.initted = true; +#if GENERATING_HTML + setInterval(function() { + GC.maybeCollect(); + }, 1000); +#else + // No HTML intervals, so you need to call GC.maybeCollect() or GC.collect() manually +#endif + }, + + malloc: function(bytes, clear, scannable) { + if (!bytes) return 0; + var ptr; + if (clear) { + ptr = _calloc(1, bytes); + } else { + ptr = _malloc(bytes); + } + GC.scannables[ptr] = scannable; + GC.sizes[ptr] = bytes; + GC.totalAllocations += bytes; + GC.recentAllocations += bytes; + return ptr; + }, + + free: function(ptr) { // does not check if anything refers to it, this is a forced free + var finalizer = GC.finalizers[ptr]; + if (finalizer) { + Runtime.getFuncWrapper(finalizer)(ptr, GC.finalizerArgs[ptr]); + GC.finalizers[ptr] = 0; + } + _free(ptr); + delete GC.sizes[ptr]; + GC.totalAllocations -= GC.sizes[ptr]; + }, + + registerFinalizer: function(ptr, func, arg, oldFunc, oldArg) { + var finalizer = GC.finalizers[ptr]; + if (finalizer) { + if (oldFunc) { + {{{ makeSetValue('oldFunc', '0', 'finalizer', 'i32') }}}; + } + if (oldArg) { + {{{ makeSetValue('oldArg', '0', 'GC.finalizerArgs[ptr]', 'i32') }}}; + } + } + GC.finalizers[ptr] = func; + GC.finalizerArgs[ptr] = arg; + }, + + maybeCollect: function() { + if (GC.needCollect()) GC.collect(); + }, + + needCollect: function() { + return GC.recentAllocations >= GC.ALLOCATIONS_TO_GC; // TODO: time, etc. + }, + + collect: function() { + GC.prep(); + GC.mark(); + GC.sweep(); + GC.recentAllocations = 0; + }, + + scan: function(start, end) { // scans a memory region and adds new reachable objects + for (var i = start; i < end; i += {{{ Runtime.getNativeTypeSize('void*') }}}) { + var ptr = {{{ makeGetValue('i', '0', 'void*') }}}; + if (GC.sizes[ptr] && !GC.reachable[ptr]) { + GC.reachable[ptr] = 1; + if (GC.scannables[ptr]) { + GC.reachableList.push(ptr); + } + } + } + }, + + prep: function() { // Clear reachables and scan for roots + GC.reachable = {}; // 1 if reachable. XXX + GC.reachableList = []; // each reachable is added once to this. XXX + // static data areas + var staticStart = STACK_MAX; + var staticEnd = _sbrk.DYNAMIC_START || STATICTOP; // after DYNAMIC_START, sbrk manages it (but it might not exist yet) + GC.scan(staticStart, staticEnd); + // TODO: scan stack and registers. Currently we assume we run from a timeout or such, so no stack/regs + // stack: STACK_ROOT to STACKTOP + // registers: call scanners + }, + + mark: function() { // mark all reachable from roots + for (var i = 0; i < GC.reachableList.length; i++) { // note that the list length changes as we push more + var ptr = GC.reachableList[i]; + GC.scan(ptr, ptr + GC.sizes[ptr]); + } + }, + + sweep: function() { // traverse all objects and free all unreachable + var freeList = []; + for (var ptr in GC.sizes) { + if (!GC.reachable[ptr]) { + freeList.push(parseInt(ptr)); + } + } + for (var i = 0; i < freeList.length; i++) { + GC.free(freeList[i]); + } + } + }, + + GC_INIT__deps: ['$GC'], + GC_INIT: function() { + GC.init(); + }, + + GC_MALLOC__deps: ['$GC'], + GC_MALLOC: function(bytes) { + return GC.malloc(bytes, true, true); + }, + + GC_MALLOC_ATOMIC__deps: ['$GC'], + GC_MALLOC_ATOMIC: function(bytes) { + return GC.malloc(bytes, false, false); + }, + + GC_FREE__deps: ['$GC'], + GC_FREE: function(ptr) { + GC.free(ptr); + }, + + GC_REGISTER_FINALIZER_NO_ORDER__deps: ['$GC'], + GC_REGISTER_FINALIZER_NO_ORDER: function(ptr, func, arg, old_func, old_arg) { + GC.registerFinalizer(ptr, func, arg, old_func, old_arg); + }, + + GC_MAYBE_COLLECT__deps: ['$GC'], + GC_MAYBE_COLLECT: function() { + GC.maybeCollect(); + }, + + GC_FORCE_COLLECT__deps: ['$GC'], + GC_FORCE_COLLECT: function() { + GC.collect(); + } + }; + + mergeInto(LibraryManager.library, LibraryGC); +} + diff --git a/src/library_gl.js b/src/library_gl.js index 052226cf..b5d65ee6 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -5,6 +5,10 @@ var LibraryGL = { $GL: { +#if GL_DEBUG + debug: true, +#endif + counter: 1, buffers: {}, programs: {}, @@ -116,6 +120,8 @@ var LibraryGL = { return allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL); case 0x1F03 /* GL_EXTENSIONS */: return allocate(intArrayFromString(Module.ctx.getSupportedExtensions().join(' ')), 'i8', ALLOC_NORMAL); + case 0x8B8C /* GL_SHADING_LANGUAGE_VERSION */: + return allocate(intArrayFromString('OpenGL ES GLSL 1.00 (WebGL)'), 'i8', ALLOC_NORMAL); default: throw 'Failure: Invalid glGetString value: ' + name_; } @@ -360,7 +366,7 @@ var LibraryGL = { }, glBindTexture: function(target, texture) { - Module.ctx.bindTexture(target, GL.textures[texture]); + Module.ctx.bindTexture(target, texture ? GL.textures[texture] : null); }, glGetTexParameterfv: function(target, pname, params) { @@ -433,7 +439,7 @@ var LibraryGL = { }, glBindRenderbuffer: function(target, renderbuffer) { - Module.ctx.bindRenderbuffer(target, GL.renderbuffers[renderbuffer]); + Module.ctx.bindRenderbuffer(target, renderbuffer ? GL.renderbuffers[renderbuffer] : null); }, glGetRenderbufferParameteriv: function(target, pname, params) { @@ -509,7 +515,7 @@ var LibraryGL = { program = GL.programs[program]; var info = Module.ctx.getActiveUniform(program, index); - var infoname = info.name.slice(0, bufsize - 1); + var infoname = info.name.slice(0, bufSize - 1); writeStringToMemory(infoname, name); if (length) { @@ -639,7 +645,7 @@ var LibraryGL = { }, glBindBuffer: function(target, buffer) { - Module.ctx.bindBuffer(target, GL.buffers[buffer]); + Module.ctx.bindBuffer(target, buffer ? GL.buffers[buffer] : null); }, glVertexAttrib1fv: function(index, v) { @@ -672,7 +678,7 @@ var LibraryGL = { program = GL.programs[program]; var info = Module.ctx.getActiveAttrib(program, index); - var infoname = info.name.slice(0, bufsize - 1); + var infoname = info.name.slice(0, bufSize - 1); writeStringToMemory(infoname, name); if (length) { @@ -719,9 +725,9 @@ var LibraryGL = { Module.ctx.shaderSource(GL.shaders[shader], source); }, - glGetShaderSource: function(shader, bufsize, length, source) { + glGetShaderSource: function(shader, bufSize, length, source) { var result = Module.ctx.getShaderSource(GL.shaders[shader]); - result.slice(0, bufsize - 1); + result.slice(0, bufSize - 1); writeStringToMemory(result, source); if (length) { {{{ makeSetValue('length', '0', 'result.length', 'i32') }}}; @@ -746,11 +752,19 @@ var LibraryGL = { }, glGetShaderiv : function(shader, pname, p) { - {{{ makeSetValue('p', '0', 'Module.ctx.getShaderParameter(GL.shaders[shader], pname)', 'i32') }}}; + if (pname == 0x8B84) { // GL_INFO_LOG_LENGTH + {{{ makeSetValue('p', '0', 'Module.ctx.getShaderInfoLog(GL.shaders[shader]).length + 1', 'i32') }}}; + } else { + {{{ makeSetValue('p', '0', 'Module.ctx.getShaderParameter(GL.shaders[shader], pname)', 'i32') }}}; + } }, glGetProgramiv : function(program, pname, p) { - {{{ makeSetValue('p', '0', 'Module.ctx.getProgramParameter(GL.programs[program], pname)', 'i32') }}}; + if (pname == 0x8B84) { // GL_INFO_LOG_LENGTH + {{{ makeSetValue('p', '0', 'Module.ctx.getProgramInfoLog(GL.programs[program]).length + 1', 'i32') }}}; + } else { + {{{ makeSetValue('p', '0', 'Module.ctx.getProgramParameter(GL.programs[program], pname)', 'i32') }}}; + } }, glIsShader: function(shader) { @@ -823,7 +837,7 @@ var LibraryGL = { }, glBindFramebuffer: function(target, framebuffer) { - Module.ctx.bindFramebuffer(target, GL.framebuffers[framebuffer]); + Module.ctx.bindFramebuffer(target, framebuffer ? GL.framebuffers[framebuffer] : null); }, glGenFramebuffers: function(n, ids) { @@ -867,24 +881,31 @@ var LibraryGL = { // GL emulation: provides misc. functionality not present in OpenGL ES 2.0 or WebGL - $GLEmulation__deps: ['glCreateShader', 'glShaderSource', 'glCompileShader', 'glCreateProgram', 'glDeleteShader', 'glDeleteProgram', 'glAttachShader', 'glActiveTexture', 'glGetShaderiv', 'glGetProgramiv', 'glLinkProgram', 'glGetProgramInfoLog', 'glGetShaderInfoLog'], $GLEmulation__postset: 'GLEmulation.init();', $GLEmulation: { init: function() { // Add some emulation workarounds Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work'); + + // XXX some of these ignored capabilities may lead to incorrect rendering, if we do not emulate them in shaders + var ignoredCapabilities = { + 0x0DE1: 1, // GL_TEXTURE_2D + 0x0B20: 1, // GL_LINE_SMOOTH + 0x0B60: 1, // GL_FOG + 0x8513: 1, // GL_TEXTURE_CUBE_MAP + 0x0BA1: 1, // GL_NORMALIZE + 0x0C60: 1, // GL_TEXTURE_GEN_S + 0x0C61: 1 // GL_TEXTURE_GEN_T + }; _glEnable = function(cap) { - if (cap == 0x0DE1) return; // GL_TEXTURE_2D - if (cap == 0x0B20) return; // GL_LINE_SMOOTH - if (cap == 0x0B60) return; // GL_FOG + if (cap in ignoredCapabilities) return; Module.ctx.enable(cap); }; _glDisable = function(cap) { - if (cap == 0x0DE1) return; // GL_TEXTURE_2D - if (cap == 0x0B20) return; // GL_LINE_SMOOTH - if (cap == 0x0B60) return; // GL_FOG + if (cap in ignoredCapabilities) return; Module.ctx.disable(cap); }; + var glGetIntegerv = _glGetIntegerv; _glGetIntegerv = function(pname, params) { switch (pname) { @@ -904,58 +925,105 @@ var LibraryGL = { {{{ makeSetValue('params', '0', 'result*4', 'i32') }}}; // GLES gives num of 4-element vectors, GL wants individual components, so multiply return; } + case 0x8871: pname = Module.ctx.MAX_COMBINED_TEXTURE_IMAGE_UNITS /* close enough */; break; // GL_MAX_TEXTURE_COORDS } glGetIntegerv(pname, params); }; + // Do some automatic rewriting to work around GLSL differences. Note that this must be done in // tandem with the rest of the program, by itself it cannot suffice. // Note that we need to remember shader types for this rewriting, saving sources makes it easier to debug. - GL.shaderTypes = {}; + GL.shaderInfos = {}; +#if GL_DEBUG GL.shaderSources = {}; GL.shaderOriginalSources = {}; +#endif var glCreateShader = _glCreateShader; _glCreateShader = function(shaderType) { var id = glCreateShader(shaderType); - GL.shaderTypes[id] = shaderType; + GL.shaderInfos[id] = { + type: shaderType, + ftransform: false + }; return id; }; + var glShaderSource = _glShaderSource; _glShaderSource = function(shader, count, string, length) { var source = GL.getSource(shader, count, string, length); +#if GL_DEBUG GL.shaderOriginalSources[shader] = source; - if (GL.shaderTypes[shader] == Module.ctx.VERTEX_SHADER) { +#endif + // XXX We add attributes and uniforms to shaders. The program can ask for the # of them, and see the + // ones we generated, potentially confusing it? Perhaps we should hide them. + if (GL.shaderInfos[shader].type == Module.ctx.VERTEX_SHADER) { // Replace ftransform() with explicit project/modelview transforms, and add position and matrix info. - source = 'attribute vec4 a_position; \n\ - uniform mat4 u_modelView; \n\ - uniform mat4 u_projection; \n' + - source.replace(/ftransform\(\)/g, 'u_projection * u_modelView * a_position') - .replace(/gl_Vertex/g, 'a_position') - .replace(/gl_ModelViewMatrix/g, 'u_modelView') - .replace(/gl_ProjectionMatrix/g, 'u_projection') - .replace(/gl_ModelViewProjectionMatrix/g, 'u_modelView * u_projection') - .replace(/gl_ModelViewMatrixTranspose\[2\]/g, 'vec3(u_modelView[0][0], u_modelView[1][0], u_modelView[2][0])'); // XXX extremely inefficient - for (var i = 0; i <= 6; i++) { + var has_pm = source.search(/u_projection/) >= 0; + var has_mm = source.search(/u_modelView/) >= 0; + var has_pv = source.search(/a_position/) >= 0; + var need_pm = 0, need_mm = 0, need_pv = 0; + var old = source; + source = source.replace(/ftransform\(\)/g, '(u_projection * u_modelView * a_position)'); + if (old != source) need_pm = need_mm = need_pv = 1; + old = source; + source = source.replace(/gl_ProjectionMatrix/g, 'u_projection'); + if (old != source) need_pm = 1; + old = source; + source = source.replace(/gl_ModelViewMatrix/g, 'u_modelView'); + if (old != source) need_mm = 1; + old = source; + source = source.replace(/gl_Vertex/g, 'a_position'); + if (old != source) need_pv = 1; + old = source; + source = source.replace(/gl_ModelViewProjectionMatrix/g, '(u_projection * u_modelView)'); + if (old != source) need_pm = need_mm = 1; + old = source; + source = source.replace(/gl_ModelViewMatrixTranspose\[2\]/g, 'vec3(u_modelView[0][0], u_modelView[1][0], u_modelView[2][0])'); // XXX extremely inefficient + if (old != source) need_mm = 1; + if (need_pv && !has_pv) source = 'attribute vec4 a_position; \n' + source; + if (need_mm && !has_mm) source = 'uniform mat4 u_modelView; \n' + source; + if (need_pm && !has_pm) source = 'uniform mat4 u_projection; \n' + source; + GL.shaderInfos[shader].ftransform = need_pm || need_mm || need_pv; // we will need to provide the fixed function stuff as attributes and uniforms + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { // XXX To handle both regular texture mapping and cube mapping, we use vec4 for tex coordinates. var old = source; + var need_vtc = source.search('v_texCoord' + i) == -1; source = source.replace(new RegExp('gl_TexCoord\\[' + i + '\\]', 'g'), 'v_texCoord' + i) .replace(new RegExp('gl_MultiTexCoord' + i, 'g'), 'a_texCoord' + i); if (source != old) { - source = 'attribute vec4 a_texCoord' + i + '; \n\ - varying vec4 v_texCoord' + i + '; \n' + source; + source = 'attribute vec4 a_texCoord' + i + '; \n' + source; + if (need_vtc) { + source = 'varying vec4 v_texCoord' + i + '; \n' + source; + } } + + old = source; + source = source.replace(new RegExp('gl_TextureMatrix\\[' + i + '\\]', 'g'), 'u_textureMatrix' + i); + if (source != old) { + source = 'uniform mat4 u_textureMatrix' + i + '; \n' + source; + } + } + if (source.indexOf('gl_FrontColor') >= 0) { + source = 'varying vec4 v_color; \n' + + source.replace(/gl_FrontColor/g, 'v_color'); } if (source.indexOf('gl_Color') >= 0) { - source = 'attribute vec4 a_color; \n\ - varying vec4 v_color; \n' + - source.replace(/gl_Color/g, 'a_color').replace(/gl_FrontColor/g, 'v_color'); + source = 'attribute vec4 a_color; \n' + + 'uniform vec4 u_color; \n' + + 'uniform int u_hasColorAttrib; \n' + + source.replace(/gl_Color/g, '(u_hasColorAttrib > 0 ? a_color : u_color)'); + } + if (source.indexOf('gl_Normal') >= 0) { + source = 'attribute vec3 a_normal; \n' + + source.replace(/gl_Normal/g, 'a_normal'); } if (source.indexOf('gl_FogFragCoord') >= 0) { source = 'varying float v_fogCoord; \n' + source.replace(/gl_FogFragCoord/g, 'v_fogCoord'); } } else { // Fragment shader - for (var i = 0; i <= 6; i++) { - var old = 0; + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { + var old = source; source = source.replace(new RegExp('gl_TexCoord\\[' + i + '\\]', 'g'), 'v_texCoord' + i); if (source != old) { source = 'varying vec4 v_texCoord' + i + '; \n' + source; @@ -967,82 +1035,194 @@ var LibraryGL = { source = source.replace(/gl_Fog.color/g, 'vec4(0.0)'); // XXX TODO source = 'precision mediump float;\n' + source; } +#if GL_DEBUG GL.shaderSources[shader] = source; +#endif Module.ctx.shaderSource(GL.shaders[shader], source); }; + var glCompileShader = _glCompileShader; _glCompileShader = function(shader) { Module.ctx.compileShader(GL.shaders[shader]); if (!Module.ctx.getShaderParameter(GL.shaders[shader], Module.ctx.COMPILE_STATUS)) { console.log('Failed to compile shader: ' + Module.ctx.getShaderInfoLog(GL.shaders[shader])); - console.log('Type: ' + GL.shaderTypes[shader]); + console.log('Info: ' + JSON.stringify(GL.shaderInfos[shader])); +#if GL_DEBUG console.log('Original source: ' + GL.shaderOriginalSources[shader]); console.log('Source: ' + GL.shaderSources[shader]); throw 'Shader compilation halt'; +#else + console.log('Enable GL_DEBUG to see shader source'); +#endif } }; - }, - procReplacements: { - 'glCreateShaderObjectARB': 'glCreateShader', - 'glShaderSourceARB': 'glShaderSource', - 'glCompileShaderARB': 'glCompileShader', - 'glCreateProgramObjectARB': 'glCreateProgram', - 'glAttachObjectARB': 'glAttachShader', - 'glLinkProgramARB': 'glLinkProgram', - 'glActiveTextureARB': 'glActiveTexture' - }, + GL.programShaders = {}; + var glAttachShader = _glAttachShader; + _glAttachShader = function(program, shader) { + if (!GL.programShaders[program]) GL.programShaders[program] = []; + GL.programShaders[program].push(shader); + glAttachShader(program, shader); + }; - procs: { - glDeleteObjectARB: function(id) { - if (GL.programs[id]) { - _glDeleteProgram(id); - } else if (GL.shaders[id]) { - _glDeleteShader(id); - } else { - console.log('WARNING: deleteObjectARB received invalid id: ' + id); + var glUseProgram = _glUseProgram; + _glUseProgram = function(program) { +#if GL_DEBUG + if (GL.debug) { + console.log('[using program with shaders:]'); + GL.programShaders[program].forEach(function(shader) { + console.log(' shader ' + shader + ', original source: ' + GL.shaderOriginalSources[shader]); + console.log(' Source: ' + GL.shaderSources[shader]); + }); } - }, +#endif + GL.currProgram = program; + glUseProgram(program); + } - glGetObjectParameterivARB: function(id, type, result) { - if (GL.programs[id]) { - if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB - {{{ makeSetValue('result', '0', 'Module.ctx.getProgramInfoLog(GL.programs[id]).length', 'i32') }}}; - return; - } - _glGetProgramiv(id, type, result); - } else if (GL.shaders[id]) { - if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB - {{{ makeSetValue('result', '0', 'Module.ctx.getShaderInfoLog(GL.shaders[id]).length', 'i32') }}}; - return; - } - _glGetShaderiv(id, type, result); - } else { - console.log('WARNING: getObjectParameterivARB received invalid id: ' + id); + var glDeleteProgram = _glDeleteProgram; + _glDeleteProgram = function(program) { + glDeleteProgram(program); + if (program == GL.currProgram) GL.currProgram = 0; + }; + + var glBindBuffer = _glBindBuffer; + _glBindBuffer = function(target, buffer) { + glBindBuffer(target, buffer); + if (target == Module.ctx.ARRAY_BUFFER) { + GL.currArrayBuffer = buffer; + } else if (target == Module.ctx.ELEMENT_ARRAY_BUFFER) { + GL.currElementArrayBuffer = buffer; + } + }; + + var glDeleteBuffers = _glDeleteBuffers; + _glDeleteBuffers = function(n, buffers) { + glDeleteBuffers(n, buffers); + for (var i = 0; i < n; i++) { + var buffer = {{{ makeGetValue('buffers', 'i*4', 'i32') }}}; + if (buffer == GL.currArrayBuffer) GL.currArrayBuffer = 0; + if (buffer == GL.currElementArrayBuffer) GL.currElementArrayBuffer = 0; } - }, + }; - glGetInfoLogARB: function(id, maxLength, length, infoLog) { - if (GL.programs[id]) { - _glGetProgramInfoLog(id, maxLength, length, infoLog); - } else if (GL.shaders[id]) { - _glGetShaderInfoLog(id, maxLength, length, infoLog); + var glGetFloatv = _glGetFloatv; + _glGetFloatv = function(pname, params) { + if (pname == 0x0BA6) { // GL_MODELVIEW_MATRIX + HEAPF32.set(GL.immediate.matrix['m'], params >> 2); + } else if (pname == 0x0BA7) { // GL_PROJECTION_MATRIX + HEAPF32.set(GL.immediate.matrix['p'], params >> 2); + } else if (pname == 0x0BA8) { // GL_TEXTURE_MATRIX + HEAPF32.set(GL.immediate.matrix['t' + GL.immediate.clientActiveTexture], params >> 2); + } else if (pname == 0x0B66) { // GL_FOG_COLOR + {{{ makeSetValue('params', '0', '0', 'float') }}}; + } else if (pname == 0x0B63) { // GL_FOG_START + {{{ makeSetValue('params', '0', '0', 'float') }}}; + } else if (pname == 0x0B64) { // GL_FOG_END + {{{ makeSetValue('params', '0', '0', 'float') }}}; } else { - console.log('WARNING: getObjectParameterivARB received invalid id: ' + id); + glGetFloatv(pname, params); } - } + }; }, - getProcAddress: function(name_) { - name_ = GLEmulation.procReplacements[name_] || name_; - var func = GLEmulation.procs[name_]; - if (!func) { - try { - func = eval('_' + name_); // XXX closure, need Module. and for them to be exported - } catch(e) { - console.log('WARNING: getProcAddress failed for ' + name_); + getProcAddress: function(name) { + name = name.replace('EXT', '').replace('ARB', ''); + // Do the translation carefully because of closure + switch (name) { + case 'glCreateShaderObject': case 'glCreateShader': func = _glCreateShader; break; + case 'glCreateProgramObject': case 'glCreateProgram': func = _glCreateProgram; break; + case 'glAttachObject': case 'glAttachShader': func = _glAttachShader; break; + case 'glUseProgramObject': case 'glUseProgram': func = _glUseProgram; break; + case 'glDeleteObject': func = function(id) { + if (GL.programs[id]) { + _glDeleteProgram(id); + } else if (GL.shaders[id]) { + _glDeleteShader(id); + } else { + console.log('WARNING: deleteObject received invalid id: ' + id); + } + }; break; + case 'glGetObjectParameteriv': func = function(id, type, result) { + if (GL.programs[id]) { + if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB + {{{ makeSetValue('result', '0', 'Module.ctx.getProgramInfoLog(GL.programs[id]).length', 'i32') }}}; + return; + } + _glGetProgramiv(id, type, result); + } else if (GL.shaders[id]) { + if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB + {{{ makeSetValue('result', '0', 'Module.ctx.getShaderInfoLog(GL.shaders[id]).length', 'i32') }}}; + return; + } + _glGetShaderiv(id, type, result); + } else { + console.log('WARNING: getObjectParameteriv received invalid id: ' + id); + } + }; break; + case 'glGetInfoLog': func = function(id, maxLength, length, infoLog) { + if (GL.programs[id]) { + _glGetProgramInfoLog(id, maxLength, length, infoLog); + } else if (GL.shaders[id]) { + _glGetShaderInfoLog(id, maxLength, length, infoLog); + } else { + console.log('WARNING: getObjectParameteriv received invalid id: ' + id); + } + }; break; + case 'glBindProgram': func = function(type, id) { + assert(id == 0); + }; break; + case 'glShaderSource': func = _glShaderSource; break; + case 'glCompileShader': func = _glCompileShader; break; + case 'glLinkProgram': func = _glLinkProgram; break; + case 'glGetUniformLocation': func = _glGetUniformLocation; break; + case 'glUniform1f': func = _glUniform1f; break; + case 'glUniform2f': func = _glUniform2f; break; + case 'glUniform3f': func = _glUniform3f; break; + case 'glUniform4f': func = _glUniform4f; break; + case 'glUniform1fv': func = _glUniform1fv; break; + case 'glUniform2fv': func = _glUniform2fv; break; + case 'glUniform3fv': func = _glUniform3fv; break; + case 'glUniform4fv': func = _glUniform4fv; break; + case 'glUniform1i': func = _glUniform1i; break; + case 'glUniform2i': func = _glUniform2i; break; + case 'glUniform3i': func = _glUniform3i; break; + case 'glUniform4i': func = _glUniform4i; break; + case 'glUniform1iv': func = _glUniform1iv; break; + case 'glUniform2iv': func = _glUniform2iv; break; + case 'glUniform3iv': func = _glUniform3iv; break; + case 'glUniform4iv': func = _glUniform4iv; break; + case 'glBindAttribLocation': func = _glBindAttribLocation; break; + case 'glGetActiveUniform': func = _glGetActiveUniform; break; + case 'glGenBuffers': func = _glGenBuffers; break; + case 'glBindBuffer': func = _glBindBuffer; break; + case 'glBufferData': func = _glBufferData; break; + case 'glBufferSubData': func = _glBufferSubData; break; + case 'glDeleteBuffers': func = _glDeleteBuffers; break; + case 'glActiveTexture': func = _glActiveTexture; break; + case 'glClientActiveTexture': func = _glClientActiveTexture; break; + case 'glGetProgramiv': func = _glGetProgramiv; break; + case 'glEnableVertexAttribArray': func = _glEnableVertexAttribArray; break; + case 'glDisableVertexAttribArray': func = _glDisableVertexAttribArray; break; + case 'glVertexAttribPointer': func = _glVertexAttribPointer; break; + case 'glBindRenderbuffer': func = _glBindRenderbuffer; break; + case 'glDeleteRenderbuffers': func = _glDeleteRenderbuffers; break; + case 'glGenRenderbuffers': func = _glGenRenderbuffers; break; + case 'glCompressedTexImage2D': func = _glCompressedTexImage2D; break; + case 'glCompressedTexSubImage2D': func = _glCompressedTexSubImage2D; break; + case 'glBindFramebuffer': func = _glBindFramebuffer; break; + case 'glGenFramebuffers': func = _glGenFramebuffers; break; + case 'glDeleteFramebuffers': func = _glDeleteFramebuffers; break; + case 'glFramebufferRenderbuffer': func = _glFramebufferRenderbuffer; break; + case 'glFramebufferTexture2D': func = _glFramebufferTexture2D; break; + case 'glGetFramebufferAttachmentParameteriv': func = _glGetFramebufferAttachmentParameteriv; break; + case 'glIsFramebuffer': func = _glIsFramebuffer; break; + case 'glCheckFramebufferStatus': func = _glCheckFramebufferStatus; break; + case 'glRenderbufferStorage': func = _glRenderbufferStorage; break; + default: { + console.log('WARNING: getProcAddress failed for ' + name); func = function() { - console.log('WARNING: empty replacement for ' + name_ + ' called, no-op'); + console.log('WARNING: empty replacement for ' + name + ' called, no-op'); return 0; }; } @@ -1053,134 +1233,282 @@ var LibraryGL = { // GL Immediate mode + $GLImmediate__postset: 'Browser.moduleContextCreatedCallbacks.push(function() { GL.immediate.init() });', + $GLImmediate__deps: ['$Browser'], $GLImmediate: { // Vertex and index data - maxElements: 1024, - vertexData: null, // current vertex data. either tempData (glBegin etc.) or a view into the heap (gl*Pointer) + maxElements: 10240, + MAX_TEXTURES: 7, + vertexData: null, // current vertex data. either tempData (glBegin etc.) or a view into the heap (gl*Pointer). Default view is F32 + vertexDataU8: null, // U8 view tempData: null, indexData: null, vertexCounter: 0, mode: 0, - renderers: {}, - renderer: null, + rendererCache: {}, + rendererComponents: {}, // small cache for calls inside glBegin/end. counts how many times the element was seen + rendererComponentPointer: 0, // next place to start a glBegin/end component // The following data structures are used for OpenGL Immediate Mode matrix routines. - matrix: { - 'm': null, // modelview - 'p': null // projection - }, - matrixStack: { - 'm': [], // modelview - 'p': [] // projection - }, + matrix: {}, + matrixStack: {}, currentMatrix: 'm', // default is modelview tempMatrix: null, - initMatrixLibrary: function() { - GL.immediate.matrix['m'] = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.matrix['p'] = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.currentMatrix = GL.immediate.matrix.lib.mat4.create(); - }, // Clientside attributes - TEXTURE: 0, - VERTEX: 1, - NUM_ATTRIBUTES: 2, - ATTRIBUTE_BY_NAME: { - 'T': 0, - 'V': 1 - }, + VERTEX: 0, + NORMAL: 1, + COLOR: 2, + TEXTURE0: 3, + TEXTURE1: 4, + TEXTURE2: 5, + TEXTURE3: 6, + TEXTURE4: 7, + TEXTURE5: 8, + TEXTURE6: 9, + NUM_ATTRIBUTES: 10, + NUM_TEXTURES: 7, + ATTRIBUTE_BY_NAME: {}, totalEnabledClientAttributes: 0, enabledClientAttributes: [0, 0], - clientAttributes: [null, null], + clientAttributes: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}], // raw data, including possible unneeded ones + liveClientAttributes: [], // the ones actually alive in the current computation, sorted + clientActiveTexture: 0, + clientColor: null, + + byteSizeByType: { + 0x1400: 1, // GL_BYTE + 0x1401: 1, // GL_UNSIGNED_BYTE + 0x1402: 2, // GL_SHORT + 0x1403: 2, // GL_UNSIGNED_SHORT + 0x1404: 4, // GL_INT + 0x1405: 4, // GL_UNSIGNED_INT + 0x1406: 4 // GL_FLOAT + }, - setClientAttribute: function(which, name, size, type, stride, pointer) { - this.clientAttributes[which] = { - size: size, type: type, stride: stride, pointer: pointer, name: name + size - }; + setClientAttribute: function(name, size, type, stride, pointer) { + var attrib = this.clientAttributes[GL.immediate.ATTRIBUTE_BY_NAME[name]]; + attrib.name = name; + attrib.size = size; + attrib.type = type; + attrib.stride = stride; + attrib.pointer = pointer; }, // Renderers - setRenderer: function(renderer) { - this.renderer = renderer; - if (this.renderers[renderer]) return; - - // Create renderer - var vertexSize = 0; - for (var i = 0; i < renderer.length; i+=2) { - var which = renderer[i]; - var size = parseInt(renderer[i+1]); - if (which == 'V') { - positionSize = size; - positionOffset = vertexSize; - } else if (which == 'T') { - textureSize = size; - textureOffset = vertexSize; + addRendererComponent: function(name, size, type) { + if (!this.rendererComponents[name]) { + this.rendererComponents[name] = 1; +#if ASSERTIONS + assert(!this.enabledClientAttributes[this.ATTRIBUTE_BY_NAME[name]]); // cannot get mixed up with this, for example we will disable this later +#endif + this.enabledClientAttributes[this.ATTRIBUTE_BY_NAME[name]] = true; + this.setClientAttribute(name, size, type, 0, this.rendererComponentPointer); + this.rendererComponentPointer += size * this.byteSizeByType[type]; + } else { + this.rendererComponents[name]++; + } + }, + + disableBeginEndClientAttributes: function() { + for (var name in this.rendererComponents) { + this.enabledClientAttributes[this.ATTRIBUTE_BY_NAME[name]] = false; + } + }, + + getRenderer: function() { + // return a renderer object given the liveClientAttributes + // we maintain a cache of renderers, optimized to not generate garbage + var attributes = GL.immediate.liveClientAttributes; + var cacheItem = GL.immediate.rendererCache; + for (var i = 0; i < attributes.length; i++) { + var attribute = attributes[i]; + if (!cacheItem[attribute.name]) cacheItem[attribute.name] = {}; + cacheItem = cacheItem[attribute.name]; + if (!cacheItem[attribute.size]) cacheItem[attribute.size] = {}; + cacheItem = cacheItem[attribute.size]; + if (!cacheItem[attribute.type]) cacheItem[attribute.type] = {}; + cacheItem = cacheItem[attribute.type]; + } + if (GL.currProgram) { + if (!cacheItem[GL.currProgram]) cacheItem[GL.currProgram] = {}; + cacheItem = cacheItem[GL.currProgram]; + } + if (!cacheItem.renderer) { +#if GL_DEBUG + console.log('generating renderer for ' + JSON.stringify(attributes)); +#endif + cacheItem.renderer = this.createRenderer(); + } + return cacheItem.renderer; + }, + + createRenderer: function(renderer) { + var useCurrProgram = !!GL.currProgram; + var hasTextures = false, textureSizes = [], textureTypes = [], textureOffsets = []; + for (var i = 0; i < GL.immediate.NUM_TEXTURES; i++) { + if (GL.immediate.enabledClientAttributes[GL.immediate.TEXTURE0 + i]) { + textureSizes[i] = GL.immediate.clientAttributes[GL.immediate.TEXTURE0 + i].size; + textureTypes[i] = GL.immediate.clientAttributes[GL.immediate.TEXTURE0 + i].type; + textureOffsets[i] = GL.immediate.clientAttributes[GL.immediate.TEXTURE0 + i].offset; + hasTextures = true; } - vertexSize += size * 4; // XXX assuming float } - // TODO: verify vertexSize is equal to the stride in enabled client arrays - // TODO: assert that we can create the renderer type we were asked - // TODO: use bufferSubData to prevent reallocation of new buffers? Or all on GPU and doesn't matter? Anyhow, use DYNAMIC as hint - this.renderers[renderer] = { - vertexSize: vertexSize, + var stride = GL.immediate.stride; + var positionSize = GL.immediate.clientAttributes[GL.immediate.VERTEX].size; + var positionType = GL.immediate.clientAttributes[GL.immediate.VERTEX].type; + var positionOffset = GL.immediate.clientAttributes[GL.immediate.VERTEX].offset; + var colorSize = 0, colorType, colorOffset; + if (GL.immediate.enabledClientAttributes[GL.immediate.COLOR]) { + colorSize = GL.immediate.clientAttributes[GL.immediate.COLOR].size; + colorType = GL.immediate.clientAttributes[GL.immediate.COLOR].type; + colorOffset = GL.immediate.clientAttributes[GL.immediate.COLOR].offset; + } + var normalSize = 0, normalType, normalOffset; + if (GL.immediate.enabledClientAttributes[GL.immediate.NORMAL]) { + normalSize = GL.immediate.clientAttributes[GL.immediate.NORMAL].size; + normalType = GL.immediate.clientAttributes[GL.immediate.NORMAL].type; + normalOffset = GL.immediate.clientAttributes[GL.immediate.NORMAL].offset; + } + var ret = { init: function() { - this.vertexShader = Module.ctx.createShader(Module.ctx.VERTEX_SHADER); - var zero = positionSize == 2 ? '0, ' : ''; - Module.ctx.shaderSource(this.vertexShader, 'attribute vec' + positionSize + ' a_position; \n\ - attribute vec2 a_texCoord; \n\ - varying vec2 v_texCoord; \n\ - uniform mat4 u_modelView; \n\ - uniform mat4 u_projection; \n\ - void main() \n\ - { \n\ - gl_Position = u_projection * (u_modelView * vec4(a_position, ' + zero + '1.0)); \n\ - v_texCoord = a_texCoord; \n\ - } \n'); - Module.ctx.compileShader(this.vertexShader); - - this.fragmentShader = Module.ctx.createShader(Module.ctx.FRAGMENT_SHADER); - Module.ctx.shaderSource(this.fragmentShader, 'precision mediump float; \n\ - varying vec2 v_texCoord; \n\ - uniform sampler2D s_texture; \n\ - void main() \n\ - { \n\ - gl_FragColor = texture2D( s_texture, v_texCoord );\n\ - } \n'); - Module.ctx.compileShader(this.fragmentShader); - - this.program = Module.ctx.createProgram(); - Module.ctx.attachShader(this.program, this.vertexShader); - Module.ctx.attachShader(this.program, this.fragmentShader); - Module.ctx.linkProgram(this.program); + if (useCurrProgram) { + if (GL.shaderInfos[GL.programShaders[GL.currProgram][0]].type == Module.ctx.VERTEX_SHADER) { + this.vertexShader = GL.shaders[GL.programShaders[GL.currProgram][0]]; + this.fragmentShader = GL.shaders[GL.programShaders[GL.currProgram][1]]; + } else { + this.vertexShader = GL.shaders[GL.programShaders[GL.currProgram][1]]; + this.fragmentShader = GL.shaders[GL.programShaders[GL.currProgram][0]]; + } + this.program = GL.programs[GL.currProgram]; + } else { + this.vertexShader = Module.ctx.createShader(Module.ctx.VERTEX_SHADER); + var zero = positionSize == 2 ? '0, ' : ''; + Module.ctx.shaderSource(this.vertexShader, 'attribute vec' + positionSize + ' a_position; \n' + + 'attribute vec2 a_texCoord0; \n' + + (hasTextures ? 'varying vec2 v_texCoord; \n' : '') + + 'varying vec4 v_color; \n' + + (colorSize ? 'attribute vec4 a_color; \n': 'uniform vec4 u_color; \n') + + 'uniform mat4 u_modelView; \n' + + 'uniform mat4 u_projection; \n' + + 'void main() \n' + + '{ \n' + + ' gl_Position = u_projection * (u_modelView * vec4(a_position, ' + zero + '1.0)); \n' + + (hasTextures ? 'v_texCoord = a_texCoord0; \n' : '') + + (colorSize ? 'v_color = a_color; \n' : 'v_color = u_color; \n') + + '} \n'); + Module.ctx.compileShader(this.vertexShader); + + this.fragmentShader = Module.ctx.createShader(Module.ctx.FRAGMENT_SHADER); + Module.ctx.shaderSource(this.fragmentShader, 'precision mediump float; \n' + + 'varying vec2 v_texCoord; \n' + + 'uniform sampler2D u_texture; \n' + + 'varying vec4 v_color; \n' + + 'void main() \n' + + '{ \n' + + (hasTextures ? 'gl_FragColor = v_color * texture2D( u_texture, v_texCoord );\n' : + 'gl_FragColor = v_color;\n') + + '} \n'); + Module.ctx.compileShader(this.fragmentShader); + + this.program = Module.ctx.createProgram(); + Module.ctx.attachShader(this.program, this.vertexShader); + Module.ctx.attachShader(this.program, this.fragmentShader); + Module.ctx.linkProgram(this.program); + } this.positionLocation = Module.ctx.getAttribLocation(this.program, 'a_position'); - this.texCoordLocation = Module.ctx.getAttribLocation(this.program, 'a_texCoord'); - this.textureLocation = Module.ctx.getUniformLocation(this.program, 's_texture'); + this.texCoordLocations = []; + for (var i = 0; i < textureSizes.length; i++) { + if (textureSizes[i]) { + this.texCoordLocations[i] = Module.ctx.getAttribLocation(this.program, 'a_texCoord' + i); + } + } + this.textureMatrixLocations = []; + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { + this.textureMatrixLocations[i] = Module.ctx.getUniformLocation(this.program, 'u_textureMatrix' + i); + } + this.colorLocation = Module.ctx.getAttribLocation(this.program, 'a_color'); + this.normalLocation = Module.ctx.getAttribLocation(this.program, 'a_normal'); + + this.textureLocation = Module.ctx.getUniformLocation(this.program, 'u_texture'); // only for immediate mode with no shaders, so only one is enough this.modelViewLocation = Module.ctx.getUniformLocation(this.program, 'u_modelView'); this.projectionLocation = Module.ctx.getUniformLocation(this.program, 'u_projection'); + this.hasColorAttribLocation = Module.ctx.getUniformLocation(this.program, 'u_hasColorAttrib'); + this.colorUniformLocation = Module.ctx.getUniformLocation(this.program, 'u_color'); + + this.hasTextures = hasTextures; + this.hasColorAttrib = colorSize > 0 && this.colorLocation >= 0; + this.hasColorUniform = !!this.colorUniformLocation; + this.hasNormal = normalSize > 0 && this.normalLocation >= 0; + + this.floatType = Module.ctx.FLOAT; // minor optimization }, prepare: function() { - Module.ctx.vertexAttribPointer(this.texCoordLocation, textureSize, Module.ctx.FLOAT, false, - vertexSize, textureOffset); - Module.ctx.vertexAttribPointer(this.positionLocation, positionSize, Module.ctx.FLOAT, false, - vertexSize, positionOffset); + if (this.modelViewLocation) Module.ctx.uniformMatrix4fv(this.modelViewLocation, false, GL.immediate.matrix['m']); + if (this.projectionLocation) Module.ctx.uniformMatrix4fv(this.projectionLocation, false, GL.immediate.matrix['p']); - Module.ctx.enableVertexAttribArray(this.texCoordLocation); + Module.ctx.vertexAttribPointer(this.positionLocation, positionSize, positionType, false, + stride, positionOffset); Module.ctx.enableVertexAttribArray(this.positionLocation); + if (this.hasTextures) { + for (var i = 0; i < textureSizes.length; i++) { + if (textureSizes[i] && this.texCoordLocations[i] >= 0) { + Module.ctx.vertexAttribPointer(this.texCoordLocations[i], textureSizes[i], textureTypes[i], false, + stride, textureOffsets[i]); + Module.ctx.enableVertexAttribArray(this.texCoordLocations[i]); + } + } + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { + if (this.textureMatrixLocations[i]) { // XXX might we need this even without the condition we are currently in? + Module.ctx.uniformMatrix4fv(this.textureMatrixLocations[i], false, GL.immediate.matrix['t' + i]); + } + } + } + if (this.hasColorAttrib) { + Module.ctx.vertexAttribPointer(this.colorLocation, colorSize, colorType, true, + stride, colorOffset); + Module.ctx.enableVertexAttribArray(this.colorLocation); + Module.ctx.uniform1i(this.hasColorAttribLocation, 1); + } else if (this.hasColorUniform) { + Module.ctx.uniform1i(this.hasColorAttribLocation, 0); + Module.ctx.uniform4fv(this.colorUniformLocation, GL.immediate.clientColor); + } + if (this.hasNormal) { + Module.ctx.vertexAttribPointer(this.normalLocation, normalSize, normalType, true, + stride, normalOffset); + Module.ctx.enableVertexAttribArray(this.normalLocation); + } + if (!useCurrProgram) { // otherwise, the user program will set the sampler2D binding and uniform itself + var texture = Module.ctx.getParameter(Module.ctx.TEXTURE_BINDING_2D); + Module.ctx.activeTexture(Module.ctx.TEXTURE0); + Module.ctx.bindTexture(Module.ctx.TEXTURE_2D, texture); + Module.ctx.uniform1i(this.textureLocation, 0); + } + }, - var texture = Module.ctx.getParameter(Module.ctx.TEXTURE_BINDING_2D); - Module.ctx.activeTexture(Module.ctx.TEXTURE0); - Module.ctx.bindTexture(Module.ctx.TEXTURE_2D, texture); - Module.ctx.uniform1i(this.textureLocation, 0); - - Module.ctx.uniformMatrix4fv(this.modelViewLocation, false, GL.immediate.matrix["m"]); - Module.ctx.uniformMatrix4fv(this.projectionLocation, false, GL.immediate.matrix["p"]); + cleanup: function() { + Module.ctx.disableVertexAttribArray(this.positionLocation); + if (this.hasTextures) { + for (var i = 0; i < textureSizes.length; i++) { + if (textureSizes[i] && this.texCoordLocations[i] >= 0) { + Module.ctx.disableVertexAttribArray(this.texCoordLocations[i]); + } + } + } + if (this.hasColorAttrib) { + Module.ctx.disableVertexAttribArray(this.colorLocation); + } + if (this.hasNormal) { + Module.ctx.disableVertexAttribArray(this.normalLocation); + } } }; - this.renderers[renderer].init(); + ret.init(); + return ret; }, // Main functions @@ -1189,126 +1517,211 @@ var LibraryGL = { Module.printErr('WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supports'); GL.immediate.initted = true; + this.matrixStack['m'] = []; + this.matrixStack['p'] = []; + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { + this.matrixStack['t' + i] = []; + } + + this.ATTRIBUTE_BY_NAME['V'] = 0; + this.ATTRIBUTE_BY_NAME['N'] = 1; + this.ATTRIBUTE_BY_NAME['C'] = 2; + this.ATTRIBUTE_BY_NAME['T0'] = 3; + this.ATTRIBUTE_BY_NAME['T1'] = 4; + this.ATTRIBUTE_BY_NAME['T2'] = 5; + this.ATTRIBUTE_BY_NAME['T3'] = 6; + this.ATTRIBUTE_BY_NAME['T4'] = 7; + this.ATTRIBUTE_BY_NAME['T5'] = 8; + this.ATTRIBUTE_BY_NAME['T6'] = 9; + + // Initialize matrix library + + GL.immediate.matrix['m'] = GL.immediate.matrix.lib.mat4.create(); + GL.immediate.matrix['p'] = GL.immediate.matrix.lib.mat4.create(); + for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) { + GL.immediate.matrix['t' + i] = GL.immediate.matrix.lib.mat4.create(); + } + // Buffers for data this.tempData = new Float32Array(this.maxElements); this.indexData = new Uint16Array(this.maxElements); + this.vertexDataU8 = new Uint8Array(this.tempData.buffer); + this.vertexObject = Module.ctx.createBuffer(); + Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, this.vertexObject); + Module.ctx.bufferData(Module.ctx.ARRAY_BUFFER, this.maxElements*4, Module.ctx.DYNAMIC_DRAW); + Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null); + this.indexObject = Module.ctx.createBuffer(); + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); + Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, this.maxElements*2, Module.ctx.DYNAMIC_DRAW); + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null); - // Replace some functions with immediate-mode aware versions + this.clientColor = new Float32Array([1, 1, 1, 1]); + + // Replace some functions with immediate-mode aware versions. If there are no client + // attributes enabled, and we use webgl-friendly modes (no GL_QUADS), then no need + // for emulation _glDrawArrays = function(mode, first, count) { - if (GL.immediate.totalEnabledClientAttributes == 0) { + if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6) { Module.ctx.drawArrays(mode, first, count); return; } -#if ASSERTIONS - assert(first == 0); // TODO -#endif - // Client attributes are to be used here, emulate that - var stride = 0, bytes = 0, attributes = [], start, renderer = ''; - for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) { - if (GL.immediate.enabledClientAttributes[i]) attributes.push(GL.immediate.clientAttributes[i]); + GL.immediate.prepareClientAttributes(count, false); + GL.immediate.mode = mode; + GL.immediate.flush(null, first); + }; + + _glDrawElements = function(mode, count, type, indices) { + if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6) { + Module.ctx.drawElements(mode, count, type, indices); + return; } - attributes.sort(function(x, y) { return x.pointer - y.pointer }); - start = attributes[0].pointer; - for (var i = 0; i < attributes.length; i++) { - var attribute = attributes[i]; + GL.immediate.prepareClientAttributes(count, false); + GL.immediate.mode = mode; + GL.immediate.flush(count, indices); + }; + }, + + // Prepares and analyzes client attributes. + // count: number of elements we will draw + // beginEnd: whether we are drawing the results of a begin/end block + prepareClientAttributes: function(count, beginEnd) { + // Client attributes are to be used here, emulate that + var stride = 0, start; + var attributes = GL.immediate.liveClientAttributes; + attributes.length = 0; + for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) { + if (GL.immediate.enabledClientAttributes[i]) attributes.push(GL.immediate.clientAttributes[i]); + } + attributes.sort(function(x, y) { return !x ? (!y ? 0 : 1) : (!y ? -1 : (x.pointer - y.pointer)) }); + start = attributes[0].pointer; + for (var i = 0; i < attributes.length; i++) { + var attribute = attributes[i]; + if (!attribute) break; #if ASSERTIONS - assert(attribute.stride); - assert(stride == 0 || stride == attribute.stride); // must all be in the same buffer + assert(stride == 0 || stride == attribute.stride); // must all be in the same buffer #endif - stride = attribute.stride; - bytes += attribute.size * 4 * count; // XXX assuming float - renderer += attribute.name; + if (attribute.stride) stride = attribute.stride; + } + + var bytes = 0; + for (var i = 0; i < attributes.length; i++) { + var attribute = attributes[i]; + if (!attribute) break; + attribute.offset = attribute.pointer - start; + if (attribute.offset > bytes) { // ensure we start where we should + assert((attribute.offset - bytes)%4 == 0); // XXX assuming 4-alignment + bytes += attribute.offset - bytes; } - for (var i = 0; i < attributes.length; i++) { - var attribute = attributes[i]; - attribute.offset = attribute.pointer - start; -#if ASSERTIONS - assert(0 <= attribute.offset && attribute.offset < stride); // must all be in the same buffer -#endif + bytes += attribute.size * GL.immediate.byteSizeByType[attribute.type]; + if (bytes % 4 != 0) bytes += 4 - (bytes % 4); // XXX assuming 4-alignment + } + assert(stride == 0 || bytes <= stride); + if (bytes < stride) { // ensure the size is that of the stride + bytes = stride; + } + GL.immediate.stride = bytes; + + if (!beginEnd) { + bytes *= count; + if (!GL.currArrayBuffer) { + GL.immediate.vertexData = {{{ makeHEAPView('F32', 'start', 'start + bytes') }}}; // XXX assuming float } - GL.immediate.vertexData = {{{ makeHEAPView('F32', 'start', 'start + bytes') }}}; // XXX assuming float GL.immediate.vertexCounter = bytes / 4; // XXX assuming float - GL.immediate.mode = mode; - GL.immediate.setRenderer(renderer); - GL.immediate.flush(); - }; + } }, - flush: function() { - var renderer = this.renderers[this.renderer]; + + flush: function(numProvidedIndexes, startIndex) { + startIndex = startIndex || 0; + + var renderer = this.getRenderer(); // Generate index data in a format suitable for GLES 2.0/WebGL - // TODO: if the mode is one that works in GLES 2.0/WebGL (not GL_QUADS), do not generate indexes at all - var numVertexes = 4 * this.vertexCounter / renderer.vertexSize; // XXX assuming float + var numVertexes = 4 * this.vertexCounter / GL.immediate.stride; // XXX assuming float assert(numVertexes % 1 == 0); - var numIndexes = 0; - if (GL.immediate.mode == 7) { // GL_QUADS - var numQuads = numVertexes / 4; - assert(numQuads % 1 == 0); - for (var i = 0; i < numQuads; i++) { - var start = i*4; - GL.immediate.indexData[numIndexes++] = start; - GL.immediate.indexData[numIndexes++] = start+1; - GL.immediate.indexData[numIndexes++] = start+2; - GL.immediate.indexData[numIndexes++] = start; - GL.immediate.indexData[numIndexes++] = start+2; - GL.immediate.indexData[numIndexes++] = start+3; - } - } else if (GL.immediate.mode == 5) { // GL_TRIANGLE_STRIP - var numTriangles = numVertexes - 2; - assert(numTriangles > 0); - for (var i = 0; i < numTriangles; i++) { - if (i % 2 == 0) { - GL.immediate.indexData[numIndexes++] = i; - GL.immediate.indexData[numIndexes++] = i+1; - GL.immediate.indexData[numIndexes++] = i+2; - } else { - GL.immediate.indexData[numIndexes++] = i+1; - GL.immediate.indexData[numIndexes++] = i; - GL.immediate.indexData[numIndexes++] = i+2; + var restoreElementArrayBuffer = false; + var numIndexes = 0; + if (numProvidedIndexes) { + numIndexes = numProvidedIndexes; + } else if (GL.immediate.mode > 6) { // above GL_TRIANGLE_FAN are the non-GL ES modes + if (GL.immediate.mode == 7) { // GL_QUADS + var numQuads = numVertexes / 4; + assert(numQuads % 1 == 0); + for (var i = 0; i < numQuads; i++) { + var start = i*4; + GL.immediate.indexData[numIndexes++] = start; + GL.immediate.indexData[numIndexes++] = start+1; + GL.immediate.indexData[numIndexes++] = start+2; + GL.immediate.indexData[numIndexes++] = start; + GL.immediate.indexData[numIndexes++] = start+2; + GL.immediate.indexData[numIndexes++] = start+3; } + } else { + throw 'unsupported immediate mode ' + GL.immediate.mode; } - } else { - throw 'unsupported immediate mode ' + GL.immediate.mode; + assert(numIndexes < GL.immediate.maxElements, 'too many immediate mode indexes'); + + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); + Module.ctx.bufferSubData(Module.ctx.ELEMENT_ARRAY_BUFFER, 0, this.indexData.subarray(0, numIndexes)); + restoreElementArrayBuffer = true; } - assert(numIndexes < GL.immediate.maxElements, 'too many immediate mode indexes'); - // Upload the data - Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, this.vertexObject); - Module.ctx.bufferData(Module.ctx.ARRAY_BUFFER, this.vertexData.subarray(0, this.vertexCounter), Module.ctx.STATIC_DRAW); - Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); - Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexData.subarray(0, numIndexes), Module.ctx.STATIC_DRAW); + if (!GL.currArrayBuffer) { + Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, this.vertexObject); + Module.ctx.bufferSubData(Module.ctx.ARRAY_BUFFER, 0, this.vertexData.subarray(0, this.vertexCounter)); + } // Render - Module.ctx.useProgram(renderer.program); - Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, this.vertexObject); + if (!GL.currProgram) { + Module.ctx.useProgram(renderer.program); + } renderer.prepare(); - Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); - Module.ctx.drawElements(Module.ctx.TRIANGLES, numIndexes, Module.ctx.UNSIGNED_SHORT, 0); + if (numIndexes) { + if (!numProvidedIndexes) { + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); + } + Module.ctx.drawElements(Module.ctx.TRIANGLES, numIndexes, Module.ctx.UNSIGNED_SHORT, startIndex); + } else { + Module.ctx.drawArrays(GL.immediate.mode, startIndex, numVertexes); + } + + renderer.cleanup(); + if (!GL.currArrayBuffer) { + Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null); + } + if (restoreElementArrayBuffer) { + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.buffers[GL.currElementArrayBuffer] || null); + } + if (!GL.currProgram) { + Module.ctx.useProgram(null); + } + + this.mode = 0; this.vertexCounter = 0; } }, - $GLImmediateSetup__deps: ['$GLImmediate', function() { return 'GL.immediate = GLImmediate; GL.immediate.matrix.lib = ' + read('gl-matrix.js') + '; GL.immediate.initMatrixLibrary();\n' }], + $GLImmediateSetup__deps: ['$GLImmediate', function() { return 'GL.immediate = GLImmediate; GL.immediate.matrix.lib = ' + read('gl-matrix.js') + ';\n' }], $GLImmediateSetup: {}, - glBegin__deps: ['$GL', '$GLImmediateSetup'], + glBegin__deps: ['$GLImmediateSetup'], glBegin: function(mode) { - if (!GL.immediate.initted) GL.immediate.init(); GL.immediate.mode = mode; - GL.immediate.renderer = null; + GL.immediate.rendererComponents = {}; // XXX + GL.immediate.rendererComponentPointer = 0; GL.immediate.vertexData = GL.immediate.tempData; }, glEnd: function() { + GL.immediate.prepareClientAttributes(GL.immediate.rendererComponents['V'], true); GL.immediate.flush(); - GL.immediate.mode = 0; + GL.immediate.disableBeginEndClientAttributes(); }, glVertex3f: function(x, y, z) { @@ -1320,84 +1733,162 @@ var LibraryGL = { GL.immediate.vertexData[GL.immediate.vertexCounter++] = z || 0; #if ASSERTIONS assert(GL.immediate.vertexCounter < GL.immediate.maxElements); - assert(GL.immediate.vertexCounter % 5 == 0); #endif - if (!GL.immediate.renderer) { - // Decide renderer based on attributes used // TODO: generalize - GL.immediate.setRenderer('T2V3'); - } + GL.immediate.addRendererComponent('V', 3, Module.ctx.FLOAT); }, - glVertex2f: 'glVertex3f', + glVertex3fv__deps: ['glVertex3f'], + glVertex3fv: function(p) { + _glVertex3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}}); + }, + glTexCoord2i: function(u, v) { #if ASSERTIONS assert(GL.immediate.mode); // must be in begin/end #endif GL.immediate.vertexData[GL.immediate.vertexCounter++] = u; GL.immediate.vertexData[GL.immediate.vertexCounter++] = v; + GL.immediate.addRendererComponent('T0', 2, Module.ctx.FLOAT); }, glTexCoord2f: 'glTexCoord2i', - glColor4b: function(){}, // TODO, including scaling for different arg types - glColor4s: 'glColor4b', - glColor4i: 'glColor4b', - glColor4f: 'glColor4b', - glColor4d: 'glColor4b', - glColor4ub: 'glColor4b', - glColor4us: 'glColor4b', - glColor4ui: 'glColor4b', - - glColor3b__deps: ['glColor4b'], - glColor3b: function(r, g, b) { - _glColor4b(r, g, b, 1); // FIXME: scaling - }, - glColor3s: 'glColor3b', - glColor3i: 'glColor3b', - glColor3f: 'glColor3b', - glColor3d: 'glColor3b', - glColor3ub: 'glColor3b', - glColor3us: 'glColor3b', - glColor3ui: 'glColor3b', + glTexCoord2fv__deps: ['glTexCoord2f'], + glTexCoord2fv: function(v) { + _glTexCoord2f({{{ makeGetValue('v', '0', 'float') }}}, {{{ makeGetValue('v', '4', 'float') }}}); + }, + + glColor4f: function(r, g, b, a) { + // TODO: make ub the default, not f, save a few mathops + if (GL.immediate.mode) { + var start = GL.immediate.vertexCounter << 2; + GL.immediate.vertexDataU8[start + 0] = r * 255; + GL.immediate.vertexDataU8[start + 1] = g * 255; + GL.immediate.vertexDataU8[start + 2] = b * 255; + GL.immediate.vertexDataU8[start + 3] = a * 255; + GL.immediate.vertexCounter++; + GL.immediate.addRendererComponent('C', 4, Module.ctx.UNSIGNED_BYTE); + } else { + GL.immediate.clientColor[0] = r; + GL.immediate.clientColor[1] = g; + GL.immediate.clientColor[2] = b; + GL.immediate.clientColor[3] = a; + } + }, + glColor4d: 'glColor4f', + glColor4ub__deps: ['glColor4f'], + glColor4ub: function(r, g, b, a) { + _glColor4f((r&255)/255, (g&255)/255, (b&255)/255, (a&255)/255); + }, + glColor4us__deps: ['glColor4f'], + glColor4us: function(r, g, b, a) { + _glColor4f((r&65525)/65535, (g&65525)/65535, (b&65525)/65535, (a&65525)/65535); + }, + glColor4ui__deps: ['glColor4f'], + glColor4ui: function(r, g, b, a) { + _glColor4f((r>>>0)/4294967295, (g>>>0)/4294967295, (b>>>0)/4294967295, (a>>>0)/4294967295); + }, + glColor3f__deps: ['glColor4f'], + glColor3f: function(r, g, b) { + _glColor4f(r, g, b, 1); + }, + glColor3d: 'glColor3f', + glColor3ub__deps: ['glColor4ub'], + glColor3ub: function(r, g, b) { + _glColor4ub(r, g, b, 255); + }, + glColor3us__deps: ['glColor4us'], + glColor3us: function(r, g, b) { + _glColor4us(r, g, b, 65535); + }, + glColor3ui__deps: ['glColor4ui'], + glColor3ui: function(r, g, b) { + _glColor4ui(r, g, b, 4294967295); + }, + + glColor3ubv__deps: ['glColor3ub'], + glColor3ubv: function(p) { + _glColor3ub({{{ makeGetValue('p', '0', 'i8') }}}, {{{ makeGetValue('p', '1', 'i8') }}}, {{{ makeGetValue('p', '2', 'i8') }}}); + }, + glColor3usv__deps: ['glColor3us'], + glColor3usv: function(p) { + _glColor3us({{{ makeGetValue('p', '0', 'i16') }}}, {{{ makeGetValue('p', '2', 'i16') }}}, {{{ makeGetValue('p', '4', 'i16') }}}); + }, + glColor3uiv__deps: ['glColor3ui'], + glColor3uiv: function(p) { + _glColor3ui({{{ makeGetValue('p', '0', 'i32') }}}, {{{ makeGetValue('p', '4', 'i32') }}}, {{{ makeGetValue('p', '8', 'i32') }}}); + }, + glColor3fv__deps: ['glColor3f'], + glColor3fv: function(p) { + _glColor3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}}); + }, + glColor4fv__deps: ['glColor4f'], + glColor4fv: function(p) { + _glColor4f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}}, {{{ makeGetValue('p', '12', 'float') }}}); + }, + + glFogf: function(){}, // TODO + + glPolygonMode: function(){}, // TODO + + glAlphaFunc: function(){}, // TODO // ClientState/gl*Pointer glEnableClientState: function(cap, disable) { - if (!GL.immediate.initted) GL.immediate.init(); + var attrib; switch(cap) { case 0x8078: // GL_TEXTURE_COORD_ARRAY - GL.immediate.enabledClientAttributes[GL.immediate.TEXTURE] = !disable; break; + attrib = GL.immediate.TEXTURE0 + GL.immediate.clientActiveTexture; break; case 0x8074: // GL_VERTEX_ARRAY - GL.immediate.enabledClientAttributes[GL.immediate.VERTEX] = !disable; break; + attrib = GL.immediate.VERTEX; break; + case 0x8075: // GL_NORMAL_ARRAY + attrib = GL.immediate.NORMAL; break; + case 0x8076: // GL_COLOR_ARRAY + attrib = GL.immediate.COLOR; break; default: throw 'unhandled clientstate: ' + cap; } - if (!disable) { - GL.immediate.totalEnabledClientAttributes++; - } else { + if (disable && GL.immediate.enabledClientAttributes[attrib]) { + GL.immediate.enabledClientAttributes[attrib] = false; GL.immediate.totalEnabledClientAttributes--; + } else if (!disable && !GL.immediate.enabledClientAttributes[attrib]) { + GL.immediate.enabledClientAttributes[attrib] = true; + GL.immediate.totalEnabledClientAttributes++; } }, glDisableClientState: function(cap) { _glEnableClientState(cap, 1); }, + glVertexPointer__deps: ['$GLEmulation'], // if any pointers are used, glVertexPointer must be, and if it is, then we need emulation + glVertexPointer: function(size, type, stride, pointer) { + GL.immediate.setClientAttribute('V', size, type, stride, pointer); + }, glTexCoordPointer: function(size, type, stride, pointer) { - GL.immediate.setClientAttribute(GL.immediate.TEXTURE, 'T', size, type, stride, pointer); + GL.immediate.setClientAttribute('T' + GL.immediate.clientActiveTexture, size, type, stride, pointer); + }, + glNormalPointer: function(type, stride, pointer) { + GL.immediate.setClientAttribute('N', 3, type, stride, pointer); + }, + glColorPointer: function(size, type, stride, pointer) { + GL.immediate.setClientAttribute('C', size, type, stride, pointer); }, - glVertexPointer: function(size, type, stride, pointer) { - GL.immediate.setClientAttribute(GL.immediate.VERTEX, 'V', size, type, stride, pointer); + glClientActiveTexture: function(texture) { + GL.immediate.clientActiveTexture = texture - 0x84C0; // GL_TEXTURE0 }, // OpenGL Immediate Mode matrix routines. // Note that in the future we might make these available only in certain modes. - glMatrixMode__deps: ['$GL', '$GLImmediateSetup'], + glMatrixMode__deps: ['$GL', '$GLImmediateSetup', '$GLEmulation'], // emulation is not strictly needed, this is a workaround glMatrixMode: function(mode) { if (mode == 0x1700 /* GL_MODELVIEW */) { GL.immediate.currentMatrix = 'm'; } else if (mode == 0x1701 /* GL_PROJECTION */) { GL.immediate.currentMatrix = 'p'; + } else if (mode == 0x1702) { // GL_TEXTURE + GL.immediate.currentMatrix = 't' + GL.immediate.clientActiveTexture; } else { throw "Wrong mode " + mode + " passed to glMatrixMode"; } @@ -1418,24 +1909,23 @@ var LibraryGL = { }, glLoadMatrixd: function(matrix) { - GL.immediate.matrix.lib.mat4.set(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadMatrixf: function(matrix) { - GL.immediate.matrix.lib.mat4.set(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}); +#if GL_DEBUG + console.log('glLoadMatrixf receiving: ' + Array.prototype.slice.call(HEAPF32.subarray(matrix >> 2, (matrix >> 2) + 16))); +#endif + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadTransposeMatrixd: function(matrix) { - GL.immediate.matrix.lib.mat4.set(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadTransposeMatrixf: function(matrix) { - GL.immediate.matrix.lib.mat4.set(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]); }, @@ -1451,16 +1941,14 @@ var LibraryGL = { glMultTransposeMatrixd: function(matrix) { var colMajor = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.matrix.lib.mat4.set(colMajor, - {{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, colMajor); GL.immediate.matrix.lib.mat4.transpose(colMajor); GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor); }, glMultTransposeMatrixf: function(matrix) { var colMajor = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.matrix.lib.mat4.set(colMajor, - {{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, colMajor); GL.immediate.matrix.lib.mat4.transpose(colMajor); GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor); }, @@ -1474,6 +1962,7 @@ var LibraryGL = { GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], GL.immediate.matrix.lib.mat4.ortho(left, right, bottom, top_, nearVal, farVal)); }, + glOrthof: 'glOrtho', glScaled: function(x, y, z) { GL.immediate.matrix.lib.mat4.scale(GL.immediate.matrix[GL.immediate.currentMatrix], [x, y, z]); @@ -1486,7 +1975,7 @@ var LibraryGL = { glTranslatef: 'glTranslated', glRotated: function(angle, x, y, z) { - GL.immediate.matrix.lib.mat4.rotate(GL.immediate.matrix[GL.immediate.currentMatrix], angle, [x, y, z]); + GL.immediate.matrix.lib.mat4.rotate(GL.immediate.matrix[GL.immediate.currentMatrix], angle*Math.PI/180, [x, y, z]); }, glRotatef: 'glRotated', @@ -1552,8 +2041,8 @@ var LibraryGL = { // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name [[0, 'shadeModel fogi fogfv getError* finish flush'], - [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear enableVertexAttribArray disableVertexAttribArray lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation polygonOffset hint sampleCoverage isEnabled*'], - [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate'], + [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear enableVertexAttribArray disableVertexAttribArray lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation polygonOffset sampleCoverage isEnabled*'], + [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint'], [3, 'texParameteri texParameterf drawArrays vertexAttrib2f stencilFunc stencilOp'], [4, 'viewport clearColor scissor vertexAttrib3f colorMask drawElements renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'], [5, 'vertexAttrib4f'], @@ -1582,5 +2071,14 @@ var LibraryGL = { }); autoAddDeps(LibraryGL, '$GL'); + +// Emulation requires everything else, potentially +LibraryGL.$GLEmulation__deps = LibraryGL.$GLEmulation__deps.slice(0); +for (var item in LibraryGL) { + if (item != '$GLEmulation' && item.substr(-6) != '__deps' && item.substr(-9) != '__postset' && item.substr(0, 2) == 'gl') { + LibraryGL.$GLEmulation__deps.push(item); + } +} + mergeInto(LibraryManager.library, LibraryGL); diff --git a/src/library_glut.js b/src/library_glut.js index e4b2d138..b0308acf 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -226,13 +226,13 @@ var LibraryGLUT = { onFullScreenEventChange: function(event){ var width; var height; - if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) { + if (document["fullScreen"] || document["mozFullScreen"] || document["webkitIsFullScreen"]) { width = screen["width"]; height = screen["height"]; } else { width = GLUT.windowWidth; height = GLUT.windowHeight; - // TODO set position + // TODO set position document.removeEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true); document.removeEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true); document.removeEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true); @@ -241,6 +241,7 @@ var LibraryGLUT = { Module['canvas'].height = height; /* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */ if (GLUT.reshapeFunc) { + // console.log("GLUT.reshapeFunc (from FS): " + width + ", " + height); FUNCTION_TABLE[GLUT.reshapeFunc](width, height); } _glutPostRedisplay(); @@ -262,16 +263,7 @@ var LibraryGLUT = { document['webkitCancelFullScreen'] || (function() {}); CFS.apply(document, []); - }, - - requestAnimationFrame: function(func) { - var RAF = window['requestAnimationFrame'] || - window['mozRequestAnimationFrame'] || - window['webkitRequestAnimationFrame'] || - window['msRequestAnimationFrame'] || - window['setTimeout']; - RAF.apply(window, [func]); - }, + } }, glutGetModifiers: function() { return GLUT.modifiers; }, @@ -378,9 +370,11 @@ var LibraryGLUT = { glutReshapeWindow__deps: ['$GLUT', 'glutPostRedisplay'], glutReshapeWindow: function(width, height) { GLUT.cancelFullScreen(); + // console.log("glutReshapeWindow: " + width + ", " + height); Module['canvas'].width = width; Module['canvas'].height = height; if (GLUT.reshapeFunc) { + // console.log("GLUT.reshapeFunc: " + width + ", " + height); FUNCTION_TABLE[GLUT.reshapeFunc](width, height); } _glutPostRedisplay(); @@ -410,7 +404,7 @@ var LibraryGLUT = { glutPostRedisplay: function() { if (GLUT.displayFunc) { - GLUT.requestAnimationFrame(FUNCTION_TABLE[GLUT.displayFunc]); + Browser.requestAnimationFrame(FUNCTION_TABLE[GLUT.displayFunc]); } }, diff --git a/src/library_sdl.js b/src/library_sdl.js index f71527af..e2e199e5 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -1,79 +1,7 @@ //"use strict"; -// To use emscripten's SDL library here, you need to define -// Module.canvas. -// -// More specifically, our SDL implementation will look for -// Module.canvas. You should fill it using something like -// -// function onLoad() { -// // Pass canvas and context to the generated code -// Module.canvas = document.getElementById('canvas'); -// } -// -// Note that this must be called during onload, since you will -// only be able to access the canvas element in the page after -// it loads. You will likely also want to disable running by -// default, with something like -// -// var Module = { -// noInitialRun: true -// }; -// -// which is defined BEFORE you load the compiled code. - -// The test_emcc test in the tests/runner.py will test this -// in its last phase, where it generates HTML. You can see -// a concrete example there. The HTML source is in src/shell.html. -// Here is a more comprehensive example: - -/* -<html> - <head> - <title>Demo</title> - <script type='text/javascript'> - var Module = { - noInitialRun: true - }; - - // implement print - var print = function(text) { - var element = document.getElementById('output') - element.innerHTML = text.replace('\n', '<br>', 'g') + element.innerHTML; - } - </script> - <script src='doom.ccsimple.js' type='text/javascript'></script> - <script type='text/javascript'> - function onLoad() { - // Pass canvas and context to the generated code, and do the actual run() here - Module.canvas = document.getElementById('canvas'); - Module.run(); - } - </script> - <body onload='onLoad()' style='background-color: black; color: white'> - <center> - <canvas id='canvas' width='320' height='200'></canvas> - </center> - <div id='output'></div> - </body> -</html> -*/ - -// Other stuff to take into account: -// -// * Make sure alpha values are proper in your input. If they are all 0, everything will be transparent! -// -// * Your code should not write a 32-bit value and expect that to set an RGBA pixel. -// The reason is that that data will be read as 8-bit values, and according to the -// load-store consistency assumption, it should be written that way (see docs/paper.pdf). -// Instead, do something like *ptr++ = R; *ptr++ = G; *ptr++ = B; -// -// * A normal C++ main loop with SDL_Delay will not work in JavaScript - there is no way -// to wait for a short time without locking up the web page entirely. The simplest -// solution here is to have a singleIteration() function which is a single loop -// iteration, and from JS to do something like setInterval(_singleIteration, 1/30) -// -// * SDL_Quit does nothing. +// See browser tests for examples (tests/runner.py, search for sdl_). Run with +// python tests/runner.py browser var LibrarySDL = { $SDL__deps: ['$FS', '$Browser'], @@ -92,19 +20,17 @@ var LibrarySDL = { fonts: [null], keyboardState: null, + shiftKey: false, + ctrlKey: false, + altKey: false, + startTime: null, mouseX: 0, mouseY: 0, - DOMEventToSDLEvent: { - 'keydown': 0x300, - 'keyup': 0x301, - 'mousedown': 0x401, - 'mouseup': 0x402, - 'mousemove': 0x400 - }, + DOMEventToSDLEvent: {}, - keyCodes: { // DOM code ==> SDL code + keyCodes: { // DOM code ==> SDL code. See https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/KeyboardEvent and SDL_keycode.h 38: 1106, // up arrow 40: 1105, // down arrow 37: 1104, // left arrow @@ -116,10 +42,39 @@ var LibrarySDL = { 17: 305, // control (right, or left) 18: 308, // alt 109: 45, // minus - 16: 304 // shift + 16: 304, // shift + + 96: 88 | 1<<10, // keypad 0 + 97: 89 | 1<<10, // keypad 1 + 98: 90 | 1<<10, // keypad 2 + 99: 91 | 1<<10, // keypad 3 + 100: 92 | 1<<10, // keypad 4 + 101: 93 | 1<<10, // keypad 5 + 102: 94 | 1<<10, // keypad 6 + 103: 95 | 1<<10, // keypad 7 + 104: 96 | 1<<10, // keypad 8 + 105: 97 | 1<<10, // keypad 9 + + 112: 58 | 1<<10, // F1 + 113: 59 | 1<<10, // F2 + 114: 60 | 1<<10, // F3 + 115: 61 | 1<<10, // F4 + 116: 62 | 1<<10, // F5 + 117: 63 | 1<<10, // F6 + 118: 64 | 1<<10, // F7 + 119: 65 | 1<<10, // F8 + 120: 66 | 1<<10, // F9 + 121: 67 | 1<<10, // F10 + 122: 68 | 1<<10, // F11 + 123: 69 | 1<<10, // F12 + + 188: 44, // comma + 190: 46, // period + 191: 47, // slash (/) + 192: 96, // backtick/backquote (`) }, - scanCodes: { // SDL keycode ==> SDL scancode + scanCodes: { // SDL keycode ==> SDL scancode. See SDL_scancode.h 97: 4, // A 98: 5, 99: 6, @@ -146,25 +101,26 @@ var LibrarySDL = { 120: 27, 121: 28, 122: 29, // Z - 48: 30, // 0 - 49: 31, - 50: 32, - 51: 33, - 52: 34, - 53: 35, - 54: 36, - 55: 37, - 56: 38, - 57: 39, // 9 + 44: 54, // comma + 46: 55, // period + 47: 56, // slash + 49: 30, // 1 + 50: 31, + 51: 32, + 52: 33, + 53: 34, + 54: 35, + 55: 36, + 56: 37, + 57: 38, // 9 + 48: 39, // 0 13: 40, // return 9: 43, // tab + 27: 41, // escape 32: 44, // space 92: 49, // backslash - 47: 56, // slash - 1106: 82, // up arrow - 1105: 81, // down arrow - 1104: 80, // left arrow - 1103: 79 // right arrow + 305: 224, // ctrl + 308: 226, // alt }, structs: { @@ -296,10 +252,7 @@ var LibrarySDL = { } else { canvas = Module['canvas']; } - var ctx = Browser.createContext(canvas, useWebGL); - if (usePageCanvas) { - Module.ctx = ctx; - } + var ctx = Browser.createContext(canvas, useWebGL, usePageCanvas); SDL.surfaces[surf] = { width: width, height: height, @@ -326,8 +279,25 @@ var LibrarySDL = { receiveEvent: function(event) { switch(event.type) { - case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': case 'mousemove': + case 'mousemove': + // workaround for firefox bug 750111 + event['movementX'] = event['mozMovementX']; + event['movementY'] = event['mozMovementY']; + // fall through + case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': case 'DOMMouseScroll': + if (event.type == 'DOMMouseScroll') { + event = { + type: 'mousedown', + button: event.detail > 0 ? 4 : 3, + pageX: event.pageX, + pageY: event.pageY + }; + } SDL.events.push(event); + if (SDL.events.length >= 10000) { + Module.printErr('SDL event queue full, dropping earliest event'); + SDL.events.shift(); + } if ((event.keyCode >= 37 && event.keyCode <= 40) || // arrow keys event.keyCode == 32 || // space event.keyCode == 33 || event.keyCode == 34) { // page up/down @@ -335,7 +305,6 @@ var LibrarySDL = { } break; } - //event.preventDefault(); return false; }, @@ -350,11 +319,18 @@ var LibrarySDL = { case 'keydown': case 'keyup': { var down = event.type === 'keydown'; //Module.print('Received key event: ' + event.keyCode); - var key = SDL.keyCodes[event.keyCode] || event.keyCode; + var key = event.keyCode; if (key >= 65 && key <= 90) { - key = String.fromCharCode(key).toLowerCase().charCodeAt(0); + key += 32; // make lowercase for SDL + } else { + key = SDL.keyCodes[event.keyCode] || event.keyCode; + } + var scan; + if (key >= 1024) { + scan = key - 1024; + } else { + scan = SDL.scanCodes[key] || key; } - var scan = SDL.scanCodes[key] || key; {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.type', 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}} //{{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.which', '1', 'i32') }}} {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.state', 'down ? 1 : 0', 'i8') }}} @@ -363,10 +339,14 @@ var LibrarySDL = { {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.keysym + SDL.structs.keysym.scancode', 'scan', 'i32') }}} {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.keysym + SDL.structs.keysym.sym', 'key', 'i32') }}} {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.keysym + SDL.structs.keysym.mod', '0', 'i32') }}} - //{{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.keysym + SDL.structs.keysym.unicode', 'key', 'i32') }}} + {{{ makeSetValue('ptr', 'SDL.structs.KeyboardEvent.keysym + SDL.structs.keysym.unicode', 'key', 'i32') }}} {{{ makeSetValue('SDL.keyboardState', 'SDL.keyCodes[event.keyCode] || event.keyCode', 'event.type == "keydown"', 'i8') }}}; + SDL.shiftKey = event.shiftKey; + SDL.ctrlKey = event.ctrlKey; + SDL.altKey = event.altKey; + break; } case 'mousedown': case 'mouseup': case 'mousemove': { @@ -385,8 +365,8 @@ var LibrarySDL = { {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.state', 'down ? 1 : 0', 'i8') }}}; {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.x', 'x', 'i32') }}}; {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.y', 'y', 'i32') }}}; - {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.xrel', 'x - SDL.mouseX', 'i32') }}}; - {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.yrel', 'y - SDL.mouseY', 'i32') }}}; + {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.xrel', 'Browser.getMovementX(x - SDL.mouseX, event)', 'i32') }}}; + {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.yrel', 'Browser.getMovementY(y - SDL.mouseY, event)', 'i32') }}}; } SDL.mouseX = x; SDL.mouseY = y; @@ -409,6 +389,20 @@ var LibrarySDL = { return ret; }, + // Sound + + allocateChannels: function(num) { // called from Mix_AllocateChannels and init + if (SDL.numChannels && SDL.numChannels >= num) return; + SDL.numChannels = num; + SDL.channels = []; + for (var i = 0; i < num; i++) { + SDL.channels[i] = { + audio: null, + volume: 1.0 + }; + } + }, + // Debugging debugSurface: function(surfData) { @@ -439,6 +433,12 @@ var LibrarySDL = { }); SDL.keyboardState = _malloc(0x10000); _memset(SDL.keyboardState, 0, 0x10000); + // Initialize this structure carefully for closure + SDL.DOMEventToSDLEvent['keydown'] = 0x300; + SDL.DOMEventToSDLEvent['keyup'] = 0x301; + SDL.DOMEventToSDLEvent['mousedown'] = 0x401; + SDL.DOMEventToSDLEvent['mouseup'] = 0x402; + SDL.DOMEventToSDLEvent['mousemove'] = 0x400; return 0; // success }, @@ -466,7 +466,7 @@ var LibrarySDL = { }, SDL_SetVideoMode: function(width, height, depth, flags) { - ['mousedown', 'mouseup', 'mousemove'].forEach(function(event) { + ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll'].forEach(function(event) { Module['canvas'].addEventListener(event, SDL.receiveEvent, true); }); Module['canvas'].width = width; @@ -604,12 +604,28 @@ var LibrarySDL = { return SDL.keyboardState; }, + SDL_GetModState: function() { + // TODO: numlock, capslock, etc. + return (SDL.shiftKey ? 0x0001 & 0x0002 : 0) | // KMOD_LSHIFT & KMOD_RSHIFT + (SDL.ctrlKey ? 0x0040 & 0x0080 : 0) | // KMOD_LCTRL & KMOD_RCTRL + (SDL.altKey ? 0x0100 & 0x0200 : 0); // KMOD_LALT & KMOD_RALT + }, + SDL_GetMouseState: function(x, y) { if (x) {{{ makeSetValue('x', '0', 'SDL.mouseX', 'i32') }}}; if (y) {{{ makeSetValue('y', '0', 'SDL.mouseY', 'i32') }}}; return 0; }, + SDL_WarpMouse: function(x, y) { + return; // TODO: implement this in a non-buggy way. Need to keep relative mouse movements correct after calling this + SDL.events.push({ + type: 'mousemove', + pageX: x + Module['canvas'].offsetLeft, + pageY: y + Module['canvas'].offsetTop + }); + }, + SDL_ShowCursor: function(toggle) { // TODO }, @@ -731,16 +747,23 @@ var LibrarySDL = { }, SDL_WM_GrabInput: function() {}, - SDL_ShowCursor: function() {}, // SDL_Image + IMG_Init: function(flags) { + return flags; // We support JPG, PNG, TIF because browsers do + }, + IMG_Load__deps: ['SDL_LockSurface'], IMG_Load: function(filename) { filename = FS.standardizePath(Pointer_stringify(filename)); + if (filename[0] == '/') { + // Convert the path to relative + filename = filename.substr(1); + } var raw = preloadedImages[filename]; if (!raw) { - Module.printErr('Cannot find preloaded image ' + filename); + Runtime.warnOnce('Cannot find preloaded image ' + filename); return 0; } var surf = SDL.makeSurface(raw.width, raw.height, 0, false, 'load:' + filename); @@ -755,10 +778,13 @@ var LibrarySDL = { return surf; }, SDL_LoadBMP: 'IMG_Load', + SDL_LoadBMP_RW: 'IMG_Load', // SDL_Audio SDL_OpenAudio: function(desired, obtained) { + SDL.allocateChannels(32); + // FIXME: Assumes 16-bit audio assert(obtained === 0, 'Cannot return obtained SDL audio params'); @@ -830,30 +856,38 @@ var LibrarySDL = { // SDL Mixer Mix_OpenAudio: function(frequency, format, channels, chunksize) { + SDL.allocateChannels(32); return 0; }, + Mix_CloseAudio: 'SDL_CloseAudio', + Mix_AllocateChannels: function(num) { - return num; // fake it + SDL.allocateChannels(num); + return num; }, Mix_ChannelFinished: function(func) { - SDL.channelFinished = func; // TODO + SDL.channelFinished = func; }, - Mix_HookMusicFinished: function(func) { - SDL.hookMusicFinished = func; + Mix_Volume: function(channel, volume) { + var info = SDL.channels[channel]; + var ret = info.volume * 128; + info.volume = volume / 128; + if (info.audio) info.audio.volume = info.volume; + return ret; }, - Mix_VolumeMusic: function(func) { - return 0; // TODO + Mix_SetPanning: function() { + return 0; // error }, Mix_LoadWAV_RW: function(filename, freesrc) { filename = FS.standardizePath(Pointer_stringify(filename)); var raw = preloadedAudios[filename]; if (!raw) { - Module.printErr('Cannot find preloaded audio ' + filename); + Runtime.warnOnce('Cannot find preloaded audio ' + filename); return 0; } var id = SDL.audios.length; @@ -865,7 +899,6 @@ var LibrarySDL = { }, Mix_FreeChunk: function(id) { - SDL.audios[id].audio.pause(); SDL.audios[id] = null; }, @@ -873,13 +906,54 @@ var LibrarySDL = { // TODO: handle loops var audio = SDL.audios[id].audio; if (!audio) return 0; - if (audio.currentTime) audio.src = audio.src; // This hack prevents lags on replaying // TODO: parallel sounds through //cloneNode(true).play() - audio.play(); - return 1; // XXX should return channel + if (channel == -1) { + channel = 0; + for (var i = 0; i < SDL.numChannels; i++) { + if (!SDL.channels[i].audio) { + channel = i; + break; + } + } + } + var info = SDL.channels[channel]; + info.audio = audio.cloneNode(true); + if (SDL.channelFinished) { + info.audio['onended'] = function() { // TODO: cache these + Runtime.getFuncWrapper(SDL.channelFinished)(channel); + } + } + info.audio.play(); + info.audio.volume = info.volume; + return channel; }, Mix_PlayChannelTimed: 'Mix_PlayChannel', // XXX ignore Timing + Mix_FadingChannel: function(channel) { + return 0; // MIX_NO_FADING, TODO + }, + + Mix_HaltChannel: function(channel) { + var info = SDL.channels[channel]; + if (info.audio) { + info.audio.pause(); + info.audio = null; + } + if (SDL.channelFinished) { + Runtime.getFuncWrapper(SDL.channelFinished)(channel); + } + return 0; + }, + + Mix_HookMusicFinished: function(func) { + SDL.hookMusicFinished = func; + }, + + Mix_VolumeMusic: function(func) { + return 0; // TODO + }, + Mix_LoadMUS: 'Mix_LoadWAV_RW', + Mix_FreeMusic: 'Mix_FreeChunk', Mix_PlayMusic: function(id, loops) { diff --git a/src/modules.js b/src/modules.js index a6aaa99a..0f3b483b 100644 --- a/src/modules.js +++ b/src/modules.js @@ -259,7 +259,7 @@ var LibraryManager = { load: function() { assert(!this.library); - var libraries = ['library.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js'].concat(additionalLibraries); + var libraries = ['library.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js', 'library_gc.js'].concat(additionalLibraries); for (var i = 0; i < libraries.length; i++) { eval(processMacros(preprocess(read(libraries[i])))); } diff --git a/src/parseTools.js b/src/parseTools.js index 92fb038a..81fa61d9 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1209,7 +1209,7 @@ function getFastValue(a, op, b, type) { return a; } } - return a + op + b; + return '(' + a + ')' + op + '(' + b + ')'; } function getFastValues(list, op, type) { @@ -1314,27 +1314,35 @@ function finalizeLLVMFunctionCall(item, noIndexizeFunctions) { // Warn about some types of casts, then fall through to the handling code below var oldType = item.params[0].type; var newType = item.type; - if (isPossiblyFunctionType(oldType) && isPossiblyFunctionType(newType) && - countNormalArgs(oldType) != countNormalArgs(newType)) { - warnOnce('Casting a function pointer type to another with a different number of arguments. See more info in the source'); - // This may be dangerous as clang generates different code for C and C++ calling conventions. The only problem - // case appears to be passing a structure by value, C will have (field1, field2) as function args, and the - // function will internally create a structure with that data, while C++ will have (struct* byVal) and it - // will create a copy before calling the function, then call it with a pointer to the copy. Mixing the two - // first of all leads to two copies being made, so this is a bad idea even regardless of Emscripten. But, - // what is a problem for Emscr ipten is that mixing these two calling conventions (say, calling a C one from - // C++) will then assume that (struct* byVal) is actually the same as (field1, field2). In native code, this - // is easily possible, you place the two fields on the stack and call the function (you know to place the - // values since there is 'byVal'). In Emscripten, though, this means we would need to always do one or the - // other of the two possibilities, for example, always passing by-value structs as (field1, field2). This - // would slow down everything, just to handle this corner case. (Which, just to point out how much of a - // corner case it is, does not appear to happen with nested structures!) - // - // The recommended solution for this problem is not to mix C and C++ calling conventions when passing structs - // by value. Either always pass structs by value within C code or C++ code, but not mixing the two by - // defining a function in one and calling it from the other (so, just changing .c to .cpp, or moving code - // from one file to another, would be enough to fix this), or, do not pass structs by value (which in general - // is inefficient, and worth avoiding if you can). + if (isPossiblyFunctionType(oldType) && isPossiblyFunctionType(newType)) { + var oldCount = countNormalArgs(oldType); + var newCount = countNormalArgs(newType); + if (oldCount != newCount && oldCount && newCount) { + warnOnce('Casting a function pointer type to another with a different number of arguments. See more info in the compiler source'); + if (VERBOSE) { + warnOnce('Casting a function pointer type to another with a different number of arguments: ' + oldType + ' vs. ' + newType + ', on ' + item.params[0].ident); + } + // This may be dangerous as clang generates different code for C and C++ calling conventions. The only problem + // case appears to be passing a structure by value, C will have (field1, field2) as function args, and the + // function will internally create a structure with that data, while C++ will have (struct* byVal) and it + // will create a copy before calling the function, then call it with a pointer to the copy. Mixing the two + // first of all leads to two copies being made, so this is a bad idea even regardless of Emscripten. But, + // what is a problem for Emscr ipten is that mixing these two calling conventions (say, calling a C one from + // C++) will then assume that (struct* byVal) is actually the same as (field1, field2). In native code, this + // is easily possible, you place the two fields on the stack and call the function (you know to place the + // values since there is 'byVal'). In Emscripten, though, this means we would need to always do one or the + // other of the two possibilities, for example, always passing by-value structs as (field1, field2). This + // would slow down everything, just to handle this corner case. (Which, just to point out how much of a + // corner case it is, does not appear to happen with nested structures!) + // + // The recommended solution for this problem is not to mix C and C++ calling conventions when passing structs + // by value. Either always pass structs by value within C code or C++ code, but not mixing the two by + // defining a function in one and calling it from the other (so, just changing .c to .cpp, or moving code + // from one file to another, would be enough to fix this), or, do not pass structs by value (which in general + // is inefficient, and worth avoiding if you can). + // + // Note that removing all arguments is acceptable, as a vast to void ()*. + } } } var temp = { diff --git a/src/postamble.js b/src/postamble.js index cf863669..ea03391c 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -32,28 +32,46 @@ Module.callMain = function callMain(args) { function run(args) { args = args || Module['arguments']; - if (Module['setStatus']) { - Module['setStatus'](''); // clear the status from "Downloading.." etc. - } - if (Module['preRun']) { Module['preRun'](); + if (runDependencies > 0) { + // preRun added a dependency, run will be called later + Module['preRun'] = null; + return 0; + } } - var ret = null; - if (Module['_main']) { - preMain(); - ret = Module.callMain(args); - if (!Module['noExitRuntime']) { - exitRuntime(); + function doRun() { + var ret = 0; + if (Module['_main']) { + preMain(); + ret = Module.callMain(args); + if (!Module['noExitRuntime']) { + exitRuntime(); + } + } + if (Module['postRun']) { + Module['postRun'](); } + return ret; } - if (Module['postRun']) { - Module['postRun'](); +#if GENERATING_HTML + if (Module['setStatus']) { + Module['setStatus']('Running...'); + setTimeout(function() { + setTimeout(function() { + Module['setStatus'](''); + }, 1); + doRun(); + }, 1); + return 0; + } else { + return doRun(); } - - return ret; +#else + return doRun(); +#endif } Module['run'] = run; diff --git a/src/preamble.js b/src/preamble.js index 986592ee..997e5ab3 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -852,8 +852,11 @@ var STRING_TABLE = []; // A counter of dependencies for calling run(). If we need to // do asynchronous work before running, increment this and -// decrement it. Incrementing must happen in Module.preRun -// or PRE_RUN_ADDITIONS (used by emcc to add file preloading). +// decrement it. Incrementing must happen in a place like +// PRE_RUN_ADDITIONS (used by emcc to add file preloading). +// Note that you can add dependencies in preRun, even though +// it happens right before run - run will be postponed until +// the dependencies are met. var runDependencies = 0; function addRunDependency() { runDependencies++; diff --git a/src/runtime.js b/src/runtime.js index 0e4b7b2d..1f8a618f 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -313,7 +313,78 @@ var Runtime = { FUNCTION_TABLE.push(func); FUNCTION_TABLE.push(0); return ret; + }, + + warnOnce: function(text) { + if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {}; + if (!Runtime.warnOnce.shown[text]) { + Runtime.warnOnce.shown[text] = 1; + Module.printErr(text); + } + }, + + funcWrappers: {}, + + getFuncWrapper: function(func) { + if (!Runtime.funcWrappers[func]) { + Runtime.funcWrappers[func] = function() { + FUNCTION_TABLE[func].apply(null, arguments); + }; + } + return Runtime.funcWrappers[func]; + }, + +#if RUNTIME_DEBUG + debug: true, // Switch to false at runtime to disable logging at the right times + + printObjectList: [], + + prettyPrint: function(arg) { + if (typeof arg == 'undefined') return '!UNDEFINED!'; + if (typeof arg == 'boolean') arg = arg + 0; + if (!arg) return arg; + var index = Runtime.printObjectList.indexOf(arg); + if (index >= 0) return '<' + arg + '|' + index + '>'; + if (arg.toString() == '[object HTMLImageElement]') { + return arg + '\n\n'; + } + if (arg.byteLength) { + return '{' + Array.prototype.slice.call(arg, 0, Math.min(arg.length, 400)) + '}'; // Useful for correct arrays, less so for compiled arrays, see the code below for that + var buf = new ArrayBuffer(32); + var i8buf = new Int8Array(buf); + var i16buf = new Int16Array(buf); + var f32buf = new Float32Array(buf); + switch(arg.toString()) { + case '[object Uint8Array]': + i8buf.set(arg.subarray(0, 32)); + break; + case '[object Float32Array]': + f32buf.set(arg.subarray(0, 5)); + break; + case '[object Uint16Array]': + i16buf.set(arg.subarray(0, 16)); + break; + default: + alert('unknown array for debugging: ' + arg); + throw 'see alert'; + } + var ret = '{' + arg.byteLength + ':\n'; + var arr = Array.prototype.slice.call(i8buf); + ret += 'i8:' + arr.toString().replace(/,/g, ',') + '\n'; + arr = Array.prototype.slice.call(f32buf, 0, 8); + ret += 'f32:' + arr.toString().replace(/,/g, ',') + '}'; + return ret; + } + if (typeof arg == 'object') { + Runtime.printObjectList.push(arg); + return '<' + arg + '|' + (Runtime.printObjectList.length-1) + '>'; + } + if (typeof arg == 'number') { + if (arg > 0) return '0x' + arg.toString(16) + ' (' + arg + ')'; + } + return arg; } +#endif }; Runtime.stackAlloc = unInline('stackAlloc', ['size']); diff --git a/src/settings.js b/src/settings.js index 7df86c90..e0286213 100644 --- a/src/settings.js +++ b/src/settings.js @@ -26,6 +26,7 @@ var ASSERTIONS = 1; // Whether we should add runtime assertions, for example to // exceed it's size, whether all allocations (stack and static) are // of positive size, etc., whether we should throw if we encounter a bad __label__, i.e., // if code flow runs into a fault +var VERBOSE = 0; // When set to 1, will generate more verbose output during compilation. var INVOKE_RUN = 1; // Whether we will call run(). Disable if you embed the generated // code in your own, and will call run() yourself at the right time @@ -100,9 +101,13 @@ var SAFE_HEAP_LOG = 0; // Log out all SAFE_HEAP operations var LABEL_DEBUG = 0; // Print out labels and functions as we enter them var EXCEPTION_DEBUG = 1; // Print out exceptions in emscriptened code -var LIBRARY_DEBUG = 0; // Print out when we enter a library call (library*.js) -var GL_DEBUG = 0; // Print out all calls into WebGL +var LIBRARY_DEBUG = 0; // Print out when we enter a library call (library*.js). You can also unset + // Runtime.debug at runtime for logging to cease, and can set it when you + // want it back. A simple way to set it in C++ is + // emscripten_run_script("Runtime.debug = ...;"); +var GL_DEBUG = 0; // Print out all calls into WebGL. As with LIBRARY_DEBUG, you can set a runtime + // option, in this case GL.debug. var DISABLE_EXCEPTION_CATCHING = 0; // Disables generating code to actually catch exceptions. If the code you // are compiling does not actually rely on catching exceptions (but the @@ -200,6 +205,8 @@ var LINKABLE = 0; // If set to 1, this file can be linked with others, either as // LINKABLE of 0 is very useful in that we can reduce the size of the // generated code very significantly, by removing everything not actually used. +var GENERATING_HTML = 0; // Set to 1 when generating .html and not just .js + var RUNTIME_TYPE_INFO = 0; // Whether to expose type info to the script at run time. This // increases the size of the generated script, but allows you // to more easily perform operations from handwritten JS on @@ -209,6 +216,16 @@ var FAKE_X86_FP80 = 1; // Replaces x86_fp80 with double. This loses precision. I // if you can, to get the original source code to build without x86_fp80 // (which is nonportable anyhow). +var GC_SUPPORT = 1; // Enables GC, see gc.h (this does not add overhead, so it is on by default) + +var WARN_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will warn on any undefined symbols that + // are not resolved by the library_*.js files. We by default + // do not warn because (1) it is normal in large projects to + // not implement everything, when you know what is not + // going to actually be called (and don't want to mess with + // the existing buildsystem), and (2) functions might be + // implemented later on, say in --pre-js + // Compiler debugging options var DEBUG_TAGS_SHOWING = []; // Some useful items: diff --git a/src/shell.html b/src/shell.html index 37509889..404c9c11 100644 --- a/src/shell.html +++ b/src/shell.html @@ -1,16 +1,24 @@ -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<html> +<!doctype html> +<html lang="en-us"> <head> + <meta charset="utf-8"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Emscripten-Generated Code</title> + <style> + .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } + canvas.emscripten { border: 1px solid black; } + textarea.emscripten { font-family: monospace; width: 80%; } + div.emscripten { text-align: center; } + </style> + </head> <body> - <center> - <canvas id='canvas' width='256' height='256' style="border: 1px solid black" - oncontextmenu="event.preventDefault()"></canvas> - <hr> - <textarea id="output" style="font-family: monospace; width: 80%" rows="8"></textarea> - <hr> - <div id='status'>Downloading...</div> - </center> + <hr/> + <div class="emscripten" id="status">Downloading...</div> + <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> + <hr/> + <div class="emscripten"><input type="button" value="fullscreen" onclick="Module.requestFullScreen()"></div> + <hr/> + <textarea class="emscripten" id="output" rows="8"></textarea> <hr> <script type='text/javascript'> // connect to canvas @@ -30,17 +38,33 @@ })(), canvas: document.getElementById('canvas'), setStatus: function(text) { + if (Module.setStatus.interval) clearInterval(Module.setStatus.interval); document.getElementById('status').innerHTML = text; + if (text) { + var counter = 0; + Module.setStatus.interval = setInterval(function() { + counter++; + counter %= 3; + var dots = ' '; + for (var i = 0; i < counter; i++) dots += '.'; + dots += '*'; + for (var i = counter; i < 2; i++) dots += '.'; + document.getElementById('status').innerHTML = text.replace('...', dots); + }, 300); + } }, totalDependencies: 0, monitorRunDependencies: function(left) { this.totalDependencies = Math.max(this.totalDependencies, left); - Module.setStatus(left ? 'Downloading: ' + (this.totalDependencies-left) + '/' + this.totalDependencies : 'All downloads complete.'); + Module.setStatus(left ? 'Downloading: ' + (this.totalDependencies-left) + '/' + this.totalDependencies + '...' : 'All downloads complete.'); } }; + Module.setStatus('Downloading...'); + </script> + <script type='text/javascript'> {{{ SCRIPT_CODE }}} + </script> </body> </html> - diff --git a/src/utility.js b/src/utility.js index 7d5e0970..42e8ede4 100644 --- a/src/utility.js +++ b/src/utility.js @@ -40,7 +40,7 @@ function dumpKeys(item) { function assertEq(a, b) { if (a !== b) { - print('Stack: ' + new Error().stack); + printErr('Stack: ' + new Error().stack); throw 'Should have been equal: ' + a + ' : ' + b; } return false; @@ -50,7 +50,7 @@ function assertTrue(a, msg) { if (!a) { msg = 'Assertion failed: ' + msg; print(msg); - print('Stack: ' + new Error().stack); + printErr('Stack: ' + new Error().stack); throw msg; } } diff --git a/system/include/emscripten.h b/system/include/emscripten.h index 7bb2ae8e..d0e6cc46 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -17,14 +17,25 @@ extern "C" { */ extern void emscripten_run_script(const char *script); extern int emscripten_run_script_int(const char *script); +extern void emscripten_async_run_script(const char *script, int millis); /* * Set a C function as the main event loop. The JS environment * will call that function at a specified number of frames per - * second. Setting 0 as the fps will use the default browser - * frame rate. + * second. Setting 0 or a negative value as the fps will use + * the browser's requestAnimationFrame mechanism. + * + * Pausing and resuming the main loop is useful if your app + * needs to perform some synchronous operation, for example + * to load a file from the network. It might be wrong to + * run the main loop before that finishes (the original + * code assumes that), so you can break the code up into + * asynchronous callbacks, but you must pause the main + * loop until they complete. */ extern void emscripten_set_main_loop(void (*func)(), int fps); +extern void emscripten_pause_main_loop(); +extern void emscripten_resume_main_loop(); extern void emscripten_cancel_main_loop(); /* @@ -32,6 +43,9 @@ extern void emscripten_cancel_main_loop(); * control to the JS event loop. This is done by a setTimeout. * When building natively this becomes a simple direct call, * after SDL_Delay (you must include SDL.h for that). + * + * If millis is negative, the browser's requestAnimationFrame + * mechanism is used. */ #if EMSCRIPTEN extern void emscripten_async_call(void (*func)(), int millis); @@ -43,6 +57,23 @@ void emscripten_async_call(void (*func)(), int millis) { #endif /* + * Hide the OS mouse cursor over the canvas. Note that SDL's + * SDL_ShowCursor command shows and hides the SDL cursor, not + * the OS one. This command is useful to hide the OS cursor + * if your app draws its own cursor. + */ +void emscripten_hide_mouse(); + +/* + * Returns the highest-precision representation of the + * current time that the browser provides. This uses either + * Date.now or performance.now. The result is *not* an + * absolute time, and is only meaningful in comparison to + * other calls to this function. The unit is ms. + */ +float emscripten_get_now(); + +/* * This macro-looking function will cause Emscripten to * generate a comment in the generated code. * XXX This is deprecated for now, because it requires us to diff --git a/system/include/features.h b/system/include/features.h new file mode 100644 index 00000000..1dd6ea6d --- /dev/null +++ b/system/include/features.h @@ -0,0 +1,3 @@ + +#include <sys/features.h> + diff --git a/system/include/gc.h b/system/include/gc.h new file mode 100644 index 00000000..996bc9ec --- /dev/null +++ b/system/include/gc.h @@ -0,0 +1,50 @@ +/* + * Boehm-compatible GC API + */ + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void __attribute__((used)) __GC_KEEPALIVE__() { + // Force inclusion of necessary dlmalloc functions + static int times = 1; + void *x = malloc(times); + free(x); + x = calloc(1, times); + free(x); + x = calloc(times, 1); + free(x); + times++; +} + +/* Initialize. */ +void GC_INIT(); + +/* Allocate memory. Cleared to 0 to erase all pointers. */ +void *GC_MALLOC(int bytes); + +/* Allocate memory for an object that the user promises will not contain pointers. */ +void *GC_MALLOC_ATOMIC(int bytes); + +/* Explicitly deallocate an object. Dangerous as it forces a free and does not check if the object is reffed. */ +void GC_FREE(void *ptr); + +/* Register a finalizer. func(ptr, arg) will be called. The old values are saved in old_func, old_arg */ +void GC_REGISTER_FINALIZER_NO_ORDER(void *ptr, void (*func)(void *, void *), void *arg, + void *(*old_func)(void *, void *), void *old_arg); + +/* Non-Boehm additions */ + +/* Call this once per frame or such, it will collect if necessary */ +void GC_MAYBE_COLLECT(); + +/* Forces a GC. Mainly useful for testing, but call it if you know a good time to GC in your app. */ +void GC_FORCE_COLLECT(); + +#ifdef __cplusplus +} +#endif + diff --git a/system/include/libc/sys/types.h b/system/include/libc/sys/types.h index 77acc92e..2f887537 100644 --- a/system/include/libc/sys/types.h +++ b/system/include/libc/sys/types.h @@ -140,12 +140,8 @@ typedef unsigned long vm_size_t; #define __BIT_TYPES_DEFINED__ -// XXX Emscripten: removed unsigned types which are already defined -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; -typedef int32_t register_t; +// XXX Emscripten: removed types which are already defined, get them from stdint +#include <stdint.h> #endif /* __MS_types__ */ /* diff --git a/system/include/net/netinet/in.h b/system/include/net/netinet/in.h index 4547696b..9229ca84 100644 --- a/system/include/net/netinet/in.h +++ b/system/include/net/netinet/in.h @@ -39,6 +39,11 @@ struct sockaddr_in6 { int sin6_scope_id; }; +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; + #ifdef __cplusplus } #endif diff --git a/system/include/net/netinet/tcp.h b/system/include/net/netinet/tcp.h new file mode 100644 index 00000000..06e8414b --- /dev/null +++ b/system/include/net/netinet/tcp.h @@ -0,0 +1,246 @@ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H 1 + +#include <features.h> + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ +#define TCP_MAXSEG 2 /* Set maximum segment size */ +#define TCP_CORK 3 /* Control sending of partial frames */ +#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +#define TCP_INFO 11 /* Information about this connection. */ +#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ +#define TCP_CONGESTION 13 /* Congestion control algorithm. */ +#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ + +#ifdef __USE_MISC +# include <sys/types.h> +# include <sys/socket.h> + +# ifdef __FAVOR_BSD +typedef u_int32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr + { + u_int16_t th_sport; /* source port */ + u_int16_t th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +# if __BYTE_ORDER == __LITTLE_ENDIAN + u_int8_t th_x2:4; /* (unused) */ + u_int8_t th_off:4; /* data offset */ +# endif +# if __BYTE_ORDER == __BIG_ENDIAN + u_int8_t th_off:4; /* data offset */ + u_int8_t th_x2:4; /* (unused) */ +# endif + u_int8_t th_flags; +# define TH_FIN 0x01 +# define TH_SYN 0x02 +# define TH_RST 0x04 +# define TH_PUSH 0x08 +# define TH_ACK 0x10 +# define TH_URG 0x20 + u_int16_t th_win; /* window */ + u_int16_t th_sum; /* checksum */ + u_int16_t th_urp; /* urgent pointer */ +}; + +# else /* !__FAVOR_BSD */ +struct tcphdr + { + u_int16_t source; + u_int16_t dest; + u_int32_t seq; + u_int32_t ack_seq; +# if __BYTE_ORDER == __LITTLE_ENDIAN + u_int16_t res1:4; + u_int16_t doff:4; + u_int16_t fin:1; + u_int16_t syn:1; + u_int16_t rst:1; + u_int16_t psh:1; + u_int16_t ack:1; + u_int16_t urg:1; + u_int16_t res2:2; +# elif __BYTE_ORDER == __BIG_ENDIAN + u_int16_t doff:4; + u_int16_t res1:4; + u_int16_t res2:2; + u_int16_t urg:1; + u_int16_t ack:1; + u_int16_t psh:1; + u_int16_t rst:1; + u_int16_t syn:1; + u_int16_t fin:1; +# else +# error "Adjust your <bits/endian.h> defines" +# endif + u_int16_t window; + u_int16_t check; + u_int16_t urg_ptr; +}; +# endif /* __FAVOR_BSD */ + +enum +{ + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING /* now a valid state */ +}; + +# define TCPOPT_EOL 0 +# define TCPOPT_NOP 1 +# define TCPOPT_MAXSEG 2 +# define TCPOLEN_MAXSEG 4 +# define TCPOPT_WINDOW 3 +# define TCPOLEN_WINDOW 3 +# define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +# define TCPOLEN_SACK_PERMITTED 2 +# define TCPOPT_SACK 5 /* Experimental */ +# define TCPOPT_TIMESTAMP 8 +# define TCPOLEN_TIMESTAMP 10 +# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ + +# define TCPOPT_TSTAMP_HDR \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +/* + * Default maximum segment size for TCP. + * With an IP MSS of 576, this is 536, + * but 512 is probably more convenient. + * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + */ +# define TCP_MSS 512 + +# define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ + +# define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +# define SOL_TCP 6 /* TCP level */ + + +# define TCPI_OPT_TIMESTAMPS 1 +# define TCPI_OPT_SACK 2 +# define TCPI_OPT_WSCALE 4 +# define TCPI_OPT_ECN 8 + +/* Values for tcpi_state. */ +enum tcp_ca_state +{ + TCP_CA_Open = 0, + TCP_CA_Disorder = 1, + TCP_CA_CWR = 2, + TCP_CA_Recovery = 3, + TCP_CA_Loss = 4 +}; + +struct tcp_info +{ + u_int8_t tcpi_state; + u_int8_t tcpi_ca_state; + u_int8_t tcpi_retransmits; + u_int8_t tcpi_probes; + u_int8_t tcpi_backoff; + u_int8_t tcpi_options; + u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; + + u_int32_t tcpi_rto; + u_int32_t tcpi_ato; + u_int32_t tcpi_snd_mss; + u_int32_t tcpi_rcv_mss; + + u_int32_t tcpi_unacked; + u_int32_t tcpi_sacked; + u_int32_t tcpi_lost; + u_int32_t tcpi_retrans; + u_int32_t tcpi_fackets; + + /* Times. */ + u_int32_t tcpi_last_data_sent; + u_int32_t tcpi_last_ack_sent; /* Not remembered, sorry. */ + u_int32_t tcpi_last_data_recv; + u_int32_t tcpi_last_ack_recv; + + /* Metrics. */ + u_int32_t tcpi_pmtu; + u_int32_t tcpi_rcv_ssthresh; + u_int32_t tcpi_rtt; + u_int32_t tcpi_rttvar; + u_int32_t tcpi_snd_ssthresh; + u_int32_t tcpi_snd_cwnd; + u_int32_t tcpi_advmss; + u_int32_t tcpi_reordering; + + u_int32_t tcpi_rcv_rtt; + u_int32_t tcpi_rcv_space; + + u_int32_t tcpi_total_retrans; +}; + + +/* For TCP_MD5SIG socket option. */ +#define TCP_MD5SIG_MAXKEYLEN 80 + +struct tcp_md5sig +{ + struct sockaddr_storage tcpm_addr; /* Address associated. */ + u_int16_t __tcpm_pad1; /* Zero. */ + u_int16_t tcpm_keylen; /* Key length. */ + u_int32_t __tcpm_pad2; /* Zero. */ + u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */ +}; + +#endif /* Misc. */ + +#endif /* netinet/tcp.h */ diff --git a/system/include/sys/socket.h b/system/include/sys/socket.h index 33c10932..69bbdcaa 100644 --- a/system/include/sys/socket.h +++ b/system/include/sys/socket.h @@ -65,6 +65,11 @@ struct msghdr int msg_flags; }; +struct linger { + int l_onoff; + int l_linger; +}; + #ifdef __cplusplus } #endif diff --git a/system/include/sys/socketvar.h b/system/include/sys/socketvar.h new file mode 100644 index 00000000..58fe99cf --- /dev/null +++ b/system/include/sys/socketvar.h @@ -0,0 +1,3 @@ + +#include <sys/socket.h> + diff --git a/system/lib/libcxx/Makefile b/system/lib/libcxx/Makefile index 98a5974d..814921ea 100644 --- a/system/lib/libcxx/Makefile +++ b/system/lib/libcxx/Makefile @@ -12,7 +12,6 @@ OBJECTS = \ debug.bc \ hash.bc \ mutex.bc \ - readme.txt \ string.bc \ thread.bc \ valarray.bc \ diff --git a/tests/browser_gc.cpp b/tests/browser_gc.cpp new file mode 100644 index 00000000..75dea10a --- /dev/null +++ b/tests/browser_gc.cpp @@ -0,0 +1,96 @@ +#include <stdio.h> +#include <gc.h> +#include <assert.h> +#include <emscripten.h> + +void *global; + +int freed = 0; + +void finalizer(void *ptr, void *arg) { + printf("finalizing %d (global == %d)\n", (int)arg, ptr == global); + freed++; + if (ptr == global) global = 0; +} + +int stage = 0; +float start = 0; + +void waiter() { + if (stage == 0) { // wait for a while, see no GCing + assert(global); + if (emscripten_get_now() - start > 2100) { + GC_MALLOC(1024*1024*2); // allocate enough to trigger a GC + start = emscripten_get_now(); + stage = 1; + printf("stage 1\n"); + } + } else if (stage == 1) { + assert(global); + if (freed > 0) { + GC_FREE(global); + stage = 2; + start = emscripten_get_now(); + printf("stage 2\n"); + } + if (emscripten_get_now() - start > 2100) { + printf("fail, too much time passed (a)\n"); + return; + } + } else if (stage == 2) { + if (emscripten_get_now() - start > 2100) { // wait and see that no gc'ing happens yet + GC_MALLOC(1024*1024*2); // allocate enough to trigger a GC + stage = 3; + start = emscripten_get_now(); + printf("stage 3\n"); + } + } else if (stage == 3) { + assert(!global); + if (freed == 5) { + printf("Ok.\n"); + int result = 1; + REPORT_RESULT(); + return; + } + if (emscripten_get_now() - start > 2100) { + printf("fail, too much time passed (b)\n"); + return; + } + } + + emscripten_async_call(waiter, 100); +} + +int main() { + start = emscripten_get_now(); + + GC_INIT(); + + void *local, *local2, *local3, *local4; + + global = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0); + local = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0); + local2 = GC_MALLOC_ATOMIC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local2, finalizer, (void*)2, 0, 0); + local3 = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer, (void*)3, 0, 0); + local4 = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer, (void*)4, 0, 0); + + void **globalData = (void**)global; + globalData[0] = local; + globalData[1] = local2; + + void **localData = (void**)local; + localData[0] = local3; + + void **local2Data = (void**)local2; + local2Data[0] = local4; // actually ignored, because local2 is atomic, so 4 is freeable + + emscripten_async_call(waiter, 100); + + return 0; +} + diff --git a/tests/cases/phientryimplicitmoar.ll b/tests/cases/phientryimplicitmoar.ll new file mode 100644 index 00000000..c83458e6 --- /dev/null +++ b/tests/cases/phientryimplicitmoar.ll @@ -0,0 +1,28 @@ +; ModuleID = 'tests/hello_world.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +target triple = "i386-pc-linux-gnu" + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] +@.str2 = private unnamed_addr constant [15 x i8] c"hello!!world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +define i32 @main() { + %retval = alloca i32, align 4 + %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str2, i32 0, i32 0)) + %a12 = zext i1 1 to i32 + br label %13 + +; <label>:13 ; preds = %13, %1 + %a14 = phi i32 [ %a12, %1 ], [ %a15, %13 ] + %call0 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) + %a15 = add nsw i32 %a14, 2 + %a16 = icmp eq i32 %a15, 9 + br i1 %a16, label %17, label %13 + +; <label>:17 ; preds = %1 + %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str2, i32 0, i32 0)) + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + diff --git a/tests/cases/phientryimplicitmoar.txt b/tests/cases/phientryimplicitmoar.txt new file mode 100644 index 00000000..50e5e9ae --- /dev/null +++ b/tests/cases/phientryimplicitmoar.txt @@ -0,0 +1,6 @@ +hello!!world! +hello, world! +hello, world! +hello, world! +hello, world! +hello!!world! diff --git a/tests/cases/phinonexist.ll b/tests/cases/phinonexist.ll new file mode 100644 index 00000000..145d2221 --- /dev/null +++ b/tests/cases/phinonexist.ll @@ -0,0 +1,25 @@ +; ModuleID = 'tests/hello_world.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +target triple = "i386-pc-linux-gnu" + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +define i32 @main() { + %retval = alloca i32, align 4 + %a12 = zext i1 1 to i32 + br label %13 + +; <label>:13 ; preds = %13, %1 + %a14 = phi i32 [ %a12, %1 ], [ %a15, %135 ] + %call0 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) + %a15 = add nsw i32 %a14, 2 + %a16 = icmp eq i32 %a15, 9 + br label %17 + +; <label>:17 ; preds = %1 + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + diff --git a/tests/cube_explosion.c b/tests/cube_explosion.c new file mode 100644 index 00000000..ee990a57 --- /dev/null +++ b/tests/cube_explosion.c @@ -0,0 +1,235 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8) + ((y*16) << 16) + 0xff331177; + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + // cubegeom: glFrustum(-0.6435469817188064, 0.1435469817188064, -0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.6435469817188064, -0.48266022190470925, 0.48266022190470925, 0.5400000214576721, 2048); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + // cubegeom glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + glRotated(0, 0, 1, 0); + glRotated(0, -1, 0, 0); + glRotated(0, 0, 0, -1); + glTranslated(-512,-512,-527); + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + GLint ok; + + const char *vertexShader = + "uniform vec4 center, animstate;\n" + "uniform vec4 texgenS, texgenT;\n" + "void main(void)\n" + "{\n" + " vec4 wobble = vec4(gl_Vertex.xyz*(1.0 + 0.5*abs(fract(dot(gl_Vertex.xyz, center.xyz) + animstate.w*0.002) - 0.5)), gl_Vertex.w);\n" + " gl_Position = gl_ModelViewProjectionMatrix * wobble;\n" + " gl_FrontColor = gl_Color;\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" + " vec2 texgen = vec2(dot(texgenS, gl_Vertex), dot(texgenT, gl_Vertex)); \n" + " gl_TexCoord[1].xy = texgen;\n" + " gl_TexCoord[2].xy = texgen - animstate.w*0.0005;\n" + "}\n"; + const char *fragmentShader = + "uniform sampler2D tex2;\n" + "uniform sampler2D tex0, tex1;\n" + "void main(void)\n" + "{\n" + " vec2 dtc = gl_TexCoord[0].xy + texture2D(tex0, gl_TexCoord[2].xy).xy*0.1; \n" + " vec4 diffuse = texture2D(tex0, dtc);\n" + " vec4 blend = texture2D(tex1, gl_TexCoord[1].xy); \n" + " diffuse *= blend.a*4.0; \n" + " diffuse.b += 0.5 - blend.a*0.5; \n" + " gl_FragColor = diffuse * gl_Color;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + // get active uniform data for 10 uniforms. XXX they include our additions from shader rewriting! XXX + + // gen texture, we already has one + + GLuint arrayBuffer; + glGenBuffers(1, &arrayBuffer); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + GLubyte arrayBufferData[] = +{0,0,0,128,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,128,0,0,0,0,0,0,128,63,171,170,170,61,0,0,128,63,0,0,0,128,0,0,0,0,0,0,128,63,171,170,42,62,0,0,128,63,0,0,0,128,0,0,0,0,0,0,128,63,0,0,128,62,0,0,128,63,0,0,0,128,0,0,0,128,0,0,128,63,171,170,170,62,0,0,128,63,0,0,0,128,0,0,0,128,0,0,128,63,85,85,213,62,0,0,128,63,0,0,0,128,0,0,0,128,0,0,128,63,0,0,0,63,0,0,128,63,0,0,0,0,0,0,0,128,0,0,128,63,85,85,21,63,0,0,128,63,0,0,0,0,0,0,0,128,0,0,128,63,171,170,42,63,0,0,128,63,0,0,0,0,0,0,0,128,0,0,128,63,0,0,64,63,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,85,85,85,63,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,171,170,106,63,0,0,128,63,0,0,0,128,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,128,0,0,0,63,215,179,93,63,0,0,0,0,85,85,85,63,0,0,128,190,215,179,221,62,215,179,93,63,171,170,170,61,85,85,85,63,215,179,221,190,0,0,128,62,215,179,93,63,171,170,42,62,85,85,85,63,0,0,0,191,0,48,13,36,215,179,93,63,0,0,128,62,85,85,85,63,215,179,221,190,0,0,128,190,215,179,93,63,171,170,170,62,85,85,85,63,0,0,128,190,215,179,221,190,215,179,93,63,85,85,213,62,85,85,85,63,0,76,163,165,0,0,0,191,215,179,93,63,0,0,0,63,85,85,85,63,0,0,128,62,215,179,221,190,215,179,93,63,85,85,21,63,85,85,85,63,215,179,221,62,0,0,128,190,215,179,93,63,171,170,42,63,85,85,85,63,0,0,0,63,0,200,211,164,215,179,93,63,0,0,64,63,85,85,85,63,215,179,221,62,0,0,128,62,215,179,93,63,85,85,85,63,85,85,85,63,0,0,128,62,215,179,221,62,215,179,93,63,171,170,106,63,85,85,85,63,0,0,0,128,0,0,0,63,215,179,93,63,0,0,128,63,85,85,85,63,0,0,0,128,215,179,93,63,0,0,0,63,0,0,0,0,171,170,42,63,215,179,221,190,0,0,64,63,0,0,0,63,171,170,170,61,171,170,42,63,0,0,64,191,215,179,221,62,0,0,0,63,171,170,42,62,171,170,42,63,215,179,93,191,63,139,116,36,0,0,0,63,0,0,128,62,171,170,42,63,0,0,64,191,215,179,221,190,0,0,0,63,171,170,170,62,171,170,42,63,215,179,221,190,0,0,64,191,0,0,0,63,85,85,213,62,171,170,42,63,83,107,13,166,215,179,93,191,0,0,0,63,0,0,0,63,171,170,42,63,215,179,221,62,0,0,64,191,0,0,0,63,85,85,21,63,171,170,42,63,0,0,64,63,215,179,221,190,0,0,0,63,171,170,42,63,171,170,42,63,215,179,93,63,111,104,55,165,0,0,0,63,0,0,64,63,171,170,42,63,0,0,64,63,215,179,221,62,0,0,0,63,85,85,85,63,171,170,42,63,215,179,221,62,0,0,64,63,0,0,0,63,171,170,106,63,171,170,42,63,0,0,0,128,215,179,93,63,0,0,0,63,0,0,128,63,171,170,42,63,0,0,0,128,0,0,128,63,0,166,17,38,0,0,0,0,0,0,0,63,0,0,0,191,215,179,93,63,0,166,17,38,171,170,170,61,0,0,0,63,215,179,93,191,0,0,0,63,0,166,17,38,171,170,42,62,0,0,0,63,0,0,128,191,0,48,141,36,0,166,17,38,0,0,128,62,0,0,0,63,215,179,93,191,0,0,0,191,0,166,17,38,171,170,170,62,0,0,0,63,0,0,0,191,215,179,93,191,0,166,17,38,85,85,213,62,0,0,0,63,0,76,35,166,0,0,128,191,0,166,17,38,0,0,0,63,0,0,0,63,0,0,0,63,215,179,93,191,0,166,17,38,85,85,21,63,0,0,0,63,215,179,93,63,0,0,0,191,0,166,17,38,171,170,42,63,0,0,0,63,0,0,128,63,0,200,83,165,0,166,17,38,0,0,64,63,0,0,0,63,215,179,93,63,0,0,0,63,0,166,17,38,85,85,85,63,0,0,0,63,0,0,0,63,215,179,93,63,0,166,17,38,171,170,106,63,0,0,0,63,0,0,0,128,0,0,128,63,0,166,17,38,0,0,128,63,0,0,0,63,0,0,0,128,215,179,93,63,0,0,0,191,0,0,0,0,171,170,170,62,215,179,221,190,0,0,64,63,0,0,0,191,171,170,170,61,171,170,170,62,0,0,64,191,215,179,221,62,0,0,0,191,171,170,42,62,171,170,170,62,215,179,93,191,63,139,116,36,0,0,0,191,0,0,128,62,171,170,170,62,0,0,64,191,215,179,221,190,0,0,0,191,171,170,170,62,171,170,170,62,215,179,221,190,0,0,64,191,0,0,0,191,85,85,213,62,171,170,170,62,83,107,13,166,215,179,93,191,0,0,0,191,0,0,0,63,171,170,170,62,215,179,221,62,0,0,64,191,0,0,0,191,85,85,21,63,171,170,170,62,0,0,64,63,215,179,221,190,0,0,0,191,171,170,42,63,171,170,170,62,215,179,93,63,111,104,55,165,0,0,0,191,0,0,64,63,171,170,170,62,0,0,64,63,215,179,221,62,0,0,0,191,85,85,85,63,171,170,170,62,215,179,221,62,0,0,64,63,0,0,0,191,171,170,106,63,171,170,170,62,0,0,0,128,215,179,93,63,0,0,0,191,0,0,128,63,171,170,170,62,0,0,0,128,0,0,0,63,215,179,93,191,0,0,0,0,171,170,42,62,0,0,128,190,215,179,221,62,215,179,93,191,171,170,170,61,171,170,42,62,215,179,221,190,0,0,128,62,215,179,93,191,171,170,42,62,171,170,42,62,0,0,0,191,0,48,13,36,215,179,93,191,0,0,128,62,171,170,42,62,215,179,221,190,0,0,128,190,215,179,93,191,171,170,170,62,171,170,42,62,0,0,128,190,215,179,221,190,215,179,93,191,85,85,213,62,171,170,42,62,0,76,163,165,0,0,0,191,215,179,93,191,0,0,0,63,171,170,42,62,0,0,128,62,215,179,221,190,215,179,93,191,85,85,21,63,171,170,42,62,215,179,221,62,0,0,128,190,215,179,93,191,171,170,42,63,171,170,42,62,0,0,0,63,0,200,211,164,215,179,93,191,0,0,64,63,171,170,42,62,215,179,221,62,0,0,128,62,215,179,93,191,85,85,85,63,171,170,42,62,0,0,128,62,215,179,221,62,215,179,93,191,171,170,106,63,171,170,42,62,0,0,0,128,0,0,0,63,215,179,93,191,0,0,128,63,171,170,42,62,0,0,0,128,0,166,145,38,0,0,128,191,0,0,0,0,0,0,64,37,0,166,17,166,63,69,124,38,0,0,128,191,171,170,170,61,0,0,64,37,63,69,124,166,0,166,17,38,0,0,128,191,171,170,42,62,0,0,64,37,0,166,145,166,122,167,160,11,0,0,128,191,0,0,128,62,0,0,64,37,63,69,124,166,0,166,17,166,0,0,128,191,171,170,170,62,0,0,64,37,0,166,17,166,63,69,124,166,0,0,128,191,85,85,213,62,0,0,64,37,223,207,57,141,0,166,145,166,0,0,128,191,0,0,0,63,0,0,64,37,0,166,17,38,63,69,124,166,0,0,128,191,85,85,21,63,0,0,64,37,63,69,124,38,0,166,17,166,0,0,128,191,171,170,42,63,0,0,64,37,0,166,145,38,55,251,112,140,0,0,128,191,0,0,64,63,0,0,64,37,63,69,124,38,0,166,17,38,0,0,128,191,85,85,85,63,0,0,64,37,0,166,17,38,63,69,124,38,0,0,128,191,171,170,106,63,0,0,64,37,0,0,0,128,0,166,145,38,0,0,128,191,0,0,128,63,0,0,64,37}; + glBufferData(GL_ARRAY_BUFFER, 1820, arrayBufferData, GL_STATIC_DRAW); + + GLuint elementBuffer; + glGenBuffers(1, &elementBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + GLubyte elementBufferData[] = +{0,0,13,0,1,0,1,0,13,0,14,0,1,0,14,0,2,0,2,0,14,0,15,0,2,0,15,0,3,0,3,0,15,0,16,0,3,0,16,0,4,0,4,0,16,0,17,0,4,0,17,0,5,0,5,0,17,0,18,0,5,0,18,0,6,0,6,0,18,0,19,0,6,0,19,0,7,0,7,0,19,0,20,0,7,0,20,0,8,0,8,0,20,0,21,0,8,0,21,0,9,0,9,0,21,0,22,0,9,0,22,0,10,0,10,0,22,0,23,0,10,0,23,0,11,0,11,0,23,0,24,0,11,0,24,0,12,0,12,0,24,0,25,0,24,0,37,0,25,0,25,0,37,0,38,0,23,0,36,0,24,0,24,0,36,0,37,0,22,0,35,0,23,0,23,0,35,0,36,0,21,0,34,0,22,0,22,0,34,0,35,0,20,0,33,0,21,0,21,0,33,0,34,0,19,0,32,0,20,0,20,0,32,0,33,0,18,0,31,0,19,0,19,0,31,0,32,0,17,0,30,0,18,0,18,0,30,0,31,0,16,0,29,0,17,0,17,0,29,0,30,0,15,0,28,0,16,0,16,0,28,0,29,0,14,0,27,0,15,0,15,0,27,0,28,0,13,0,26,0,14,0,14,0,26,0,27,0,26,0,39,0,27,0,27,0,39,0,40,0,27,0,40,0,28,0,28,0,40,0,41,0,28,0,41,0,29,0,29,0,41,0,42,0,29,0,42,0,30,0,30,0,42,0,43,0,30,0,43,0,31,0,31,0,43,0,44,0,31,0,44,0,32,0,32,0,44,0,45,0,32,0,45,0,33,0,33,0,45,0,46,0,33,0,46,0,34,0,34,0,46,0,47,0,34,0,47,0,35,0,35,0,47,0,48,0,35,0,48,0,36,0,36,0,48,0,49,0,36,0,49,0,37,0,37,0,49,0,50,0,37,0,50,0,38,0,38,0,50,0,51,0,50,0,63,0,51,0,51,0,63,0,64,0,49,0,62,0,50,0,50,0,62,0,63,0,48,0,61,0,49,0,49,0,61,0,62,0,47,0,60,0,48,0,48,0,60,0,61,0,46,0,59,0,47,0,47,0,59,0,60,0,45,0,58,0,46,0,46,0,58,0,59,0,44,0,57,0,45,0,45,0,57,0,58,0,43,0,56,0,44,0,44,0,56,0,57,0,42,0,55,0,43,0,43,0,55,0,56,0,41,0,54,0,42,0,42,0,54,0,55,0,40,0,53,0,41,0,41,0,53,0,54,0,39,0,52,0,40,0,40,0,52,0,53,0,52,0,65,0,53,0,53,0,65,0,66,0,53,0,66,0,54,0,54,0,66,0,67,0,54,0,67,0,55,0,55,0,67,0,68,0,55,0,68,0,56,0,56,0,68,0,69,0,56,0,69,0,57,0,57,0,69,0,70,0,57,0,70,0,58,0,58,0,70,0,71,0,58,0,71,0,59,0,59,0,71,0,72,0,59,0,72,0,60,0,60,0,72,0,73,0,60,0,73,0,61,0,61,0,73,0,74,0,61,0,74,0,62,0,62,0,74,0,75,0,62,0,75,0,63,0,63,0,75,0,76,0,63,0,76,0,64,0,64,0,76,0,77,0,76,0,89,0,77,0,77,0,89,0,90,0,75,0,88,0,76,0,76,0,88,0,89,0,74,0,87,0,75,0,75,0,87,0,88,0,73,0,86,0,74,0,74,0,86,0,87,0,72,0,85,0,73,0,73,0,85,0,86,0,71,0,84,0,72,0,72,0,84,0,85,0,70,0,83,0,71,0,71,0,83,0,84,0,69,0,82,0,70,0,70,0,82,0,83,0,68,0,81,0,69,0,69,0,81,0,82,0,67,0,80,0,68,0,68,0,80,0,81,0,66,0,79,0,67,0,67,0,79,0,80,0,65,0,78,0,66,0,66,0,78,0,79,0}; + glBufferData(GL_ELEMENT_ARRAY_BUFFER, 864, elementBufferData, GL_STATIC_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // try to confuse the client state tracker + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(3, GL_FLOAT, 20, 0); + glTexCoordPointer(2, GL_FLOAT, 20, (void*)12); + + glPushMatrix(); + glTranslated(484.50579833984375, 589.3919067382812, 528.0055541992188); + + GLint texgenSLocation = glGetUniformLocation(program, "texgenS"); + assert(texgenSLocation >= 0); + GLfloat texgenSData[4] = { 0.31012535095214844, 0.05928778275847435, 0.38769474625587463, 0.5 }; + glUniform4fv(texgenSLocation, 1, texgenSData); + + GLint texgenTLocation = glGetUniformLocation(program, "texgenT"); + assert(texgenTLocation >= 0 && texgenTLocation != texgenSLocation); + GLfloat texgenTData[4] = { -0.12697559595108032, -0.4524572193622589, 0.17076200246810913, 0.5 }; + glUniform4fv(texgenTLocation, 1, texgenTData); + + GLint centerLocation = glGetUniformLocation(program, "center"); + if (centerLocation >= 0) { + GLfloat centerData[4] = { 484.50579833984375, 589.3919067382812, 528.0055541992188, 0 }; + glUniform4fv(centerLocation, 1, centerData); + } + + GLint animstateLocation = glGetUniformLocation(program, "animstate"); + assert(animstateLocation >= 0); + GLfloat animstateData[4] = { 1, 55, 51, 10709 }; + glUniform4fv(animstateLocation, 1, animstateData); + + glRotated(1529.857142857143, 0.5773502588272095, 0.5773502588272095, 0.5773502588272095); + glScaled(-55, 55, -55); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture); // XXX this is after setting Pointers, do we miss it? Also, does it not need clientActiveTexture - should we have updated that? + glActiveTexture(GL_TEXTURE0); + glColor4f(1, 0.158823529411764705, 0.058823529411764705, 1); + + glDrawElements(GL_TRIANGLES, 432, GL_UNSIGNED_SHORT, 0); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom.c b/tests/cubegeom.c new file mode 100644 index 00000000..ecefb24a --- /dev/null +++ b/tests/cubegeom.c @@ -0,0 +1,295 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/100.0 + texgenscroll.xy;\n" // added /100 here + " gl_TexCoord[1].xy = gl_MultiTexCoord1.xy/100.0 * 3.051851e-05;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = diffuse * lm;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_color.c b/tests/cubegeom_color.c new file mode 100644 index 00000000..7d384324 --- /dev/null +++ b/tests/cubegeom_color.c @@ -0,0 +1,295 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 128, 255, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 255, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 196, 128, 255, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 0, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 64, 128, 255, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 100, 128, 255, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/100.0 + texgenscroll.xy;\n" // added /100 here + " gl_TexCoord[1] = gl_Color;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = (diffuse * lm * 0.2) + gl_TexCoord[1];\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_color2.c b/tests/cubegeom_color2.c new file mode 100644 index 00000000..5294329d --- /dev/null +++ b/tests/cubegeom_color2.c @@ -0,0 +1,299 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 128, 255, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 255, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 196, 128, 255, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 0, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 64, 128, 255, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 100, 128, 255, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/100.0 + texgenscroll.xy;\n" // added /100 here + " gl_TexCoord[1] = gl_Color;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = (diffuse * lm * 0.2) + gl_TexCoord[1];\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + + // Disable the color attrib, and use a fixed color + glDisableClientState(GL_COLOR_ARRAY); + glColor3f(1.0, 0.25, 0.33); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_mt.c b/tests/cubegeom_mt.c new file mode 100644 index 00000000..464de7cc --- /dev/null +++ b/tests/cubegeom_mt.c @@ -0,0 +1,300 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8) + ((x*y) << 16); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0x00, 0x00, 0xff, 0x77, + 0x00, 0x44, 0xaa, 0x77, + 0x44, 0x00, 0xcc, 0x77, + 0x00, 0x44, 0x77, 0x77 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 1, 0, 1, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 1, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 1, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 1, 0, 1, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 1, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 1, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 1, 0, 1, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 1, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 1, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 1, 0, 1, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 1, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + + glClientActiveTexture(GL_TEXTURE1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + + glClientActiveTexture(GL_TEXTURE0); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/100.0 + texgenscroll.xy;\n" // added /100 here + " gl_TexCoord[1].xy = gl_MultiTexCoord1.xy/100.0 * 3.051851e-05;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = diffuse * lm;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_normal.c b/tests/cubegeom_normal.c new file mode 100644 index 00000000..d128fef2 --- /dev/null +++ b/tests/cubegeom_normal.c @@ -0,0 +1,295 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 11, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 23, 20, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 35, 30, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 47, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 51, 50, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 64, 60, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 70, 70, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 89, 80, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 94, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 20, 10, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 31, 20, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 42, 30, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 53, 40, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 64, 50, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 75, 60, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 86, 70, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/10000.0 + (0.001*texgenscroll.xy) + gl_Normal.xy;\n" // added /100 here + " gl_TexCoord[1].xy = gl_MultiTexCoord1.xy/100.0 * 3.051851e-05;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = diffuse * lm;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_pre.c b/tests/cubegeom_pre.c new file mode 100644 index 00000000..8001a2b8 --- /dev/null +++ b/tests/cubegeom_pre.c @@ -0,0 +1,307 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + //glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + + glActiveTexture(GL_TEXTURE0); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "attribute vec4 a_position;\n" + "attribute vec4 a_texCoord0;\n" + "uniform mat4 u_modelView;\n" + "uniform mat4 u_projection;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" + " gl_Position = (u_projection * u_modelView * a_position) + vec4(200, 0, 0, 0);\n" + " v_texCoord0.xy = a_texCoord0.xy/20.0;\n" // added /20 here + "}\n"; + const char *fragmentShader = "uniform sampler2D diffusemap;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, v_texCoord0.xy);\n" + " gl_FragColor = diffuse;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with vertex\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with fragment\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + { + GLfloat data[16]; + glGetFloatv(GL_MODELVIEW_MATRIX, data); + printf("Modelview: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + GLint modelViewLocation = glGetUniformLocation(program, "u_modelView"); + assert(modelViewLocation >= 0); + glUniformMatrix4fv(modelViewLocation, 1, GL_FALSE, data); + } + { + GLfloat data[16]; + glGetFloatv(GL_PROJECTION_MATRIX, data); + printf("Projection: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + GLint projectionLocation = glGetUniformLocation(program, "u_projection"); + assert(projectionLocation >= 0); + glUniformMatrix4fv(projectionLocation, 1, GL_FALSE, data); + } + + glBindAttribLocation(program, 0, "a_position"); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 32, (void*)0); + glEnableVertexAttribArray(0); + + glBindAttribLocation(program, 1, "a_texCoord0"); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 32, (void*)16); + glEnableVertexAttribArray(1); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/cubegeom_pre2.c b/tests/cubegeom_pre2.c new file mode 100644 index 00000000..ae8dcf9f --- /dev/null +++ b/tests/cubegeom_pre2.c @@ -0,0 +1,348 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + //glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + +// glEnable(GL_CULL_FACE); + // glEnable(GL_DEPTH_TEST); + + //glClear(GL_DEPTH_BUFFER_BIT); + +// glEnableClientState(GL_NORMAL_ARRAY); + // glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); +// glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build +// glTexCoordPointer(2, GL_SHORT, 32, (void*)24); +// glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup +// glNormalPointer(GL_BYTE, 32, (void*)12); +// glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform mat4 u_modelView;\n" + "uniform mat4 u_projection;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" // (gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex) + // (u_projection * u_modelView * a_position) + " gl_Position = (u_projection * u_modelView * gl_Vertex) + vec4(200, 0, 0, 0);\n" + " v_texCoord0.xy = gl_MultiTexCoord0.xy/20.0;\n" // added /100 here + "}\n"; + const char *fragmentShader = "uniform sampler2D diffusemap;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, v_texCoord0.xy);\n" + " gl_FragColor = diffuse;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with vertex\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with fragment\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + //GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + //assert(lightmapLocation >= 0); + //glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + //GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + //assert(texgenscrollLocation >= 0); + + //GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + //assert(colorparamsLocation >= 0); + + //GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + //glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + //GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + //glUniform4fv(colorparamsLocation, 1, colorparamsData); + + { + GLfloat data[16]; + glGetFloatv(GL_MODELVIEW_MATRIX, data); + printf("Modelview: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + //memset(data, 0, 16*4); + GLint modelViewLocation = glGetUniformLocation(program, "u_modelView"); + assert(modelViewLocation >= 0); + glUniformMatrix4fv(modelViewLocation, 1, GL_FALSE, data); + } + { + GLfloat data[16]; + glGetFloatv(GL_PROJECTION_MATRIX, data); + printf("Projection: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + //memset(data, 0, 16*4); + GLint projectionLocation = glGetUniformLocation(program, "u_projection"); + assert(projectionLocation >= 0); + glUniformMatrix4fv(projectionLocation, 1, GL_FALSE, data); + } + +/* + glBindAttribLocation(program, 0, "a_position"); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 32, (void*)0); + glEnableVertexAttribArray(0); + + glBindAttribLocation(program, 1, "v_texCoord0"); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 32, (void*)16); + glEnableVertexAttribArray(1); +*/ + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + // SDL_Quit(); + + return 0; +} + diff --git a/tests/cubegeom_pre3.c b/tests/cubegeom_pre3.c new file mode 100644 index 00000000..a1f811b6 --- /dev/null +++ b/tests/cubegeom_pre3.c @@ -0,0 +1,348 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + //glTranslated(-512,-512,-527); // XXX this should be uncommented, but if it is then nothing is shown + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 128, 128, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform mat4 u_modelView;\n" + "uniform mat4 u_projection;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" // (gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex) + // (u_projection * u_modelView * a_position) + " gl_Position = (u_projection * u_modelView * gl_Vertex) + vec4(200, 0, 0, 0);\n" + " v_texCoord0.xy = gl_MultiTexCoord0.xy/20.0;\n" // added /100 here + "}\n"; + const char *fragmentShader = "uniform sampler2D diffusemap;\n" + "varying vec4 v_texCoord0;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, v_texCoord0.xy);\n" + " gl_FragColor = diffuse;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with vertex\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + if (!ok) { + printf("Shader compilation error with fragment\n"); + GLint infoLen = 0; + glGetShaderiv (vs, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + char* infoLog = (char *)malloc(sizeof(char) * infoLen+1); + glGetShaderInfoLog(vs, infoLen, NULL, infoLog); + printf("Error compiling shader:\n%s\n", infoLog); + } + } + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + //GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + //assert(lightmapLocation >= 0); + //glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + //GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + //assert(texgenscrollLocation >= 0); + + //GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + //assert(colorparamsLocation >= 0); + + //GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + //glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + //GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + //glUniform4fv(colorparamsLocation, 1, colorparamsData); + + { + GLfloat data[16]; + glGetFloatv(GL_MODELVIEW_MATRIX, data); + printf("Modelview: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + //memset(data, 0, 16*4); + GLint modelViewLocation = glGetUniformLocation(program, "u_modelView"); + assert(modelViewLocation >= 0); + glUniformMatrix4fv(modelViewLocation, 1, GL_FALSE, data); + } + { + GLfloat data[16]; + glGetFloatv(GL_PROJECTION_MATRIX, data); + printf("Projection: "); + for (int i = 0; i < 16; i++) printf("%.3f, ", data[i]); + printf("\n"); + //memset(data, 0, 16*4); + GLint projectionLocation = glGetUniformLocation(program, "u_projection"); + assert(projectionLocation >= 0); + glUniformMatrix4fv(projectionLocation, 1, GL_FALSE, data); + } + +/* + glBindAttribLocation(program, 0, "a_position"); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 32, (void*)0); + glEnableVertexAttribArray(0); + + glBindAttribLocation(program, 1, "v_texCoord0"); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 32, (void*)16); + glEnableVertexAttribArray(1); +*/ + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + // SDL_Quit(); + + return 0; +} + diff --git a/tests/cubegeom_texturematrix.c b/tests/cubegeom_texturematrix.c new file mode 100644 index 00000000..229bf2a8 --- /dev/null +++ b/tests/cubegeom_texturematrix.c @@ -0,0 +1,312 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void verify() { + int width = 640, height = 480; + unsigned char *data = (unsigned char*)malloc(width*height*4); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + int sum = 0; + for (int x = 0; x < width*height*4; x++) { + if (x % 4 != 3) sum += x * data[x]; + } +#if EMSCRIPTEN + int result = sum; + REPORT_RESULT(); +#endif +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + glClearColor( 0, 0, 0, 0 ); + glClear( GL_COLOR_BUFFER_BIT ); + + // Create a texture + + GLuint texture; + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte textureData[16*16*4]; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8); + } + } + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, textureData ); + + // Create a second texture + + GLuint texture2; + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLubyte texture2Data[] = { 0xff, 0, 0, 0xff, + 0, 0xff, 0, 0xaa, + 0, 0, 0xff, 0x55, + 0x80, 0x90, 0x70, 0 }; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texture2Data ); + + // BEGIN + +#if USE_GLEW + glewInit(); +#endif + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // original: glFrustum(-0.6435469817188064, 0.6435469817188064 ,-0.48266022190470925, 0.48266022190470925 ,0.5400000214576721, 2048); + glFrustum(-0.6435469817188064, 0.1435469817188064 ,-0.48266022190470925, 0.88266022190470925 ,0.5400000214576721, 2048); + glRotatef(-30, 1, 1, 1); + //GLfloat pm[] = { 1.372136116027832, 0, 0, 0, 0, 0.7910231351852417, 0, 0, -0.6352481842041016, 0.29297152161598206, -1.0005275011062622, -1, 0, 0, -1.080284833908081, 0 }; + //glLoadMatrixf(pm); + + glMatrixMode(GL_MODELVIEW); + GLfloat matrixData[] = { -1, 0, 0, 0, + 0, 0,-1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 }; + glLoadMatrixf(matrixData); + + glActiveTexture(GL_TEXTURE0); // TODO: try 1 + glMatrixMode(GL_TEXTURE); + GLfloat tm[] = { 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 }; + glLoadMatrixf(tm); + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glClear(GL_DEPTH_BUFFER_BIT); + + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_VERTEX_ARRAY); + + GLuint arrayBuffer, elementBuffer; + glGenBuffers(1, &arrayBuffer); + glGenBuffers(1, &elementBuffer); + + GLubyte arrayData[] = { +/* +[0, 0, 0, 67] ==> 128 float +[0, 0, 128, 67] ==> 256 float +[0, 0, 0, 68] ==> 512 float +[0, 0, 128, 68] ==> 1024 float + +[vertex x ] [vertex y ] [vertex z ] [nr] [texture u ] [texture v ] [lm u ] [lm v ] [color r,g,b,a ] */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 128, 255, 128, // 0 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 1 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 128, // 2 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 255, // 3 + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 196, 128, 255, 128, // 4 + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 255, 128, // 5 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 6 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 64, 255, 0, // 7 + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 64, 128, 255, 128, // 8 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 9 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 10 + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 11 + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 67, 0, 0, 0, 0, 100, 128, 255, 128, // 12 + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 0, 67, 0, 0, 0, 0, 128, 0, 255, 128, // 13 + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 128, // 14 + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 128, 67, 0, 0, 0, 0, 128, 128, 255, 0, // 15 + + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 0, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 128, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, + 0, 0, 128, 68, 0, 0, 128, 68, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128 + }; + assert(sizeof(arrayData) == 1408); + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(arrayData), arrayData, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 }; + assert(sizeof(elementData) == 48); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementData), elementData, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + + // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B + glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound + glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build + glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup + glNormalPointer(GL_BYTE, 32, (void*)12); + glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); + + glBindTexture(GL_TEXTURE_2D, texture); // diffuse? + glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texture2); // lightmap? + glActiveTexture(GL_TEXTURE0); + + GLint ok; + + const char *vertexShader = "uniform vec4 texgenscroll;\n" + "void main(void)\n" + "{\n" + " gl_Position = gl_TextureMatrix[0] * ftransform();\n" + " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/100.0 + texgenscroll.xy;\n" // added /100 here + " gl_TexCoord[1] = gl_Color;\n" + "}\n"; + const char *fragmentShader = "uniform vec4 colorparams;\n" + "uniform sampler2D diffusemap, lightmap;\n" + "void main(void)\n" + "{\n" + " vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n" + " vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n" + " diffuse *= colorparams;\n" + " gl_FragColor = (diffuse * lm * 0.2) + gl_TexCoord[1];\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv ( vs, GL_COMPILE_STATUS, &ok ); + if ( !ok ) + { + GLint infoLen = 0; + glGetShaderiv ( vs, GL_INFO_LOG_LENGTH, &infoLen ); + if ( infoLen > 1 ) + { + char* infoLog = (char*)malloc (sizeof(char) * infoLen ); + glGetShaderInfoLog ( vs, infoLen, NULL, infoLog ); + printf ( "Error compiling shader:\n%s\n", infoLog ); + free ( infoLog ); + } + glDeleteShader ( vs ); + return 0; + } + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + GLint lightmapLocation = glGetUniformLocation(program, "lightmap"); + assert(lightmapLocation >= 0); + glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit? + + GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap"); + assert(diffusemapLocation >= 0); + glUniform1i(diffusemapLocation, 0); + + GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll"); + assert(texgenscrollLocation >= 0); + + GLint colorparamsLocation = glGetUniformLocation(program, "colorparams"); + assert(colorparamsLocation >= 0); + + GLfloat texgenscrollData[] = { 0, 0, 0, 0 }; + glUniform4fv(texgenscrollLocation, 1, texgenscrollData); + + GLfloat colorparamsData[] = { 2, 2, 2, 1 }; + glUniform4fv(colorparamsLocation, 1, colorparamsData); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)12); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*) 0); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)24); + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)36); + + // END + + SDL_GL_SwapBuffers(); + + verify(); + +#if !EMSCRIPTEN + SDL_Delay(1500); +#endif + + SDL_Quit(); + + return 0; +} diff --git a/tests/emscripten_api_browser.cpp b/tests/emscripten_api_browser.cpp index 37ffbdd6..20e2dbb5 100644 --- a/tests/emscripten_api_browser.cpp +++ b/tests/emscripten_api_browser.cpp @@ -1,5 +1,6 @@ #include<stdio.h> #include<math.h> +#include<stdlib.h> #include<SDL.h> #include<emscripten.h> #include<assert.h> @@ -8,12 +9,34 @@ int last = 0; extern "C" { -void third() { +bool fived = false; +void five() { + fived = true; + emscripten_resume_main_loop(); +} + +void mainey() { + static int counter = 0; + printf("mainey: %d\n", counter++); + if (counter == 20) { + emscripten_pause_main_loop(); + emscripten_async_call(five, 1000); + } else if (counter == 22) { // very soon after 20, so without pausing we fail + int result = fived; + REPORT_RESULT(); + } +} + +void four() { + printf("four!\n"); + emscripten_set_main_loop(mainey, 0); +} + +void __attribute__((used)) third() { int now = SDL_GetTicks(); printf("thard! %d\n", now); assert(fabs(now - last - 1000) < 500); - int result = 1; - REPORT_RESULT(); + emscripten_async_call(four, -1); // triggers requestAnimationFrame } void second() { @@ -21,16 +44,23 @@ void second() { printf("sacond! %d\n", now); assert(fabs(now - last - 500) < 250); last = now; - emscripten_async_call(third, 1000); + emscripten_async_run_script("_third()", 1000); } } +void never() { + int result = 0; + REPORT_RESULT(); +} + int main() { SDL_Init(0); last = SDL_GetTicks(); printf("frist! %d\n", last); + atexit(never); // should never be called - it is wrong to exit the runtime orderly if we have async calls! + emscripten_async_call(second, 500); return 1; diff --git a/tests/gl_ps.c b/tests/gl_ps.c new file mode 100644 index 00000000..81579c1d --- /dev/null +++ b/tests/gl_ps.c @@ -0,0 +1,230 @@ +/******************************************************************* + * * + * Using SDL With OpenGL * + * * + * Tutorial by Kyle Foley (sdw) * + * * + * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL * + * * + *******************************************************************/ + +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#include "SDL/SDL_image.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +void shaders() { +#if USE_GLEW + glewInit(); +#endif + + GLint ok; + + const char *vertexShader = "void main(void) \n" + "{ \n" + " gl_Position = ftransform(); \n" + " gl_TexCoord[0] = gl_MultiTexCoord0; \n" + " gl_FrontColor = gl_Color; \n" + "} \n"; + const char *fragmentShader = "uniform sampler2D tex0; \n" + "void main(void) \n" + "{ \n" + " gl_FragColor = gl_Color * texture2D(tex0, gl_TexCoord[0].xy); \n" + "} \n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &vertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, &fragmentShader, NULL); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); + assert(ok); + + GLuint program = glCreateProgram(); + + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + glGetProgramiv(program, GL_LINK_STATUS, &ok); + assert(ok); + + glUseProgram(program); + + { + // Also, check getting the error log + const char *fakeVertexShader = "atbute ve4 blarg; ### AAA\n"; + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, &fakeVertexShader, NULL); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); + assert(!ok); + GLint infoLen = 0; + glGetShaderiv(vs, GL_INFO_LOG_LENGTH, &infoLen); + assert(infoLen > 1); + } +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + + // Slightly different SDL initialization + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new* + + screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + // Set the OpenGL state after creating the context with SDL_SetVideoMode + + glClearColor( 0, 0, 0, 0 ); + +#if !EMSCRIPTEN + glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL +#endif + + glViewport( 0, 0, 640, 480 ); + + glMatrixMode( GL_PROJECTION ); + GLfloat matrixData[] = { 2.0/640, 0, 0, 0, + 0, -2.0/480, 0, 0, + 0, 0, -1, 0, + -1, 1, 0, 1 }; + glLoadMatrixf(matrixData); // test loadmatrix + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + // Load the OpenGL texture + + GLuint texture; // Texture object handle + SDL_Surface *surface; // Gives us the information to make the texture + + if ( (surface = IMG_Load("screenshot.png")) ) { + + // Check that the image's width is a power of 2 + if ( (surface->w & (surface->w - 1)) != 0 ) { + printf("warning: image.bmp's width is not a power of 2\n"); + } + + // Also check if the height is a power of 2 + if ( (surface->h & (surface->h - 1)) != 0 ) { + printf("warning: image.bmp's height is not a power of 2\n"); + } + + // Have OpenGL generate a texture object handle for us + glGenTextures( 1, &texture ); + + // Bind the texture object + glBindTexture( GL_TEXTURE_2D, texture ); + + // Set the texture's stretching properties + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + //SDL_LockSurface(surface); + + // Add some greyness + memset(surface->pixels, 0x66, surface->w*surface->h); + + // Edit the texture object's image data using the information SDL_Surface gives us + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); + + //SDL_UnlockSurface(surface); + } + else { + printf("SDL could not load image.bmp: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + // Free the SDL_Surface only if it was successfully created + if ( surface ) { + SDL_FreeSurface( surface ); + } + + // Clear the screen before drawing + glClear( GL_COLOR_BUFFER_BIT ); + + shaders(); + + // Bind the texture to which subsequent calls refer to + glBindTexture( GL_TEXTURE_2D, texture ); + + // Use clientside vertex pointers to render two items + GLfloat vertexData[] = { 0, 0, 10, 10, // texture2, position2 + 1, 0, 300, 10, + 1, 1, 300, 128, + 0, 1, 10, 128, + 0, 0.5, 410, 10, + 1, 0.5, 600, 10, + 1, 1, 630, 200, + 0.5, 1, 310, 250, + 0, 0, 100, 300, + 1, 0, 300, 300, + 1, 1, 300, 400, + 0, 1, 100, 400 }; + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 4*4, &vertexData[0]); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 4*4, &vertexData[2]); + + glDrawArrays(GL_QUADS, 0, 12); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + + SDL_GL_SwapBuffers(); + +#if !EMSCRIPTEN + // Wait for 3 seconds to give us a chance to see the image + SDL_Delay(3000); +#endif + + // Now we can delete the OpenGL texture and close down SDL + glDeleteTextures( 1, &texture ); + + SDL_Quit(); + + return 0; +} diff --git a/tests/gl_ps.png b/tests/gl_ps.png Binary files differnew file mode 100644 index 00000000..185f7166 --- /dev/null +++ b/tests/gl_ps.png diff --git a/tests/hello_world_gles.c b/tests/hello_world_gles.c index 6f7a4324..78595a49 100644 --- a/tests/hello_world_gles.c +++ b/tests/hello_world_gles.c @@ -1,16 +1,16 @@ /* * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * Ported to GLES2. * Kristian Høgsberg <krh@bitplanet.net> * May 3, 2010 - * + * * Improve GLES2 port: * * Refactor gear drawing. * * Use correct normals for surfaces. @@ -113,15 +113,15 @@ static GLfloat ProjectionMatrix[16]; /** The direction of the directional light for the scene */ static const GLfloat LightSourcePosition[4] = { 5.0, 5.0, 10.0, 1.0}; -/** +/** * Fills a gear vertex. - * + * * @param v the vertex to fill * @param x the x coordinate * @param y the y coordinate * @param z the z coortinate - * @param n pointer to the normal table - * + * @param n pointer to the normal table + * * @return the operation error code */ static GearVertex * @@ -139,13 +139,13 @@ vert(GearVertex *v, GLfloat x, GLfloat y, GLfloat z, GLfloat n[3]) /** * Create a gear wheel. - * + * * @param inner_radius radius of hole at center * @param outer_radius radius at center of teeth * @param width width of gear * @param teeth number of teeth * @param tooth_depth depth of tooth - * + * * @return pointer to the constructed struct gear */ static struct gear * @@ -289,11 +289,11 @@ create_gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, return gear; } -/** +/** * Multiplies two 4x4 matrices. - * + * * The result is stored in matrix m. - * + * * @param m the first matrix to multiply * @param n the second matrix to multiply */ @@ -316,9 +316,9 @@ multiply(GLfloat *m, const GLfloat *n) memcpy(m, &tmp, sizeof tmp); } -/** +/** * Rotates a 4x4 matrix. - * + * * @param[in,out] m the matrix to rotate * @param angle the angle to rotate * @param x the x component of the direction to rotate to @@ -333,7 +333,7 @@ rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) sincos(angle, &s, &c); GLfloat r[16] = { x * x * (1 - c) + c, y * x * (1 - c) + z * s, x * z * (1 - c) - y * s, 0, - x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0, + x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0, x * z * (1 - c) + y * s, y * z * (1 - c) - x * s, z * z * (1 - c) + c, 0, 0, 0, 0, 1 }; @@ -342,9 +342,9 @@ rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) } -/** +/** * Translates a 4x4 matrix. - * + * * @param[in,out] m the matrix to translate * @param x the x component of the direction to translate to * @param y the y component of the direction to translate to @@ -358,9 +358,9 @@ translate(GLfloat *m, GLfloat x, GLfloat y, GLfloat z) multiply(m, t); } -/** +/** * Creates an identity 4x4 matrix. - * + * * @param m the matrix make an identity matrix */ static void @@ -376,12 +376,12 @@ identity(GLfloat *m) memcpy(m, t, sizeof(t)); } -/** +/** * Transposes a 4x4 matrix. * * @param m the matrix to transpose */ -static void +static void transpose(GLfloat *m) { GLfloat t[16] = { @@ -420,9 +420,9 @@ invert(GLfloat *m) multiply(m, t); } -/** +/** * Calculate a perspective projection transformation. - * + * * @param m the matrix to save the transformation in * @param fovy the field of view in the y direction * @param aspect the view aspect ratio @@ -485,7 +485,7 @@ draw_gear(struct gear *gear, GLfloat *transform, glUniformMatrix4fv(ModelViewProjectionMatrix_location, 1, GL_FALSE, model_view_projection); - /* + /* * Create and set the NormalMatrix. It's the inverse transpose of the * ModelView matrix. */ @@ -520,7 +520,7 @@ draw_gear(struct gear *gear, GLfloat *transform, glDisableVertexAttribArray(0); } -/** +/** * Draws the gears. */ static void @@ -549,9 +549,9 @@ gears_draw(void) glutSwapBuffers(); } -/** +/** * Handles a new window size or exposure. - * + * * @param width the window width * @param height the window height */ @@ -565,9 +565,9 @@ gears_reshape(int width, int height) glViewport(0, 0, (GLint) width, (GLint) height); } -/** +/** * Handles special glut events. - * + * * @param special the event to handle. */ static void @@ -586,6 +586,9 @@ gears_special(int special, int crap, int morecrap) case GLUT_KEY_DOWN: view_rot[0] -= 5.0; break; + case GLUT_KEY_F11: + glutFullScreen(); + break; } } diff --git a/tests/msvc10/README.txt b/tests/msvc10/README.txt new file mode 100644 index 00000000..49a2a478 --- /dev/null +++ b/tests/msvc10/README.txt @@ -0,0 +1,5 @@ +This folder contains Visual Studio 2010 project files for Emscripten tests. + +Building the solution requires the vs-tool plugin, which enables Emscripten builds to be invoked from within Visual Studio. + +Find the vs-tool plugin from here https://github.com/juj/vs-tool diff --git a/tests/msvc10/dlmalloc_test.vcxproj b/tests/msvc10/dlmalloc_test.vcxproj new file mode 100644 index 00000000..087ff17f --- /dev/null +++ b/tests/msvc10/dlmalloc_test.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A44C4C27-F173-47D0-8626-59A21D86AC1E}</ProjectGuid> + <RootNamespace>dlmalloc_test</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\dlmalloc_test.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/emscripten_api_browser.vcxproj b/tests/msvc10/emscripten_api_browser.vcxproj new file mode 100644 index 00000000..9f4a05fd --- /dev/null +++ b/tests/msvc10/emscripten_api_browser.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{65E0ED61-A813-4AEB-8DB0-A58657858EE2}</ProjectGuid> + <RootNamespace>emscripten_api_browser</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\emscripten_api_browser.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/fannkuch.vcxproj b/tests/msvc10/fannkuch.vcxproj new file mode 100644 index 00000000..9b325ea3 --- /dev/null +++ b/tests/msvc10/fannkuch.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C29BBEE3-02D1-459A-B8BA-832A3439F12D}</ProjectGuid> + <RootNamespace>fannkuch</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\fannkuch.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/fasta.vcxproj b/tests/msvc10/fasta.vcxproj new file mode 100644 index 00000000..d0c10027 --- /dev/null +++ b/tests/msvc10/fasta.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{DDB7FF8E-EC42-4406-832C-F2B043D8760E}</ProjectGuid> + <RootNamespace>fasta</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\fasta.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/files.vcxproj b/tests/msvc10/files.vcxproj new file mode 100644 index 00000000..cba0f3a0 --- /dev/null +++ b/tests/msvc10/files.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{BE6A123E-9729-44A3-976F-3C06A3724894}</ProjectGuid> + <RootNamespace>files</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\files.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_10_MultiTexture.vcxproj b/tests/msvc10/glbook_10_MultiTexture.vcxproj new file mode 100644 index 00000000..b59fda0a --- /dev/null +++ b/tests/msvc10/glbook_10_MultiTexture.vcxproj @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}</ProjectGuid> + <RootNamespace>glbook_10_MultiTexture</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <None Include="..\glbook\Chapter_10\MultiTexture\basemap.tga" /> + <None Include="..\glbook\Chapter_10\MultiTexture\lightmap.tga" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_10\MultiTexture\MultiTexture.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_11_Multisample.vcxproj b/tests/msvc10/glbook_11_Multisample.vcxproj new file mode 100644 index 00000000..ae5170be --- /dev/null +++ b/tests/msvc10/glbook_11_Multisample.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{AD9E59DF-1628-4081-8672-212A7103FAAD}</ProjectGuid> + <RootNamespace>glbook_11_Multisample</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_11\Multisample\Multisample.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_11_Stencil_Test.vcxproj b/tests/msvc10/glbook_11_Stencil_Test.vcxproj new file mode 100644 index 00000000..d72d7fa6 --- /dev/null +++ b/tests/msvc10/glbook_11_Stencil_Test.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{2D60F3E0-B83A-4442-94D3-AB4B2F068476}</ProjectGuid> + <RootNamespace>glbook_11_Stencil_Test</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_11\Stencil_Test\Stencil_Test.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_13_ParticleSystem.vcxproj b/tests/msvc10/glbook_13_ParticleSystem.vcxproj new file mode 100644 index 00000000..458d76fa --- /dev/null +++ b/tests/msvc10/glbook_13_ParticleSystem.vcxproj @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{3E62931D-2795-4BD1-8AA7-55F5440AD293}</ProjectGuid> + <RootNamespace>glbook_13_ParticleSystem</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_13\ParticleSystem\ParticleSystem.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <None Include="..\glbook\Chapter_13\ParticleSystem\smoke.tga" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_15_Hello_Triangle_KD.vcxproj b/tests/msvc10/glbook_15_Hello_Triangle_KD.vcxproj new file mode 100644 index 00000000..654164b3 --- /dev/null +++ b/tests/msvc10/glbook_15_Hello_Triangle_KD.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A971FFED-3417-452B-B488-6D4F9F257847}</ProjectGuid> + <RootNamespace>glbook_15_Hello_Triangle_KD</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_15\Hello_Triangle_KD\Hello_Triangle_KD.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_2_Hello_Triangle.vcxproj b/tests/msvc10/glbook_2_Hello_Triangle.vcxproj new file mode 100644 index 00000000..b992294d --- /dev/null +++ b/tests/msvc10/glbook_2_Hello_Triangle.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_2\Hello_Triangle\Hello_Triangle.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{FA655211-CC00-4827-BBCB-B8749BB7671D}</ProjectGuid> + <RootNamespace>glbook_2_Hello_Triangle</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_8_Simple_VertexShader.vcxproj b/tests/msvc10/glbook_8_Simple_VertexShader.vcxproj new file mode 100644 index 00000000..fb01c1da --- /dev/null +++ b/tests/msvc10/glbook_8_Simple_VertexShader.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}</ProjectGuid> + <RootNamespace>glbook_8_Simple_VertexShader</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_8\Simple_VertexShader\Simple_VertexShader.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_9_MipMap2D.vcxproj b/tests/msvc10/glbook_9_MipMap2D.vcxproj new file mode 100644 index 00000000..1d747d1d --- /dev/null +++ b/tests/msvc10/glbook_9_MipMap2D.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}</ProjectGuid> + <RootNamespace>glbook_9_MipMap2D</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_9\MipMap2D\MipMap2D.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_9_Simple_Texture2D.vcxproj b/tests/msvc10/glbook_9_Simple_Texture2D.vcxproj new file mode 100644 index 00000000..d9232e5d --- /dev/null +++ b/tests/msvc10/glbook_9_Simple_Texture2D.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A7C445F9-FCE6-48D5-9343-734071A59185}</ProjectGuid> + <RootNamespace>glbook_9_Simple_Texture2D</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_9\Simple_Texture2D\Simple_Texture2D.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_9_Simple_TextureCubemap.vcxproj b/tests/msvc10/glbook_9_Simple_TextureCubemap.vcxproj new file mode 100644 index 00000000..c5c6ee1b --- /dev/null +++ b/tests/msvc10/glbook_9_Simple_TextureCubemap.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C5500D5B-9489-4109-A6E4-CF8F7E1518E7}</ProjectGuid> + <RootNamespace>glbook_9_Simple_TextureCubemap</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_9\Simple_TextureCubemap\Simple_TextureCubemap.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/glbook_9_TextureWrap.vcxproj b/tests/msvc10/glbook_9_TextureWrap.vcxproj new file mode 100644 index 00000000..6cfbb0c8 --- /dev/null +++ b/tests/msvc10/glbook_9_TextureWrap.vcxproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{982D6A44-9080-4A89-911E-BC1E495267D1}</ProjectGuid> + <RootNamespace>glbook_9_TextureWrap</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <ClCompile> + <AdditionalIncludeDirectories>$(SolutionDir)../glbook/Common</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\glbook\Chapter_9\TextureWrap\TextureWrap.c" /> + <ClCompile Include="..\glbook\Common\esShader.c" /> + <ClCompile Include="..\glbook\Common\esShapes.c" /> + <ClCompile Include="..\glbook\Common\esTransform.c" /> + <ClCompile Include="..\glbook\Common\esUtil.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\glbook\Common\esUtil.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hashtest.vcxproj b/tests/msvc10/hashtest.vcxproj new file mode 100644 index 00000000..fe0ca2ab --- /dev/null +++ b/tests/msvc10/hashtest.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{61D7F11F-25EE-4C2C-9D73-8601F68B055E}</ProjectGuid> + <RootNamespace>hashtest</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hashtest.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_libcxx.vcxproj b/tests/msvc10/hello_libcxx.vcxproj new file mode 100644 index 00000000..8bd201e5 --- /dev/null +++ b/tests/msvc10/hello_libcxx.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{19DB739D-7EEB-4B99-BB6D-C12F086B5F24}</ProjectGuid> + <RootNamespace>hello_libcxx</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_libcxx.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_malloc.vcxproj b/tests/msvc10/hello_malloc.vcxproj new file mode 100644 index 00000000..6340257a --- /dev/null +++ b/tests/msvc10/hello_malloc.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{DFBD530C-9163-4558-B607-2A226BCC8DC0}</ProjectGuid> + <RootNamespace>hello_malloc</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_malloc.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_c.vcxproj b/tests/msvc10/hello_world_c.vcxproj new file mode 100644 index 00000000..be79a7b8 --- /dev/null +++ b/tests/msvc10/hello_world_c.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{660E83C1-82AC-487C-BF5E-CFB6B82196BC}</ProjectGuid> + <RootNamespace>hello_world_c</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_cpp.vcxproj b/tests/msvc10/hello_world_cpp.vcxproj new file mode 100644 index 00000000..31ff3034 --- /dev/null +++ b/tests/msvc10/hello_world_cpp.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}</ProjectGuid> + <RootNamespace>hello_world_cpp</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_file.vcxproj b/tests/msvc10/hello_world_file.vcxproj new file mode 100644 index 00000000..f076aba8 --- /dev/null +++ b/tests/msvc10/hello_world_file.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}</ProjectGuid> + <RootNamespace>hello_world_file</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world_file.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_gles.vcxproj b/tests/msvc10/hello_world_gles.vcxproj new file mode 100644 index 00000000..371a5115 --- /dev/null +++ b/tests/msvc10/hello_world_gles.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\hello_world_gles.c" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{6A41CB2E-0022-47E1-89C5-FB2B558BEB91}</ProjectGuid> + <RootNamespace>hello_world_gles</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_loop.vcxproj b/tests/msvc10/hello_world_loop.vcxproj new file mode 100644 index 00000000..96d5b697 --- /dev/null +++ b/tests/msvc10/hello_world_loop.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{DB3B6C01-8CF9-4397-843E-403D5063F2DE}</ProjectGuid> + <RootNamespace>hello_world_loop</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world_loop.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_loop_malloc.vcxproj b/tests/msvc10/hello_world_loop_malloc.vcxproj new file mode 100644 index 00000000..3302c42d --- /dev/null +++ b/tests/msvc10/hello_world_loop_malloc.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{5C72F8EA-B852-49F6-A979-DE5011957BC7}</ProjectGuid> + <RootNamespace>hello_world_loop_malloc</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world_loop_malloc.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/hello_world_sdl.vcxproj b/tests/msvc10/hello_world_sdl.vcxproj new file mode 100644 index 00000000..4b5ef9e3 --- /dev/null +++ b/tests/msvc10/hello_world_sdl.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{DA2F2979-2902-42BC-B8DA-6B18FE2AF444}</ProjectGuid> + <RootNamespace>hello_world_sdl</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\hello_world_sdl.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/new.vcxproj b/tests/msvc10/new.vcxproj new file mode 100644 index 00000000..11ad95ae --- /dev/null +++ b/tests/msvc10/new.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{5190107D-91B3-4EF8-82CB-08381DD19ABB}</ProjectGuid> + <RootNamespace>new</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\new.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/raytrace.vcxproj b/tests/msvc10/raytrace.vcxproj new file mode 100644 index 00000000..9084d044 --- /dev/null +++ b/tests/msvc10/raytrace.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}</ProjectGuid> + <RootNamespace>raytrace</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\raytrace.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_audio.vcxproj b/tests/msvc10/sdl_audio.vcxproj new file mode 100644 index 00000000..80a48d90 --- /dev/null +++ b/tests/msvc10/sdl_audio.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{F28A1DE1-5949-4AF5-8901-A37871C2514E}</ProjectGuid> + <RootNamespace>sdl_audio</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_audio.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_canvas.vcxproj b/tests/msvc10/sdl_canvas.vcxproj new file mode 100644 index 00000000..42215b38 --- /dev/null +++ b/tests/msvc10/sdl_canvas.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\sdl_canvas.c" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{CE360D01-4362-4FE4-A77E-8EF6E3F623CF}</ProjectGuid> + <RootNamespace>sdl_canvas</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_gl_read.vcxproj b/tests/msvc10/sdl_gl_read.vcxproj new file mode 100644 index 00000000..de6233c1 --- /dev/null +++ b/tests/msvc10/sdl_gl_read.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}</ProjectGuid> + <RootNamespace>sdl_gl_read</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_gl_read.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_image.vcxproj b/tests/msvc10/sdl_image.vcxproj new file mode 100644 index 00000000..631ea5cd --- /dev/null +++ b/tests/msvc10/sdl_image.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{5CE874BD-2F32-4579-B682-4B74E5764F13}</ProjectGuid> + <RootNamespace>sdl_image</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_image.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_key.vcxproj b/tests/msvc10/sdl_key.vcxproj new file mode 100644 index 00000000..3840256a --- /dev/null +++ b/tests/msvc10/sdl_key.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{1C5338A3-7020-4086-AE99-BC79EA3D42C1}</ProjectGuid> + <RootNamespace>sdl_key</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_key.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_mouse.vcxproj b/tests/msvc10/sdl_mouse.vcxproj new file mode 100644 index 00000000..7d582eb3 --- /dev/null +++ b/tests/msvc10/sdl_mouse.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{D3295E36-57BB-4C42-92D8-2AA150024256}</ProjectGuid> + <RootNamespace>sdl_mouse</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_mouse.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/sdl_ogl.vcxproj b/tests/msvc10/sdl_ogl.vcxproj new file mode 100644 index 00000000..b96eac4d --- /dev/null +++ b/tests/msvc10/sdl_ogl.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}</ProjectGuid> + <RootNamespace>sdl_ogl</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\sdl_ogl.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/skinning_test_no_simd.vcxproj b/tests/msvc10/skinning_test_no_simd.vcxproj new file mode 100644 index 00000000..b15dc996 --- /dev/null +++ b/tests/msvc10/skinning_test_no_simd.vcxproj @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{678A07B3-3A25-40E4-8A36-7A399056188A}</ProjectGuid> + <RootNamespace>skinning_test_no_simd</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\skinning_test_no_simd.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/tests_msvc10.sln b/tests/msvc10/tests_msvc10.sln new file mode 100644 index 00000000..67333016 --- /dev/null +++ b/tests/msvc10/tests_msvc10.sln @@ -0,0 +1,286 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_gles", "hello_world_gles.vcxproj", "{6A41CB2E-0022-47E1-89C5-FB2B558BEB91}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fannkuch", "fannkuch.vcxproj", "{C29BBEE3-02D1-459A-B8BA-832A3439F12D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fasta", "fasta.vcxproj", "{DDB7FF8E-EC42-4406-832C-F2B043D8760E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_9_Simple_Texture2D", "glbook_9_Simple_Texture2D.vcxproj", "{A7C445F9-FCE6-48D5-9343-734071A59185}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_9_Simple_TextureCubemap", "glbook_9_Simple_TextureCubemap.vcxproj", "{C5500D5B-9489-4109-A6E4-CF8F7E1518E7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_9_TextureWrap", "glbook_9_TextureWrap.vcxproj", "{982D6A44-9080-4A89-911E-BC1E495267D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_10_MultiTexture", "glbook_10_MultiTexture.vcxproj", "{A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_11_Multisample", "glbook_11_Multisample.vcxproj", "{AD9E59DF-1628-4081-8672-212A7103FAAD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_11_Stencil_Test", "glbook_11_Stencil_Test.vcxproj", "{2D60F3E0-B83A-4442-94D3-AB4B2F068476}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_13_ParticleSystem", "glbook_13_ParticleSystem.vcxproj", "{3E62931D-2795-4BD1-8AA7-55F5440AD293}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_15_Hello_Triangle_KD", "glbook_15_Hello_Triangle_KD.vcxproj", "{A971FFED-3417-452B-B488-6D4F9F257847}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_8_Simple_VertexShader", "glbook_8_Simple_VertexShader.vcxproj", "{2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_9_MipMap2D", "glbook_9_MipMap2D.vcxproj", "{9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raytrace", "raytrace.vcxproj", "{2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_c", "hello_world_c.vcxproj", "{660E83C1-82AC-487C-BF5E-CFB6B82196BC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_cpp", "hello_world_cpp.vcxproj", "{5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_file", "hello_world_file.vcxproj", "{EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_malloc", "hello_malloc.vcxproj", "{DFBD530C-9163-4558-B607-2A226BCC8DC0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_libcxx", "hello_libcxx.vcxproj", "{19DB739D-7EEB-4B99-BB6D-C12F086B5F24}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_loop", "hello_world_loop.vcxproj", "{DB3B6C01-8CF9-4397-843E-403D5063F2DE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_loop_malloc", "hello_world_loop_malloc.vcxproj", "{5C72F8EA-B852-49F6-A979-DE5011957BC7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world_sdl", "hello_world_sdl.vcxproj", "{DA2F2979-2902-42BC-B8DA-6B18FE2AF444}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dlmalloc_test", "dlmalloc_test.vcxproj", "{A44C4C27-F173-47D0-8626-59A21D86AC1E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emscripten_api_browser", "emscripten_api_browser.vcxproj", "{65E0ED61-A813-4AEB-8DB0-A58657858EE2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "files", "files.vcxproj", "{BE6A123E-9729-44A3-976F-3C06A3724894}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hashtest", "hashtest.vcxproj", "{61D7F11F-25EE-4C2C-9D73-8601F68B055E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "new", "new.vcxproj", "{5190107D-91B3-4EF8-82CB-08381DD19ABB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_audio", "sdl_audio.vcxproj", "{F28A1DE1-5949-4AF5-8901-A37871C2514E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_canvas", "sdl_canvas.vcxproj", "{CE360D01-4362-4FE4-A77E-8EF6E3F623CF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_gl_read", "sdl_gl_read.vcxproj", "{3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_image", "sdl_image.vcxproj", "{5CE874BD-2F32-4579-B682-4B74E5764F13}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_key", "sdl_key.vcxproj", "{1C5338A3-7020-4086-AE99-BC79EA3D42C1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_mouse", "sdl_mouse.vcxproj", "{D3295E36-57BB-4C42-92D8-2AA150024256}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl_ogl", "sdl_ogl.vcxproj", "{670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "skinning_test_no_simd", "skinning_test_no_simd.vcxproj", "{678A07B3-3A25-40E4-8A36-7A399056188A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "twopart", "twopart.vcxproj", "{C896D890-9132-4A2D-8BA8-0EB6888FEAC2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glbook_2_Hello_Triangle", "glbook_2_Hello_Triangle.vcxproj", "{FA655211-CC00-4827-BBCB-B8749BB7671D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gles", "gles", "{9DCFC12B-65CB-4965-9F16-C63B467E2E9E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sdl", "sdl", "{70A8D326-5CBD-4C8A-BE84-39B0528C2479}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "other", "other", "{8E55380B-7067-47FF-8B6B-6D656B8D8CC3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "README", "README", "{AFB0F421-9B24-495D-B961-EA94780F36E5}" + ProjectSection(SolutionItems) = preProject + README.txt = README.txt + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Emscripten = Debug|Emscripten + Release|Emscripten = Release|Emscripten + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6A41CB2E-0022-47E1-89C5-FB2B558BEB91}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {6A41CB2E-0022-47E1-89C5-FB2B558BEB91}.Debug|Emscripten.Build.0 = Debug|Emscripten + {6A41CB2E-0022-47E1-89C5-FB2B558BEB91}.Release|Emscripten.ActiveCfg = Release|Emscripten + {6A41CB2E-0022-47E1-89C5-FB2B558BEB91}.Release|Emscripten.Build.0 = Release|Emscripten + {C29BBEE3-02D1-459A-B8BA-832A3439F12D}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {C29BBEE3-02D1-459A-B8BA-832A3439F12D}.Debug|Emscripten.Build.0 = Debug|Emscripten + {C29BBEE3-02D1-459A-B8BA-832A3439F12D}.Release|Emscripten.ActiveCfg = Release|Emscripten + {C29BBEE3-02D1-459A-B8BA-832A3439F12D}.Release|Emscripten.Build.0 = Release|Emscripten + {DDB7FF8E-EC42-4406-832C-F2B043D8760E}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {DDB7FF8E-EC42-4406-832C-F2B043D8760E}.Debug|Emscripten.Build.0 = Debug|Emscripten + {DDB7FF8E-EC42-4406-832C-F2B043D8760E}.Release|Emscripten.ActiveCfg = Release|Emscripten + {DDB7FF8E-EC42-4406-832C-F2B043D8760E}.Release|Emscripten.Build.0 = Release|Emscripten + {A7C445F9-FCE6-48D5-9343-734071A59185}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {A7C445F9-FCE6-48D5-9343-734071A59185}.Debug|Emscripten.Build.0 = Debug|Emscripten + {A7C445F9-FCE6-48D5-9343-734071A59185}.Release|Emscripten.ActiveCfg = Release|Emscripten + {A7C445F9-FCE6-48D5-9343-734071A59185}.Release|Emscripten.Build.0 = Release|Emscripten + {C5500D5B-9489-4109-A6E4-CF8F7E1518E7}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {C5500D5B-9489-4109-A6E4-CF8F7E1518E7}.Debug|Emscripten.Build.0 = Debug|Emscripten + {C5500D5B-9489-4109-A6E4-CF8F7E1518E7}.Release|Emscripten.ActiveCfg = Release|Emscripten + {C5500D5B-9489-4109-A6E4-CF8F7E1518E7}.Release|Emscripten.Build.0 = Release|Emscripten + {982D6A44-9080-4A89-911E-BC1E495267D1}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {982D6A44-9080-4A89-911E-BC1E495267D1}.Debug|Emscripten.Build.0 = Debug|Emscripten + {982D6A44-9080-4A89-911E-BC1E495267D1}.Release|Emscripten.ActiveCfg = Release|Emscripten + {982D6A44-9080-4A89-911E-BC1E495267D1}.Release|Emscripten.Build.0 = Release|Emscripten + {A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}.Debug|Emscripten.Build.0 = Debug|Emscripten + {A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}.Release|Emscripten.ActiveCfg = Release|Emscripten + {A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B}.Release|Emscripten.Build.0 = Release|Emscripten + {AD9E59DF-1628-4081-8672-212A7103FAAD}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {AD9E59DF-1628-4081-8672-212A7103FAAD}.Debug|Emscripten.Build.0 = Debug|Emscripten + {AD9E59DF-1628-4081-8672-212A7103FAAD}.Release|Emscripten.ActiveCfg = Release|Emscripten + {AD9E59DF-1628-4081-8672-212A7103FAAD}.Release|Emscripten.Build.0 = Release|Emscripten + {2D60F3E0-B83A-4442-94D3-AB4B2F068476}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {2D60F3E0-B83A-4442-94D3-AB4B2F068476}.Debug|Emscripten.Build.0 = Debug|Emscripten + {2D60F3E0-B83A-4442-94D3-AB4B2F068476}.Release|Emscripten.ActiveCfg = Release|Emscripten + {2D60F3E0-B83A-4442-94D3-AB4B2F068476}.Release|Emscripten.Build.0 = Release|Emscripten + {3E62931D-2795-4BD1-8AA7-55F5440AD293}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {3E62931D-2795-4BD1-8AA7-55F5440AD293}.Debug|Emscripten.Build.0 = Debug|Emscripten + {3E62931D-2795-4BD1-8AA7-55F5440AD293}.Release|Emscripten.ActiveCfg = Release|Emscripten + {3E62931D-2795-4BD1-8AA7-55F5440AD293}.Release|Emscripten.Build.0 = Release|Emscripten + {A971FFED-3417-452B-B488-6D4F9F257847}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {A971FFED-3417-452B-B488-6D4F9F257847}.Debug|Emscripten.Build.0 = Debug|Emscripten + {A971FFED-3417-452B-B488-6D4F9F257847}.Release|Emscripten.ActiveCfg = Release|Emscripten + {A971FFED-3417-452B-B488-6D4F9F257847}.Release|Emscripten.Build.0 = Release|Emscripten + {2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}.Debug|Emscripten.Build.0 = Debug|Emscripten + {2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}.Release|Emscripten.ActiveCfg = Release|Emscripten + {2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E}.Release|Emscripten.Build.0 = Release|Emscripten + {9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}.Debug|Emscripten.Build.0 = Debug|Emscripten + {9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}.Release|Emscripten.ActiveCfg = Release|Emscripten + {9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B}.Release|Emscripten.Build.0 = Release|Emscripten + {2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}.Debug|Emscripten.Build.0 = Debug|Emscripten + {2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}.Release|Emscripten.ActiveCfg = Release|Emscripten + {2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8}.Release|Emscripten.Build.0 = Release|Emscripten + {660E83C1-82AC-487C-BF5E-CFB6B82196BC}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {660E83C1-82AC-487C-BF5E-CFB6B82196BC}.Debug|Emscripten.Build.0 = Debug|Emscripten + {660E83C1-82AC-487C-BF5E-CFB6B82196BC}.Release|Emscripten.ActiveCfg = Release|Emscripten + {660E83C1-82AC-487C-BF5E-CFB6B82196BC}.Release|Emscripten.Build.0 = Release|Emscripten + {5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}.Debug|Emscripten.Build.0 = Debug|Emscripten + {5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}.Release|Emscripten.ActiveCfg = Release|Emscripten + {5970CDD4-FB0A-4E66-B7C9-DAD9E580628D}.Release|Emscripten.Build.0 = Release|Emscripten + {EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}.Debug|Emscripten.Build.0 = Debug|Emscripten + {EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}.Release|Emscripten.ActiveCfg = Release|Emscripten + {EB0B52B6-0177-4CEE-955D-3C7F052E5F5B}.Release|Emscripten.Build.0 = Release|Emscripten + {DFBD530C-9163-4558-B607-2A226BCC8DC0}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {DFBD530C-9163-4558-B607-2A226BCC8DC0}.Debug|Emscripten.Build.0 = Debug|Emscripten + {DFBD530C-9163-4558-B607-2A226BCC8DC0}.Release|Emscripten.ActiveCfg = Release|Emscripten + {DFBD530C-9163-4558-B607-2A226BCC8DC0}.Release|Emscripten.Build.0 = Release|Emscripten + {19DB739D-7EEB-4B99-BB6D-C12F086B5F24}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {19DB739D-7EEB-4B99-BB6D-C12F086B5F24}.Debug|Emscripten.Build.0 = Debug|Emscripten + {19DB739D-7EEB-4B99-BB6D-C12F086B5F24}.Release|Emscripten.ActiveCfg = Release|Emscripten + {19DB739D-7EEB-4B99-BB6D-C12F086B5F24}.Release|Emscripten.Build.0 = Release|Emscripten + {DB3B6C01-8CF9-4397-843E-403D5063F2DE}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {DB3B6C01-8CF9-4397-843E-403D5063F2DE}.Debug|Emscripten.Build.0 = Debug|Emscripten + {DB3B6C01-8CF9-4397-843E-403D5063F2DE}.Release|Emscripten.ActiveCfg = Release|Emscripten + {DB3B6C01-8CF9-4397-843E-403D5063F2DE}.Release|Emscripten.Build.0 = Release|Emscripten + {5C72F8EA-B852-49F6-A979-DE5011957BC7}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {5C72F8EA-B852-49F6-A979-DE5011957BC7}.Debug|Emscripten.Build.0 = Debug|Emscripten + {5C72F8EA-B852-49F6-A979-DE5011957BC7}.Release|Emscripten.ActiveCfg = Release|Emscripten + {5C72F8EA-B852-49F6-A979-DE5011957BC7}.Release|Emscripten.Build.0 = Release|Emscripten + {DA2F2979-2902-42BC-B8DA-6B18FE2AF444}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {DA2F2979-2902-42BC-B8DA-6B18FE2AF444}.Debug|Emscripten.Build.0 = Debug|Emscripten + {DA2F2979-2902-42BC-B8DA-6B18FE2AF444}.Release|Emscripten.ActiveCfg = Release|Emscripten + {DA2F2979-2902-42BC-B8DA-6B18FE2AF444}.Release|Emscripten.Build.0 = Release|Emscripten + {A44C4C27-F173-47D0-8626-59A21D86AC1E}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {A44C4C27-F173-47D0-8626-59A21D86AC1E}.Debug|Emscripten.Build.0 = Debug|Emscripten + {A44C4C27-F173-47D0-8626-59A21D86AC1E}.Release|Emscripten.ActiveCfg = Release|Emscripten + {A44C4C27-F173-47D0-8626-59A21D86AC1E}.Release|Emscripten.Build.0 = Release|Emscripten + {65E0ED61-A813-4AEB-8DB0-A58657858EE2}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {65E0ED61-A813-4AEB-8DB0-A58657858EE2}.Debug|Emscripten.Build.0 = Debug|Emscripten + {65E0ED61-A813-4AEB-8DB0-A58657858EE2}.Release|Emscripten.ActiveCfg = Release|Emscripten + {65E0ED61-A813-4AEB-8DB0-A58657858EE2}.Release|Emscripten.Build.0 = Release|Emscripten + {BE6A123E-9729-44A3-976F-3C06A3724894}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {BE6A123E-9729-44A3-976F-3C06A3724894}.Debug|Emscripten.Build.0 = Debug|Emscripten + {BE6A123E-9729-44A3-976F-3C06A3724894}.Release|Emscripten.ActiveCfg = Release|Emscripten + {BE6A123E-9729-44A3-976F-3C06A3724894}.Release|Emscripten.Build.0 = Release|Emscripten + {61D7F11F-25EE-4C2C-9D73-8601F68B055E}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {61D7F11F-25EE-4C2C-9D73-8601F68B055E}.Debug|Emscripten.Build.0 = Debug|Emscripten + {61D7F11F-25EE-4C2C-9D73-8601F68B055E}.Release|Emscripten.ActiveCfg = Release|Emscripten + {61D7F11F-25EE-4C2C-9D73-8601F68B055E}.Release|Emscripten.Build.0 = Release|Emscripten + {5190107D-91B3-4EF8-82CB-08381DD19ABB}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {5190107D-91B3-4EF8-82CB-08381DD19ABB}.Debug|Emscripten.Build.0 = Debug|Emscripten + {5190107D-91B3-4EF8-82CB-08381DD19ABB}.Release|Emscripten.ActiveCfg = Release|Emscripten + {5190107D-91B3-4EF8-82CB-08381DD19ABB}.Release|Emscripten.Build.0 = Release|Emscripten + {F28A1DE1-5949-4AF5-8901-A37871C2514E}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {F28A1DE1-5949-4AF5-8901-A37871C2514E}.Debug|Emscripten.Build.0 = Debug|Emscripten + {F28A1DE1-5949-4AF5-8901-A37871C2514E}.Release|Emscripten.ActiveCfg = Release|Emscripten + {F28A1DE1-5949-4AF5-8901-A37871C2514E}.Release|Emscripten.Build.0 = Release|Emscripten + {CE360D01-4362-4FE4-A77E-8EF6E3F623CF}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {CE360D01-4362-4FE4-A77E-8EF6E3F623CF}.Debug|Emscripten.Build.0 = Debug|Emscripten + {CE360D01-4362-4FE4-A77E-8EF6E3F623CF}.Release|Emscripten.ActiveCfg = Release|Emscripten + {CE360D01-4362-4FE4-A77E-8EF6E3F623CF}.Release|Emscripten.Build.0 = Release|Emscripten + {3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}.Debug|Emscripten.Build.0 = Debug|Emscripten + {3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}.Release|Emscripten.ActiveCfg = Release|Emscripten + {3EA4E5F5-67B6-4F83-95D7-E041FFF787B0}.Release|Emscripten.Build.0 = Release|Emscripten + {5CE874BD-2F32-4579-B682-4B74E5764F13}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {5CE874BD-2F32-4579-B682-4B74E5764F13}.Debug|Emscripten.Build.0 = Debug|Emscripten + {5CE874BD-2F32-4579-B682-4B74E5764F13}.Release|Emscripten.ActiveCfg = Release|Emscripten + {5CE874BD-2F32-4579-B682-4B74E5764F13}.Release|Emscripten.Build.0 = Release|Emscripten + {1C5338A3-7020-4086-AE99-BC79EA3D42C1}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {1C5338A3-7020-4086-AE99-BC79EA3D42C1}.Debug|Emscripten.Build.0 = Debug|Emscripten + {1C5338A3-7020-4086-AE99-BC79EA3D42C1}.Release|Emscripten.ActiveCfg = Release|Emscripten + {1C5338A3-7020-4086-AE99-BC79EA3D42C1}.Release|Emscripten.Build.0 = Release|Emscripten + {D3295E36-57BB-4C42-92D8-2AA150024256}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {D3295E36-57BB-4C42-92D8-2AA150024256}.Debug|Emscripten.Build.0 = Debug|Emscripten + {D3295E36-57BB-4C42-92D8-2AA150024256}.Release|Emscripten.ActiveCfg = Release|Emscripten + {D3295E36-57BB-4C42-92D8-2AA150024256}.Release|Emscripten.Build.0 = Release|Emscripten + {670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}.Debug|Emscripten.Build.0 = Debug|Emscripten + {670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}.Release|Emscripten.ActiveCfg = Release|Emscripten + {670EA36B-AD2B-4BFC-8DD3-AE024736AFB2}.Release|Emscripten.Build.0 = Release|Emscripten + {678A07B3-3A25-40E4-8A36-7A399056188A}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {678A07B3-3A25-40E4-8A36-7A399056188A}.Debug|Emscripten.Build.0 = Debug|Emscripten + {678A07B3-3A25-40E4-8A36-7A399056188A}.Release|Emscripten.ActiveCfg = Release|Emscripten + {678A07B3-3A25-40E4-8A36-7A399056188A}.Release|Emscripten.Build.0 = Release|Emscripten + {C896D890-9132-4A2D-8BA8-0EB6888FEAC2}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {C896D890-9132-4A2D-8BA8-0EB6888FEAC2}.Debug|Emscripten.Build.0 = Debug|Emscripten + {C896D890-9132-4A2D-8BA8-0EB6888FEAC2}.Release|Emscripten.ActiveCfg = Release|Emscripten + {C896D890-9132-4A2D-8BA8-0EB6888FEAC2}.Release|Emscripten.Build.0 = Release|Emscripten + {FA655211-CC00-4827-BBCB-B8749BB7671D}.Debug|Emscripten.ActiveCfg = Debug|Emscripten + {FA655211-CC00-4827-BBCB-B8749BB7671D}.Debug|Emscripten.Build.0 = Debug|Emscripten + {FA655211-CC00-4827-BBCB-B8749BB7671D}.Release|Emscripten.ActiveCfg = Release|Emscripten + {FA655211-CC00-4827-BBCB-B8749BB7671D}.Release|Emscripten.Build.0 = Release|Emscripten + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A7C445F9-FCE6-48D5-9343-734071A59185} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {C5500D5B-9489-4109-A6E4-CF8F7E1518E7} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {982D6A44-9080-4A89-911E-BC1E495267D1} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {A2D564BE-34DE-43DC-B8F9-605CEF4BFC4B} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {AD9E59DF-1628-4081-8672-212A7103FAAD} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {2D60F3E0-B83A-4442-94D3-AB4B2F068476} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {3E62931D-2795-4BD1-8AA7-55F5440AD293} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {A971FFED-3417-452B-B488-6D4F9F257847} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {2FD5F24F-8B73-4C62-81D6-B6B866E5EC5E} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {9EB49BEC-C7A0-4AEE-AF19-AACB057DE08B} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {FA655211-CC00-4827-BBCB-B8749BB7671D} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {6A41CB2E-0022-47E1-89C5-FB2B558BEB91} = {9DCFC12B-65CB-4965-9F16-C63B467E2E9E} + {DDB7FF8E-EC42-4406-832C-F2B043D8760E} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {2F3AD7E0-AA5D-4639-8F6A-53BDBD88EBD8} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {660E83C1-82AC-487C-BF5E-CFB6B82196BC} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {5970CDD4-FB0A-4E66-B7C9-DAD9E580628D} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {EB0B52B6-0177-4CEE-955D-3C7F052E5F5B} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {DFBD530C-9163-4558-B607-2A226BCC8DC0} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {19DB739D-7EEB-4B99-BB6D-C12F086B5F24} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {DB3B6C01-8CF9-4397-843E-403D5063F2DE} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {5C72F8EA-B852-49F6-A979-DE5011957BC7} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {A44C4C27-F173-47D0-8626-59A21D86AC1E} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {65E0ED61-A813-4AEB-8DB0-A58657858EE2} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {BE6A123E-9729-44A3-976F-3C06A3724894} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {61D7F11F-25EE-4C2C-9D73-8601F68B055E} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {5190107D-91B3-4EF8-82CB-08381DD19ABB} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {678A07B3-3A25-40E4-8A36-7A399056188A} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {C896D890-9132-4A2D-8BA8-0EB6888FEAC2} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {C29BBEE3-02D1-459A-B8BA-832A3439F12D} = {8E55380B-7067-47FF-8B6B-6D656B8D8CC3} + {F28A1DE1-5949-4AF5-8901-A37871C2514E} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {CE360D01-4362-4FE4-A77E-8EF6E3F623CF} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {3EA4E5F5-67B6-4F83-95D7-E041FFF787B0} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {5CE874BD-2F32-4579-B682-4B74E5764F13} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {1C5338A3-7020-4086-AE99-BC79EA3D42C1} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {D3295E36-57BB-4C42-92D8-2AA150024256} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {670EA36B-AD2B-4BFC-8DD3-AE024736AFB2} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + {DA2F2979-2902-42BC-B8DA-6B18FE2AF444} = {70A8D326-5CBD-4C8A-BE84-39B0528C2479} + EndGlobalSection +EndGlobal diff --git a/tests/msvc10/tests_msvc10.vcxproj b/tests/msvc10/tests_msvc10.vcxproj new file mode 100644 index 00000000..bb69b0e6 --- /dev/null +++ b/tests/msvc10/tests_msvc10.vcxproj @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{6FB6B535-11C3-4011-B06B-74ACD387DFCC}</ProjectGuid> + <RootNamespace>tests_msvc10</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/msvc10/twopart.vcxproj b/tests/msvc10/twopart.vcxproj new file mode 100644 index 00000000..7d299984 --- /dev/null +++ b/tests/msvc10/twopart.vcxproj @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Emscripten"> + <Configuration>Debug</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Emscripten"> + <Configuration>Release</Configuration> + <Platform>Emscripten</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C896D890-9132-4A2D-8BA8-0EB6888FEAC2}</ProjectGuid> + <RootNamespace>twopart</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <PlatformToolset>emcc</PlatformToolset> + <ConfigurationType>HTMLPage</ConfigurationType> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Emscripten'"> + <IntDir>$(Platform)\$(ProjectName)_$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\twopart_main.cpp" /> + <ClCompile Include="..\twopart_side.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tests/pre_run_deps.cpp b/tests/pre_run_deps.cpp new file mode 100644 index 00000000..41c06972 --- /dev/null +++ b/tests/pre_run_deps.cpp @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <emscripten.h> + +int main() { + printf("main() called.\n"); + int result = emscripten_run_script_int("Module.okk"); + REPORT_RESULT(); + return 1; +} + diff --git a/tests/runner.py b/tests/runner.py index fcb84952..bf3bf119 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -355,7 +355,6 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows js_engines = filter(lambda engine: engine not in self.banned_js_engines, js_engines) if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check %s and settings.py and the paths therein.' % EM_CONFIG) for engine in js_engines: - engine = filter(lambda arg: arg != '-n', engine) # SpiderMonkey issue 716255 js_output = self.run_generated_code(engine, filename + '.o.js', args) if output_nicerizer is not None: js_output = output_nicerizer(js_output) @@ -909,6 +908,53 @@ m_divisor is 1091269979 code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read() assert 'goog.math.Long' not in code and 'jsbn' not in code, 'i64 precise math should not have been included if not actually used' + def test_i64_zextneg(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2') + + src = r''' + #include <stdint.h> + #include <stdio.h> + + int main(int argc, char *argv[]) + { + uint8_t byte = 0x80; + uint16_t two = byte; + uint32_t four = byte; + uint64_t eight = byte; + + printf("value: %d,%d,%d,%lld.\n", byte, two, four, eight); + + return 0; + } + ''' + self.do_run(src, 'value: 128,128,128,128.') + + def test_i64_7z(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2') + + src = r''' + #include <stdint.h> + #include <stdio.h> + uint64_t a, b; + int main(int argc, char *argv[]) + { + a = argc; + b = argv[1][0]; + if (a > a + b || a > a + b + 1) { + printf("one %lld, %lld", a, b); + return 0; + } + printf("zero %lld, %lld", a, b); + return 0; + } + ''' + self.do_run(src, 'zero 2, 104', ['hallo']) + + def test_sha1(self): + if self.emcc_args == None: return self.skip('needs ta2') + + self.do_run(open(path_from_root('tests', 'sha1.c')).read(), 'SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6') + def test_cube2hash(self): # A good test of i64 math if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2 C-style memory aliasing') @@ -2702,7 +2748,7 @@ def process(filename): output = Popen(['python', EMCC, all_name], stderr=PIPE).communicate() # Check for warning in the generated code generated = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read() - assert 'Casting a function pointer type to another with a different number of arguments.' in output[1], 'Missing expected warning' + assert 'Casting a function pointer type to another with a different number of arguments' in output[1], 'Missing expected warning' def test_stdlibs(self): if Settings.USE_TYPED_ARRAYS == 2: @@ -3546,6 +3592,7 @@ def process(filename): printf("%g\n", strtod("0", &endptr)); printf("%g\n", strtod("0.", &endptr)); printf("%g\n", strtod("0.0", &endptr)); + printf("%g\n", strtod("-0.0", &endptr)); printf("%g\n", strtod("1", &endptr)); printf("%g\n", strtod("1.", &endptr)); printf("%g\n", strtod("1.0", &endptr)); @@ -3570,6 +3617,7 @@ def process(filename): 0 0 0 + 0 1 1 1 @@ -3588,6 +3636,7 @@ def process(filename): ''' self.do_run(src, re.sub(r'\n\s+', '\n', expected)) + self.do_run(src.replace('strtod', 'strtold'), re.sub(r'\n\s+', '\n', expected)) # XXX add real support for long double def test_strtok(self): src = r''' @@ -3759,10 +3808,28 @@ at function.:blag printf("|%s|\n", buffy); sscanf("cheez somethingmoar\tyet more\n", "cheez %s", buffy); printf("|%s|\n", buffy); + + int numverts = -1; + printf("%d\n", sscanf(" numverts 1499\n", " numverts %d", &numverts)); // white space is the same, even if tab vs space + printf("%d\n", numverts); + + int index; + float u, v; + short start, count; + printf("%d\n", sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n", " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count)); + printf("%d,%.6f,%.6f,%hu,%hu\n", index, u, v, start, count); + + int neg, neg2, neg3 = 0; + printf("%d\n", sscanf("-123 -765 -34-6", "%d %u %d", &neg, &neg2, &neg3)); + printf("%d,%u,%d\n", neg, neg2, neg3); + return 0; } ''' - self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300\n|some|\n|something|\n|somethingmoar|') + self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' + + '1\n1499\n' + + '5\n87,0.481565,0.059481,0,1\n' + + '3\n-123,4294966531,-34\n') def test_sscanf_2(self): # doubles @@ -4902,7 +4969,7 @@ def process(filename): self.do_run(r''' #define SQLITE_DISABLE_LFS #define LONGDOUBLE_TYPE double - #define SQLITE_INT64_TYPE int + #define SQLITE_INT64_TYPE long long int #define SQLITE_THREADSAFE 0 ''' + open(path_from_root('tests', 'sqlite', 'sqlite3.c'), 'r').read() + open(path_from_root('tests', 'sqlite', 'benchmark.c'), 'r').read(), @@ -6029,6 +6096,120 @@ def process(filename): ''' self.do_run(src, 'hello, world!\ncleanup\nExit Status: 118') + def test_gc(self): + if self.emcc_args == None: return self.skip('needs ta2') + + Settings.GC_SUPPORT = 1 + + src = r''' + #include <stdio.h> + #include <gc.h> + #include <assert.h> + + void *global; + + void finalizer(void *ptr, void *arg) { + printf("finalizing %d (global == %d)\n", (int)arg, ptr == global); + } + + void finalizer2(void *ptr, void *arg) { + printf("finalizing2 %d (global == %d)\n", (int)arg, ptr == global); + } + + int main() { + GC_INIT(); + + void *local, *local2, *local3, *local4; + + // Hold on to global, drop locals + + global = GC_MALLOC(1024); // rooted since in a static allocation + GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0); + printf("alloc %p\n", global); + + local = GC_MALLOC(1024); // not rooted since stack is not scanned + GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0); + printf("alloc %p\n", local); + + assert((char*)local - (char*)global >= 1024 || (char*)global - (char*)local >= 1024); + + local2 = GC_MALLOC(1024); // no finalizer + printf("alloc %p\n", local2); + + local3 = GC_MALLOC(1024); // with finalizable2 + GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer2, (void*)2, 0, 0); + printf("alloc %p\n", local); + + local4 = GC_MALLOC(1024); // yet another + GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer2, (void*)3, 0, 0); + printf("alloc %p\n", local); + + printf("basic test\n"); + + GC_FORCE_COLLECT(); + + printf("*\n"); + + GC_FREE(global); // force free will actually work + + // scanning inside objects + + global = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0); + local = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0); + local2 = GC_MALLOC_ATOMIC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local2, finalizer, (void*)2, 0, 0); + local3 = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer, (void*)3, 0, 0); + local4 = GC_MALLOC(12); + GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer, (void*)4, 0, 0); + + void **globalData = (void**)global; + globalData[0] = local; + globalData[1] = local2; + + void **localData = (void**)local; + localData[0] = local3; + + void **local2Data = (void**)local2; + local2Data[0] = local4; // actually ignored, because local2 is atomic, so 4 is freeable + + printf("object scan test test\n"); + + GC_FORCE_COLLECT(); + + printf("*\n"); + + GC_FREE(global); // force free will actually work + + printf("*\n"); + + GC_FORCE_COLLECT(); + + printf(".\n"); + + global = 0; + + return 0; + } + ''' + self.do_run(src, '''basic test +finalizing 1 (global == 0) +finalizing2 2 (global == 0) +finalizing2 3 (global == 0) +* +finalizing 0 (global == 1) +object scan test test +finalizing 4 (global == 0) +* +finalizing 0 (global == 1) +* +finalizing 1 (global == 0) +finalizing 2 (global == 0) +finalizing 3 (global == 0) +. +''') # Generate tests for everything def make_run(fullname, name=-1, compiler=-1, llvm_opts=0, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None): @@ -6126,6 +6307,10 @@ This is free and open source software under the MIT license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ''', output[0].replace('\r', ''), output[1].replace('\r', '')) + # -v, without input files + output = Popen(['python', compiler, '-v'], stdout=PIPE, stderr=PIPE).communicate() + self.assertContained('''clang version''', output[1].replace('\r', ''), output[1].replace('\r', '')) + # --help output = Popen(['python', compiler, '--help'], stdout=PIPE, stderr=PIPE).communicate() self.assertContained('''%s [options] file... @@ -6354,6 +6539,26 @@ f.close() # TODO: test normal project linking, static and dynamic: get_library should not need to be told what to link! # TODO: deprecate llvm optimizations, dlmalloc, etc. in emscripten.py. + def test_catch_undef(self): + open(os.path.join(self.get_dir(), 'test.cpp'), 'w').write(r''' + #include <vector> + #include <stdio.h> + + class Test { + public: + std::vector<int> vector; + }; + + Test globalInstance; + + int main() { + printf("hello, world!\n"); + return 1; + } + ''') + Popen(['python', EMCC, os.path.join(self.get_dir(), 'test.cpp'), '-fcatch-undefined-behavior']).communicate() + self.assertContained('hello, world!', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_l_link(self): # Linking with -lLIBNAME and -L/DIRNAME should work @@ -6570,6 +6775,38 @@ f.close() Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'before.js', '--post-js', 'after.js']).communicate() self.assertContained('hello from main\nhello from js\n', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_sdl_endianness(self): + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r''' + #include <stdio.h> + #include <SDL/SDL.h> + + int main() { + printf("%d, %d, %d\n", SDL_BYTEORDER, SDL_LIL_ENDIAN, SDL_BIG_ENDIAN); + return 0; + } + ''') + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')]).communicate() + self.assertContained('1234, 1234, 4321\n', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + + def test_warn_undefined(self): + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r''' + #include <stdio.h> + + extern "C" { + void something(); + } + + int main() { + something(); + return 0; + } + ''') + output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'WARN_ON_UNDEFINED_SYMBOLS=1'], stderr=PIPE).communicate() + self.assertContained('Unresolved symbol: _something\n', output[1]) + + output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')], stderr=PIPE).communicate() + self.assertNotContained('Unresolved symbol: _something\n', output[1]) + def test_prepost(self): open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(''' #include <stdio.h> @@ -6629,6 +6866,8 @@ f.close() ['simplifyExpressionsPre', 'optimizeShiftsConservative']), (path_from_root('tools', 'test-js-optimizer-t2.js'), open(path_from_root('tools', 'test-js-optimizer-t2-output.js')).read(), ['simplifyExpressionsPre', 'optimizeShiftsAggressive']), + (path_from_root('tools', 'test-js-optimizer-regs.js'), open(path_from_root('tools', 'test-js-optimizer-regs-output.js')).read(), + ['registerize']), ]: output = Popen([NODE_JS, JS_OPTIMIZER, input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0] self.assertIdentical(expected, output.replace('\n\n', '\n')) @@ -6664,6 +6903,23 @@ fscanfed: 10 - hello ''', output[0]) self.assertIdentical('texte\n', output[1]) + def test_emconfig(self): + output = Popen(['python', EMCONFIG, 'LLVM_ROOT'], stdout=PIPE, stderr=PIPE).communicate()[0] + assert output == LLVM_ROOT + "\n" + invalid = 'Usage: em-config VAR_NAME\n' + # Don't accept variables that do not exist + output = Popen(['python', EMCONFIG, 'VAR_WHICH_DOES_NOT_EXIST'], stdout=PIPE, stderr=PIPE).communicate()[0] + assert output == invalid + # Don't accept no arguments + output = Popen(['python', EMCONFIG], stdout=PIPE, stderr=PIPE).communicate()[0] + assert output == invalid + # Don't accept more than one variable + output = Popen(['python', EMCONFIG, 'LLVM_ROOT', 'EMCC'], stdout=PIPE, stderr=PIPE).communicate()[0] + assert output == invalid + # Don't accept arbitrary python code + output = Popen(['python', EMCONFIG, 'sys.argv[1]'], stdout=PIPE, stderr=PIPE).communicate()[0] + assert output == invalid + elif 'browser' in str(sys.argv): # Browser tests. @@ -6739,7 +6995,7 @@ elif 'browser' in str(sys.argv): browser.harness_queue.put('http://localhost:8888/' + html_file) output = '[no http server activity]' start = time.time() - while time.time() - start < 5: + while time.time() - start < 60: if not queue.empty(): output = queue.get() break @@ -6863,27 +7119,47 @@ elif 'browser' in str(sys.argv): def test_preload_file(self): open(os.path.join(self.get_dir(), 'somefile.txt'), 'w').write('''load me right before running the code please''') - open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r''' - #include <stdio.h> - #include <string.h> - #include <emscripten.h> - int main() { - FILE *f = fopen("somefile.txt", "r"); - char buf[100]; - fread(buf, 1, 20, f); - buf[20] = 0; - fclose(f); - printf("|%s|\n", buf); + def make_main(path): + print path + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r''' + #include <stdio.h> + #include <string.h> + #include <emscripten.h> + int main() { + FILE *f = fopen("%s", "r"); + char buf[100]; + fread(buf, 1, 20, f); + buf[20] = 0; + fclose(f); + printf("|%%s|\n", buf); - int result = !strcmp("load me right before", buf); - REPORT_RESULT(); - return 0; - } - ''')) + int result = !strcmp("load me right before", buf); + REPORT_RESULT(); + return 0; + } + ''' % path)) + make_main('somefile.txt') Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'somefile.txt', '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + # By absolute path + + make_main(os.path.join(self.get_dir(), 'somefile.txt')) + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', os.path.join(self.get_dir(), 'somefile.txt'), '-o', 'page.html']).communicate() + self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + + # With FS.preloadFile + + open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' + Module.preRun = function() { + FS.createPreloadedFile('/', 'someotherfile.txt', 'somefile.txt', true, false); + }; + ''') + make_main('someotherfile.txt') + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'pre.js', '-o', 'page.html']).communicate() + self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + def test_multifile(self): # a few files inside a directory self.clear() @@ -7050,10 +7326,11 @@ elif 'browser' in str(sys.argv): Module['canvas'].dispatchEvent(event1); } } + window['simulateMouseEvent'] = simulateMouseEvent; ''') open(os.path.join(self.get_dir(), 'sdl_mouse.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_mouse.c')).read())) - Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-o', 'page.html', '--pre-js', 'pre.js']).communicate() + Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-O2', '--minify', '0', '-o', 'page.html', '--pre-js', 'pre.js']).communicate() self.run_browser('page.html', '', '/report_result?740') def test_sdl_audio(self): @@ -7072,10 +7349,17 @@ elif 'browser' in str(sys.argv): self.run_browser('something.html', '.', '/report_result?1') def test_sdl_ogl(self): - # SDL, OpenGL, textures, immediate mode + # SDL, OpenGL, textures, immediate mode. Closure for more coverage shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-gray.png')) - Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate() + self.reftest(path_from_root('tests', 'screenshot-gray-purple.png')) + Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate() + self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0') + + def test_sdl_ogl_defaultmatrixmode(self): + # SDL, OpenGL, textures, immediate mode. Closure for more coverage + shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) + self.reftest(path_from_root('tests', 'screenshot-gray-purple.png')) + Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl_defaultMatrixMode.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate() self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0') def test_sdl_ogl_p(self): @@ -7165,10 +7449,74 @@ elif 'browser' in str(sys.argv): Popen(['python', EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js'] + args).communicate() self.run_browser('program.html', '', '/report_result?0') + def btest(self, filename, expected=None, reference=None, args=[]): # TODO: use in all other tests + if not reference: + open(os.path.join(self.get_dir(), filename), 'w').write(self.with_report_result(open(path_from_root('tests', filename)).read())) + else: + expected = '0' # 0 pixels difference than reference + shutil.copyfile(path_from_root('tests', filename), os.path.join(self.get_dir(), filename)) + self.reftest(path_from_root('tests', reference)) + args += ['--pre-js', 'reftest.js'] + Popen(['python', EMCC, os.path.join(self.get_dir(), filename), '-o', 'test.html'] + args).communicate() + self.run_browser('test.html', '.', '/report_result?' + expected) + def test_emscripten_api(self): - open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(open(path_from_root('tests', 'emscripten_api_browser.cpp')).read())) - Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html']).communicate() - self.run_browser('page.html', '', '/report_result?1') + self.btest('emscripten_api_browser.cpp', '1') + + def test_gc(self): + self.btest('browser_gc.cpp', '1') + + def test_sdlglshader(self): + self.btest('sdlglshader.c', reference='sdlglshader.png', args=['--closure', '1']) + + def test_gl_ps(self): + # pointers and a shader + shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) + self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png']) + + def test_cubegeom_pre(self): + self.btest('cubegeom_pre.c', expected='-1472804742') + + def test_cubegeom_pre2(self): + self.btest('cubegeom_pre2.c', expected='-1472804742', args=['-s', 'GL_DEBUG=1']) # some coverage for GL_DEBUG not breaking the build + + def test_cubegeom_pre3(self): + self.btest('cubegeom_pre3.c', expected='-1472804742') + + def test_cubegeom(self): + self.btest('cubegeom.c', expected='188641320') + + def test_cubegeom_color(self): + self.btest('cubegeom_color.c', expected='588472350') + + def test_cubegeom_normal(self): + self.btest('cubegeom_normal.c', expected='752917084') + + def test_cubegeom_mt(self): + self.btest('cubegeom_mt.c', expected='-457159152') # multitexture + + def test_cubegeom_color2(self): + self.btest('cubegeom_color2.c', expected='1121999515') + + def test_cubegeom_texturematrix(self): + self.btest('cubegeom_texturematrix.c', expected='1297500583') + + def test_cube_explosion(self): + self.btest('cube_explosion.c', expected='667220544') + + def test_pre_run_deps(self): + # Adding a dependency in preRun will delay run + open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' + Module.preRun = function() { + addRunDependency(); + Module.print('preRun called, added a dependency...'); + setTimeout(function() { + Module.okk = 10; + removeRunDependency() + }, 2000); + }; + ''') + self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js']) elif 'benchmark' in str(sys.argv): # Benchmarks. Run them with argument |benchmark|. To run a specific test, do diff --git a/tests/screenshot-gray-purple.png b/tests/screenshot-gray-purple.png Binary files differnew file mode 100644 index 00000000..514b29a1 --- /dev/null +++ b/tests/screenshot-gray-purple.png diff --git a/tests/sdl_audio.c b/tests/sdl_audio.c index 4927d868..938df3c4 100644 --- a/tests/sdl_audio.c +++ b/tests/sdl_audio.c @@ -10,14 +10,23 @@ void play2(); void play() { int channel = Mix_PlayChannel(-1, sound, 1); - assert(channel >= 0); + assert(channel == 0); emscripten_run_script("setTimeout(Module['_play2'], 500)"); } +void done(int channel) { + assert(channel == 1); + + int result = 1; + REPORT_RESULT(); +} + void play2() { + Mix_ChannelFinished(done); + int channel2 = Mix_PlayChannel(-1, sound2, 1); - assert(channel2 >= 0); + assert(channel2 == 1); } int main(int argc, char **argv) { @@ -42,9 +51,6 @@ int main(int argc, char **argv) { printf("you should hear two sounds. press the button to replay!\n"); - int result = 1; - REPORT_RESULT(); - return 0; } diff --git a/tests/sdl_image.c b/tests/sdl_image.c index d934f863..9d8c36f2 100644 --- a/tests/sdl_image.c +++ b/tests/sdl_image.c @@ -4,30 +4,40 @@ #include <assert.h> #include <emscripten.h> -int main() { - SDL_Init(SDL_INIT_VIDEO); - SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE); - - SDL_Surface *image = IMG_Load("screenshot.jpg"); +int testImage(SDL_Surface* screen, const char* fileName) { + SDL_Surface *image = IMG_Load(fileName); if (!image) { printf("IMG_Load: %s\n", IMG_GetError()); - return 1; + return 0; } assert(image->format->BitsPerPixel == 32); assert(image->format->BytesPerPixel == 4); assert(image->pitch == 4*image->w); + int result = image->w; SDL_BlitSurface (image, NULL, screen, NULL); SDL_FreeSurface (image); - SDL_Flip(screen); + return result; +} + +int main() { + SDL_Init(SDL_INIT_VIDEO); + SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE); + + int result = 0; + result = testImage(screen, "screenshot.jpg"); // relative path + assert(result != 0); + result |= testImage(screen, "/screenshot.jpg"); // absolute path + assert(result != 0); + + SDL_Flip(screen); printf("you should see an image.\n"); SDL_Quit(); - int result = image->w; REPORT_RESULT(); return 0; diff --git a/tests/sdl_key.c b/tests/sdl_key.c index f82f8e72..19b0a3d6 100644 --- a/tests/sdl_key.c +++ b/tests/sdl_key.c @@ -25,7 +25,8 @@ void one() { } printf("unknown key: sym %d scancode %d\n", event.key.keysym.sym, event.key.keysym.scancode); REPORT_RESULT(); - emscripten_run_script("throw 'done'"); + emscripten_run_script("throw 'done'"); // comment this out to leave event handling active. Use the following to log DOM keys: + // addEventListener('keyup', function(event) { console.log(event.keyCode) }, true) } } break; @@ -39,13 +40,13 @@ int main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); - emscripten_run_script("simulateKeyEvent(38)"); - emscripten_run_script("simulateKeyEvent(40)"); - emscripten_run_script("simulateKeyEvent(37)"); - emscripten_run_script("simulateKeyEvent(39)"); - emscripten_run_script("simulateKeyEvent(32)"); - emscripten_run_script("simulateKeyEvent(97)"); - emscripten_run_script("simulateKeyEvent(98)"); + emscripten_run_script("simulateKeyEvent(38)"); // up + emscripten_run_script("simulateKeyEvent(40)"); // down + emscripten_run_script("simulateKeyEvent(37)"); // left + emscripten_run_script("simulateKeyEvent(39)"); // right + emscripten_run_script("simulateKeyEvent(32)"); // space + emscripten_run_script("simulateKeyEvent(65)"); // a + emscripten_run_script("simulateKeyEvent(66)"); // b emscripten_run_script("simulateKeyEvent(100)"); // trigger the end if (argc == 1337) one(); // keep it alive diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c index 7fc14638..eb4aa425 100644 --- a/tests/sdl_mouse.c +++ b/tests/sdl_mouse.c @@ -49,11 +49,11 @@ int main() { SDL_Rect rect = { 0, 0, 600, 450 }; SDL_FillRect(screen, &rect, 0x2244ffff); - emscripten_run_script("simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20 - emscripten_run_script("simulateMouseEvent(10, 20, 0)"); // click - emscripten_run_script("simulateMouseEvent(10, 20, 0)"); // click some more, but this one should be ignored through PeepEvent - emscripten_run_script("simulateMouseEvent(30, 77, -1)"); // move some more - emscripten_run_script("simulateMouseEvent(30, 77, 1)"); // trigger the end + emscripten_run_script("window.simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20 + emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click + emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click some more, but this one should be ignored through PeepEvent + emscripten_run_script("window.simulateMouseEvent(30, 77, -1)"); // move some more + emscripten_run_script("window.simulateMouseEvent(30, 77, 1)"); // trigger the end emscripten_set_main_loop(one, 0); diff --git a/tests/sdl_ogl.c b/tests/sdl_ogl.c index 9aaae280..6b6a5b4a 100644 --- a/tests/sdl_ogl.c +++ b/tests/sdl_ogl.c @@ -58,6 +58,7 @@ int main(int argc, char *argv[]) glViewport( 0, 0, 640, 480 ); glMatrixMode( GL_PROJECTION ); + glPushMatrix(); // just for testing glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1, 1 ); @@ -138,7 +139,26 @@ int main(int argc, char *argv[]) glTexCoord2i( 1, 1 ); glVertex3f( 300, 400, 0 ); glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 ); glEnd(); - + +#if !EMSCRIPTEN + glDisable(GL_TEXTURE_2D); +#endif + + glColor3ub(90, 255, 255); + glBegin( GL_QUADS ); + glVertex3f( 10, 410, 0 ); + glVertex3f( 300, 410, 0 ); + glVertex3f( 300, 480, 0 ); + glVertex3f( 10, 470, 0 ); + glEnd(); + + glBegin( GL_QUADS ); + glColor3f(1.0, 0, 1.0); glVertex3f( 410, 410, 0 ); + glColor3f(0, 1.0, 0); glVertex3f( 600, 410, 0 ); + glColor3f(0, 0, 1.0); glVertex3f( 600, 480, 0 ); + glColor3f(1.0, 1.0, 1.0); glVertex3f( 410, 470, 0 ); + glEnd(); + SDL_GL_SwapBuffers(); #if !EMSCRIPTEN diff --git a/tests/sdl_ogl_defaultMatrixMode.c b/tests/sdl_ogl_defaultMatrixMode.c new file mode 100644 index 00000000..0da0a326 --- /dev/null +++ b/tests/sdl_ogl_defaultMatrixMode.c @@ -0,0 +1,176 @@ +/******************************************************************* + * * + * Using SDL With OpenGL * + * * + * Tutorial by Kyle Foley (sdw) * + * * + * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL * + * * + *******************************************************************/ + +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#include "SDL/SDL.h" +#include "SDL/SDL_image.h" +#include "SDL/SDL_opengl.h" + +#include <stdio.h> +#include <string.h> + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + + // Slightly different SDL initialization + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new* + + screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + // Set the OpenGL state after creating the context with SDL_SetVideoMode + + glClearColor( 0, 0, 0, 0 ); + +#if !EMSCRIPTEN + glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL +#endif + + glViewport( 0, 0, 640, 480 ); + + // GL_MODELVIEW should be the default... + //glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); // just for testing + glLoadIdentity(); + + glOrtho( 0, 640, 480, 0, -1, 1 ); + + // Load the OpenGL texture + + GLuint texture; // Texture object handle + SDL_Surface *surface; // Gives us the information to make the texture + + if ( (surface = IMG_Load("screenshot.png")) ) { + + // Check that the image's width is a power of 2 + if ( (surface->w & (surface->w - 1)) != 0 ) { + printf("warning: image.bmp's width is not a power of 2\n"); + } + + // Also check if the height is a power of 2 + if ( (surface->h & (surface->h - 1)) != 0 ) { + printf("warning: image.bmp's height is not a power of 2\n"); + } + + // Have OpenGL generate a texture object handle for us + glGenTextures( 1, &texture ); + + // Bind the texture object + glBindTexture( GL_TEXTURE_2D, texture ); + + // Set the texture's stretching properties + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + //SDL_LockSurface(surface); + + // Add some greyness + memset(surface->pixels, 0x66, surface->w*surface->h); + + // Edit the texture object's image data using the information SDL_Surface gives us + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); + + //SDL_UnlockSurface(surface); + } + else { + printf("SDL could not load image.bmp: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + // Free the SDL_Surface only if it was successfully created + if ( surface ) { + SDL_FreeSurface( surface ); + } + + // Clear the screen before drawing + glClear( GL_COLOR_BUFFER_BIT ); + + // Bind the texture to which subsequent calls refer to + glBindTexture( GL_TEXTURE_2D, texture ); + + glBegin( GL_QUADS ); + glTexCoord2i( 0, 0 ); glVertex3f( 10, 10, 0 ); + glTexCoord2i( 1, 0 ); glVertex3f( 300, 10, 0 ); + glTexCoord2i( 1, 1 ); glVertex3f( 300, 128, 0 ); + glTexCoord2i( 0, 1 ); glVertex3f( 10, 128, 0 ); + + glTexCoord2f( 0, 0.5 ); glVertex3f( 410, 10, 0 ); + glTexCoord2f( 1, 0.5 ); glVertex3f( 600, 10, 0 ); + glTexCoord2f( 1, 1 ); glVertex3f( 630, 200, 0 ); + glTexCoord2f( 0.5, 1 ); glVertex3f( 310, 250, 0 ); + glEnd(); + + glBegin( GL_TRIANGLE_STRIP ); + glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 ); + glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 ); + glTexCoord2i( 1, 1 ); glVertex3f( 300, 400, 0 ); + glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 ); + glEnd(); + +#if !EMSCRIPTEN + glDisable(GL_TEXTURE_2D); +#endif + + glColor3ub(90, 255, 255); + glBegin( GL_QUADS ); + glVertex3f( 10, 410, 0 ); + glVertex3f( 300, 410, 0 ); + glVertex3f( 300, 480, 0 ); + glVertex3f( 10, 470, 0 ); + glEnd(); + + glBegin( GL_QUADS ); + glColor3f(1.0, 0, 1.0); glVertex3f( 410, 410, 0 ); + glColor3f(0, 1.0, 0); glVertex3f( 600, 410, 0 ); + glColor3f(0, 0, 1.0); glVertex3f( 600, 480, 0 ); + glColor3f(1.0, 1.0, 1.0); glVertex3f( 410, 470, 0 ); + glEnd(); + + SDL_GL_SwapBuffers(); + +#if !EMSCRIPTEN + // Wait for 3 seconds to give us a chance to see the image + SDL_Delay(3000); +#endif + + // Now we can delete the OpenGL texture and close down SDL + glDeleteTextures( 1, &texture ); + + SDL_Quit(); + + return 0; +} diff --git a/tests/sdl_ogl_p.c b/tests/sdl_ogl_p.c index 3978f66c..949aaa44 100644 --- a/tests/sdl_ogl_p.c +++ b/tests/sdl_ogl_p.c @@ -58,10 +58,12 @@ int main(int argc, char *argv[]) glViewport( 0, 0, 640, 480 ); glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); + GLfloat matrixData[] = { 2.0/640, 0, 0, 0, + 0, -2.0/480, 0, 0, + 0, 0, -1, 0, + -1, 1, 0, 1 }; + glLoadMatrixf(matrixData); // test loadmatrix - glOrtho( 0, 640, 480, 0, -1, 1 ); - glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); diff --git a/tests/sdlglshader.c b/tests/sdlglshader.c new file mode 100644 index 00000000..a096ef20 --- /dev/null +++ b/tests/sdlglshader.c @@ -0,0 +1,153 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#include "SDL/SDL.h" +#include "SDL/SDL_opengl.h" + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +// GL_ARB_shading_language_100, GL_ARB_shader_objects, GL_ARB_fragment_shader, GL_ARB_vertex_shader +PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObject_ = NULL; +PFNGLDELETEOBJECTARBPROC glDeleteObject_ = NULL; +PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObject_ = NULL; +PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObject_ = NULL; +PFNGLSHADERSOURCEARBPROC glShaderSource_ = NULL; +PFNGLCOMPILESHADERARBPROC glCompileShader_ = NULL; +PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv_ = NULL; +PFNGLATTACHOBJECTARBPROC glAttachObject_ = NULL; +PFNGLGETINFOLOGARBPROC glGetInfoLog_ = NULL; +PFNGLLINKPROGRAMARBPROC glLinkProgram_ = NULL; +PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocation_ = NULL; +PFNGLUNIFORM1FARBPROC glUniform1f_ = NULL; +PFNGLUNIFORM2FARBPROC glUniform2f_ = NULL; +PFNGLUNIFORM3FARBPROC glUniform3f_ = NULL; +PFNGLUNIFORM4FARBPROC glUniform4f_ = NULL; +PFNGLUNIFORM1FVARBPROC glUniform1fv_ = NULL; +PFNGLUNIFORM2FVARBPROC glUniform2fv_ = NULL; +PFNGLUNIFORM3FVARBPROC glUniform3fv_ = NULL; +PFNGLUNIFORM4FVARBPROC glUniform4fv_ = NULL; +PFNGLUNIFORM1IARBPROC glUniform1i_ = NULL; +PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocation_ = NULL; +PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniform_ = NULL; + +void initARB() { + glCreateProgramObject_ = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + glDeleteObject_ = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); + glUseProgramObject_ = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + glCreateShaderObject_ = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + glShaderSource_ = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); + glCompileShader_ = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); + glGetObjectParameteriv_ = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + glAttachObject_ = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); + glGetInfoLog_ = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); + glLinkProgram_ = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); + glGetUniformLocation_ = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); + glUniform1f_ = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); + glUniform2f_ = (PFNGLUNIFORM2FARBPROC) SDL_GL_GetProcAddress("glUniform2fARB"); + glUniform3f_ = (PFNGLUNIFORM3FARBPROC) SDL_GL_GetProcAddress("glUniform3fARB"); + glUniform4f_ = (PFNGLUNIFORM4FARBPROC) SDL_GL_GetProcAddress("glUniform4fARB"); + glUniform1fv_ = (PFNGLUNIFORM1FVARBPROC) SDL_GL_GetProcAddress("glUniform1fvARB"); + glUniform2fv_ = (PFNGLUNIFORM2FVARBPROC) SDL_GL_GetProcAddress("glUniform2fvARB"); + glUniform3fv_ = (PFNGLUNIFORM3FVARBPROC) SDL_GL_GetProcAddress("glUniform3fvARB"); + glUniform4fv_ = (PFNGLUNIFORM4FVARBPROC) SDL_GL_GetProcAddress("glUniform4fvARB"); + glUniform1i_ = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); + glBindAttribLocation_ = (PFNGLBINDATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glBindAttribLocationARB"); + glGetActiveUniform_ = (PFNGLGETACTIVEUNIFORMARBPROC) SDL_GL_GetProcAddress("glGetActiveUniformARB"); +} + +void setShaders() { + GLuint v, f, p; + GLint ok; + + const char *vv = "void main() \n" + "{ \n" + " gl_Position = ftransform() + vec4(0.1, -0.25, 0, 0); \n" + "}"; + const char *ff = "void main() \n" + "{ \n" + " gl_FragColor = vec4(gl_FragCoord.y/480.0, gl_FragCoord.x/640.0, 0.66, 1.0); \n" + "}"; + + v = glCreateShaderObject_(GL_VERTEX_SHADER); + f = glCreateShaderObject_(GL_FRAGMENT_SHADER); + + glShaderSource_(v, 1, &vv,NULL); + glShaderSource_(f, 1, &ff,NULL); + + glCompileShader_(v); + glGetObjectParameteriv_(v, GL_OBJECT_COMPILE_STATUS_ARB, &ok); + assert(ok); + + glCompileShader_(f); + glGetObjectParameteriv_(f, GL_OBJECT_COMPILE_STATUS_ARB, &ok); + assert(ok); + + p = glCreateProgramObject_(); + glAttachObject_(p,f); + glAttachObject_(p,v); + + glLinkProgram_(p); + glGetObjectParameteriv_(p, GL_OBJECT_LINK_STATUS_ARB, &ok); + assert(ok); + + glUseProgramObject_(p); +} + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + + assert(SDL_Init(SDL_INIT_VIDEO) == 0); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); + assert(screen); + + glClearColor(0, 0, 0, 0); + glViewport(0, 0, 640, 480); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, 640, 480, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClear(GL_COLOR_BUFFER_BIT); + + initARB(); + setShaders(); + + glColor3f(0, 1, 1); // is overridden by the shader, useful for debugging native builds + glBegin( GL_TRIANGLES ); + glTexCoord2i(0, 0); glVertex3f( 10, 10, 0); + glTexCoord2i(1, 0); glVertex3f( 300, 10, 0); + glTexCoord2i(1, 1); glVertex3f( 300, 328, 0); + glEnd(); + + glColor3f(1, 1, 0); // is overridden by the shader, useful for debugging native builds + glBegin( GL_TRIANGLES ); + glTexCoord2f(0, 0.5); glVertex3f(410, 10, 0); + glTexCoord2f(1, 0.5); glVertex3f(600, 10, 0); + glTexCoord2f(1, 1 ); glVertex3f(630, 400, 0); + glEnd(); + + SDL_GL_SwapBuffers(); + +#if !EMSCRIPTEN + SDL_Delay(3000); +#endif + + SDL_Quit(); + return 0; +} + diff --git a/tests/sdlglshader.png b/tests/sdlglshader.png Binary files differnew file mode 100644 index 00000000..5e52a617 --- /dev/null +++ b/tests/sdlglshader.png diff --git a/tests/sha1.c b/tests/sha1.c new file mode 100644 index 00000000..034939b5 --- /dev/null +++ b/tests/sha1.c @@ -0,0 +1,241 @@ + +/* from valgrind tests */ + +/* ================ sha1.c ================ */ +/* +SHA-1 in C +By Steve Reid <steve@edmweb.com> +100% Public Domain + +Test Vectors (from FIPS PUB 180-1) +"abc" + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 +A million repetitions of "a" + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F +*/ + +/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */ +/* #define SHA1HANDSOFF * Copies data before messing with it. */ + +#define SHA1HANDSOFF + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> /* for u_int*_t */ + +/* ================ sha1.h ================ */ +/* +SHA-1 in C +By Steve Reid <steve@edmweb.com> +100% Public Domain +*/ + +typedef struct { + u_int32_t state[5]; + u_int32_t count[2]; + unsigned char buffer[64]; +} SHA1_CTX; + +void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]); +void SHA1Init(SHA1_CTX* context); +void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len); +void SHA1Final(unsigned char digest[20], SHA1_CTX* context); +/* ================ end of sha1.h ================ */ +#include <endian.h> + +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + +/* blk0() and blk() perform the initial expand. */ +/* I got the idea of expanding during the round function from SSLeay */ +#if BYTE_ORDER == LITTLE_ENDIAN +#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ + |(rol(block->l[i],8)&0x00FF00FF)) +#elif BYTE_ORDER == BIG_ENDIAN +#define blk0(i) block->l[i] +#else +#error "Endianness not defined!" +#endif +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ + ^block->l[(i+2)&15]^block->l[i&15],1)) + +/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); +#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); +#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); + + +/* Hash a single 512-bit block. This is the core of the algorithm. */ + +void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]) +{ +u_int32_t a, b, c, d, e; +typedef union { + unsigned char c[64]; + u_int32_t l[16]; +} CHAR64LONG16; +#ifdef SHA1HANDSOFF +CHAR64LONG16 block[1]; /* use array to appear as a pointer */ + memcpy(block, buffer, 64); +#else + /* The following had better never be used because it causes the + * pointer-to-const buffer to be cast into a pointer to non-const. + * And the result is written through. I threw a "const" in, hoping + * this will cause a diagnostic. + */ +CHAR64LONG16* block = (const CHAR64LONG16*)buffer; +#endif + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; +#ifdef SHA1HANDSOFF + memset(block, '\0', sizeof(block)); +#endif +} + + +/* SHA1Init - Initialize new context */ + +void SHA1Init(SHA1_CTX* context) +{ + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; +} + + +/* Run your data through this. */ + +void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len) +{ +u_int32_t i; +u_int32_t j; + + j = context->count[0]; + if ((context->count[0] += len << 3) < j) + context->count[1]++; + context->count[1] += (len>>29); + j = (j >> 3) & 63; + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); +} + + +/* Add padding and return the message digest. */ + +void SHA1Final(unsigned char digest[20], SHA1_CTX* context) +{ +unsigned i; +unsigned char finalcount[8]; +unsigned char c; + +#if 0 /* untested "improvement" by DHR */ + /* Convert context->count to a sequence of bytes + * in finalcount. Second element first, but + * big-endian order within element. + * But we do it all backwards. + */ + unsigned char *fcp = &finalcount[8]; + + for (i = 0; i < 2; i++) + { + u_int32_t t = context->count[i]; + int j; + + for (j = 0; j < 4; t >>= 8, j++) + *--fcp = (unsigned char) t; + } +#else + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } +#endif + c = 0200; + SHA1Update(context, &c, 1); + while ((context->count[0] & 504) != 448) { + c = 0000; + SHA1Update(context, &c, 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + /* Wipe variables */ + memset(context, '\0', sizeof(*context)); + memset(&finalcount, '\0', sizeof(finalcount)); +} +/* ================ end of sha1.c ================ */ + +#define BUFSIZE 4096 + +int +main(int argc, char **argv) +{ + SHA1_CTX ctx; + unsigned char hash[20], buf[BUFSIZE]; + int i; + + for(i=0;i<BUFSIZE;i++) + buf[i] = i; + + SHA1Init(&ctx); + for(i=0;i<1000;i++) + SHA1Update(&ctx, buf, BUFSIZE); + SHA1Final(hash, &ctx); + + printf("SHA1="); + for(i=0;i<20;i++) + printf("%02x", hash[i]); + printf("\n"); + return 0; +} + diff --git a/tests/sqlite/benchmark.c b/tests/sqlite/benchmark.c index c1385525..802abab1 100644 --- a/tests/sqlite/benchmark.c +++ b/tests/sqlite/benchmark.c @@ -21,6 +21,7 @@ int test(){ "INSERT INTO t2 VALUES(1,13153,'thirteen thousand one hundred fifty three');", "INSERT INTO t2 VALUES(1,987,'some other number');", "SELECT count(*) FROM t2;", + "SELECT datetime('2012-04-16 12:35:57', '+1 days');", "SELECT a, b, c FROM t2;", NULL }; diff --git a/tests/sqlite/benchmark.txt b/tests/sqlite/benchmark.txt index 472221df..622493b3 100644 --- a/tests/sqlite/benchmark.txt +++ b/tests/sqlite/benchmark.txt @@ -1,5 +1,7 @@ count(*) = 2 +datetime('2012-04-16 12:35:57', '+1 days') = 2012-04-17 12:35:57 + a = 1 b = 13153 c = thirteen thousand one hundred fifty three diff --git a/third_party/lzma.js/doit.sh b/third_party/lzma.js/doit.sh index a8071534..1fe516b3 100755 --- a/third_party/lzma.js/doit.sh +++ b/third_party/lzma.js/doit.sh @@ -9,25 +9,25 @@ exit # just build natively, that's it echo "bitcode full (encoder+decoder)" make clean -DECODER_ONLY=0 ~/Dev/emscripten/emmake make lzip -j 4 +DECODER_ONLY=0 ../../../emmake make lzip -j 4 mv lzip lzip-full.bc echo "bitcode decoder only" make clean -DECODER_ONLY=1 ~/Dev/emscripten/emmake make lzip -j 4 +DECODER_ONLY=1 ../../../emmake make lzip -j 4 mv lzip lzip-decoder.bc cd .. echo "javascript full" -~/Dev/emscripten/emcc -O2 lzip/lzip-full.bc -o lzma-full.raw.js +../../emcc -O2 lzip/lzip-full.bc -o lzma-full.raw.js # -s INLINING_LIMIT=0 cat pre.js > lzma-full.js cat lzma-full.raw.js >> lzma-full.js cat post.js >> lzma-full.js echo "javascript decoder" -~/Dev/emscripten/emcc -O2 lzip/lzip-decoder.bc -o lzma-decoder.raw.js +../../emcc -O2 lzip/lzip-decoder.bc -o lzma-decoder.raw.js # -s INLINING_LIMIT=0 cat pre.js > lzma-decoder.js cat lzma-decoder.raw.js >> lzma-decoder.js diff --git a/tools/autodebugger.py b/tools/autodebugger.py index 943ff043..3631548c 100644 --- a/tools/autodebugger.py +++ b/tools/autodebugger.py @@ -13,6 +13,7 @@ import os, sys, re ALLOW_POINTERS = False ALLOW_MISC = True MEMCPY = False +NO_DLMALLOC = True POSTAMBLE = ''' @.emscripten.autodebug.str = private constant [10 x i8] c"AD:%d,%d\\0A\\00", align 1 ; [#uses=1] @@ -206,6 +207,7 @@ for.end: ; preds = %for.body, %entry lines_added = 0 lines = data.split('\n') in_func = False +added_entry = False for i in range(len(lines)): if MEMCPY: if not lines[i].startswith('declare void'): @@ -215,50 +217,55 @@ for i in range(len(lines)): pre = '' if lines[i].startswith('define '): in_func = True + if NO_DLMALLOC and ('@malloc(' in lines[i] or '@free(' in lines[i] or '@sys_alloc(' in lines[i] or '@segment_holding(' in lines[i] or '@init_top(' in lines[i] or '@add_segment(' in lines[i] or '@tmalloc_small(' in lines[i]): + in_func = False + if in_func: + added_entry = False elif lines[i].startswith('}'): in_func = False - elif in_func and ' = alloca' not in lines[i] and lines[i].startswith(' '): + elif in_func and not added_entry and ' = alloca' not in lines[i] and lines[i].startswith(' '): # This is a good place to mark entry to this function - in_func = False + added_entry = True index = i+1+lines_added pre = ' call void @emscripten_autodebug_i32(i32 -1, i32 %d)' % index - elif lines[i].startswith(' ret '): + elif in_func and lines[i].startswith(' ret '): # This is a good place to mark entry to this function index = i+1+lines_added pre = ' call void @emscripten_autodebug_i32(i32 -2, i32 %d)' % index - m = re.match(' store (?P<type>i64|i32|i16|i8|float|double|%?[\w\.\*]+) (?P<var>%?[\w.+_]+), .*', lines[i]) - if m: - index = i+1+lines_added - if m.group('type') in ['i8', 'i16', 'i32', 'i64', 'float', 'double']: - lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %s)' % (m.group('type'), index, m.group('type'), m.group('var')) - lines_added += 1 - elif ALLOW_POINTERS and m.group('type').endswith('*') and m.group('type').count('*') == 1: - lines[i] += '\n %%ead.%d = ptrtoint %s %s to i32' % (index, m.group('type'), m.group('var')) - lines[i] += '\n call void @emscripten_autodebug_i32(i32 %d, i32 %%ead.%d)' % (index, index) - lines_added += 2 - continue - m = re.match(' %(?P<var>[\w_.]+) = load (?P<type>i64|i32|i16|i8|float|double+)\* [^(].*.*', lines[i]) - if m: - index = i+1+lines_added - lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), index, m.group('type'), m.group('var')) - lines_added += 1 - continue - if ALLOW_MISC: - m = re.match(' %(?P<var>[\w_.]+) = (call|mul|add) (nsw )?(?P<type>i64|i32|i16|i8|float|double+) .*', lines[i]) + if in_func: + m = re.match(' store (?P<type>i64|i32|i16|i8|float|double|%?[\w\.\*]+) (?P<var>%?[\w.+_]+), .*', lines[i]) if m: index = i+1+lines_added - lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), index, m.group('type'), m.group('var')) - lines_added += 1 + if m.group('type') in ['i8', 'i16', 'i32', 'i64', 'float', 'double']: + lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %s)' % (m.group('type'), index, m.group('type'), m.group('var')) + lines_added += 1 + elif ALLOW_POINTERS and m.group('type').endswith('*') and m.group('type').count('*') == 1: + lines[i] += '\n %%ead.%d = ptrtoint %s %s to i32' % (index, m.group('type'), m.group('var')) + lines[i] += '\n call void @emscripten_autodebug_i32(i32 %d, i32 %%ead.%d)' % (index, index) + lines_added += 2 continue - m = re.match(' call void @llvm\.memcpy\.p0i8\.p0i8\.i32\(i8\* %(?P<dst>[\w_.]+), i8\* %(?P<src>[\w_.]+), i32 8, i32 (?P<align>\d+),.*', lines[i]) + m = re.match(' %(?P<var>[\w_.]+) = load (?P<type>i64|i32|i16|i8|float|double+)\* [^(].*.*', lines[i]) if m: index = i+1+lines_added - lines[i] += '\n %%adpretemp%d = bitcast i8* %%%s to i64*' % (index, m.group('src')) + \ - '\n %%adtemp%d = load i64* %%adpretemp%d, align %s' % (index, index, m.group('align')) + \ - '\n call void @emscripten_autodebug_%s(i32 %d, %s %%adtemp%d)' % ('i64', index, 'i64', index) - lines_added += 3 + lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), index, m.group('type'), m.group('var')) + lines_added += 1 continue + if ALLOW_MISC: + m = re.match(' %(?P<var>[\w_.]+) = (call|mul|add) (nsw )?(?P<type>i64|i32|i16|i8|float|double+) .*', lines[i]) + if m: + index = i+1+lines_added + lines[i] += '\n call void @emscripten_autodebug_%s(i32 %d, %s %%%s)' % (m.group('type'), index, m.group('type'), m.group('var')) + lines_added += 1 + continue + m = re.match(' call void @llvm\.memcpy\.p0i8\.p0i8\.i32\(i8\* %(?P<dst>[\w_.]+), i8\* %(?P<src>[\w_.]+), i32 8, i32 (?P<align>\d+),.*', lines[i]) + if m: + index = i+1+lines_added + lines[i] += '\n %%adpretemp%d = bitcast i8* %%%s to i64*' % (index, m.group('src')) + \ + '\n %%adtemp%d = load i64* %%adpretemp%d, align %s' % (index, index, m.group('align')) + \ + '\n call void @emscripten_autodebug_%s(i32 %d, %s %%adtemp%d)' % ('i64', index, 'i64', index) + lines_added += 3 + continue finally: if len(pre) > 0: diff --git a/tools/bisect_pair.py b/tools/bisect_pair.py index 3b880b28..8eea0d61 100644 --- a/tools/bisect_pair.py +++ b/tools/bisect_pair.py @@ -47,14 +47,12 @@ if len(curr) > 0: chunks.append(curr) # Bisect both sides of the span, until we have a single chunk -low = 0 high = len(chunks) print 'beginning bisection, %d chunks' % high -while high-low > 2: - mid = (low + high)/2 - print ' current status: %d - %d - %d' % (low, mid, high) +for mid in range(high): + print ' current: %d' % mid # Take chunks from the middle and on. This is important because the eliminator removes variables, so starting from the beginning will add errors curr_diff = '\n'.join(map(lambda parts: '\n'.join(parts), chunks[mid:])) + '\n' difff = open('diff.diff', 'w') @@ -64,11 +62,11 @@ while high-low > 2: Popen(['patch', 'middle', 'diff.diff'], stdout=PIPE, stderr=PIPE).communicate() result = run_js('middle', stderr=PIPE) if result == left_result: - high = mid+1 - else: - low = mid + print 'found where it starts to work: %d' % mid + found = mid + break -critical = '\n'.join(chunks[low]) + '\n' +critical = '\n'.join(chunks[found-1]) + '\n' c = open('critical.diff', 'w') c.write(critical) @@ -76,8 +74,8 @@ c.close() print 'sanity check' shutil.copy('middle', 'middle2') Popen(['patch', 'middle2', 'critical.diff'], stdout=PIPE, stderr=PIPE).communicate() -assert run_js('middle', stderr=PIPE) == left_result -assert run_js('middle2', stderr=PIPE) != left_result +assert run_js('middle', stderr=PIPE) == left_result, 'middle was expected %s' % left_result +assert run_js('middle2', stderr=PIPE) != left_result, 'middle2 was expected NOT %s' % left_result print 'middle is like left, middle2 is like right, critical.diff is the difference that matters,' print critical diff --git a/tools/clean_webconsole.py b/tools/clean_webconsole.py index 56bd9e2b..43694179 100644 --- a/tools/clean_webconsole.py +++ b/tools/clean_webconsole.py @@ -2,7 +2,23 @@ Removes timestamp and line info from a webgl log ''' -import os, sys +import os, sys, re + +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +def path_from_root(*pathelems): + return os.path.join(__rootpath__, *pathelems) + +def nice(x): + return '0x' + ('0' * (len(x)-6)) + x[2:].upper() + +repdata = open(path_from_root('system', 'include', 'GL', 'gl.h')).readlines() + ['\n'] + \ + open(path_from_root('system', 'include', 'GL', 'glext.h')).readlines() +reps = {} +for rep in repdata: + rep = rep.replace('\t', ' ').replace('\n', '') + parts = filter(lambda part: part != '', rep.split(' ')) + if len(parts) == 3 and parts[0] == '#define': + reps[nice(parts[2])] = '%s (%s)' % (parts[1], parts[2]) lines = sys.stdin.read().split('\n') @@ -10,8 +26,9 @@ for line in lines: if line.startswith('['): line = line[15:] line = line.split(' @ ')[0] + line = re.sub('(0x[\dabcdef]+)', lambda hexx: reps[nice(hexx.group(0))] if nice(hexx.group(0)) in reps else nice(hexx.group(0)), line) print line -for i in range(100): - print +#for i in range(100): +# print diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index aac21e87..fd8036bf 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -126,4 +126,2724 @@ function llvm3_1() { run($j_0 / 2); } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1"] +function _inflate($strm, $flush) { + var __stackBase__ = STACKTOP; + STACKTOP += 4; + var __label__; + var $hbuf = __stackBase__; + var $cmp = ($strm | 0) == 0; + $_$2 : do { + if ($cmp) { + var $retval_0 = -2; + } else { + var $0 = HEAPU32[($strm + 28 | 0) >> 2]; + if (($0 | 0) == 0) { + var $retval_0 = -2; + break; + } + var $next_out = $strm + 12 | 0; + var $1 = HEAP32[$next_out >> 2]; + if (($1 | 0) == 0) { + var $retval_0 = -2; + break; + } + var $next_in = $strm | 0; + var $2 = HEAP32[$next_in >> 2]; + if (($2 | 0) == 0) { + if (!((HEAP32[($strm + 4 | 0) >> 2] | 0) == 0)) { + var $retval_0 = -2; + break; + } + } + var $4 = $0; + var $mode = $0 | 0; + var $5 = HEAP32[$mode >> 2]; + if (($5 | 0) == 11) { + HEAP32[$mode >> 2] = 12; + var $8 = HEAP32[$next_out >> 2]; + var $7 = HEAP32[$next_in >> 2]; + var $6 = 12; + } else { + var $8 = $1; + var $7 = $2; + var $6 = $5; + } + var $6; + var $7; + var $8; + var $avail_out = $strm + 16 | 0; + var $9 = HEAP32[$avail_out >> 2]; + var $avail_in15 = $strm + 4 | 0; + var $10 = HEAPU32[$avail_in15 >> 2]; + var $11 = $0 + 56 | 0; + var $13 = $0 + 60 | 0; + var $15 = $0 + 8 | 0; + var $16 = $0 + 24 | 0; + var $arrayidx = $hbuf | 0; + var $arrayidx40 = $hbuf + 1 | 0; + var $17 = $0 + 16 | 0; + var $18 = $0 + 32 | 0; + var $msg = $strm + 24 | 0; + var $19 = $0 + 36 | 0; + var $20 = $0 + 20 | 0; + var $adler = $strm + 48 | 0; + var $21 = $0 + 64 | 0; + var $22 = $0 + 12 | 0; + var $23 = ($flush - 5 | 0) >>> 0 < 2; + var $24 = $0 + 4 | 0; + var $cmp660 = ($flush | 0) == 6; + var $25 = $0 + 7108 | 0; + var $26 = $0 + 84 | 0; + var $27 = $0 + 76 | 0; + var $28 = $0 + 72 | 0; + var $29 = $0 + 7112 | 0; + var $30 = $0 + 68 | 0; + var $31 = $0 + 44 | 0; + var $32 = $0 + 7104 | 0; + var $33 = $0 + 48 | 0; + var $34 = $0 + 52 | 0; + var $35 = $0 + 40 | 0; + var $total_out = $strm + 20 | 0; + var $36 = $0 + 28 | 0; + var $arrayidx199 = $hbuf + 2 | 0; + var $arrayidx202 = $hbuf + 3 | 0; + var $37 = $0 + 96 | 0; + var $38 = $0 + 100 | 0; + var $39 = $0 + 92 | 0; + var $40 = $0 + 104 | 0; + var $lens = $0 + 112 | 0; + var $41 = $lens; + var $next861 = $0 + 108 | 0; + var $42 = $next861; + var $43 = $next861 | 0; + var $arraydecay860_c = $0 + 1328 | 0; + var $44 = $0 + 76 | 0; + var $arraydecay864 = $lens; + var $arraydecay867 = $0 + 752 | 0; + var $45 = $0 + 624 | 0; + var $46 = $0 + 80 | 0; + var $47 = $0 + 88 | 0; + var $48 = $0 + 80 | 0; + var $ret_0 = 0; + var $next_0 = $7; + var $put_0 = $8; + var $have_0 = $10; + var $left_0 = $9; + var $hold_0 = HEAP32[$11 >> 2]; + var $bits_0 = HEAP32[$13 >> 2]; + var $out_0 = $9; + var $49 = $6; + $_$12 : while (1) { + var $49; + var $out_0; + var $bits_0; + var $hold_0; + var $left_0; + var $have_0; + var $put_0; + var $next_0; + var $ret_0; + $_$14 : do { + if (($49 | 0) == 0) { + var $50 = HEAPU32[$15 >> 2]; + if (($50 | 0) == 0) { + HEAP32[$mode >> 2] = 12; + var $ret_0_be = $ret_0; + var $next_0_be = $next_0; + var $put_0_be = $put_0; + var $have_0_be = $have_0; + var $left_0_be = $left_0; + var $hold_0_be = $hold_0; + var $bits_0_be = $bits_0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $next_1 = $next_0; + var $have_1 = $have_0; + var $hold_1 = $hold_0; + var $bits_1 = $bits_0; + while (1) { + var $bits_1; + var $hold_1; + var $have_1; + var $next_1; + if (!($bits_1 >>> 0 < 16)) { + break; + } + if (($have_1 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_1; + var $have_58 = 0; + var $hold_54 = $hold_1; + var $bits_54 = $bits_1; + var $out_4 = $out_0; + break $_$12; + } + var $add = ((HEAPU8[$next_1] & 255) << $bits_1) + $hold_1 | 0; + var $next_1 = $next_1 + 1 | 0; + var $have_1 = $have_1 - 1 | 0; + var $hold_1 = $add; + var $bits_1 = $bits_1 + 8 | 0; + } + if (($50 & 2 | 0) != 0 & ($hold_1 | 0) == 35615) { + var $call = _crc32(0, 0, 0); + HEAP32[$16 >> 2] = $call; + HEAP8[$arrayidx] = 31; + HEAP8[$arrayidx40] = -117; + var $52 = HEAP32[$16 >> 2]; + var $call42 = _crc32($52, $arrayidx, 2); + HEAP32[$16 >> 2] = $call42; + HEAP32[$mode >> 2] = 1; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = 0; + var $bits_0_be = 0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$17 >> 2] = 0; + var $53 = HEAP32[$18 >> 2]; + if (($53 | 0) == 0) { + var $54 = $50; + } else { + var $done = $53 + 48 | 0; + HEAP32[$done >> 2] = -1; + var $54 = HEAP32[$15 >> 2]; + } + var $54; + var $tobool56 = ($54 & 1 | 0) == 0; + do { + if (!$tobool56) { + if (!((((($hold_1 << 8 & 65280) + ($hold_1 >>> 8) | 0) >>> 0) % 31 | 0) == 0)) { + break; + } + if (($hold_1 & 15 | 0) == 8) { + var $shr74 = $hold_1 >>> 4; + var $sub = $bits_1 - 4 | 0; + var $add77 = ($shr74 & 15) + 8 | 0; + var $55 = HEAPU32[$19 >> 2]; + var $cmp78 = ($55 | 0) == 0; + do { + if (!$cmp78) { + if (!($add77 >>> 0 > $55 >>> 0)) { + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str3100 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $shr74; + var $bits_0_be = $sub; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + HEAP32[$19 >> 2] = $add77; + } while (0); + HEAP32[$20 >> 2] = 1 << $add77; + var $call91 = _adler32(0, 0, 0); + HEAP32[$16 >> 2] = $call91; + HEAP32[$adler >> 2] = $call91; + HEAP32[$mode >> 2] = $hold_1 >>> 12 & 2 ^ 11; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = 0; + var $bits_0_be = 0; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str299 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $hold_1; + var $bits_0_be = $bits_1; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + } while (0); + HEAP32[$msg >> 2] = STRING_TABLE.__str198 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $hold_1; + var $bits_0_be = $bits_1; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 1) { + var $next_2 = $next_0; + var $have_2 = $have_0; + var $hold_2 = $hold_0; + var $bits_2 = $bits_0; + while (1) { + var $bits_2; + var $hold_2; + var $have_2; + var $next_2; + if (!($bits_2 >>> 0 < 16)) { + break; + } + if (($have_2 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_2; + var $have_58 = 0; + var $hold_54 = $hold_2; + var $bits_54 = $bits_2; + var $out_4 = $out_0; + break $_$12; + } + var $add113 = ((HEAPU8[$next_2] & 255) << $bits_2) + $hold_2 | 0; + var $next_2 = $next_2 + 1 | 0; + var $have_2 = $have_2 - 1 | 0; + var $hold_2 = $add113; + var $bits_2 = $bits_2 + 8 | 0; + } + HEAP32[$17 >> 2] = $hold_2; + if (!(($hold_2 & 255 | 0) == 8)) { + HEAP32[$msg >> 2] = STRING_TABLE.__str299 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_2; + var $put_0_be = $put_0; + var $have_0_be = $have_2; + var $left_0_be = $left_0; + var $hold_0_be = $hold_2; + var $bits_0_be = $bits_2; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + if (($hold_2 & 57344 | 0) == 0) { + var $59 = HEAPU32[$18 >> 2]; + if (($59 | 0) == 0) { + var $60 = $hold_2; + } else { + HEAP32[($59 | 0) >> 2] = $hold_2 >>> 8 & 1; + var $60 = HEAP32[$17 >> 2]; + } + var $60; + if (!(($60 & 512 | 0) == 0)) { + HEAP8[$arrayidx] = $hold_2 & 255; + HEAP8[$arrayidx40] = $hold_2 >>> 8 & 255; + var $61 = HEAP32[$16 >> 2]; + var $call154 = _crc32($61, $arrayidx, 2); + HEAP32[$16 >> 2] = $call154; + } + HEAP32[$mode >> 2] = 2; + var $next_3 = $next_2; + var $have_3 = $have_2; + var $hold_3 = 0; + var $bits_3 = 0; + __label__ = 44; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str4101 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_2; + var $put_0_be = $put_0; + var $have_0_be = $have_2; + var $left_0_be = $left_0; + var $hold_0_be = $hold_2; + var $bits_0_be = $bits_2; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 2) { + var $next_3 = $next_0; + var $have_3 = $have_0; + var $hold_3 = $hold_0; + var $bits_3 = $bits_0; + __label__ = 44; + } else if (($49 | 0) == 3) { + var $next_4 = $next_0; + var $have_4 = $have_0; + var $hold_4 = $hold_0; + var $bits_4 = $bits_0; + __label__ = 52; + } else if (($49 | 0) == 4) { + var $next_5 = $next_0; + var $have_5 = $have_0; + var $hold_5 = $hold_0; + var $bits_5 = $bits_0; + __label__ = 60; + } else if (($49 | 0) == 5) { + var $next_8 = $next_0; + var $have_8 = $have_0; + var $hold_8 = $hold_0; + var $bits_8 = $bits_0; + __label__ = 71; + } else if (($49 | 0) == 6) { + var $next_11 = $next_0; + var $have_11 = $have_0; + var $hold_9 = $hold_0; + var $bits_9 = $bits_0; + var $89 = HEAP32[$17 >> 2]; + __label__ = 81; + break; + } else if (($49 | 0) == 7) { + var $next_13 = $next_0; + var $have_13 = $have_0; + var $hold_10 = $hold_0; + var $bits_10 = $bits_0; + __label__ = 94; + } else if (($49 | 0) == 8) { + var $next_15 = $next_0; + var $have_15 = $have_0; + var $hold_11 = $hold_0; + var $bits_11 = $bits_0; + __label__ = 107; + } else if (($49 | 0) == 9) { + var $next_18 = $next_0; + var $have_18 = $have_0; + var $hold_14 = $hold_0; + var $bits_14 = $bits_0; + while (1) { + var $bits_14; + var $hold_14; + var $have_18; + var $next_18; + if (!($bits_14 >>> 0 < 32)) { + break; + } + if (($have_18 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_18; + var $have_58 = 0; + var $hold_54 = $hold_14; + var $bits_54 = $bits_14; + var $out_4 = $out_0; + break $_$12; + } + var $add564 = ((HEAPU8[$next_18] & 255) << $bits_14) + $hold_14 | 0; + var $next_18 = $next_18 + 1 | 0; + var $have_18 = $have_18 - 1 | 0; + var $hold_14 = $add564; + var $bits_14 = $bits_14 + 8 | 0; + } + var $add581 = _llvm_bswap_i32($hold_14); + HEAP32[$16 >> 2] = $add581; + HEAP32[$adler >> 2] = $add581; + HEAP32[$mode >> 2] = 10; + var $next_19 = $next_18; + var $have_19 = $have_18; + var $hold_15 = 0; + var $bits_15 = 0; + __label__ = 120; + break; + } else if (($49 | 0) == 10) { + var $next_19 = $next_0; + var $have_19 = $have_0; + var $hold_15 = $hold_0; + var $bits_15 = $bits_0; + __label__ = 120; + } else if (($49 | 0) == 11) { + var $next_20 = $next_0; + var $have_20 = $have_0; + var $hold_16 = $hold_0; + var $bits_16 = $bits_0; + __label__ = 123; + } else if (($49 | 0) == 12) { + var $next_21 = $next_0; + var $have_21 = $have_0; + var $hold_17 = $hold_0; + var $bits_17 = $bits_0; + __label__ = 124; + } else if (($49 | 0) == 13) { + var $and681 = $bits_0 & 7; + var $next_23 = $next_0; + var $have_23 = $have_0; + var $hold_19 = $hold_0 >>> ($and681 >>> 0); + var $bits_19 = $bits_0 - $and681 | 0; + while (1) { + var $bits_19; + var $hold_19; + var $have_23; + var $next_23; + if (!($bits_19 >>> 0 < 32)) { + break; + } + if (($have_23 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_23; + var $have_58 = 0; + var $hold_54 = $hold_19; + var $bits_54 = $bits_19; + var $out_4 = $out_0; + break $_$12; + } + var $add701 = ((HEAPU8[$next_23] & 255) << $bits_19) + $hold_19 | 0; + var $next_23 = $next_23 + 1 | 0; + var $have_23 = $have_23 - 1 | 0; + var $hold_19 = $add701; + var $bits_19 = $bits_19 + 8 | 0; + } + var $and708 = $hold_19 & 65535; + if (!(($and708 | 0) == ($hold_19 >>> 16 ^ 65535 | 0))) { + HEAP32[$msg >> 2] = STRING_TABLE.__str7104 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_23; + var $put_0_be = $put_0; + var $have_0_be = $have_23; + var $left_0_be = $left_0; + var $hold_0_be = $hold_19; + var $bits_0_be = $bits_19; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$21 >> 2] = $and708; + HEAP32[$mode >> 2] = 14; + if ($cmp660) { + var $ret_8 = $ret_0; + var $next_58 = $next_23; + var $have_58 = $have_23; + var $hold_54 = 0; + var $bits_54 = 0; + var $out_4 = $out_0; + break $_$12; + } + var $next_24 = $next_23; + var $have_24 = $have_23; + var $hold_20 = 0; + var $bits_20 = 0; + __label__ = 143; + break; + } else if (($49 | 0) == 14) { + var $next_24 = $next_0; + var $have_24 = $have_0; + var $hold_20 = $hold_0; + var $bits_20 = $bits_0; + __label__ = 143; + } else if (($49 | 0) == 15) { + var $next_25 = $next_0; + var $have_25 = $have_0; + var $hold_21 = $hold_0; + var $bits_21 = $bits_0; + __label__ = 144; + } else if (($49 | 0) == 16) { + var $next_26 = $next_0; + var $have_26 = $have_0; + var $hold_22 = $hold_0; + var $bits_22 = $bits_0; + while (1) { + var $bits_22; + var $hold_22; + var $have_26; + var $next_26; + if (!($bits_22 >>> 0 < 14)) { + break; + } + if (($have_26 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_26; + var $have_58 = 0; + var $hold_54 = $hold_22; + var $bits_54 = $bits_22; + var $out_4 = $out_0; + break $_$12; + } + var $add767 = ((HEAPU8[$next_26] & 255) << $bits_22) + $hold_22 | 0; + var $next_26 = $next_26 + 1 | 0; + var $have_26 = $have_26 - 1 | 0; + var $hold_22 = $add767; + var $bits_22 = $bits_22 + 8 | 0; + } + var $add775 = ($hold_22 & 31) + 257 | 0; + HEAP32[$37 >> 2] = $add775; + var $add782 = ($hold_22 >>> 5 & 31) + 1 | 0; + HEAP32[$38 >> 2] = $add782; + HEAP32[$39 >> 2] = ($hold_22 >>> 10 & 15) + 4 | 0; + var $shr791 = $hold_22 >>> 14; + var $sub792 = $bits_22 - 14 | 0; + if ($add775 >>> 0 > 286 | $add782 >>> 0 > 30) { + HEAP32[$msg >> 2] = STRING_TABLE.__str8105 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_26; + var $put_0_be = $put_0; + var $have_0_be = $have_26; + var $left_0_be = $left_0; + var $hold_0_be = $shr791; + var $bits_0_be = $sub792; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$40 >> 2] = 0; + HEAP32[$mode >> 2] = 17; + var $next_27 = $next_26; + var $have_27 = $have_26; + var $hold_23 = $shr791; + var $bits_23 = $sub792; + __label__ = 154; + break; + } else if (($49 | 0) == 17) { + var $next_27 = $next_0; + var $have_27 = $have_0; + var $hold_23 = $hold_0; + var $bits_23 = $bits_0; + __label__ = 154; + } else if (($49 | 0) == 18) { + var $ret_1_ph = $ret_0; + var $next_29_ph = $next_0; + var $have_29_ph = $have_0; + var $hold_25_ph = $hold_0; + var $bits_25_ph = $bits_0; + __label__ = 164; + } else if (($49 | 0) == 19) { + var $ret_2 = $ret_0; + var $next_37 = $next_0; + var $have_37 = $have_0; + var $hold_33 = $hold_0; + var $bits_33 = $bits_0; + __label__ = 205; + } else if (($49 | 0) == 20) { + var $ret_3 = $ret_0; + var $next_38 = $next_0; + var $have_38 = $have_0; + var $hold_34 = $hold_0; + var $bits_34 = $bits_0; + __label__ = 206; + } else if (($49 | 0) == 21) { + var $ret_4 = $ret_0; + var $next_42 = $next_0; + var $have_42 = $have_0; + var $hold_38 = $hold_0; + var $bits_38 = $bits_0; + var $156 = HEAP32[$28 >> 2]; + __label__ = 227; + break; + } else if (($49 | 0) == 22) { + var $ret_5_ph = $ret_0; + var $next_45_ph = $next_0; + var $have_45_ph = $have_0; + var $hold_41_ph = $hold_0; + var $bits_41_ph = $bits_0; + __label__ = 234; + } else if (($49 | 0) == 23) { + var $ret_6 = $ret_0; + var $next_48 = $next_0; + var $have_48 = $have_0; + var $hold_44 = $hold_0; + var $bits_44 = $bits_0; + var $167 = HEAP32[$28 >> 2]; + __label__ = 248; + break; + } else if (($49 | 0) == 24) { + var $ret_7 = $ret_0; + var $next_51 = $next_0; + var $have_51 = $have_0; + var $hold_47 = $hold_0; + var $bits_47 = $bits_0; + __label__ = 254; + } else if (($49 | 0) == 25) { + if (($left_0 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } + HEAP8[$put_0] = HEAP32[$21 >> 2] & 255; + HEAP32[$mode >> 2] = 20; + var $ret_0_be = $ret_0; + var $next_0_be = $next_0; + var $put_0_be = $put_0 + 1 | 0; + var $have_0_be = $have_0; + var $left_0_be = $left_0 - 1 | 0; + var $hold_0_be = $hold_0; + var $bits_0_be = $bits_0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 26) { + var $tobool1626 = (HEAP32[$15 >> 2] | 0) == 0; + do { + if (!$tobool1626) { + var $next_52 = $next_0; + var $have_52 = $have_0; + var $hold_48 = $hold_0; + var $bits_48 = $bits_0; + while (1) { + var $bits_48; + var $hold_48; + var $have_52; + var $next_52; + if (!($bits_48 >>> 0 < 32)) { + break; + } + if (($have_52 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_52; + var $have_58 = 0; + var $hold_54 = $hold_48; + var $bits_54 = $bits_48; + var $out_4 = $out_0; + break $_$12; + } + var $add1642 = ((HEAPU8[$next_52] & 255) << $bits_48) + $hold_48 | 0; + var $next_52 = $next_52 + 1 | 0; + var $have_52 = $have_52 - 1 | 0; + var $hold_48 = $add1642; + var $bits_48 = $bits_48 + 8 | 0; + } + var $sub1649 = $out_0 - $left_0 | 0; + var $add1650 = HEAP32[$total_out >> 2] + $sub1649 | 0; + HEAP32[$total_out >> 2] = $add1650; + var $add1651 = HEAP32[$36 >> 2] + $sub1649 | 0; + HEAP32[$36 >> 2] = $add1651; + if (!(($out_0 | 0) == ($left_0 | 0))) { + var $192 = HEAP32[$16 >> 2]; + var $add_ptr1659 = $put_0 + (-$sub1649 | 0) | 0; + if ((HEAP32[$17 >> 2] | 0) == 0) { + var $call1665 = _adler32($192, $add_ptr1659, $sub1649); + var $cond1667 = $call1665; + } else { + var $call1660 = _crc32($192, $add_ptr1659, $sub1649); + var $cond1667 = $call1660; + } + var $cond1667; + HEAP32[$16 >> 2] = $cond1667; + HEAP32[$adler >> 2] = $cond1667; + } + if ((HEAP32[$17 >> 2] | 0) == 0) { + var $add1685 = _llvm_bswap_i32($hold_48); + var $cond1687 = $add1685; + } else { + var $cond1687 = $hold_48; + } + var $cond1687; + if (($cond1687 | 0) == (HEAP32[$16 >> 2] | 0)) { + var $next_53 = $next_52; + var $have_53 = $have_52; + var $hold_49 = 0; + var $bits_49 = 0; + var $out_1 = $left_0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str17114 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_52; + var $put_0_be = $put_0; + var $have_0_be = $have_52; + var $left_0_be = $left_0; + var $hold_0_be = $hold_48; + var $bits_0_be = $bits_48; + var $out_0_be = $left_0; + __label__ = 268; + break $_$14; + } + var $next_53 = $next_0; + var $have_53 = $have_0; + var $hold_49 = $hold_0; + var $bits_49 = $bits_0; + var $out_1 = $out_0; + } while (0); + var $out_1; + var $bits_49; + var $hold_49; + var $have_53; + var $next_53; + HEAP32[$mode >> 2] = 27; + var $next_54 = $next_53; + var $have_54 = $have_53; + var $hold_50 = $hold_49; + var $bits_50 = $bits_49; + var $out_2 = $out_1; + __label__ = 286; + break; + } else if (($49 | 0) == 27) { + var $next_54 = $next_0; + var $have_54 = $have_0; + var $hold_50 = $hold_0; + var $bits_50 = $bits_0; + var $out_2 = $out_0; + __label__ = 286; + } else if (($49 | 0) == 28) { + var $ret_8 = 1; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } else if (($49 | 0) == 29) { + var $ret_8 = -3; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } else if (($49 | 0) == 30) { + var $retval_0 = -4; + break $_$2; + } else { + var $retval_0 = -2; + break $_$2; + } + } while (0); + $_$106 : do { + if (__label__ == 44) { + while (1) { + var $bits_3; + var $hold_3; + var $have_3; + var $next_3; + if (!($bits_3 >>> 0 < 32)) { + break; + } + if (($have_3 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_3; + var $have_58 = 0; + var $hold_54 = $hold_3; + var $bits_54 = $bits_3; + var $out_4 = $out_0; + break $_$12; + } + var $add176 = ((HEAPU8[$next_3] & 255) << $bits_3) + $hold_3 | 0; + var $next_3 = $next_3 + 1 | 0; + var $have_3 = $have_3 - 1 | 0; + var $hold_3 = $add176; + var $bits_3 = $bits_3 + 8 | 0; + } + var $63 = HEAP32[$18 >> 2]; + if (!(($63 | 0) == 0)) { + var $time = $63 + 4 | 0; + HEAP32[$time >> 2] = $hold_3; + } + if (!((HEAP32[$17 >> 2] & 512 | 0) == 0)) { + HEAP8[$arrayidx] = $hold_3 & 255; + HEAP8[$arrayidx40] = $hold_3 >>> 8 & 255; + HEAP8[$arrayidx199] = $hold_3 >>> 16 & 255; + HEAP8[$arrayidx202] = $hold_3 >>> 24 & 255; + var $65 = HEAP32[$16 >> 2]; + var $call205 = _crc32($65, $arrayidx, 4); + HEAP32[$16 >> 2] = $call205; + } + HEAP32[$mode >> 2] = 3; + var $next_4 = $next_3; + var $have_4 = $have_3; + var $hold_4 = 0; + var $bits_4 = 0; + __label__ = 52; + break; + } else if (__label__ == 120) { + var $bits_15; + var $hold_15; + var $have_19; + var $next_19; + if ((HEAP32[$22 >> 2] | 0) == 0) { + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_19; + HEAP32[$avail_in15 >> 2] = $have_19; + HEAP32[$11 >> 2] = $hold_15; + HEAP32[$13 >> 2] = $bits_15; + var $retval_0 = 2; + break $_$2; + } + var $call602 = _adler32(0, 0, 0); + HEAP32[$16 >> 2] = $call602; + HEAP32[$adler >> 2] = $call602; + HEAP32[$mode >> 2] = 11; + var $next_20 = $next_19; + var $have_20 = $have_19; + var $hold_16 = $hold_15; + var $bits_16 = $bits_15; + __label__ = 123; + break; + } else if (__label__ == 143) { + var $bits_20; + var $hold_20; + var $have_24; + var $next_24; + HEAP32[$mode >> 2] = 15; + var $next_25 = $next_24; + var $have_25 = $have_24; + var $hold_21 = $hold_20; + var $bits_21 = $bits_20; + __label__ = 144; + break; + } else if (__label__ == 154) { + while (1) { + var $bits_23; + var $hold_23; + var $have_27; + var $next_27; + var $122 = HEAPU32[$40 >> 2]; + if (!($122 >>> 0 < HEAPU32[$39 >> 2] >>> 0)) { + break; + } + var $next_28 = $next_27; + var $have_28 = $have_27; + var $hold_24 = $hold_23; + var $bits_24 = $bits_23; + while (1) { + var $bits_24; + var $hold_24; + var $have_28; + var $next_28; + if (!($bits_24 >>> 0 < 3)) { + break; + } + if (($have_28 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_28; + var $have_58 = 0; + var $hold_54 = $hold_24; + var $bits_54 = $bits_24; + var $out_4 = $out_0; + break $_$12; + } + var $add829 = ((HEAPU8[$next_28] & 255) << $bits_24) + $hold_24 | 0; + var $next_28 = $next_28 + 1 | 0; + var $have_28 = $have_28 - 1 | 0; + var $hold_24 = $add829; + var $bits_24 = $bits_24 + 8 | 0; + } + HEAP32[$40 >> 2] = $122 + 1 | 0; + HEAP16[($41 + ((HEAPU16[(_inflate_order + ($122 << 1) | 0) >> 1] & 65535) << 1) | 0) >> 1] = $hold_24 & 65535 & 7; + var $next_27 = $next_28; + var $have_27 = $have_28; + var $hold_23 = $hold_24 >>> 3; + var $bits_23 = $bits_24 - 3 | 0; + } + var $cmp850111 = $122 >>> 0 < 19; + $_$131 : do { + if ($cmp850111) { + var $126 = $122; + while (1) { + var $126; + HEAP32[$40 >> 2] = $126 + 1 | 0; + HEAP16[($41 + ((HEAPU16[(_inflate_order + ($126 << 1) | 0) >> 1] & 65535) << 1) | 0) >> 1] = 0; + var $_pr = HEAPU32[$40 >> 2]; + if (!($_pr >>> 0 < 19)) { + break $_$131; + } + var $126 = $_pr; + } + } + } while (0); + HEAP32[$43 >> 2] = $arraydecay860_c; + HEAP32[$44 >> 2] = $arraydecay860_c; + HEAP32[$26 >> 2] = 7; + var $call868 = _inflate_table(0, $arraydecay864, 19, $42, $26, $arraydecay867); + if (($call868 | 0) == 0) { + HEAP32[$40 >> 2] = 0; + HEAP32[$mode >> 2] = 18; + var $ret_1_ph = 0; + var $next_29_ph = $next_27; + var $have_29_ph = $have_27; + var $hold_25_ph = $hold_23; + var $bits_25_ph = $bits_23; + __label__ = 164; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str9106 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call868; + var $next_0_be = $next_27; + var $put_0_be = $put_0; + var $have_0_be = $have_27; + var $left_0_be = $left_0; + var $hold_0_be = $hold_23; + var $bits_0_be = $bits_23; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 286) { + var $out_2; + var $bits_50; + var $hold_50; + var $have_54; + var $next_54; + var $tobool1702 = (HEAP32[$15 >> 2] | 0) == 0; + do { + if (!$tobool1702) { + if ((HEAP32[$17 >> 2] | 0) == 0) { + var $next_56 = $next_54; + var $have_56 = $have_54; + var $hold_52 = $hold_50; + var $bits_52 = $bits_50; + break; + } + var $next_55 = $next_54; + var $have_55 = $have_54; + var $hold_51 = $hold_50; + var $bits_51 = $bits_50; + while (1) { + var $bits_51; + var $hold_51; + var $have_55; + var $next_55; + if (!($bits_51 >>> 0 < 32)) { + break; + } + if (($have_55 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_55; + var $have_58 = 0; + var $hold_54 = $hold_51; + var $bits_54 = $bits_51; + var $out_4 = $out_2; + break $_$12; + } + var $add1721 = ((HEAPU8[$next_55] & 255) << $bits_51) + $hold_51 | 0; + var $next_55 = $next_55 + 1 | 0; + var $have_55 = $have_55 - 1 | 0; + var $hold_51 = $add1721; + var $bits_51 = $bits_51 + 8 | 0; + } + if (($hold_51 | 0) == (HEAP32[$36 >> 2] | 0)) { + var $next_56 = $next_55; + var $have_56 = $have_55; + var $hold_52 = 0; + var $bits_52 = 0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str18115 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_55; + var $put_0_be = $put_0; + var $have_0_be = $have_55; + var $left_0_be = $left_0; + var $hold_0_be = $hold_51; + var $bits_0_be = $bits_51; + var $out_0_be = $out_2; + __label__ = 268; + break $_$106; + } + var $next_56 = $next_54; + var $have_56 = $have_54; + var $hold_52 = $hold_50; + var $bits_52 = $bits_50; + } while (0); + var $bits_52; + var $hold_52; + var $have_56; + var $next_56; + HEAP32[$mode >> 2] = 28; + var $ret_8 = 1; + var $next_58 = $next_56; + var $have_58 = $have_56; + var $hold_54 = $hold_52; + var $bits_54 = $bits_52; + var $out_4 = $out_2; + break $_$12; + } + } while (0); + $_$148 : do { + if (__label__ == 52) { + while (1) { + var $bits_4; + var $hold_4; + var $have_4; + var $next_4; + if (!($bits_4 >>> 0 < 16)) { + break; + } + if (($have_4 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_4; + var $have_58 = 0; + var $hold_54 = $hold_4; + var $bits_54 = $bits_4; + var $out_4 = $out_0; + break $_$12; + } + var $add227 = ((HEAPU8[$next_4] & 255) << $bits_4) + $hold_4 | 0; + var $next_4 = $next_4 + 1 | 0; + var $have_4 = $have_4 - 1 | 0; + var $hold_4 = $add227; + var $bits_4 = $bits_4 + 8 | 0; + } + var $67 = HEAP32[$18 >> 2]; + if (!(($67 | 0) == 0)) { + var $xflags = $67 + 8 | 0; + HEAP32[$xflags >> 2] = $hold_4 & 255; + var $os = HEAP32[$18 >> 2] + 12 | 0; + HEAP32[$os >> 2] = $hold_4 >>> 8; + } + if (!((HEAP32[$17 >> 2] & 512 | 0) == 0)) { + HEAP8[$arrayidx] = $hold_4 & 255; + HEAP8[$arrayidx40] = $hold_4 >>> 8 & 255; + var $70 = HEAP32[$16 >> 2]; + var $call253 = _crc32($70, $arrayidx, 2); + HEAP32[$16 >> 2] = $call253; + } + HEAP32[$mode >> 2] = 4; + var $next_5 = $next_4; + var $have_5 = $have_4; + var $hold_5 = 0; + var $bits_5 = 0; + __label__ = 60; + break; + } else if (__label__ == 123) { + var $bits_16; + var $hold_16; + var $have_20; + var $next_20; + if ($23) { + var $ret_8 = $ret_0; + var $next_58 = $next_20; + var $have_58 = $have_20; + var $hold_54 = $hold_16; + var $bits_54 = $bits_16; + var $out_4 = $out_0; + break $_$12; + } + var $next_21 = $next_20; + var $have_21 = $have_20; + var $hold_17 = $hold_16; + var $bits_17 = $bits_16; + __label__ = 124; + break; + } else if (__label__ == 144) { + var $bits_21; + var $hold_21; + var $have_25; + var $next_25; + var $119 = HEAPU32[$21 >> 2]; + if (($119 | 0) == 0) { + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_0; + var $next_0_be = $next_25; + var $put_0_be = $put_0; + var $have_0_be = $have_25; + var $left_0_be = $left_0; + var $hold_0_be = $hold_21; + var $bits_0_be = $bits_21; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $copy_3 = $119 >>> 0 > $have_25 >>> 0 ? $have_25 : $119; + var $copy_4 = $copy_3 >>> 0 > $left_0 >>> 0 ? $left_0 : $copy_3; + if (($copy_4 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_25; + var $have_58 = $have_25; + var $hold_54 = $hold_21; + var $bits_54 = $bits_21; + var $out_4 = $out_0; + break $_$12; + } + _memcpy($put_0, $next_25, $copy_4, 1); + var $sub744 = $have_25 - $copy_4 | 0; + var $add_ptr745 = $next_25 + $copy_4 | 0; + var $sub746 = $left_0 - $copy_4 | 0; + var $add_ptr747 = $put_0 + $copy_4 | 0; + var $sub749 = HEAP32[$21 >> 2] - $copy_4 | 0; + HEAP32[$21 >> 2] = $sub749; + var $ret_0_be = $ret_0; + var $next_0_be = $add_ptr745; + var $put_0_be = $add_ptr747; + var $have_0_be = $sub744; + var $left_0_be = $sub746; + var $hold_0_be = $hold_21; + var $bits_0_be = $bits_21; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 164) { + var $bits_25_ph; + var $hold_25_ph; + var $have_29_ph; + var $next_29_ph; + var $ret_1_ph; + var $next_29 = $next_29_ph; + var $have_29 = $have_29_ph; + var $hold_25 = $hold_25_ph; + var $bits_25 = $bits_25_ph; + $_$167 : while (1) { + var $bits_25; + var $hold_25; + var $have_29; + var $next_29; + var $128 = HEAPU32[$40 >> 2]; + var $129 = HEAPU32[$37 >> 2]; + var $add881 = HEAP32[$38 >> 2] + $129 | 0; + if ($128 >>> 0 < $add881 >>> 0) { + var $sub888 = (1 << HEAP32[$26 >> 2]) - 1 | 0; + var $132 = HEAPU32[$27 >> 2]; + var $next_30 = $next_29; + var $have_30 = $have_29; + var $hold_26 = $hold_25; + var $bits_26 = $bits_25; + while (1) { + var $bits_26; + var $hold_26; + var $have_30; + var $next_30; + var $and889 = $sub888 & $hold_26; + var $conv893 = HEAPU8[$132 + ($and889 << 2) + 1 | 0] & 255; + if (!($conv893 >>> 0 > $bits_26 >>> 0)) { + break; + } + if (($have_30 | 0) == 0) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_30; + var $have_58 = 0; + var $hold_54 = $hold_26; + var $bits_54 = $bits_26; + var $out_4 = $out_0; + break $_$12; + } + var $add907 = ((HEAPU8[$next_30] & 255) << $bits_26) + $hold_26 | 0; + var $next_30 = $next_30 + 1 | 0; + var $have_30 = $have_30 - 1 | 0; + var $hold_26 = $add907; + var $bits_26 = $bits_26 + 8 | 0; + } + var $tmp26 = HEAPU16[($132 + ($and889 << 2) + 2 | 0) >> 1]; + if (($tmp26 & 65535) < 16) { + var $next_31 = $next_30; + var $have_31 = $have_30; + var $hold_27 = $hold_26; + var $bits_27 = $bits_26; + while (1) { + var $bits_27; + var $hold_27; + var $have_31; + var $next_31; + if (!($bits_27 >>> 0 < $conv893 >>> 0)) { + break; + } + if (($have_31 | 0) == 0) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_31; + var $have_58 = 0; + var $hold_54 = $hold_27; + var $bits_54 = $bits_27; + var $out_4 = $out_0; + break $_$12; + } + var $add931 = ((HEAPU8[$next_31] & 255) << $bits_27) + $hold_27 | 0; + var $next_31 = $next_31 + 1 | 0; + var $have_31 = $have_31 - 1 | 0; + var $hold_27 = $add931; + var $bits_27 = $bits_27 + 8 | 0; + } + var $shr941 = $hold_27 >>> ($conv893 >>> 0); + var $sub944 = $bits_27 - $conv893 | 0; + HEAP32[$40 >> 2] = $128 + 1 | 0; + HEAP16[($41 + ($128 << 1) | 0) >> 1] = $tmp26; + var $next_29 = $next_31; + var $have_29 = $have_31; + var $hold_25 = $shr941; + var $bits_25 = $sub944; + } else { + if ($tmp26 << 16 >> 16 == 16) { + var $add962 = $conv893 + 2 | 0; + var $next_32 = $next_30; + var $have_32 = $have_30; + var $hold_28 = $hold_26; + var $bits_28 = $bits_26; + while (1) { + var $bits_28; + var $hold_28; + var $have_32; + var $next_32; + if (!($bits_28 >>> 0 < $add962 >>> 0)) { + break; + } + if (($have_32 | 0) == 0) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_32; + var $have_58 = 0; + var $hold_54 = $hold_28; + var $bits_54 = $bits_28; + var $out_4 = $out_0; + break $_$12; + } + var $add975 = ((HEAPU8[$next_32] & 255) << $bits_28) + $hold_28 | 0; + var $next_32 = $next_32 + 1 | 0; + var $have_32 = $have_32 - 1 | 0; + var $hold_28 = $add975; + var $bits_28 = $bits_28 + 8 | 0; + } + var $shr985 = $hold_28 >>> ($conv893 >>> 0); + var $sub988 = $bits_28 - $conv893 | 0; + if (($128 | 0) == 0) { + HEAP32[$msg >> 2] = STRING_TABLE.__str10107 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_32; + var $put_0_be = $put_0; + var $have_0_be = $have_32; + var $left_0_be = $left_0; + var $hold_0_be = $shr985; + var $bits_0_be = $sub988; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $len_0 = HEAP16[($41 + (($128 - 1 | 0) << 1) | 0) >> 1]; + var $next_35 = $next_32; + var $have_35 = $have_32; + var $hold_31 = $shr985 >>> 2; + var $bits_31 = $sub988 - 2 | 0; + var $copy_5 = ($shr985 & 3) + 3 | 0; + } else if ($tmp26 << 16 >> 16 == 17) { + var $add1020 = $conv893 + 3 | 0; + var $next_33 = $next_30; + var $have_33 = $have_30; + var $hold_29 = $hold_26; + var $bits_29 = $bits_26; + while (1) { + var $bits_29; + var $hold_29; + var $have_33; + var $next_33; + if (!($bits_29 >>> 0 < $add1020 >>> 0)) { + break; + } + if (($have_33 | 0) == 0) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_33; + var $have_58 = 0; + var $hold_54 = $hold_29; + var $bits_54 = $bits_29; + var $out_4 = $out_0; + break $_$12; + } + var $add1033 = ((HEAPU8[$next_33] & 255) << $bits_29) + $hold_29 | 0; + var $next_33 = $next_33 + 1 | 0; + var $have_33 = $have_33 - 1 | 0; + var $hold_29 = $add1033; + var $bits_29 = $bits_29 + 8 | 0; + } + var $shr1043 = $hold_29 >>> ($conv893 >>> 0); + var $len_0 = 0; + var $next_35 = $next_33; + var $have_35 = $have_33; + var $hold_31 = $shr1043 >>> 3; + var $bits_31 = (-3 - $conv893 | 0) + $bits_29 | 0; + var $copy_5 = ($shr1043 & 7) + 3 | 0; + } else { + var $add1061 = $conv893 + 7 | 0; + var $next_34 = $next_30; + var $have_34 = $have_30; + var $hold_30 = $hold_26; + var $bits_30 = $bits_26; + while (1) { + var $bits_30; + var $hold_30; + var $have_34; + var $next_34; + if (!($bits_30 >>> 0 < $add1061 >>> 0)) { + break; + } + if (($have_34 | 0) == 0) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_34; + var $have_58 = 0; + var $hold_54 = $hold_30; + var $bits_54 = $bits_30; + var $out_4 = $out_0; + break $_$12; + } + var $add1074 = ((HEAPU8[$next_34] & 255) << $bits_30) + $hold_30 | 0; + var $next_34 = $next_34 + 1 | 0; + var $have_34 = $have_34 - 1 | 0; + var $hold_30 = $add1074; + var $bits_30 = $bits_30 + 8 | 0; + } + var $shr1084 = $hold_30 >>> ($conv893 >>> 0); + var $len_0 = 0; + var $next_35 = $next_34; + var $have_35 = $have_34; + var $hold_31 = $shr1084 >>> 7; + var $bits_31 = (-7 - $conv893 | 0) + $bits_30 | 0; + var $copy_5 = ($shr1084 & 127) + 11 | 0; + } + var $copy_5; + var $bits_31; + var $hold_31; + var $have_35; + var $next_35; + var $len_0; + if (($128 + $copy_5 | 0) >>> 0 > $add881 >>> 0) { + HEAP32[$msg >> 2] = STRING_TABLE.__str10107 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_35; + var $put_0_be = $put_0; + var $have_0_be = $have_35; + var $left_0_be = $left_0; + var $hold_0_be = $hold_31; + var $bits_0_be = $bits_31; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $copy_6127 = $copy_5; + var $139 = $128; + while (1) { + var $139; + var $copy_6127; + var $dec1111 = $copy_6127 - 1 | 0; + HEAP32[$40 >> 2] = $139 + 1 | 0; + HEAP16[($41 + ($139 << 1) | 0) >> 1] = $len_0; + if (($dec1111 | 0) == 0) { + var $next_29 = $next_35; + var $have_29 = $have_35; + var $hold_25 = $hold_31; + var $bits_25 = $bits_31; + continue $_$167; + } + var $copy_6127 = $dec1111; + var $139 = HEAP32[$40 >> 2]; + } + } + } else { + if ((HEAP32[$mode >> 2] | 0) == 29) { + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + if (HEAP16[$45 >> 1] << 16 >> 16 == 0) { + HEAP32[$msg >> 2] = STRING_TABLE.__str11108 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + HEAP32[$43 >> 2] = $arraydecay860_c; + HEAP32[$44 >> 2] = $arraydecay860_c; + HEAP32[$26 >> 2] = 9; + var $call1149 = _inflate_table(1, $arraydecay864, $129, $42, $26, $arraydecay867); + if (!(($call1149 | 0) == 0)) { + HEAP32[$msg >> 2] = STRING_TABLE.__str12109 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call1149; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $_c = HEAP32[$42 >> 2]; + HEAP32[$46 >> 2] = $_c; + HEAP32[$47 >> 2] = 6; + var $add_ptr1159 = $arraydecay864 + (HEAP32[$37 >> 2] << 1) | 0; + var $143 = HEAP32[$38 >> 2]; + var $call1165 = _inflate_table(2, $add_ptr1159, $143, $42, $47, $arraydecay867); + if (!(($call1165 | 0) == 0)) { + HEAP32[$msg >> 2] = STRING_TABLE.__str13110 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call1165; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + HEAP32[$mode >> 2] = 19; + if ($cmp660) { + var $ret_8 = 0; + var $next_58 = $next_29; + var $have_58 = $have_29; + var $hold_54 = $hold_25; + var $bits_54 = $bits_25; + var $out_4 = $out_0; + break $_$12; + } + var $ret_2 = 0; + var $next_37 = $next_29; + var $have_37 = $have_29; + var $hold_33 = $hold_25; + var $bits_33 = $bits_25; + __label__ = 205; + break $_$148; + } + } + } + } while (0); + do { + if (__label__ == 60) { + var $bits_5; + var $hold_5; + var $have_5; + var $next_5; + var $71 = HEAPU32[$17 >> 2]; + var $tobool263 = ($71 & 1024 | 0) == 0; + do { + if ($tobool263) { + var $76 = HEAP32[$18 >> 2]; + if (($76 | 0) == 0) { + var $next_7 = $next_5; + var $have_7 = $have_5; + var $hold_7 = $hold_5; + var $bits_7 = $bits_5; + break; + } + var $extra = $76 + 16 | 0; + HEAP32[$extra >> 2] = 0; + var $next_7 = $next_5; + var $have_7 = $have_5; + var $hold_7 = $hold_5; + var $bits_7 = $bits_5; + } else { + var $next_6 = $next_5; + var $have_6 = $have_5; + var $hold_6 = $hold_5; + var $bits_6 = $bits_5; + while (1) { + var $bits_6; + var $hold_6; + var $have_6; + var $next_6; + if (!($bits_6 >>> 0 < 16)) { + break; + } + if (($have_6 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_6; + var $have_58 = 0; + var $hold_54 = $hold_6; + var $bits_54 = $bits_6; + var $out_4 = $out_0; + break $_$12; + } + var $add279 = ((HEAPU8[$next_6] & 255) << $bits_6) + $hold_6 | 0; + var $next_6 = $next_6 + 1 | 0; + var $have_6 = $have_6 - 1 | 0; + var $hold_6 = $add279; + var $bits_6 = $bits_6 + 8 | 0; + } + HEAP32[$21 >> 2] = $hold_6; + var $73 = HEAP32[$18 >> 2]; + if (($73 | 0) == 0) { + var $74 = $71; + } else { + var $extra_len = $73 + 20 | 0; + HEAP32[$extra_len >> 2] = $hold_6; + var $74 = HEAP32[$17 >> 2]; + } + var $74; + if (($74 & 512 | 0) == 0) { + var $next_7 = $next_6; + var $have_7 = $have_6; + var $hold_7 = 0; + var $bits_7 = 0; + break; + } + HEAP8[$arrayidx] = $hold_6 & 255; + HEAP8[$arrayidx40] = $hold_6 >>> 8 & 255; + var $75 = HEAP32[$16 >> 2]; + var $call302 = _crc32($75, $arrayidx, 2); + HEAP32[$16 >> 2] = $call302; + var $next_7 = $next_6; + var $have_7 = $have_6; + var $hold_7 = 0; + var $bits_7 = 0; + } + } while (0); + var $bits_7; + var $hold_7; + var $have_7; + var $next_7; + HEAP32[$mode >> 2] = 5; + var $next_8 = $next_7; + var $have_8 = $have_7; + var $hold_8 = $hold_7; + var $bits_8 = $bits_7; + __label__ = 71; + break; + } else if (__label__ == 124) { + var $bits_17; + var $hold_17; + var $have_21; + var $next_21; + if ((HEAP32[$24 >> 2] | 0) == 0) { + var $next_22 = $next_21; + var $have_22 = $have_21; + var $hold_18 = $hold_17; + var $bits_18 = $bits_17; + while (1) { + var $bits_18; + var $hold_18; + var $have_22; + var $next_22; + if (!($bits_18 >>> 0 < 3)) { + break; + } + if (($have_22 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_22; + var $have_58 = 0; + var $hold_54 = $hold_18; + var $bits_54 = $bits_18; + var $out_4 = $out_0; + break $_$12; + } + var $add641 = ((HEAPU8[$next_22] & 255) << $bits_18) + $hold_18 | 0; + var $next_22 = $next_22 + 1 | 0; + var $have_22 = $have_22 - 1 | 0; + var $hold_18 = $add641; + var $bits_18 = $bits_18 + 8 | 0; + } + HEAP32[$24 >> 2] = $hold_18 & 1; + var $and655 = $hold_18 >>> 1 & 3; + do { + if (($and655 | 0) == 0) { + HEAP32[$mode >> 2] = 13; + } else if (($and655 | 0) == 1) { + _fixedtables($4); + HEAP32[$mode >> 2] = 19; + if (!$cmp660) { + break; + } + var $ret_8 = $ret_0; + var $next_58 = $next_22; + var $have_58 = $have_22; + var $hold_54 = $hold_18 >>> 3; + var $bits_54 = $bits_18 - 3 | 0; + var $out_4 = $out_0; + break $_$12; + } else if (($and655 | 0) == 2) { + HEAP32[$mode >> 2] = 16; + } else if (($and655 | 0) == 3) { + HEAP32[$msg >> 2] = STRING_TABLE.__str6103 | 0; + HEAP32[$mode >> 2] = 29; + } + } while (0); + var $ret_0_be = $ret_0; + var $next_0_be = $next_22; + var $put_0_be = $put_0; + var $have_0_be = $have_22; + var $left_0_be = $left_0; + var $hold_0_be = $hold_18 >>> 3; + var $bits_0_be = $bits_18 - 3 | 0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $and619 = $bits_17 & 7; + HEAP32[$mode >> 2] = 26; + var $ret_0_be = $ret_0; + var $next_0_be = $next_21; + var $put_0_be = $put_0; + var $have_0_be = $have_21; + var $left_0_be = $left_0; + var $hold_0_be = $hold_17 >>> ($and619 >>> 0); + var $bits_0_be = $bits_17 - $and619 | 0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 205) { + var $bits_33; + var $hold_33; + var $have_37; + var $next_37; + var $ret_2; + HEAP32[$mode >> 2] = 20; + var $ret_3 = $ret_2; + var $next_38 = $next_37; + var $have_38 = $have_37; + var $hold_34 = $hold_33; + var $bits_34 = $bits_33; + __label__ = 206; + break; + } + } while (0); + do { + if (__label__ == 71) { + var $bits_8; + var $hold_8; + var $have_8; + var $next_8; + var $77 = HEAPU32[$17 >> 2]; + if (($77 & 1024 | 0) == 0) { + var $next_10 = $next_8; + var $have_10 = $have_8; + var $88 = $77; + } else { + var $78 = HEAPU32[$21 >> 2]; + var $copy_0 = $78 >>> 0 > $have_8 >>> 0 ? $have_8 : $78; + if (($copy_0 | 0) == 0) { + var $next_9 = $next_8; + var $have_9 = $have_8; + var $87 = $78; + var $86 = $77; + } else { + var $79 = HEAPU32[$18 >> 2]; + var $cmp330 = ($79 | 0) == 0; + do { + if ($cmp330) { + var $83 = $77; + } else { + var $80 = HEAP32[($79 + 16 | 0) >> 2]; + if (($80 | 0) == 0) { + var $83 = $77; + break; + } + var $sub341 = HEAP32[($79 + 20 | 0) >> 2] - $78 | 0; + var $add_ptr = $80 + $sub341 | 0; + var $82 = HEAPU32[($79 + 24 | 0) >> 2]; + var $cond351 = ($sub341 + $copy_0 | 0) >>> 0 > $82 >>> 0 ? $82 - $sub341 | 0 : $copy_0; + _memcpy($add_ptr, $next_8, $cond351, 1); + var $83 = HEAP32[$17 >> 2]; + } + } while (0); + var $83; + if (!(($83 & 512 | 0) == 0)) { + var $84 = HEAP32[$16 >> 2]; + var $call358 = _crc32($84, $next_8, $copy_0); + HEAP32[$16 >> 2] = $call358; + } + var $sub361 = $have_8 - $copy_0 | 0; + var $add_ptr362 = $next_8 + $copy_0 | 0; + var $sub364 = HEAP32[$21 >> 2] - $copy_0 | 0; + HEAP32[$21 >> 2] = $sub364; + var $next_9 = $add_ptr362; + var $have_9 = $sub361; + var $87 = $sub364; + var $86 = $83; + } + var $86; + var $87; + var $have_9; + var $next_9; + if (!(($87 | 0) == 0)) { + var $ret_8 = $ret_0; + var $next_58 = $next_9; + var $have_58 = $have_9; + var $hold_54 = $hold_8; + var $bits_54 = $bits_8; + var $out_4 = $out_0; + break $_$12; + } + var $next_10 = $next_9; + var $have_10 = $have_9; + var $88 = $86; + } + var $88; + var $have_10; + var $next_10; + HEAP32[$21 >> 2] = 0; + HEAP32[$mode >> 2] = 6; + var $next_11 = $next_10; + var $have_11 = $have_10; + var $hold_9 = $hold_8; + var $bits_9 = $bits_8; + var $89 = $88; + __label__ = 81; + break; + } else if (__label__ == 206) { + var $bits_34; + var $hold_34; + var $have_38; + var $next_38; + var $ret_3; + if ($have_38 >>> 0 > 5 & $left_0 >>> 0 > 257) { + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_38; + HEAP32[$avail_in15 >> 2] = $have_38; + HEAP32[$11 >> 2] = $hold_34; + HEAP32[$13 >> 2] = $bits_34; + _inflate_fast($strm, $out_0); + var $144 = HEAP32[$next_out >> 2]; + var $145 = HEAP32[$avail_out >> 2]; + var $146 = HEAP32[$next_in >> 2]; + var $147 = HEAP32[$avail_in15 >> 2]; + var $148 = HEAP32[$11 >> 2]; + var $149 = HEAP32[$13 >> 2]; + if (!((HEAP32[$mode >> 2] | 0) == 11)) { + var $ret_0_be = $ret_3; + var $next_0_be = $146; + var $put_0_be = $144; + var $have_0_be = $147; + var $left_0_be = $145; + var $hold_0_be = $148; + var $bits_0_be = $149; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$25 >> 2] = -1; + var $ret_0_be = $ret_3; + var $next_0_be = $146; + var $put_0_be = $144; + var $have_0_be = $147; + var $left_0_be = $145; + var $hold_0_be = $148; + var $bits_0_be = $149; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$25 >> 2] = 0; + var $sub1213 = (1 << HEAP32[$26 >> 2]) - 1 | 0; + var $152 = HEAPU32[$27 >> 2]; + var $next_39 = $next_38; + var $have_39 = $have_38; + var $hold_35 = $hold_34; + var $bits_35 = $bits_34; + while (1) { + var $bits_35; + var $hold_35; + var $have_39; + var $next_39; + var $and1214 = $sub1213 & $hold_35; + var $tmp22 = HEAPU8[$152 + ($and1214 << 2) + 1 | 0]; + var $conv1218 = $tmp22 & 255; + if (!($conv1218 >>> 0 > $bits_35 >>> 0)) { + break; + } + if (($have_39 | 0) == 0) { + var $ret_8 = $ret_3; + var $next_58 = $next_39; + var $have_58 = 0; + var $hold_54 = $hold_35; + var $bits_54 = $bits_35; + var $out_4 = $out_0; + break $_$12; + } + var $add1232 = ((HEAPU8[$next_39] & 255) << $bits_35) + $hold_35 | 0; + var $next_39 = $next_39 + 1 | 0; + var $have_39 = $have_39 - 1 | 0; + var $hold_35 = $add1232; + var $bits_35 = $bits_35 + 8 | 0; + } + var $tmp21 = HEAPU8[$152 + ($and1214 << 2) | 0]; + var $tmp23 = HEAPU16[($152 + ($and1214 << 2) + 2 | 0) >> 1]; + var $conv1237 = $tmp21 & 255; + var $tobool1238 = $tmp21 << 24 >> 24 == 0; + do { + if ($tobool1238) { + var $next_41 = $next_39; + var $have_41 = $have_39; + var $hold_37 = $hold_35; + var $bits_37 = $bits_35; + var $here_09_0 = 0; + var $here_110_0 = $tmp22; + var $here_211_0 = $tmp23; + var $155 = 0; + } else { + if (!(($conv1237 & 240 | 0) == 0)) { + var $next_41 = $next_39; + var $have_41 = $have_39; + var $hold_37 = $hold_35; + var $bits_37 = $bits_35; + var $here_09_0 = $tmp21; + var $here_110_0 = $tmp22; + var $here_211_0 = $tmp23; + var $155 = 0; + break; + } + var $conv1248 = $tmp23 & 65535; + var $sub1255 = (1 << ($conv1218 + $conv1237 | 0)) - 1 | 0; + var $next_40 = $next_39; + var $have_40 = $have_39; + var $hold_36 = $hold_35; + var $bits_36 = $bits_35; + while (1) { + var $bits_36; + var $hold_36; + var $have_40; + var $next_40; + var $add1260 = (($hold_36 & $sub1255) >>> ($conv1218 >>> 0)) + $conv1248 | 0; + var $tmp19 = HEAPU8[$152 + ($add1260 << 2) + 1 | 0]; + if (!((($tmp19 & 255) + $conv1218 | 0) >>> 0 > $bits_36 >>> 0)) { + break; + } + if (($have_40 | 0) == 0) { + var $ret_8 = $ret_3; + var $next_58 = $next_40; + var $have_58 = 0; + var $hold_54 = $hold_36; + var $bits_54 = $bits_36; + var $out_4 = $out_0; + break $_$12; + } + var $add1281 = ((HEAPU8[$next_40] & 255) << $bits_36) + $hold_36 | 0; + var $next_40 = $next_40 + 1 | 0; + var $have_40 = $have_40 - 1 | 0; + var $hold_36 = $add1281; + var $bits_36 = $bits_36 + 8 | 0; + } + var $tmp20 = HEAP16[($152 + ($add1260 << 2) + 2 | 0) >> 1]; + var $tmp18 = HEAP8[$152 + ($add1260 << 2) | 0]; + var $shr1289 = $hold_36 >>> ($conv1218 >>> 0); + var $sub1292 = $bits_36 - $conv1218 | 0; + HEAP32[$25 >> 2] = $conv1218; + var $next_41 = $next_40; + var $have_41 = $have_40; + var $hold_37 = $shr1289; + var $bits_37 = $sub1292; + var $here_09_0 = $tmp18; + var $here_110_0 = $tmp19; + var $here_211_0 = $tmp20; + var $155 = $conv1218; + } + } while (0); + var $155; + var $here_211_0; + var $here_110_0; + var $here_09_0; + var $bits_37; + var $hold_37; + var $have_41; + var $next_41; + var $conv1302 = $here_110_0 & 255; + var $shr1303 = $hold_37 >>> ($conv1302 >>> 0); + var $sub1306 = $bits_37 - $conv1302 | 0; + HEAP32[$25 >> 2] = $155 + $conv1302 | 0; + HEAP32[$21 >> 2] = $here_211_0 & 65535; + var $conv1317 = $here_09_0 & 255; + if ($here_09_0 << 24 >> 24 == 0) { + HEAP32[$mode >> 2] = 25; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + if (!(($conv1317 & 32 | 0) == 0)) { + HEAP32[$25 >> 2] = -1; + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + if (($conv1317 & 64 | 0) == 0) { + var $and1341 = $conv1317 & 15; + HEAP32[$28 >> 2] = $and1341; + HEAP32[$mode >> 2] = 21; + var $ret_4 = $ret_3; + var $next_42 = $next_41; + var $have_42 = $have_41; + var $hold_38 = $shr1303; + var $bits_38 = $sub1306; + var $156 = $and1341; + __label__ = 227; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str2171 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + } while (0); + do { + if (__label__ == 81) { + var $89; + var $bits_9; + var $hold_9; + var $have_11; + var $next_11; + var $tobool376 = ($89 & 2048 | 0) == 0; + do { + if ($tobool376) { + var $98 = HEAP32[$18 >> 2]; + if (($98 | 0) == 0) { + var $next_12 = $next_11; + var $have_12 = $have_11; + break; + } + var $name428 = $98 + 28 | 0; + HEAP32[$name428 >> 2] = 0; + var $next_12 = $next_11; + var $have_12 = $have_11; + } else { + if (($have_11 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_11; + var $have_58 = 0; + var $hold_54 = $hold_9; + var $bits_54 = $bits_9; + var $out_4 = $out_0; + break $_$12; + } + var $copy_1 = 0; + while (1) { + var $copy_1; + var $inc = $copy_1 + 1 | 0; + var $90 = HEAP8[$next_11 + $copy_1 | 0]; + var $91 = HEAP32[$18 >> 2]; + var $cmp386 = ($91 | 0) == 0; + do { + if (!$cmp386) { + var $name = $91 + 28 | 0; + if ((HEAP32[$name >> 2] | 0) == 0) { + break; + } + var $93 = HEAPU32[$21 >> 2]; + if (!($93 >>> 0 < HEAPU32[($91 + 32 | 0) >> 2] >>> 0)) { + break; + } + HEAP32[$21 >> 2] = $93 + 1 | 0; + HEAP8[HEAP32[$name >> 2] + $93 | 0] = $90; + } + } while (0); + var $tobool405 = $90 << 24 >> 24 != 0; + if (!($tobool405 & $inc >>> 0 < $have_11 >>> 0)) { + break; + } + var $copy_1 = $inc; + } + if (!((HEAP32[$17 >> 2] & 512 | 0) == 0)) { + var $97 = HEAP32[$16 >> 2]; + var $call414 = _crc32($97, $next_11, $inc); + HEAP32[$16 >> 2] = $call414; + } + var $sub417 = $have_11 - $inc | 0; + var $add_ptr418 = $next_11 + $inc | 0; + if ($tobool405) { + var $ret_8 = $ret_0; + var $next_58 = $add_ptr418; + var $have_58 = $sub417; + var $hold_54 = $hold_9; + var $bits_54 = $bits_9; + var $out_4 = $out_0; + break $_$12; + } + var $next_12 = $add_ptr418; + var $have_12 = $sub417; + } + } while (0); + var $have_12; + var $next_12; + HEAP32[$21 >> 2] = 0; + HEAP32[$mode >> 2] = 7; + var $next_13 = $next_12; + var $have_13 = $have_12; + var $hold_10 = $hold_9; + var $bits_10 = $bits_9; + __label__ = 94; + break; + } else if (__label__ == 227) { + var $156; + var $bits_38; + var $hold_38; + var $have_42; + var $next_42; + var $ret_4; + if (($156 | 0) == 0) { + var $next_44 = $next_42; + var $have_44 = $have_42; + var $hold_40 = $hold_38; + var $bits_40 = $bits_38; + var $160 = HEAP32[$21 >> 2]; + } else { + var $next_43 = $next_42; + var $have_43 = $have_42; + var $hold_39 = $hold_38; + var $bits_39 = $bits_38; + while (1) { + var $bits_39; + var $hold_39; + var $have_43; + var $next_43; + if (!($bits_39 >>> 0 < $156 >>> 0)) { + break; + } + if (($have_43 | 0) == 0) { + var $ret_8 = $ret_4; + var $next_58 = $next_43; + var $have_58 = 0; + var $hold_54 = $hold_39; + var $bits_54 = $bits_39; + var $out_4 = $out_0; + break $_$12; + } + var $add1363 = ((HEAPU8[$next_43] & 255) << $bits_39) + $hold_39 | 0; + var $next_43 = $next_43 + 1 | 0; + var $have_43 = $have_43 - 1 | 0; + var $hold_39 = $add1363; + var $bits_39 = $bits_39 + 8 | 0; + } + var $add1375 = HEAP32[$21 >> 2] + (((1 << $156) - 1 | 0) & $hold_39) | 0; + HEAP32[$21 >> 2] = $add1375; + var $add1385 = HEAP32[$25 >> 2] + $156 | 0; + HEAP32[$25 >> 2] = $add1385; + var $next_44 = $next_43; + var $have_44 = $have_43; + var $hold_40 = $hold_39 >>> ($156 >>> 0); + var $bits_40 = $bits_39 - $156 | 0; + var $160 = $add1375; + } + var $160; + var $bits_40; + var $hold_40; + var $have_44; + var $next_44; + HEAP32[$29 >> 2] = $160; + HEAP32[$mode >> 2] = 22; + var $ret_5_ph = $ret_4; + var $next_45_ph = $next_44; + var $have_45_ph = $have_44; + var $hold_41_ph = $hold_40; + var $bits_41_ph = $bits_40; + __label__ = 234; + break; + } + } while (0); + do { + if (__label__ == 94) { + var $bits_10; + var $hold_10; + var $have_13; + var $next_13; + var $tobool436 = (HEAP32[$17 >> 2] & 4096 | 0) == 0; + do { + if ($tobool436) { + var $108 = HEAP32[$18 >> 2]; + if (($108 | 0) == 0) { + var $next_14 = $next_13; + var $have_14 = $have_13; + break; + } + var $comment492 = $108 + 36 | 0; + HEAP32[$comment492 >> 2] = 0; + var $next_14 = $next_13; + var $have_14 = $have_13; + } else { + if (($have_13 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_13; + var $have_58 = 0; + var $hold_54 = $hold_10; + var $bits_54 = $bits_10; + var $out_4 = $out_0; + break $_$12; + } + var $copy_2 = 0; + while (1) { + var $copy_2; + var $inc443 = $copy_2 + 1 | 0; + var $100 = HEAP8[$next_13 + $copy_2 | 0]; + var $101 = HEAP32[$18 >> 2]; + var $cmp447 = ($101 | 0) == 0; + do { + if (!$cmp447) { + var $comment = $101 + 36 | 0; + if ((HEAP32[$comment >> 2] | 0) == 0) { + break; + } + var $103 = HEAPU32[$21 >> 2]; + if (!($103 >>> 0 < HEAPU32[($101 + 40 | 0) >> 2] >>> 0)) { + break; + } + HEAP32[$21 >> 2] = $103 + 1 | 0; + HEAP8[HEAP32[$comment >> 2] + $103 | 0] = $100; + } + } while (0); + var $tobool467 = $100 << 24 >> 24 != 0; + if (!($tobool467 & $inc443 >>> 0 < $have_13 >>> 0)) { + break; + } + var $copy_2 = $inc443; + } + if (!((HEAP32[$17 >> 2] & 512 | 0) == 0)) { + var $107 = HEAP32[$16 >> 2]; + var $call478 = _crc32($107, $next_13, $inc443); + HEAP32[$16 >> 2] = $call478; + } + var $sub481 = $have_13 - $inc443 | 0; + var $add_ptr482 = $next_13 + $inc443 | 0; + if ($tobool467) { + var $ret_8 = $ret_0; + var $next_58 = $add_ptr482; + var $have_58 = $sub481; + var $hold_54 = $hold_10; + var $bits_54 = $bits_10; + var $out_4 = $out_0; + break $_$12; + } + var $next_14 = $add_ptr482; + var $have_14 = $sub481; + } + } while (0); + var $have_14; + var $next_14; + HEAP32[$mode >> 2] = 8; + var $next_15 = $next_14; + var $have_15 = $have_14; + var $hold_11 = $hold_10; + var $bits_11 = $bits_10; + __label__ = 107; + break; + } else if (__label__ == 234) { + var $bits_41_ph; + var $hold_41_ph; + var $have_45_ph; + var $next_45_ph; + var $ret_5_ph; + var $sub1393 = (1 << HEAP32[$47 >> 2]) - 1 | 0; + var $162 = HEAPU32[$48 >> 2]; + var $next_45 = $next_45_ph; + var $have_45 = $have_45_ph; + var $hold_41 = $hold_41_ph; + var $bits_41 = $bits_41_ph; + while (1) { + var $bits_41; + var $hold_41; + var $have_45; + var $next_45; + var $and1394 = $sub1393 & $hold_41; + var $tmp16 = HEAPU8[$162 + ($and1394 << 2) + 1 | 0]; + var $conv1398 = $tmp16 & 255; + if (!($conv1398 >>> 0 > $bits_41 >>> 0)) { + break; + } + if (($have_45 | 0) == 0) { + var $ret_8 = $ret_5_ph; + var $next_58 = $next_45; + var $have_58 = 0; + var $hold_54 = $hold_41; + var $bits_54 = $bits_41; + var $out_4 = $out_0; + break $_$12; + } + var $add1412 = ((HEAPU8[$next_45] & 255) << $bits_41) + $hold_41 | 0; + var $next_45 = $next_45 + 1 | 0; + var $have_45 = $have_45 - 1 | 0; + var $hold_41 = $add1412; + var $bits_41 = $bits_41 + 8 | 0; + } + var $tmp15 = HEAPU8[$162 + ($and1394 << 2) | 0]; + var $tmp17 = HEAPU16[($162 + ($and1394 << 2) + 2 | 0) >> 1]; + var $conv1418 = $tmp15 & 255; + if (($conv1418 & 240 | 0) == 0) { + var $conv1425 = $tmp17 & 65535; + var $sub1432 = (1 << ($conv1398 + $conv1418 | 0)) - 1 | 0; + var $next_46 = $next_45; + var $have_46 = $have_45; + var $hold_42 = $hold_41; + var $bits_42 = $bits_41; + while (1) { + var $bits_42; + var $hold_42; + var $have_46; + var $next_46; + var $add1437 = (($hold_42 & $sub1432) >>> ($conv1398 >>> 0)) + $conv1425 | 0; + var $tmp13 = HEAPU8[$162 + ($add1437 << 2) + 1 | 0]; + if (!((($tmp13 & 255) + $conv1398 | 0) >>> 0 > $bits_42 >>> 0)) { + break; + } + if (($have_46 | 0) == 0) { + var $ret_8 = $ret_5_ph; + var $next_58 = $next_46; + var $have_58 = 0; + var $hold_54 = $hold_42; + var $bits_54 = $bits_42; + var $out_4 = $out_0; + break $_$12; + } + var $add1458 = ((HEAPU8[$next_46] & 255) << $bits_42) + $hold_42 | 0; + var $next_46 = $next_46 + 1 | 0; + var $have_46 = $have_46 - 1 | 0; + var $hold_42 = $add1458; + var $bits_42 = $bits_42 + 8 | 0; + } + var $tmp14 = HEAP16[($162 + ($add1437 << 2) + 2 | 0) >> 1]; + var $tmp12 = HEAP8[$162 + ($add1437 << 2) | 0]; + var $shr1466 = $hold_42 >>> ($conv1398 >>> 0); + var $sub1469 = $bits_42 - $conv1398 | 0; + var $add1475 = HEAP32[$25 >> 2] + $conv1398 | 0; + HEAP32[$25 >> 2] = $add1475; + var $next_47 = $next_46; + var $have_47 = $have_46; + var $hold_43 = $shr1466; + var $bits_43 = $sub1469; + var $here_09_1 = $tmp12; + var $here_110_1 = $tmp13; + var $here_211_1 = $tmp14; + var $166 = $add1475; + } else { + var $next_47 = $next_45; + var $have_47 = $have_45; + var $hold_43 = $hold_41; + var $bits_43 = $bits_41; + var $here_09_1 = $tmp15; + var $here_110_1 = $tmp16; + var $here_211_1 = $tmp17; + var $166 = HEAP32[$25 >> 2]; + } + var $166; + var $here_211_1; + var $here_110_1; + var $here_09_1; + var $bits_43; + var $hold_43; + var $have_47; + var $next_47; + var $conv1479 = $here_110_1 & 255; + var $shr1480 = $hold_43 >>> ($conv1479 >>> 0); + var $sub1483 = $bits_43 - $conv1479 | 0; + HEAP32[$25 >> 2] = $166 + $conv1479 | 0; + var $conv1491 = $here_09_1 & 255; + if (($conv1491 & 64 | 0) == 0) { + HEAP32[$30 >> 2] = $here_211_1 & 65535; + var $and1502 = $conv1491 & 15; + HEAP32[$28 >> 2] = $and1502; + HEAP32[$mode >> 2] = 23; + var $ret_6 = $ret_5_ph; + var $next_48 = $next_47; + var $have_48 = $have_47; + var $hold_44 = $shr1480; + var $bits_44 = $sub1483; + var $167 = $and1502; + __label__ = 248; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str1170 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_5_ph; + var $next_0_be = $next_47; + var $put_0_be = $put_0; + var $have_0_be = $have_47; + var $left_0_be = $left_0; + var $hold_0_be = $shr1480; + var $bits_0_be = $sub1483; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + } while (0); + $_$359 : do { + if (__label__ == 107) { + var $bits_11; + var $hold_11; + var $have_15; + var $next_15; + var $109 = HEAPU32[$17 >> 2]; + var $tobool499 = ($109 & 512 | 0) == 0; + do { + if (!$tobool499) { + var $next_16 = $next_15; + var $have_16 = $have_15; + var $hold_12 = $hold_11; + var $bits_12 = $bits_11; + while (1) { + var $bits_12; + var $hold_12; + var $have_16; + var $next_16; + if (!($bits_12 >>> 0 < 16)) { + break; + } + if (($have_16 | 0) == 0) { + var $ret_8 = $ret_0; + var $next_58 = $next_16; + var $have_58 = 0; + var $hold_54 = $hold_12; + var $bits_54 = $bits_12; + var $out_4 = $out_0; + break $_$12; + } + var $add515 = ((HEAPU8[$next_16] & 255) << $bits_12) + $hold_12 | 0; + var $next_16 = $next_16 + 1 | 0; + var $have_16 = $have_16 - 1 | 0; + var $hold_12 = $add515; + var $bits_12 = $bits_12 + 8 | 0; + } + if (($hold_12 | 0) == (HEAP32[$16 >> 2] & 65535 | 0)) { + var $next_17 = $next_16; + var $have_17 = $have_16; + var $hold_13 = 0; + var $bits_13 = 0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str5102 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_16; + var $put_0_be = $put_0; + var $have_0_be = $have_16; + var $left_0_be = $left_0; + var $hold_0_be = $hold_12; + var $bits_0_be = $bits_12; + var $out_0_be = $out_0; + __label__ = 268; + break $_$359; + } + var $next_17 = $next_15; + var $have_17 = $have_15; + var $hold_13 = $hold_11; + var $bits_13 = $bits_11; + } while (0); + var $bits_13; + var $hold_13; + var $have_17; + var $next_17; + var $112 = HEAPU32[$18 >> 2]; + if (!(($112 | 0) == 0)) { + HEAP32[($112 + 44 | 0) >> 2] = $109 >>> 9 & 1; + var $done543 = HEAP32[$18 >> 2] + 48 | 0; + HEAP32[$done543 >> 2] = 1; + } + var $call545 = _crc32(0, 0, 0); + HEAP32[$16 >> 2] = $call545; + HEAP32[$adler >> 2] = $call545; + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_0; + var $next_0_be = $next_17; + var $put_0_be = $put_0; + var $have_0_be = $have_17; + var $left_0_be = $left_0; + var $hold_0_be = $hold_13; + var $bits_0_be = $bits_13; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 248) { + var $167; + var $bits_44; + var $hold_44; + var $have_48; + var $next_48; + var $ret_6; + if (($167 | 0) == 0) { + var $next_50 = $next_48; + var $have_50 = $have_48; + var $hold_46 = $hold_44; + var $bits_46 = $bits_44; + } else { + var $next_49 = $next_48; + var $have_49 = $have_48; + var $hold_45 = $hold_44; + var $bits_45 = $bits_44; + while (1) { + var $bits_45; + var $hold_45; + var $have_49; + var $next_49; + if (!($bits_45 >>> 0 < $167 >>> 0)) { + break; + } + if (($have_49 | 0) == 0) { + var $ret_8 = $ret_6; + var $next_58 = $next_49; + var $have_58 = 0; + var $hold_54 = $hold_45; + var $bits_54 = $bits_45; + var $out_4 = $out_0; + break $_$12; + } + var $add1524 = ((HEAPU8[$next_49] & 255) << $bits_45) + $hold_45 | 0; + var $next_49 = $next_49 + 1 | 0; + var $have_49 = $have_49 - 1 | 0; + var $hold_45 = $add1524; + var $bits_45 = $bits_45 + 8 | 0; + } + var $add1536 = HEAP32[$30 >> 2] + (((1 << $167) - 1 | 0) & $hold_45) | 0; + HEAP32[$30 >> 2] = $add1536; + var $add1546 = HEAP32[$25 >> 2] + $167 | 0; + HEAP32[$25 >> 2] = $add1546; + var $next_50 = $next_49; + var $have_50 = $have_49; + var $hold_46 = $hold_45 >>> ($167 >>> 0); + var $bits_46 = $bits_45 - $167 | 0; + } + var $bits_46; + var $hold_46; + var $have_50; + var $next_50; + HEAP32[$mode >> 2] = 24; + var $ret_7 = $ret_6; + var $next_51 = $next_50; + var $have_51 = $have_50; + var $hold_47 = $hold_46; + var $bits_47 = $bits_46; + __label__ = 254; + break; + } + } while (0); + $_$380 : do { + if (__label__ == 254) { + var $bits_47; + var $hold_47; + var $have_51; + var $next_51; + var $ret_7; + if (($left_0 | 0) == 0) { + var $ret_8 = $ret_7; + var $next_58 = $next_51; + var $have_58 = $have_51; + var $hold_54 = $hold_47; + var $bits_54 = $bits_47; + var $out_4 = $out_0; + break $_$12; + } + var $sub1554 = $out_0 - $left_0 | 0; + var $171 = HEAPU32[$30 >> 2]; + var $cmp1556 = $171 >>> 0 > $sub1554 >>> 0; + do { + if ($cmp1556) { + var $sub1560 = $171 - $sub1554 | 0; + var $cmp1561 = $sub1560 >>> 0 > HEAPU32[$31 >> 2] >>> 0; + do { + if ($cmp1561) { + if ((HEAP32[$32 >> 2] | 0) == 0) { + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str169 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $put_0; + var $have_0_be = $have_51; + var $left_0_be = $left_0; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + break $_$380; + } + } while (0); + var $174 = HEAPU32[$33 >> 2]; + if ($sub1560 >>> 0 > $174 >>> 0) { + var $sub1574 = $sub1560 - $174 | 0; + var $from_0 = HEAP32[$34 >> 2] + (HEAP32[$35 >> 2] - $sub1574 | 0) | 0; + var $copy_7 = $sub1574; + } else { + var $from_0 = HEAP32[$34 >> 2] + ($174 - $sub1560 | 0) | 0; + var $copy_7 = $sub1560; + } + var $copy_7; + var $from_0; + var $178 = HEAPU32[$21 >> 2]; + if (!($copy_7 >>> 0 > $178 >>> 0)) { + var $from_1 = $from_0; + var $copy_8 = $copy_7; + var $180 = $178; + break; + } + var $from_1 = $from_0; + var $copy_8 = $178; + var $180 = $178; + } else { + var $179 = HEAP32[$21 >> 2]; + var $from_1 = $put_0 + (-$171 | 0) | 0; + var $copy_8 = $179; + var $180 = $179; + } + } while (0); + var $180; + var $copy_8; + var $from_1; + var $copy_9 = $copy_8 >>> 0 > $left_0 >>> 0 ? $left_0 : $copy_8; + HEAP32[$21 >> 2] = $180 - $copy_9 | 0; + var $181 = $copy_8 ^ -1; + var $182 = $left_0 ^ -1; + var $umax = $181 >>> 0 > $182 >>> 0 ? $181 : $182; + var $from_2 = $from_1; + var $put_1 = $put_0; + var $copy_10 = $copy_9; + while (1) { + var $copy_10; + var $put_1; + var $from_2; + var $184 = HEAP8[$from_2]; + HEAP8[$put_1] = $184; + var $dec1605 = $copy_10 - 1 | 0; + if (($dec1605 | 0) == 0) { + break; + } + var $from_2 = $from_2 + 1 | 0; + var $put_1 = $put_1 + 1 | 0; + var $copy_10 = $dec1605; + } + var $sub1598 = $left_0 - $copy_9 | 0; + var $scevgep632 = $put_0 + ($umax ^ -1) | 0; + if (!((HEAP32[$21 >> 2] | 0) == 0)) { + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $scevgep632; + var $have_0_be = $have_51; + var $left_0_be = $sub1598; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + break; + } + HEAP32[$mode >> 2] = 20; + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $scevgep632; + var $have_0_be = $have_51; + var $left_0_be = $sub1598; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + } + } while (0); + var $out_0_be; + var $bits_0_be; + var $hold_0_be; + var $left_0_be; + var $have_0_be; + var $put_0_be; + var $next_0_be; + var $ret_0_be; + var $ret_0 = $ret_0_be; + var $next_0 = $next_0_be; + var $put_0 = $put_0_be; + var $have_0 = $have_0_be; + var $left_0 = $left_0_be; + var $hold_0 = $hold_0_be; + var $bits_0 = $bits_0_be; + var $out_0 = $out_0_be; + var $49 = HEAP32[$mode >> 2]; + } + var $out_4; + var $bits_54; + var $hold_54; + var $have_58; + var $next_58; + var $ret_8; + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_58; + HEAP32[$avail_in15 >> 2] = $have_58; + HEAP32[$11 >> 2] = $hold_54; + HEAP32[$13 >> 2] = $bits_54; + var $tobool1755 = (HEAP32[$35 >> 2] | 0) == 0; + do { + if ($tobool1755) { + if (!(HEAPU32[$mode >> 2] >>> 0 < 26)) { + __label__ = 300; + break; + } + if (($out_4 | 0) == (HEAP32[$avail_out >> 2] | 0)) { + __label__ = 300; + break; + } + __label__ = 298; + break; + } else { + __label__ = 298; + } + } while (0); + do { + if (__label__ == 298) { + var $call1765 = _updatewindow($strm, $out_4); + if (($call1765 | 0) == 0) { + break; + } + HEAP32[$mode >> 2] = 30; + var $retval_0 = -4; + break $_$2; + } + } while (0); + var $202 = HEAPU32[$avail_in15 >> 2]; + var $203 = HEAPU32[$avail_out >> 2]; + var $sub1774 = $out_4 - $203 | 0; + var $total_in = $strm + 8 | 0; + var $add1775 = ($10 - $202 | 0) + HEAP32[$total_in >> 2] | 0; + HEAP32[$total_in >> 2] = $add1775; + var $add1777 = HEAP32[$total_out >> 2] + $sub1774 | 0; + HEAP32[$total_out >> 2] = $add1777; + var $add1779 = HEAP32[$36 >> 2] + $sub1774 | 0; + HEAP32[$36 >> 2] = $add1779; + var $tobool1783 = ($out_4 | 0) == ($203 | 0); + if (!((HEAP32[$15 >> 2] | 0) == 0 | $tobool1783)) { + var $209 = HEAP32[$16 >> 2]; + var $add_ptr1791 = HEAP32[$next_out >> 2] + (-$sub1774 | 0) | 0; + if ((HEAP32[$17 >> 2] | 0) == 0) { + var $call1798 = _adler32($209, $add_ptr1791, $sub1774); + var $cond1800 = $call1798; + } else { + var $call1792 = _crc32($209, $add_ptr1791, $sub1774); + var $cond1800 = $call1792; + } + var $cond1800; + HEAP32[$16 >> 2] = $cond1800; + HEAP32[$adler >> 2] = $cond1800; + } + var $cond1807 = (HEAP32[$24 >> 2] | 0) != 0 ? 64 : 0; + var $213 = HEAP32[$mode >> 2]; + var $cond1812 = ($213 | 0) == 11 ? 128 : 0; + if (($213 | 0) == 19) { + var $214 = 256; + } else { + var $phitmp = ($213 | 0) == 14 ? 256 : 0; + var $214 = $phitmp; + } + var $214; + var $add1821 = (($cond1807 + HEAP32[$13 >> 2] | 0) + $cond1812 | 0) + $214 | 0; + HEAP32[($strm + 44 | 0) >> 2] = $add1821; + var $ret_9 = (($10 | 0) == ($202 | 0) & $tobool1783 | ($flush | 0) == 4) & ($ret_8 | 0) == 0 ? -5 : $ret_8; + var $retval_0 = $ret_9; + } + } while (0); + var $retval_0; + STACKTOP = __stackBase__; + return $retval_0; + return null; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate"] diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index 55f74d67..a2d62a25 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -140,4 +140,3304 @@ function llvm3_1() { run($j_0 / 2); } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1"] +function _inflate($strm, $flush) { + var __stackBase__ = STACKTOP; + STACKTOP += 4; + var __label__; + var $hbuf = __stackBase__; + var $cmp = ($strm | 0) == 0; + $_$2 : do { + if ($cmp) { + var $retval_0 = -2; + } else { + var $state1 = $strm + 28 | 0; + var $0 = HEAPU32[$state1 >> 2]; + var $cmp2 = ($0 | 0) == 0; + if ($cmp2) { + var $retval_0 = -2; + break; + } + var $next_out = $strm + 12 | 0; + var $1 = HEAP32[$next_out >> 2]; + var $cmp4 = ($1 | 0) == 0; + if ($cmp4) { + var $retval_0 = -2; + break; + } + var $next_in = $strm | 0; + var $2 = HEAP32[$next_in >> 2]; + var $cmp6 = ($2 | 0) == 0; + if ($cmp6) { + var $avail_in = $strm + 4 | 0; + var $3 = HEAP32[$avail_in >> 2]; + var $cmp7 = ($3 | 0) == 0; + if (!$cmp7) { + var $retval_0 = -2; + break; + } + } + var $4 = $0; + var $mode = $0 | 0; + var $5 = HEAP32[$mode >> 2]; + var $cmp9 = ($5 | 0) == 11; + if ($cmp9) { + HEAP32[$mode >> 2] = 12; + var $_pre = HEAP32[$next_out >> 2]; + var $_pre882 = HEAP32[$next_in >> 2]; + var $8 = $_pre; + var $7 = $_pre882; + var $6 = 12; + } else { + var $8 = $1; + var $7 = $2; + var $6 = $5; + } + var $6; + var $7; + var $8; + var $avail_out = $strm + 16 | 0; + var $9 = HEAP32[$avail_out >> 2]; + var $avail_in15 = $strm + 4 | 0; + var $10 = HEAPU32[$avail_in15 >> 2]; + var $11 = $0 + 56 | 0; + var $12 = HEAP32[$11 >> 2]; + var $13 = $0 + 60 | 0; + var $14 = HEAP32[$13 >> 2]; + var $15 = $0 + 8 | 0; + var $16 = $0 + 24 | 0; + var $arrayidx = $hbuf | 0; + var $arrayidx40 = $hbuf + 1 | 0; + var $17 = $0 + 16 | 0; + var $head = $0 + 32 | 0; + var $18 = $head; + var $msg = $strm + 24 | 0; + var $19 = $0 + 36 | 0; + var $20 = $0 + 20 | 0; + var $adler = $strm + 48 | 0; + var $21 = $0 + 64 | 0; + var $22 = $0 + 12 | 0; + var $flush_off = $flush - 5 | 0; + var $23 = $flush_off >>> 0 < 2; + var $24 = $0 + 4 | 0; + var $cmp660 = ($flush | 0) == 6; + var $25 = $0 + 7108 | 0; + var $26 = $0 + 84 | 0; + var $lencode1215 = $0 + 76 | 0; + var $27 = $lencode1215; + var $28 = $0 + 72 | 0; + var $29 = $0 + 7112 | 0; + var $30 = $0 + 68 | 0; + var $31 = $0 + 44 | 0; + var $32 = $0 + 7104 | 0; + var $33 = $0 + 48 | 0; + var $window = $0 + 52 | 0; + var $34 = $window; + var $35 = $0 + 40 | 0; + var $total_out = $strm + 20 | 0; + var $36 = $0 + 28 | 0; + var $arrayidx199 = $hbuf + 2 | 0; + var $arrayidx202 = $hbuf + 3 | 0; + var $37 = $0 + 96 | 0; + var $38 = $0 + 100 | 0; + var $39 = $0 + 92 | 0; + var $40 = $0 + 104 | 0; + var $lens = $0 + 112 | 0; + var $41 = $lens; + var $codes = $0 + 1328 | 0; + var $next861 = $0 + 108 | 0; + var $42 = $next861; + var $43 = $next861 | 0; + var $arraydecay860_c = $codes; + var $44 = $0 + 76 | 0; + var $arraydecay864 = $lens; + var $work = $0 + 752 | 0; + var $arraydecay867 = $work; + var $arrayidx1128 = $0 + 624 | 0; + var $45 = $arrayidx1128; + var $46 = $0 + 80 | 0; + var $47 = $0 + 88 | 0; + var $distcode1395 = $0 + 80 | 0; + var $48 = $distcode1395; + var $ret_0 = 0; + var $next_0 = $7; + var $put_0 = $8; + var $have_0 = $10; + var $left_0 = $9; + var $hold_0 = $12; + var $bits_0 = $14; + var $out_0 = $9; + var $49 = $6; + $_$12 : while (1) { + var $49; + var $out_0; + var $bits_0; + var $hold_0; + var $left_0; + var $have_0; + var $put_0; + var $next_0; + var $ret_0; + $_$14 : do { + if (($49 | 0) == 0) { + var $50 = HEAPU32[$15 >> 2]; + var $cmp19 = ($50 | 0) == 0; + if ($cmp19) { + HEAP32[$mode >> 2] = 12; + var $ret_0_be = $ret_0; + var $next_0_be = $next_0; + var $put_0_be = $put_0; + var $have_0_be = $have_0; + var $left_0_be = $left_0; + var $hold_0_be = $hold_0; + var $bits_0_be = $bits_0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $next_1 = $next_0; + var $have_1 = $have_0; + var $hold_1 = $hold_0; + var $bits_1 = $bits_0; + while (1) { + var $bits_1; + var $hold_1; + var $have_1; + var $next_1; + var $cmp24 = $bits_1 >>> 0 < 16; + if (!$cmp24) { + break; + } + var $cmp26 = ($have_1 | 0) == 0; + if ($cmp26) { + var $ret_8 = $ret_0; + var $next_58 = $next_1; + var $have_58 = 0; + var $hold_54 = $hold_1; + var $bits_54 = $bits_1; + var $out_4 = $out_0; + break $_$12; + } + // XXX first chunk with a difference (no impact) + var $dec = $have_1 - 1 | 0; + var $incdec_ptr = $next_1 + 1 | 0; + var $51 = HEAPU8[$next_1]; + var $conv = $51 & 255; + var $shl = $conv << $bits_1; + var $add = $shl + $hold_1 | 0; + var $add29 = $bits_1 + 8 | 0; + var $next_1 = $incdec_ptr; + var $have_1 = $dec; + var $hold_1 = $add; + var $bits_1 = $add29; + } + var $and = $50 & 2; + var $tobool = ($and | 0) != 0; + var $cmp34 = ($hold_1 | 0) == 35615; + var $or_cond = $tobool & $cmp34; + if ($or_cond) { + var $call = _crc32(0, 0, 0); + HEAP32[$16 >> 2] = $call; + HEAP8[$arrayidx] = 31; + HEAP8[$arrayidx40] = -117; + var $52 = HEAP32[$16 >> 2]; + var $call42 = _crc32($52, $arrayidx, 2); + HEAP32[$16 >> 2] = $call42; + HEAP32[$mode >> 2] = 1; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = 0; + var $bits_0_be = 0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$17 >> 2] = 0; + var $53 = HEAP32[$18 >> 2]; + var $cmp49 = ($53 | 0) == 0; + if ($cmp49) { + var $54 = $50; + } else { + var $done = $53 + 48 | 0; + HEAP32[$done >> 2] = -1; + var $_pre884 = HEAP32[$15 >> 2]; + var $54 = $_pre884; + } + var $54; + var $and55 = $54 & 1; + var $tobool56 = ($and55 | 0) == 0; + do { + if (!$tobool56) { + var $and58 = $hold_1 << 8; + var $shl59 = $and58 & 65280; + var $shr60 = $hold_1 >>> 8; + var $add61 = $shl59 + $shr60 | 0; + var $rem = ($add61 >>> 0) % 31; + var $tobool62 = ($rem | 0) == 0; + if (!$tobool62) { + break; + } + var $and66 = $hold_1 & 15; + var $cmp67 = ($and66 | 0) == 8; + if ($cmp67) { + var $shr74 = $hold_1 >>> 4; + var $sub = $bits_1 - 4 | 0; + var $and76 = $shr74 & 15; + var $add77 = $and76 + 8 | 0; + var $55 = HEAPU32[$19 >> 2]; + var $cmp78 = ($55 | 0) == 0; + do { + if (!$cmp78) { + var $cmp83 = $add77 >>> 0 > $55 >>> 0; + if (!$cmp83) { + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str3100 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $shr74; + var $bits_0_be = $sub; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + HEAP32[$19 >> 2] = $add77; + } while (0); + var $shl90 = 1 << $add77; + HEAP32[$20 >> 2] = $shl90; + var $call91 = _adler32(0, 0, 0); + HEAP32[$16 >> 2] = $call91; + HEAP32[$adler >> 2] = $call91; + var $and93 = $hold_1 >>> 12; + var $56 = $and93 & 2; + var $57 = $56 ^ 11; + HEAP32[$mode >> 2] = $57; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = 0; + var $bits_0_be = 0; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str299 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $hold_1; + var $bits_0_be = $bits_1; + var $out_0_be = $out_0; + __label__ = 268; + break $_$14; + } + } while (0); + HEAP32[$msg >> 2] = STRING_TABLE.__str198 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_1; + var $put_0_be = $put_0; + var $have_0_be = $have_1; + var $left_0_be = $left_0; + var $hold_0_be = $hold_1; + var $bits_0_be = $bits_1; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 1) { + var $next_2 = $next_0; + var $have_2 = $have_0; + var $hold_2 = $hold_0; + var $bits_2 = $bits_0; + while (1) { + var $bits_2; + var $hold_2; + var $have_2; + var $next_2; + var $cmp101 = $bits_2 >>> 0 < 16; + if (!$cmp101) { + break; + } + var $cmp105 = ($have_2 | 0) == 0; + if ($cmp105) { + var $ret_8 = $ret_0; + var $next_58 = $next_2; + var $have_58 = 0; + var $hold_54 = $hold_2; + var $bits_54 = $bits_2; + var $out_4 = $out_0; + break $_$12; + } + var $dec109 = $have_2 - 1 | 0; + var $incdec_ptr110 = $next_2 + 1 | 0; + var $58 = HEAPU8[$next_2]; + var $conv111 = $58 & 255; + var $shl112 = $conv111 << $bits_2; + var $add113 = $shl112 + $hold_2 | 0; + var $add114 = $bits_2 + 8 | 0; + var $next_2 = $incdec_ptr110; + var $have_2 = $dec109; + var $hold_2 = $add113; + var $bits_2 = $add114; + } + HEAP32[$17 >> 2] = $hold_2; + var $and120 = $hold_2 & 255; + var $cmp121 = ($and120 | 0) == 8; + if (!$cmp121) { + HEAP32[$msg >> 2] = STRING_TABLE.__str299 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_2; + var $put_0_be = $put_0; + var $have_0_be = $have_2; + var $left_0_be = $left_0; + var $hold_0_be = $hold_2; + var $bits_0_be = $bits_2; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $and128 = $hold_2 & 57344; + var $tobool129 = ($and128 | 0) == 0; + if ($tobool129) { + var $59 = HEAPU32[$18 >> 2]; + var $cmp135 = ($59 | 0) == 0; + if ($cmp135) { + var $60 = $hold_2; + } else { + var $shr138 = $hold_2 >>> 8; + var $and139 = $shr138 & 1; + var $text = $59 | 0; + HEAP32[$text >> 2] = $and139; + var $_pre887 = HEAP32[$17 >> 2]; + var $60 = $_pre887; + } + var $60; + var $and143 = $60 & 512; + var $tobool144 = ($and143 | 0) == 0; + if (!$tobool144) { + var $conv147 = $hold_2 & 255; + HEAP8[$arrayidx] = $conv147; + var $shr149 = $hold_2 >>> 8; + var $conv150 = $shr149 & 255; + HEAP8[$arrayidx40] = $conv150; + var $61 = HEAP32[$16 >> 2]; + var $call154 = _crc32($61, $arrayidx, 2); + HEAP32[$16 >> 2] = $call154; + } + HEAP32[$mode >> 2] = 2; + var $next_3 = $next_2; + var $have_3 = $have_2; + var $hold_3 = 0; + var $bits_3 = 0; + __label__ = 44; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str4101 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_2; + var $put_0_be = $put_0; + var $have_0_be = $have_2; + var $left_0_be = $left_0; + var $hold_0_be = $hold_2; + var $bits_0_be = $bits_2; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 2) { + var $next_3 = $next_0; + var $have_3 = $have_0; + var $hold_3 = $hold_0; + var $bits_3 = $bits_0; + __label__ = 44; + } else if (($49 | 0) == 3) { + var $next_4 = $next_0; + var $have_4 = $have_0; + var $hold_4 = $hold_0; + var $bits_4 = $bits_0; + __label__ = 52; + } else if (($49 | 0) == 4) { + var $next_5 = $next_0; + var $have_5 = $have_0; + var $hold_5 = $hold_0; + var $bits_5 = $bits_0; + __label__ = 60; + } else if (($49 | 0) == 5) { + var $next_8 = $next_0; + var $have_8 = $have_0; + var $hold_8 = $hold_0; + var $bits_8 = $bits_0; + __label__ = 71; + } else if (($49 | 0) == 6) { + var $_pre888 = HEAP32[$17 >> 2]; + var $next_11 = $next_0; + var $have_11 = $have_0; + var $hold_9 = $hold_0; + var $bits_9 = $bits_0; + var $89 = $_pre888; + __label__ = 81; + break; + } else if (($49 | 0) == 7) { + var $next_13 = $next_0; + var $have_13 = $have_0; + var $hold_10 = $hold_0; + var $bits_10 = $bits_0; + __label__ = 94; + } else if (($49 | 0) == 8) { + var $next_15 = $next_0; + var $have_15 = $have_0; + var $hold_11 = $hold_0; + var $bits_11 = $bits_0; + __label__ = 107; + } else if (($49 | 0) == 9) { + var $next_18 = $next_0; + var $have_18 = $have_0; + var $hold_14 = $hold_0; + var $bits_14 = $bits_0; + while (1) { + var $bits_14; + var $hold_14; + var $have_18; + var $next_18; + var $cmp552 = $bits_14 >>> 0 < 32; + if (!$cmp552) { + break; + } + var $cmp556 = ($have_18 | 0) == 0; + if ($cmp556) { + var $ret_8 = $ret_0; + var $next_58 = $next_18; + var $have_58 = 0; + var $hold_54 = $hold_14; + var $bits_54 = $bits_14; + var $out_4 = $out_0; + break $_$12; + } + var $dec560 = $have_18 - 1 | 0; + var $incdec_ptr561 = $next_18 + 1 | 0; + var $114 = HEAPU8[$next_18]; + var $conv562 = $114 & 255; + var $shl563 = $conv562 << $bits_14; + var $add564 = $shl563 + $hold_14 | 0; + var $add565 = $bits_14 + 8 | 0; + var $next_18 = $incdec_ptr561; + var $have_18 = $dec560; + var $hold_14 = $add564; + var $bits_14 = $add565; + } + var $add581 = _llvm_bswap_i32($hold_14); + HEAP32[$16 >> 2] = $add581; + HEAP32[$adler >> 2] = $add581; + HEAP32[$mode >> 2] = 10; + var $next_19 = $next_18; + var $have_19 = $have_18; + var $hold_15 = 0; + var $bits_15 = 0; + __label__ = 120; + break; + } else if (($49 | 0) == 10) { + var $next_19 = $next_0; + var $have_19 = $have_0; + var $hold_15 = $hold_0; + var $bits_15 = $bits_0; + __label__ = 120; + } else if (($49 | 0) == 11) { + var $next_20 = $next_0; + var $have_20 = $have_0; + var $hold_16 = $hold_0; + var $bits_16 = $bits_0; + __label__ = 123; + } else if (($49 | 0) == 12) { + var $next_21 = $next_0; + var $have_21 = $have_0; + var $hold_17 = $hold_0; + var $bits_17 = $bits_0; + __label__ = 124; + } else if (($49 | 0) == 13) { + var $and681 = $bits_0 & 7; + var $shr682 = $hold_0 >>> ($and681 >>> 0); + var $sub684 = $bits_0 - $and681 | 0; + var $next_23 = $next_0; + var $have_23 = $have_0; + var $hold_19 = $shr682; + var $bits_19 = $sub684; + while (1) { + var $bits_19; + var $hold_19; + var $have_23; + var $next_23; + var $cmp689 = $bits_19 >>> 0 < 32; + if (!$cmp689) { + break; + } + var $cmp693 = ($have_23 | 0) == 0; + if ($cmp693) { + var $ret_8 = $ret_0; + var $next_58 = $next_23; + var $have_58 = 0; + var $hold_54 = $hold_19; + var $bits_54 = $bits_19; + var $out_4 = $out_0; + break $_$12; + } + var $dec697 = $have_23 - 1 | 0; + var $incdec_ptr698 = $next_23 + 1 | 0; + var $118 = HEAPU8[$next_23]; + var $conv699 = $118 & 255; + var $shl700 = $conv699 << $bits_19; + var $add701 = $shl700 + $hold_19 | 0; + var $add702 = $bits_19 + 8 | 0; + var $next_23 = $incdec_ptr698; + var $have_23 = $dec697; + var $hold_19 = $add701; + var $bits_19 = $add702; + } + var $and708 = $hold_19 & 65535; + var $shr709 = $hold_19 >>> 16; + var $xor = $shr709 ^ 65535; + var $cmp710 = ($and708 | 0) == ($xor | 0); + if (!$cmp710) { + HEAP32[$msg >> 2] = STRING_TABLE.__str7104 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_23; + var $put_0_be = $put_0; + var $have_0_be = $have_23; + var $left_0_be = $left_0; + var $hold_0_be = $hold_19; + var $bits_0_be = $bits_19; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$21 >> 2] = $and708; + HEAP32[$mode >> 2] = 14; + if ($cmp660) { + var $ret_8 = $ret_0; + var $next_58 = $next_23; + var $have_58 = $have_23; + var $hold_54 = 0; + var $bits_54 = 0; + var $out_4 = $out_0; + break $_$12; + } + var $next_24 = $next_23; + var $have_24 = $have_23; + var $hold_20 = 0; + var $bits_20 = 0; + __label__ = 143; + break; + } else if (($49 | 0) == 14) { + var $next_24 = $next_0; + var $have_24 = $have_0; + var $hold_20 = $hold_0; + var $bits_20 = $bits_0; + __label__ = 143; + } else if (($49 | 0) == 15) { + var $next_25 = $next_0; + var $have_25 = $have_0; + var $hold_21 = $hold_0; + var $bits_21 = $bits_0; + __label__ = 144; + } else if (($49 | 0) == 16) { + var $next_26 = $next_0; + var $have_26 = $have_0; + var $hold_22 = $hold_0; + var $bits_22 = $bits_0; + while (1) { + var $bits_22; + var $hold_22; + var $have_26; + var $next_26; + var $cmp755 = $bits_22 >>> 0 < 14; + if (!$cmp755) { + break; + } + var $cmp759 = ($have_26 | 0) == 0; + if ($cmp759) { + var $ret_8 = $ret_0; + var $next_58 = $next_26; + var $have_58 = 0; + var $hold_54 = $hold_22; + var $bits_54 = $bits_22; + var $out_4 = $out_0; + break $_$12; + } + var $dec763 = $have_26 - 1 | 0; + var $incdec_ptr764 = $next_26 + 1 | 0; + var $121 = HEAPU8[$next_26]; + var $conv765 = $121 & 255; + var $shl766 = $conv765 << $bits_22; + var $add767 = $shl766 + $hold_22 | 0; + var $add768 = $bits_22 + 8 | 0; + var $next_26 = $incdec_ptr764; + var $have_26 = $dec763; + var $hold_22 = $add767; + var $bits_22 = $add768; + } + var $and774 = $hold_22 & 31; + var $add775 = $and774 + 257 | 0; + HEAP32[$37 >> 2] = $add775; + var $shr777 = $hold_22 >>> 5; + var $and781 = $shr777 & 31; + var $add782 = $and781 + 1 | 0; + HEAP32[$38 >> 2] = $add782; + var $shr784 = $hold_22 >>> 10; + var $and788 = $shr784 & 15; + var $add789 = $and788 + 4 | 0; + HEAP32[$39 >> 2] = $add789; + var $shr791 = $hold_22 >>> 14; + var $sub792 = $bits_22 - 14 | 0; + var $cmp796 = $add775 >>> 0 > 286; + var $cmp800 = $add782 >>> 0 > 30; + var $or_cond894 = $cmp796 | $cmp800; + if ($or_cond894) { + HEAP32[$msg >> 2] = STRING_TABLE.__str8105 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_26; + var $put_0_be = $put_0; + var $have_0_be = $have_26; + var $left_0_be = $left_0; + var $hold_0_be = $shr791; + var $bits_0_be = $sub792; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$40 >> 2] = 0; + HEAP32[$mode >> 2] = 17; + var $next_27 = $next_26; + var $have_27 = $have_26; + var $hold_23 = $shr791; + var $bits_23 = $sub792; + __label__ = 154; + break; + } else if (($49 | 0) == 17) { + var $next_27 = $next_0; + var $have_27 = $have_0; + var $hold_23 = $hold_0; + var $bits_23 = $bits_0; + __label__ = 154; + } else if (($49 | 0) == 18) { + var $ret_1_ph = $ret_0; + var $next_29_ph = $next_0; + var $have_29_ph = $have_0; + var $hold_25_ph = $hold_0; + var $bits_25_ph = $bits_0; + __label__ = 164; + } else if (($49 | 0) == 19) { + var $ret_2 = $ret_0; + var $next_37 = $next_0; + var $have_37 = $have_0; + var $hold_33 = $hold_0; + var $bits_33 = $bits_0; + __label__ = 205; + } else if (($49 | 0) == 20) { + var $ret_3 = $ret_0; + var $next_38 = $next_0; + var $have_38 = $have_0; + var $hold_34 = $hold_0; + var $bits_34 = $bits_0; + __label__ = 206; + } else if (($49 | 0) == 21) { + var $_pre889 = HEAP32[$28 >> 2]; + var $ret_4 = $ret_0; + var $next_42 = $next_0; + var $have_42 = $have_0; + var $hold_38 = $hold_0; + var $bits_38 = $bits_0; + var $156 = $_pre889; + __label__ = 227; + break; + } else if (($49 | 0) == 22) { + var $ret_5_ph = $ret_0; + var $next_45_ph = $next_0; + var $have_45_ph = $have_0; + var $hold_41_ph = $hold_0; + var $bits_41_ph = $bits_0; + __label__ = 234; + } else if (($49 | 0) == 23) { + var $_pre891 = HEAP32[$28 >> 2]; + var $ret_6 = $ret_0; + var $next_48 = $next_0; + var $have_48 = $have_0; + var $hold_44 = $hold_0; + var $bits_44 = $bits_0; + var $167 = $_pre891; + __label__ = 248; + break; + } else if (($49 | 0) == 24) { + var $ret_7 = $ret_0; + var $next_51 = $next_0; + var $have_51 = $have_0; + var $hold_47 = $hold_0; + var $bits_47 = $bits_0; + __label__ = 254; + } else if (($49 | 0) == 25) { + var $cmp1615 = ($left_0 | 0) == 0; + if ($cmp1615) { + var $ret_8 = $ret_0; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } + var $186 = HEAP32[$21 >> 2]; + var $conv1620 = $186 & 255; + var $incdec_ptr1621 = $put_0 + 1 | 0; + HEAP8[$put_0] = $conv1620; + var $dec1622 = $left_0 - 1 | 0; + HEAP32[$mode >> 2] = 20; + var $ret_0_be = $ret_0; + var $next_0_be = $next_0; + var $put_0_be = $incdec_ptr1621; + var $have_0_be = $have_0; + var $left_0_be = $dec1622; + var $hold_0_be = $hold_0; + var $bits_0_be = $bits_0; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (($49 | 0) == 26) { + var $187 = HEAP32[$15 >> 2]; + var $tobool1626 = ($187 | 0) == 0; + do { + if (!$tobool1626) { + var $next_52 = $next_0; + var $have_52 = $have_0; + var $hold_48 = $hold_0; + var $bits_48 = $bits_0; + while (1) { + var $bits_48; + var $hold_48; + var $have_52; + var $next_52; + var $cmp1630 = $bits_48 >>> 0 < 32; + if (!$cmp1630) { + break; + } + var $cmp1634 = ($have_52 | 0) == 0; + if ($cmp1634) { + var $ret_8 = $ret_0; + var $next_58 = $next_52; + var $have_58 = 0; + var $hold_54 = $hold_48; + var $bits_54 = $bits_48; + var $out_4 = $out_0; + break $_$12; + } + var $dec1638 = $have_52 - 1 | 0; + var $incdec_ptr1639 = $next_52 + 1 | 0; + var $188 = HEAPU8[$next_52]; + var $conv1640 = $188 & 255; + var $shl1641 = $conv1640 << $bits_48; + var $add1642 = $shl1641 + $hold_48 | 0; + var $add1643 = $bits_48 + 8 | 0; + var $next_52 = $incdec_ptr1639; + var $have_52 = $dec1638; + var $hold_48 = $add1642; + var $bits_48 = $add1643; + } + var $sub1649 = $out_0 - $left_0 | 0; + var $189 = HEAP32[$total_out >> 2]; + var $add1650 = $189 + $sub1649 | 0; + HEAP32[$total_out >> 2] = $add1650; + var $190 = HEAP32[$36 >> 2]; + var $add1651 = $190 + $sub1649 | 0; + HEAP32[$36 >> 2] = $add1651; + var $tobool1652 = ($out_0 | 0) == ($left_0 | 0); + if (!$tobool1652) { + var $191 = HEAP32[$17 >> 2]; + var $tobool1655 = ($191 | 0) == 0; + var $192 = HEAP32[$16 >> 2]; + var $idx_neg1658 = -$sub1649 | 0; + var $add_ptr1659 = $put_0 + $idx_neg1658 | 0; + if ($tobool1655) { + var $call1665 = _adler32($192, $add_ptr1659, $sub1649); + var $cond1667 = $call1665; + } else { + var $call1660 = _crc32($192, $add_ptr1659, $sub1649); + var $cond1667 = $call1660; + } + var $cond1667; + HEAP32[$16 >> 2] = $cond1667; + HEAP32[$adler >> 2] = $cond1667; + } + var $193 = HEAP32[$17 >> 2]; + var $tobool1672 = ($193 | 0) == 0; + if ($tobool1672) { + var $add1685 = _llvm_bswap_i32($hold_48); + var $cond1687 = $add1685; + } else { + var $cond1687 = $hold_48; + } + var $cond1687; + var $194 = HEAP32[$16 >> 2]; + var $cmp1689 = ($cond1687 | 0) == ($194 | 0); + if ($cmp1689) { + var $next_53 = $next_52; + var $have_53 = $have_52; + var $hold_49 = 0; + var $bits_49 = 0; + var $out_1 = $left_0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str17114 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_52; + var $put_0_be = $put_0; + var $have_0_be = $have_52; + var $left_0_be = $left_0; + var $hold_0_be = $hold_48; + var $bits_0_be = $bits_48; + var $out_0_be = $left_0; + __label__ = 268; + break $_$14; + } + var $next_53 = $next_0; + var $have_53 = $have_0; + var $hold_49 = $hold_0; + var $bits_49 = $bits_0; + var $out_1 = $out_0; + } while (0); + var $out_1; + var $bits_49; + var $hold_49; + var $have_53; + var $next_53; + HEAP32[$mode >> 2] = 27; + var $next_54 = $next_53; + var $have_54 = $have_53; + var $hold_50 = $hold_49; + var $bits_50 = $bits_49; + var $out_2 = $out_1; + __label__ = 286; + break; + } else if (($49 | 0) == 27) { + var $next_54 = $next_0; + var $have_54 = $have_0; + var $hold_50 = $hold_0; + var $bits_50 = $bits_0; + var $out_2 = $out_0; + __label__ = 286; + } else if (($49 | 0) == 28) { + var $ret_8 = 1; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } else if (($49 | 0) == 29) { + var $ret_8 = -3; + var $next_58 = $next_0; + var $have_58 = $have_0; + var $hold_54 = $hold_0; + var $bits_54 = $bits_0; + var $out_4 = $out_0; + break $_$12; + } else if (($49 | 0) == 30) { + var $retval_0 = -4; + break $_$2; + } else { + var $retval_0 = -2; + break $_$2; + } + } while (0); + $_$106 : do { + if (__label__ == 44) { + while (1) { + var $bits_3; + var $hold_3; + var $have_3; + var $next_3; + var $cmp164 = $bits_3 >>> 0 < 32; + if (!$cmp164) { + break; + } + var $cmp168 = ($have_3 | 0) == 0; + if ($cmp168) { + var $ret_8 = $ret_0; + var $next_58 = $next_3; + var $have_58 = 0; + var $hold_54 = $hold_3; + var $bits_54 = $bits_3; + var $out_4 = $out_0; + break $_$12; + } + var $dec172 = $have_3 - 1 | 0; + var $incdec_ptr173 = $next_3 + 1 | 0; + var $62 = HEAPU8[$next_3]; + var $conv174 = $62 & 255; + var $shl175 = $conv174 << $bits_3; + var $add176 = $shl175 + $hold_3 | 0; + var $add177 = $bits_3 + 8 | 0; + var $next_3 = $incdec_ptr173; + var $have_3 = $dec172; + var $hold_3 = $add176; + var $bits_3 = $add177; + } + var $63 = HEAP32[$18 >> 2]; + var $cmp182 = ($63 | 0) == 0; + if (!$cmp182) { + var $time = $63 + 4 | 0; + HEAP32[$time >> 2] = $hold_3; + } + var $64 = HEAP32[$17 >> 2]; + var $and188 = $64 & 512; + var $tobool189 = ($and188 | 0) == 0; + if (!$tobool189) { + var $conv192 = $hold_3 & 255; + HEAP8[$arrayidx] = $conv192; + var $shr194 = $hold_3 >>> 8; + var $conv195 = $shr194 & 255; + HEAP8[$arrayidx40] = $conv195; + var $shr197 = $hold_3 >>> 16; + var $conv198 = $shr197 & 255; + HEAP8[$arrayidx199] = $conv198; + var $shr200 = $hold_3 >>> 24; + var $conv201 = $shr200 & 255; + HEAP8[$arrayidx202] = $conv201; + var $65 = HEAP32[$16 >> 2]; + var $call205 = _crc32($65, $arrayidx, 4); + HEAP32[$16 >> 2] = $call205; + } + HEAP32[$mode >> 2] = 3; + var $next_4 = $next_3; + var $have_4 = $have_3; + var $hold_4 = 0; + var $bits_4 = 0; + __label__ = 52; + break; + } else if (__label__ == 120) { + var $bits_15; + var $hold_15; + var $have_19; + var $next_19; + var $115 = HEAP32[$22 >> 2]; + var $cmp589 = ($115 | 0) == 0; + if ($cmp589) { + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_19; + HEAP32[$avail_in15 >> 2] = $have_19; + HEAP32[$11 >> 2] = $hold_15; + HEAP32[$13 >> 2] = $bits_15; + var $retval_0 = 2; + break $_$2; + } + var $call602 = _adler32(0, 0, 0); + HEAP32[$16 >> 2] = $call602; + HEAP32[$adler >> 2] = $call602; + HEAP32[$mode >> 2] = 11; + var $next_20 = $next_19; + var $have_20 = $have_19; + var $hold_16 = $hold_15; + var $bits_16 = $bits_15; + __label__ = 123; + break; + } else if (__label__ == 143) { + var $bits_20; + var $hold_20; + var $have_24; + var $next_24; + HEAP32[$mode >> 2] = 15; + var $next_25 = $next_24; + var $have_25 = $have_24; + var $hold_21 = $hold_20; + var $bits_21 = $bits_20; + __label__ = 144; + break; + } else if (__label__ == 154) { + while (1) { + var $bits_23; + var $hold_23; + var $have_27; + var $next_27; + var $122 = HEAPU32[$40 >> 2]; + var $123 = HEAPU32[$39 >> 2]; + var $cmp812 = $122 >>> 0 < $123 >>> 0; + if (!$cmp812) { + break; + } + var $next_28 = $next_27; + var $have_28 = $have_27; + var $hold_24 = $hold_23; + var $bits_24 = $bits_23; + while (1) { + var $bits_24; + var $hold_24; + var $have_28; + var $next_28; + var $cmp817 = $bits_24 >>> 0 < 3; + if (!$cmp817) { + break; + } + var $cmp821 = ($have_28 | 0) == 0; + if ($cmp821) { + var $ret_8 = $ret_0; + var $next_58 = $next_28; + var $have_58 = 0; + var $hold_54 = $hold_24; + var $bits_54 = $bits_24; + var $out_4 = $out_0; + break $_$12; + } + var $dec825 = $have_28 - 1 | 0; + var $incdec_ptr826 = $next_28 + 1 | 0; + var $124 = HEAPU8[$next_28]; + var $conv827 = $124 & 255; + var $shl828 = $conv827 << $bits_24; + var $add829 = $shl828 + $hold_24 | 0; + var $add830 = $bits_24 + 8 | 0; + var $next_28 = $incdec_ptr826; + var $have_28 = $dec825; + var $hold_24 = $add829; + var $bits_24 = $add830; + } + var $hold_24_tr = $hold_24 & 65535; + var $conv837 = $hold_24_tr & 7; + var $inc839 = $122 + 1 | 0; + HEAP32[$40 >> 2] = $inc839; + var $arrayidx840 = _inflate_order + ($122 << 1) | 0; + var $125 = HEAPU16[$arrayidx840 >> 1]; + var $idxprom = $125 & 65535; + var $arrayidx841 = $41 + ($idxprom << 1) | 0; + HEAP16[$arrayidx841 >> 1] = $conv837; + var $shr843 = $hold_24 >>> 3; + var $sub844 = $bits_24 - 3 | 0; + var $next_27 = $next_28; + var $have_27 = $have_28; + var $hold_23 = $shr843; + var $bits_23 = $sub844; + } + var $cmp850111 = $122 >>> 0 < 19; + $_$131 : do { + if ($cmp850111) { + var $126 = $122; + while (1) { + var $126; + var $inc854 = $126 + 1 | 0; + HEAP32[$40 >> 2] = $inc854; + var $arrayidx855 = _inflate_order + ($126 << 1) | 0; + var $127 = HEAPU16[$arrayidx855 >> 1]; + var $idxprom856 = $127 & 65535; + var $arrayidx858 = $41 + ($idxprom856 << 1) | 0; + HEAP16[$arrayidx858 >> 1] = 0; + var $_pr = HEAPU32[$40 >> 2]; + var $cmp850 = $_pr >>> 0 < 19; + if (!$cmp850) { + break $_$131; + } + var $126 = $_pr; + } + } + } while (0); + HEAP32[$43 >> 2] = $arraydecay860_c; + HEAP32[$44 >> 2] = $arraydecay860_c; + HEAP32[$26 >> 2] = 7; + var $call868 = _inflate_table(0, $arraydecay864, 19, $42, $26, $arraydecay867); + var $tobool869 = ($call868 | 0) == 0; + if ($tobool869) { + HEAP32[$40 >> 2] = 0; + HEAP32[$mode >> 2] = 18; + var $ret_1_ph = 0; + var $next_29_ph = $next_27; + var $have_29_ph = $have_27; + var $hold_25_ph = $hold_23; + var $bits_25_ph = $bits_23; + __label__ = 164; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str9106 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call868; + var $next_0_be = $next_27; + var $put_0_be = $put_0; + var $have_0_be = $have_27; + var $left_0_be = $left_0; + var $hold_0_be = $hold_23; + var $bits_0_be = $bits_23; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 286) { + var $out_2; + var $bits_50; + var $hold_50; + var $have_54; + var $next_54; + var $195 = HEAP32[$15 >> 2]; + var $tobool1702 = ($195 | 0) == 0; + do { + if (!$tobool1702) { + var $196 = HEAP32[$17 >> 2]; + var $tobool1705 = ($196 | 0) == 0; + if ($tobool1705) { + var $next_56 = $next_54; + var $have_56 = $have_54; + var $hold_52 = $hold_50; + var $bits_52 = $bits_50; + break; + } + var $next_55 = $next_54; + var $have_55 = $have_54; + var $hold_51 = $hold_50; + var $bits_51 = $bits_50; + while (1) { + var $bits_51; + var $hold_51; + var $have_55; + var $next_55; + var $cmp1709 = $bits_51 >>> 0 < 32; + if (!$cmp1709) { + break; + } + var $cmp1713 = ($have_55 | 0) == 0; + if ($cmp1713) { + var $ret_8 = $ret_0; + var $next_58 = $next_55; + var $have_58 = 0; + var $hold_54 = $hold_51; + var $bits_54 = $bits_51; + var $out_4 = $out_2; + break $_$12; + } + var $dec1717 = $have_55 - 1 | 0; + var $incdec_ptr1718 = $next_55 + 1 | 0; + var $197 = HEAPU8[$next_55]; + var $conv1719 = $197 & 255; + var $shl1720 = $conv1719 << $bits_51; + var $add1721 = $shl1720 + $hold_51 | 0; + var $add1722 = $bits_51 + 8 | 0; + var $next_55 = $incdec_ptr1718; + var $have_55 = $dec1717; + var $hold_51 = $add1721; + var $bits_51 = $add1722; + } + var $198 = HEAP32[$36 >> 2]; + var $cmp1729 = ($hold_51 | 0) == ($198 | 0); + if ($cmp1729) { + var $next_56 = $next_55; + var $have_56 = $have_55; + var $hold_52 = 0; + var $bits_52 = 0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str18115 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_55; + var $put_0_be = $put_0; + var $have_0_be = $have_55; + var $left_0_be = $left_0; + var $hold_0_be = $hold_51; + var $bits_0_be = $bits_51; + var $out_0_be = $out_2; + __label__ = 268; + break $_$106; + } + var $next_56 = $next_54; + var $have_56 = $have_54; + var $hold_52 = $hold_50; + var $bits_52 = $bits_50; + } while (0); + var $bits_52; + var $hold_52; + var $have_56; + var $next_56; + HEAP32[$mode >> 2] = 28; + var $ret_8 = 1; + var $next_58 = $next_56; + var $have_58 = $have_56; + var $hold_54 = $hold_52; + var $bits_54 = $bits_52; + var $out_4 = $out_2; + break $_$12; + } + } while (0); + $_$148 : do { + if (__label__ == 52) { + while (1) { + var $bits_4; + var $hold_4; + var $have_4; + var $next_4; + var $cmp215 = $bits_4 >>> 0 < 16; + if (!$cmp215) { + break; + } + var $cmp219 = ($have_4 | 0) == 0; + if ($cmp219) { + var $ret_8 = $ret_0; + var $next_58 = $next_4; + var $have_58 = 0; + var $hold_54 = $hold_4; + var $bits_54 = $bits_4; + var $out_4 = $out_0; + break $_$12; + } + var $dec223 = $have_4 - 1 | 0; + var $incdec_ptr224 = $next_4 + 1 | 0; + var $66 = HEAPU8[$next_4]; + var $conv225 = $66 & 255; + var $shl226 = $conv225 << $bits_4; + var $add227 = $shl226 + $hold_4 | 0; + var $add228 = $bits_4 + 8 | 0; + var $next_4 = $incdec_ptr224; + var $have_4 = $dec223; + var $hold_4 = $add227; + var $bits_4 = $add228; + } + var $67 = HEAP32[$18 >> 2]; + var $cmp233 = ($67 | 0) == 0; + if (!$cmp233) { + var $and236 = $hold_4 & 255; + var $xflags = $67 + 8 | 0; + HEAP32[$xflags >> 2] = $and236; + var $shr238 = $hold_4 >>> 8; + var $68 = HEAP32[$18 >> 2]; + var $os = $68 + 12 | 0; + HEAP32[$os >> 2] = $shr238; + } + var $69 = HEAP32[$17 >> 2]; + var $and242 = $69 & 512; + var $tobool243 = ($and242 | 0) == 0; + if (!$tobool243) { + var $conv246 = $hold_4 & 255; + HEAP8[$arrayidx] = $conv246; + var $shr248 = $hold_4 >>> 8; + var $conv249 = $shr248 & 255; + HEAP8[$arrayidx40] = $conv249; + var $70 = HEAP32[$16 >> 2]; + var $call253 = _crc32($70, $arrayidx, 2); + HEAP32[$16 >> 2] = $call253; + } + HEAP32[$mode >> 2] = 4; + var $next_5 = $next_4; + var $have_5 = $have_4; + var $hold_5 = 0; + var $bits_5 = 0; + __label__ = 60; + break; + } else if (__label__ == 123) { + var $bits_16; + var $hold_16; + var $have_20; + var $next_20; + if ($23) { + var $ret_8 = $ret_0; + var $next_58 = $next_20; + var $have_58 = $have_20; + var $hold_54 = $hold_16; + var $bits_54 = $bits_16; + var $out_4 = $out_0; + break $_$12; + } + var $next_21 = $next_20; + var $have_21 = $have_20; + var $hold_17 = $hold_16; + var $bits_17 = $bits_16; + __label__ = 124; + break; + } else if (__label__ == 144) { + var $bits_21; + var $hold_21; + var $have_25; + var $next_25; + var $119 = HEAPU32[$21 >> 2]; + var $tobool730 = ($119 | 0) == 0; + if ($tobool730) { + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_0; + var $next_0_be = $next_25; + var $put_0_be = $put_0; + var $have_0_be = $have_25; + var $left_0_be = $left_0; + var $hold_0_be = $hold_21; + var $bits_0_be = $bits_21; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $cmp732 = $119 >>> 0 > $have_25 >>> 0; + var $copy_3 = $cmp732 ? $have_25 : $119; + var $cmp736 = $copy_3 >>> 0 > $left_0 >>> 0; + var $copy_4 = $cmp736 ? $left_0 : $copy_3; + var $cmp740 = ($copy_4 | 0) == 0; + if ($cmp740) { + var $ret_8 = $ret_0; + var $next_58 = $next_25; + var $have_58 = $have_25; + var $hold_54 = $hold_21; + var $bits_54 = $bits_21; + var $out_4 = $out_0; + break $_$12; + } + _memcpy($put_0, $next_25, $copy_4, 1); + var $sub744 = $have_25 - $copy_4 | 0; + var $add_ptr745 = $next_25 + $copy_4 | 0; + var $sub746 = $left_0 - $copy_4 | 0; + var $add_ptr747 = $put_0 + $copy_4 | 0; + var $120 = HEAP32[$21 >> 2]; + var $sub749 = $120 - $copy_4 | 0; + HEAP32[$21 >> 2] = $sub749; + var $ret_0_be = $ret_0; + var $next_0_be = $add_ptr745; + var $put_0_be = $add_ptr747; + var $have_0_be = $sub744; + var $left_0_be = $sub746; + var $hold_0_be = $hold_21; + var $bits_0_be = $bits_21; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 164) { + var $bits_25_ph; + var $hold_25_ph; + var $have_29_ph; + var $next_29_ph; + var $ret_1_ph; + var $next_29 = $next_29_ph; + var $have_29 = $have_29_ph; + var $hold_25 = $hold_25_ph; + var $bits_25 = $bits_25_ph; + $_$167 : while (1) { + var $bits_25; + var $hold_25; + var $have_29; + var $next_29; + var $128 = HEAPU32[$40 >> 2]; + var $129 = HEAPU32[$37 >> 2]; + var $130 = HEAP32[$38 >> 2]; + var $add881 = $130 + $129 | 0; + var $cmp882 = $128 >>> 0 < $add881 >>> 0; + if ($cmp882) { + var $131 = HEAP32[$26 >> 2]; + var $shl887 = 1 << $131; + var $sub888 = $shl887 - 1 | 0; + var $132 = HEAPU32[$27 >> 2]; + var $next_30 = $next_29; + var $have_30 = $have_29; + var $hold_26 = $hold_25; + var $bits_26 = $bits_25; + while (1) { + var $bits_26; + var $hold_26; + var $have_30; + var $next_30; + var $and889 = $sub888 & $hold_26; + var $arrayidx891_1 = $132 + ($and889 << 2) + 1 | 0; + var $tmp25 = HEAPU8[$arrayidx891_1]; + var $conv893 = $tmp25 & 255; + var $cmp894 = $conv893 >>> 0 > $bits_26 >>> 0; + if (!$cmp894) { + break; + } + var $cmp899 = ($have_30 | 0) == 0; + if ($cmp899) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_30; + var $have_58 = 0; + var $hold_54 = $hold_26; + var $bits_54 = $bits_26; + var $out_4 = $out_0; + break $_$12; + } + var $dec903 = $have_30 - 1 | 0; + var $incdec_ptr904 = $next_30 + 1 | 0; + var $133 = HEAPU8[$next_30]; + var $conv905 = $133 & 255; + var $shl906 = $conv905 << $bits_26; + var $add907 = $shl906 + $hold_26 | 0; + var $add908 = $bits_26 + 8 | 0; + var $next_30 = $incdec_ptr904; + var $have_30 = $dec903; + var $hold_26 = $add907; + var $bits_26 = $add908; + } + var $arrayidx891_2 = $132 + ($and889 << 2) + 2 | 0; + var $tmp26 = HEAPU16[$arrayidx891_2 >> 1]; + var $cmp912 = ($tmp26 & 65535) < 16; + if ($cmp912) { + var $next_31 = $next_30; + var $have_31 = $have_30; + var $hold_27 = $hold_26; + var $bits_27 = $bits_26; + while (1) { + var $bits_27; + var $hold_27; + var $have_31; + var $next_31; + var $cmp919 = $bits_27 >>> 0 < $conv893 >>> 0; + if (!$cmp919) { + break; + } + var $cmp923 = ($have_31 | 0) == 0; + if ($cmp923) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_31; + var $have_58 = 0; + var $hold_54 = $hold_27; + var $bits_54 = $bits_27; + var $out_4 = $out_0; + break $_$12; + } + var $dec927 = $have_31 - 1 | 0; + var $incdec_ptr928 = $next_31 + 1 | 0; + var $134 = HEAPU8[$next_31]; + var $conv929 = $134 & 255; + var $shl930 = $conv929 << $bits_27; + var $add931 = $shl930 + $hold_27 | 0; + var $add932 = $bits_27 + 8 | 0; + var $next_31 = $incdec_ptr928; + var $have_31 = $dec927; + var $hold_27 = $add931; + var $bits_27 = $add932; + } + var $shr941 = $hold_27 >>> ($conv893 >>> 0); + var $sub944 = $bits_27 - $conv893 | 0; + var $inc949 = $128 + 1 | 0; + HEAP32[$40 >> 2] = $inc949; + var $arrayidx951 = $41 + ($128 << 1) | 0; + HEAP16[$arrayidx951 >> 1] = $tmp26; + var $next_29 = $next_31; + var $have_29 = $have_31; + var $hold_25 = $shr941; + var $bits_25 = $sub944; + } else { + if ($tmp26 << 16 >> 16 == 16) { + var $add962 = $conv893 + 2 | 0; + var $next_32 = $next_30; + var $have_32 = $have_30; + var $hold_28 = $hold_26; + var $bits_28 = $bits_26; + while (1) { + var $bits_28; + var $hold_28; + var $have_32; + var $next_32; + var $cmp963 = $bits_28 >>> 0 < $add962 >>> 0; + if (!$cmp963) { + break; + } + var $cmp967 = ($have_32 | 0) == 0; + if ($cmp967) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_32; + var $have_58 = 0; + var $hold_54 = $hold_28; + var $bits_54 = $bits_28; + var $out_4 = $out_0; + break $_$12; + } + var $dec971 = $have_32 - 1 | 0; + var $incdec_ptr972 = $next_32 + 1 | 0; + var $135 = HEAPU8[$next_32]; + var $conv973 = $135 & 255; + var $shl974 = $conv973 << $bits_28; + var $add975 = $shl974 + $hold_28 | 0; + var $add976 = $bits_28 + 8 | 0; + var $next_32 = $incdec_ptr972; + var $have_32 = $dec971; + var $hold_28 = $add975; + var $bits_28 = $add976; + } + var $shr985 = $hold_28 >>> ($conv893 >>> 0); + var $sub988 = $bits_28 - $conv893 | 0; + var $cmp992 = ($128 | 0) == 0; + if ($cmp992) { + HEAP32[$msg >> 2] = STRING_TABLE.__str10107 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_32; + var $put_0_be = $put_0; + var $have_0_be = $have_32; + var $left_0_be = $left_0; + var $hold_0_be = $shr985; + var $bits_0_be = $sub988; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $sub999 = $128 - 1 | 0; + var $arrayidx1001 = $41 + ($sub999 << 1) | 0; + var $136 = HEAP16[$arrayidx1001 >> 1]; + var $and1003 = $shr985 & 3; + var $add1004 = $and1003 + 3 | 0; + var $shr1006 = $shr985 >>> 2; + var $sub1007 = $sub988 - 2 | 0; + var $len_0 = $136; + var $next_35 = $next_32; + var $have_35 = $have_32; + var $hold_31 = $shr1006; + var $bits_31 = $sub1007; + var $copy_5 = $add1004; + } else if ($tmp26 << 16 >> 16 == 17) { + var $add1020 = $conv893 + 3 | 0; + var $next_33 = $next_30; + var $have_33 = $have_30; + var $hold_29 = $hold_26; + var $bits_29 = $bits_26; + while (1) { + var $bits_29; + var $hold_29; + var $have_33; + var $next_33; + var $cmp1021 = $bits_29 >>> 0 < $add1020 >>> 0; + if (!$cmp1021) { + break; + } + var $cmp1025 = ($have_33 | 0) == 0; + if ($cmp1025) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_33; + var $have_58 = 0; + var $hold_54 = $hold_29; + var $bits_54 = $bits_29; + var $out_4 = $out_0; + break $_$12; + } + var $dec1029 = $have_33 - 1 | 0; + var $incdec_ptr1030 = $next_33 + 1 | 0; + var $137 = HEAPU8[$next_33]; + var $conv1031 = $137 & 255; + var $shl1032 = $conv1031 << $bits_29; + var $add1033 = $shl1032 + $hold_29 | 0; + var $add1034 = $bits_29 + 8 | 0; + var $next_33 = $incdec_ptr1030; + var $have_33 = $dec1029; + var $hold_29 = $add1033; + var $bits_29 = $add1034; + } + var $shr1043 = $hold_29 >>> ($conv893 >>> 0); + var $and1049 = $shr1043 & 7; + var $add1050 = $and1049 + 3 | 0; + var $shr1052 = $shr1043 >>> 3; + var $sub1046 = -3 - $conv893 | 0; + var $sub1053 = $sub1046 + $bits_29 | 0; + var $len_0 = 0; + var $next_35 = $next_33; + var $have_35 = $have_33; + var $hold_31 = $shr1052; + var $bits_31 = $sub1053; + var $copy_5 = $add1050; + } else { + var $add1061 = $conv893 + 7 | 0; + var $next_34 = $next_30; + var $have_34 = $have_30; + var $hold_30 = $hold_26; + var $bits_30 = $bits_26; + while (1) { + var $bits_30; + var $hold_30; + var $have_34; + var $next_34; + var $cmp1062 = $bits_30 >>> 0 < $add1061 >>> 0; + if (!$cmp1062) { + break; + } + var $cmp1066 = ($have_34 | 0) == 0; + if ($cmp1066) { + var $ret_8 = $ret_1_ph; + var $next_58 = $next_34; + var $have_58 = 0; + var $hold_54 = $hold_30; + var $bits_54 = $bits_30; + var $out_4 = $out_0; + break $_$12; + } + var $dec1070 = $have_34 - 1 | 0; + var $incdec_ptr1071 = $next_34 + 1 | 0; + var $138 = HEAPU8[$next_34]; + var $conv1072 = $138 & 255; + var $shl1073 = $conv1072 << $bits_30; + var $add1074 = $shl1073 + $hold_30 | 0; + var $add1075 = $bits_30 + 8 | 0; + var $next_34 = $incdec_ptr1071; + var $have_34 = $dec1070; + var $hold_30 = $add1074; + var $bits_30 = $add1075; + } + var $shr1084 = $hold_30 >>> ($conv893 >>> 0); + var $and1090 = $shr1084 & 127; + var $add1091 = $and1090 + 11 | 0; + var $shr1093 = $shr1084 >>> 7; + var $sub1087 = -7 - $conv893 | 0; + var $sub1094 = $sub1087 + $bits_30 | 0; + var $len_0 = 0; + var $next_35 = $next_34; + var $have_35 = $have_34; + var $hold_31 = $shr1093; + var $bits_31 = $sub1094; + var $copy_5 = $add1091; + } + var $copy_5; + var $bits_31; + var $hold_31; + var $have_35; + var $next_35; + var $len_0; + var $add1100 = $128 + $copy_5 | 0; + var $cmp1104 = $add1100 >>> 0 > $add881 >>> 0; + if ($cmp1104) { + HEAP32[$msg >> 2] = STRING_TABLE.__str10107 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_35; + var $put_0_be = $put_0; + var $have_0_be = $have_35; + var $left_0_be = $left_0; + var $hold_0_be = $hold_31; + var $bits_0_be = $bits_31; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $copy_6127 = $copy_5; + var $139 = $128; + while (1) { + var $139; + var $copy_6127; + var $dec1111 = $copy_6127 - 1 | 0; + var $inc1116 = $139 + 1 | 0; + HEAP32[$40 >> 2] = $inc1116; + var $arrayidx1118 = $41 + ($139 << 1) | 0; + HEAP16[$arrayidx1118 >> 1] = $len_0; + var $tobool1112 = ($dec1111 | 0) == 0; + if ($tobool1112) { + var $next_29 = $next_35; + var $have_29 = $have_35; + var $hold_25 = $hold_31; + var $bits_25 = $bits_31; + continue $_$167; + } + var $_pre892 = HEAP32[$40 >> 2]; + var $copy_6127 = $dec1111; + var $139 = $_pre892; + } + } + } else { + var $_pr38 = HEAP32[$mode >> 2]; + var $cmp1123 = ($_pr38 | 0) == 29; + if ($cmp1123) { + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $140 = HEAP16[$45 >> 1]; + var $cmp1130 = $140 << 16 >> 16 == 0; + if ($cmp1130) { + HEAP32[$msg >> 2] = STRING_TABLE.__str11108 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_1_ph; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + HEAP32[$43 >> 2] = $arraydecay860_c; + HEAP32[$44 >> 2] = $arraydecay860_c; + HEAP32[$26 >> 2] = 9; + var $call1149 = _inflate_table(1, $arraydecay864, $129, $42, $26, $arraydecay867); + var $tobool1150 = ($call1149 | 0) == 0; + if (!$tobool1150) { + HEAP32[$msg >> 2] = STRING_TABLE.__str12109 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call1149; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + var $141 = HEAP32[$42 >> 2]; + var $_c = $141; + HEAP32[$46 >> 2] = $_c; + HEAP32[$47 >> 2] = 6; + var $142 = HEAP32[$37 >> 2]; + var $add_ptr1159 = $arraydecay864 + ($142 << 1) | 0; + var $143 = HEAP32[$38 >> 2]; + var $call1165 = _inflate_table(2, $add_ptr1159, $143, $42, $47, $arraydecay867); + var $tobool1166 = ($call1165 | 0) == 0; + if (!$tobool1166) { + HEAP32[$msg >> 2] = STRING_TABLE.__str13110 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $call1165; + var $next_0_be = $next_29; + var $put_0_be = $put_0; + var $have_0_be = $have_29; + var $left_0_be = $left_0; + var $hold_0_be = $hold_25; + var $bits_0_be = $bits_25; + var $out_0_be = $out_0; + __label__ = 268; + break $_$148; + } + HEAP32[$mode >> 2] = 19; + if ($cmp660) { + var $ret_8 = 0; + var $next_58 = $next_29; + var $have_58 = $have_29; + var $hold_54 = $hold_25; + var $bits_54 = $bits_25; + var $out_4 = $out_0; + break $_$12; + } + var $ret_2 = 0; + var $next_37 = $next_29; + var $have_37 = $have_29; + var $hold_33 = $hold_25; + var $bits_33 = $bits_25; + __label__ = 205; + break $_$148; + } + } + } + } while (0); + do { + if (__label__ == 60) { + var $bits_5; + var $hold_5; + var $have_5; + var $next_5; + var $71 = HEAPU32[$17 >> 2]; + var $and262 = $71 & 1024; + var $tobool263 = ($and262 | 0) == 0; + do { + if ($tobool263) { + var $76 = HEAP32[$18 >> 2]; + var $cmp310 = ($76 | 0) == 0; + if ($cmp310) { + var $next_7 = $next_5; + var $have_7 = $have_5; + var $hold_7 = $hold_5; + var $bits_7 = $bits_5; + break; + } + var $extra = $76 + 16 | 0; + HEAP32[$extra >> 2] = 0; + var $next_7 = $next_5; + var $have_7 = $have_5; + var $hold_7 = $hold_5; + var $bits_7 = $bits_5; + } else { + var $next_6 = $next_5; + var $have_6 = $have_5; + var $hold_6 = $hold_5; + var $bits_6 = $bits_5; + while (1) { + var $bits_6; + var $hold_6; + var $have_6; + var $next_6; + var $cmp267 = $bits_6 >>> 0 < 16; + if (!$cmp267) { + break; + } + var $cmp271 = ($have_6 | 0) == 0; + if ($cmp271) { + var $ret_8 = $ret_0; + var $next_58 = $next_6; + var $have_58 = 0; + var $hold_54 = $hold_6; + var $bits_54 = $bits_6; + var $out_4 = $out_0; + break $_$12; + } + var $dec275 = $have_6 - 1 | 0; + var $incdec_ptr276 = $next_6 + 1 | 0; + var $72 = HEAPU8[$next_6]; + var $conv277 = $72 & 255; + var $shl278 = $conv277 << $bits_6; + var $add279 = $shl278 + $hold_6 | 0; + var $add280 = $bits_6 + 8 | 0; + var $next_6 = $incdec_ptr276; + var $have_6 = $dec275; + var $hold_6 = $add279; + var $bits_6 = $add280; + } + HEAP32[$21 >> 2] = $hold_6; + var $73 = HEAP32[$18 >> 2]; + var $cmp285 = ($73 | 0) == 0; + if ($cmp285) { + var $74 = $71; + } else { + var $extra_len = $73 + 20 | 0; + HEAP32[$extra_len >> 2] = $hold_6; + var $_pre885 = HEAP32[$17 >> 2]; + var $74 = $_pre885; + } + var $74; + var $and291 = $74 & 512; + var $tobool292 = ($and291 | 0) == 0; + if ($tobool292) { + var $next_7 = $next_6; + var $have_7 = $have_6; + var $hold_7 = 0; + var $bits_7 = 0; + break; + } + var $conv295 = $hold_6 & 255; + HEAP8[$arrayidx] = $conv295; + var $shr297 = $hold_6 >>> 8; + var $conv298 = $shr297 & 255; + HEAP8[$arrayidx40] = $conv298; + var $75 = HEAP32[$16 >> 2]; + var $call302 = _crc32($75, $arrayidx, 2); + HEAP32[$16 >> 2] = $call302; + var $next_7 = $next_6; + var $have_7 = $have_6; + var $hold_7 = 0; + var $bits_7 = 0; + } + } while (0); + var $bits_7; + var $hold_7; + var $have_7; + var $next_7; + HEAP32[$mode >> 2] = 5; + var $next_8 = $next_7; + var $have_8 = $have_7; + var $hold_8 = $hold_7; + var $bits_8 = $bits_7; + __label__ = 71; + break; + } else if (__label__ == 124) { + var $bits_17; + var $hold_17; + var $have_21; + var $next_21; + var $116 = HEAP32[$24 >> 2]; + var $tobool616 = ($116 | 0) == 0; + if ($tobool616) { + var $next_22 = $next_21; + var $have_22 = $have_21; + var $hold_18 = $hold_17; + var $bits_18 = $bits_17; + while (1) { + var $bits_18; + var $hold_18; + var $have_22; + var $next_22; + var $cmp629 = $bits_18 >>> 0 < 3; + if (!$cmp629) { + break; + } + var $cmp633 = ($have_22 | 0) == 0; + if ($cmp633) { + var $ret_8 = $ret_0; + var $next_58 = $next_22; + var $have_58 = 0; + var $hold_54 = $hold_18; + var $bits_54 = $bits_18; + var $out_4 = $out_0; + break $_$12; + } + var $dec637 = $have_22 - 1 | 0; + var $incdec_ptr638 = $next_22 + 1 | 0; + var $117 = HEAPU8[$next_22]; + var $conv639 = $117 & 255; + var $shl640 = $conv639 << $bits_18; + var $add641 = $shl640 + $hold_18 | 0; + var $add642 = $bits_18 + 8 | 0; + var $next_22 = $incdec_ptr638; + var $have_22 = $dec637; + var $hold_18 = $add641; + var $bits_18 = $add642; + } + var $and648 = $hold_18 & 1; + HEAP32[$24 >> 2] = $and648; + var $shr651 = $hold_18 >>> 1; + var $and655 = $shr651 & 3; + do { + if (($and655 | 0) == 0) { + HEAP32[$mode >> 2] = 13; + } else if (($and655 | 0) == 1) { + _fixedtables($4); + HEAP32[$mode >> 2] = 19; + if (!$cmp660) { + break; + } + var $shr664 = $hold_18 >>> 3; + var $sub665 = $bits_18 - 3 | 0; + var $ret_8 = $ret_0; + var $next_58 = $next_22; + var $have_58 = $have_22; + var $hold_54 = $shr664; + var $bits_54 = $sub665; + var $out_4 = $out_0; + break $_$12; + } else if (($and655 | 0) == 2) { + HEAP32[$mode >> 2] = 16; + } else if (($and655 | 0) == 3) { + HEAP32[$msg >> 2] = STRING_TABLE.__str6103 | 0; + HEAP32[$mode >> 2] = 29; + } + } while (0); + var $shr675 = $hold_18 >>> 3; + var $sub676 = $bits_18 - 3 | 0; + var $ret_0_be = $ret_0; + var $next_0_be = $next_22; + var $put_0_be = $put_0; + var $have_0_be = $have_22; + var $left_0_be = $left_0; + var $hold_0_be = $shr675; + var $bits_0_be = $sub676; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $and619 = $bits_17 & 7; + var $shr620 = $hold_17 >>> ($and619 >>> 0); + var $sub622 = $bits_17 - $and619 | 0; + HEAP32[$mode >> 2] = 26; + var $ret_0_be = $ret_0; + var $next_0_be = $next_21; + var $put_0_be = $put_0; + var $have_0_be = $have_21; + var $left_0_be = $left_0; + var $hold_0_be = $shr620; + var $bits_0_be = $sub622; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 205) { + var $bits_33; + var $hold_33; + var $have_37; + var $next_37; + var $ret_2; + HEAP32[$mode >> 2] = 20; + var $ret_3 = $ret_2; + var $next_38 = $next_37; + var $have_38 = $have_37; + var $hold_34 = $hold_33; + var $bits_34 = $bits_33; + __label__ = 206; + break; + } + } while (0); + do { + if (__label__ == 71) { + var $bits_8; + var $hold_8; + var $have_8; + var $next_8; + var $77 = HEAPU32[$17 >> 2]; + var $and319 = $77 & 1024; + var $tobool320 = ($and319 | 0) == 0; + if ($tobool320) { + var $next_10 = $next_8; + var $have_10 = $have_8; + var $88 = $77; + } else { + var $78 = HEAPU32[$21 >> 2]; + var $cmp323 = $78 >>> 0 > $have_8 >>> 0; + var $copy_0 = $cmp323 ? $have_8 : $78; + var $tobool327 = ($copy_0 | 0) == 0; + if ($tobool327) { + var $next_9 = $next_8; + var $have_9 = $have_8; + var $87 = $78; + var $86 = $77; + } else { + var $79 = HEAPU32[$18 >> 2]; + var $cmp330 = ($79 | 0) == 0; + do { + if ($cmp330) { + var $83 = $77; + } else { + var $extra334 = $79 + 16 | 0; + var $80 = HEAP32[$extra334 >> 2]; + var $cmp335 = ($80 | 0) == 0; + if ($cmp335) { + var $83 = $77; + break; + } + var $extra_len339 = $79 + 20 | 0; + var $81 = HEAP32[$extra_len339 >> 2]; + var $sub341 = $81 - $78 | 0; + var $add_ptr = $80 + $sub341 | 0; + var $add344 = $sub341 + $copy_0 | 0; + var $extra_max = $79 + 24 | 0; + var $82 = HEAPU32[$extra_max >> 2]; + var $cmp346 = $add344 >>> 0 > $82 >>> 0; + var $sub350 = $82 - $sub341 | 0; + var $cond351 = $cmp346 ? $sub350 : $copy_0; + _memcpy($add_ptr, $next_8, $cond351, 1); + var $_pre886 = HEAP32[$17 >> 2]; + var $83 = $_pre886; + } + } while (0); + var $83; + var $and354 = $83 & 512; + var $tobool355 = ($and354 | 0) == 0; + if (!$tobool355) { + var $84 = HEAP32[$16 >> 2]; + var $call358 = _crc32($84, $next_8, $copy_0); + HEAP32[$16 >> 2] = $call358; + } + var $sub361 = $have_8 - $copy_0 | 0; + var $add_ptr362 = $next_8 + $copy_0 | 0; + var $85 = HEAP32[$21 >> 2]; + var $sub364 = $85 - $copy_0 | 0; + HEAP32[$21 >> 2] = $sub364; + var $next_9 = $add_ptr362; + var $have_9 = $sub361; + var $87 = $sub364; + var $86 = $83; + } + var $86; + var $87; + var $have_9; + var $next_9; + var $tobool367 = ($87 | 0) == 0; + if (!$tobool367) { + var $ret_8 = $ret_0; + var $next_58 = $next_9; + var $have_58 = $have_9; + var $hold_54 = $hold_8; + var $bits_54 = $bits_8; + var $out_4 = $out_0; + break $_$12; + } + var $next_10 = $next_9; + var $have_10 = $have_9; + var $88 = $86; + } + var $88; + var $have_10; + var $next_10; + HEAP32[$21 >> 2] = 0; + HEAP32[$mode >> 2] = 6; + var $next_11 = $next_10; + var $have_11 = $have_10; + var $hold_9 = $hold_8; + var $bits_9 = $bits_8; + var $89 = $88; + __label__ = 81; + break; + } else if (__label__ == 206) { + var $bits_34; + var $hold_34; + var $have_38; + var $next_38; + var $ret_3; + var $cmp1179 = $have_38 >>> 0 > 5; + var $cmp1182 = $left_0 >>> 0 > 257; + var $or_cond33 = $cmp1179 & $cmp1182; + if ($or_cond33) { + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_38; + HEAP32[$avail_in15 >> 2] = $have_38; + HEAP32[$11 >> 2] = $hold_34; + HEAP32[$13 >> 2] = $bits_34; + _inflate_fast($strm, $out_0); + var $144 = HEAP32[$next_out >> 2]; + var $145 = HEAP32[$avail_out >> 2]; + var $146 = HEAP32[$next_in >> 2]; + var $147 = HEAP32[$avail_in15 >> 2]; + var $148 = HEAP32[$11 >> 2]; + var $149 = HEAP32[$13 >> 2]; + var $150 = HEAP32[$mode >> 2]; + var $cmp1204 = ($150 | 0) == 11; + if (!$cmp1204) { + var $ret_0_be = $ret_3; + var $next_0_be = $146; + var $put_0_be = $144; + var $have_0_be = $147; + var $left_0_be = $145; + var $hold_0_be = $148; + var $bits_0_be = $149; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$25 >> 2] = -1; + var $ret_0_be = $ret_3; + var $next_0_be = $146; + var $put_0_be = $144; + var $have_0_be = $147; + var $left_0_be = $145; + var $hold_0_be = $148; + var $bits_0_be = $149; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + HEAP32[$25 >> 2] = 0; + var $151 = HEAP32[$26 >> 2]; + var $shl1212 = 1 << $151; + var $sub1213 = $shl1212 - 1 | 0; + var $152 = HEAPU32[$27 >> 2]; + var $next_39 = $next_38; + var $have_39 = $have_38; + var $hold_35 = $hold_34; + var $bits_35 = $bits_34; + while (1) { + var $bits_35; + var $hold_35; + var $have_39; + var $next_39; + var $and1214 = $sub1213 & $hold_35; + var $arrayidx1216_1 = $152 + ($and1214 << 2) + 1 | 0; + var $tmp22 = HEAPU8[$arrayidx1216_1]; + var $conv1218 = $tmp22 & 255; + var $cmp1219 = $conv1218 >>> 0 > $bits_35 >>> 0; + if (!$cmp1219) { + break; + } + var $cmp1224 = ($have_39 | 0) == 0; + if ($cmp1224) { + var $ret_8 = $ret_3; + var $next_58 = $next_39; + var $have_58 = 0; + var $hold_54 = $hold_35; + var $bits_54 = $bits_35; + var $out_4 = $out_0; + break $_$12; + } + var $dec1228 = $have_39 - 1 | 0; + var $incdec_ptr1229 = $next_39 + 1 | 0; + var $153 = HEAPU8[$next_39]; + var $conv1230 = $153 & 255; + var $shl1231 = $conv1230 << $bits_35; + var $add1232 = $shl1231 + $hold_35 | 0; + var $add1233 = $bits_35 + 8 | 0; + var $next_39 = $incdec_ptr1229; + var $have_39 = $dec1228; + var $hold_35 = $add1232; + var $bits_35 = $add1233; + } + var $arrayidx1216_0 = $152 + ($and1214 << 2) | 0; + var $tmp21 = HEAPU8[$arrayidx1216_0]; + var $arrayidx1216_2 = $152 + ($and1214 << 2) + 2 | 0; + var $tmp23 = HEAPU16[$arrayidx1216_2 >> 1]; + var $conv1237 = $tmp21 & 255; + var $tobool1238 = $tmp21 << 24 >> 24 == 0; + do { + if ($tobool1238) { + var $next_41 = $next_39; + var $have_41 = $have_39; + var $hold_37 = $hold_35; + var $bits_37 = $bits_35; + var $here_09_0 = 0; + var $here_110_0 = $tmp22; + var $here_211_0 = $tmp23; + var $155 = 0; + } else { + var $and1242 = $conv1237 & 240; + var $cmp1243 = ($and1242 | 0) == 0; + if (!$cmp1243) { + var $next_41 = $next_39; + var $have_41 = $have_39; + var $hold_37 = $hold_35; + var $bits_37 = $bits_35; + var $here_09_0 = $tmp21; + var $here_110_0 = $tmp22; + var $here_211_0 = $tmp23; + var $155 = 0; + break; + } + var $conv1248 = $tmp23 & 65535; + var $add1253 = $conv1218 + $conv1237 | 0; + var $shl1254 = 1 << $add1253; + var $sub1255 = $shl1254 - 1 | 0; + var $next_40 = $next_39; + var $have_40 = $have_39; + var $hold_36 = $hold_35; + var $bits_36 = $bits_35; + while (1) { + var $bits_36; + var $hold_36; + var $have_40; + var $next_40; + var $and1256 = $hold_36 & $sub1255; + var $shr1259 = $and1256 >>> ($conv1218 >>> 0); + var $add1260 = $shr1259 + $conv1248 | 0; + var $arrayidx1262_1 = $152 + ($add1260 << 2) + 1 | 0; + var $tmp19 = HEAPU8[$arrayidx1262_1]; + var $conv1266 = $tmp19 & 255; + var $add1267 = $conv1266 + $conv1218 | 0; + var $cmp1268 = $add1267 >>> 0 > $bits_36 >>> 0; + if (!$cmp1268) { + break; + } + var $cmp1273 = ($have_40 | 0) == 0; + if ($cmp1273) { + var $ret_8 = $ret_3; + var $next_58 = $next_40; + var $have_58 = 0; + var $hold_54 = $hold_36; + var $bits_54 = $bits_36; + var $out_4 = $out_0; + break $_$12; + } + var $dec1277 = $have_40 - 1 | 0; + var $incdec_ptr1278 = $next_40 + 1 | 0; + var $154 = HEAPU8[$next_40]; + var $conv1279 = $154 & 255; + var $shl1280 = $conv1279 << $bits_36; + var $add1281 = $shl1280 + $hold_36 | 0; + var $add1282 = $bits_36 + 8 | 0; + var $next_40 = $incdec_ptr1278; + var $have_40 = $dec1277; + var $hold_36 = $add1281; + var $bits_36 = $add1282; + } + var $arrayidx1262_2 = $152 + ($add1260 << 2) + 2 | 0; + var $arrayidx1262_0 = $152 + ($add1260 << 2) | 0; + var $tmp20 = HEAP16[$arrayidx1262_2 >> 1]; + var $tmp18 = HEAP8[$arrayidx1262_0]; + var $shr1289 = $hold_36 >>> ($conv1218 >>> 0); + var $sub1292 = $bits_36 - $conv1218 | 0; + HEAP32[$25 >> 2] = $conv1218; + var $next_41 = $next_40; + var $have_41 = $have_40; + var $hold_37 = $shr1289; + var $bits_37 = $sub1292; + var $here_09_0 = $tmp18; + var $here_110_0 = $tmp19; + var $here_211_0 = $tmp20; + var $155 = $conv1218; + } + } while (0); + var $155; + var $here_211_0; + var $here_110_0; + var $here_09_0; + var $bits_37; + var $hold_37; + var $have_41; + var $next_41; + var $conv1302 = $here_110_0 & 255; + var $shr1303 = $hold_37 >>> ($conv1302 >>> 0); + var $sub1306 = $bits_37 - $conv1302 | 0; + var $add1312 = $155 + $conv1302 | 0; + HEAP32[$25 >> 2] = $add1312; + var $conv1314 = $here_211_0 & 65535; + HEAP32[$21 >> 2] = $conv1314; + var $conv1317 = $here_09_0 & 255; + var $cmp1318 = $here_09_0 << 24 >> 24 == 0; + if ($cmp1318) { + HEAP32[$mode >> 2] = 25; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $and1325 = $conv1317 & 32; + var $tobool1326 = ($and1325 | 0) == 0; + if (!$tobool1326) { + HEAP32[$25 >> 2] = -1; + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + var $and1333 = $conv1317 & 64; + var $tobool1334 = ($and1333 | 0) == 0; + if ($tobool1334) { + var $and1341 = $conv1317 & 15; + HEAP32[$28 >> 2] = $and1341; + HEAP32[$mode >> 2] = 21; + var $ret_4 = $ret_3; + var $next_42 = $next_41; + var $have_42 = $have_41; + var $hold_38 = $shr1303; + var $bits_38 = $sub1306; + var $156 = $and1341; + __label__ = 227; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str2171 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_3; + var $next_0_be = $next_41; + var $put_0_be = $put_0; + var $have_0_be = $have_41; + var $left_0_be = $left_0; + var $hold_0_be = $shr1303; + var $bits_0_be = $sub1306; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + } while (0); + do { + if (__label__ == 81) { + var $89; + var $bits_9; + var $hold_9; + var $have_11; + var $next_11; + var $and375 = $89 & 2048; + var $tobool376 = ($and375 | 0) == 0; + do { + if ($tobool376) { + var $98 = HEAP32[$18 >> 2]; + var $cmp424 = ($98 | 0) == 0; + if ($cmp424) { + var $next_12 = $next_11; + var $have_12 = $have_11; + break; + } + var $name428 = $98 + 28 | 0; + HEAP32[$name428 >> 2] = 0; + var $next_12 = $next_11; + var $have_12 = $have_11; + } else { + var $cmp378 = ($have_11 | 0) == 0; + if ($cmp378) { + var $ret_8 = $ret_0; + var $next_58 = $next_11; + var $have_58 = 0; + var $hold_54 = $hold_9; + var $bits_54 = $bits_9; + var $out_4 = $out_0; + break $_$12; + } + var $copy_1 = 0; + while (1) { + var $copy_1; + var $inc = $copy_1 + 1 | 0; + var $arrayidx383 = $next_11 + $copy_1 | 0; + var $90 = HEAP8[$arrayidx383]; + var $91 = HEAP32[$18 >> 2]; + var $cmp386 = ($91 | 0) == 0; + do { + if (!$cmp386) { + var $name = $91 + 28 | 0; + var $92 = HEAP32[$name >> 2]; + var $cmp390 = ($92 | 0) == 0; + if ($cmp390) { + break; + } + var $93 = HEAPU32[$21 >> 2]; + var $name_max = $91 + 32 | 0; + var $94 = HEAPU32[$name_max >> 2]; + var $cmp395 = $93 >>> 0 < $94 >>> 0; + if (!$cmp395) { + break; + } + var $inc400 = $93 + 1 | 0; + HEAP32[$21 >> 2] = $inc400; + var $95 = HEAP32[$name >> 2]; + var $arrayidx403 = $95 + $93 | 0; + HEAP8[$arrayidx403] = $90; + } + } while (0); + var $tobool405 = $90 << 24 >> 24 != 0; + var $cmp406 = $inc >>> 0 < $have_11 >>> 0; + var $or_cond31 = $tobool405 & $cmp406; + if (!$or_cond31) { + break; + } + var $copy_1 = $inc; + } + var $96 = HEAP32[$17 >> 2]; + var $and410 = $96 & 512; + var $tobool411 = ($and410 | 0) == 0; + if (!$tobool411) { + var $97 = HEAP32[$16 >> 2]; + var $call414 = _crc32($97, $next_11, $inc); + HEAP32[$16 >> 2] = $call414; + } + var $sub417 = $have_11 - $inc | 0; + var $add_ptr418 = $next_11 + $inc | 0; + if ($tobool405) { + var $ret_8 = $ret_0; + var $next_58 = $add_ptr418; + var $have_58 = $sub417; + var $hold_54 = $hold_9; + var $bits_54 = $bits_9; + var $out_4 = $out_0; + break $_$12; + } + var $next_12 = $add_ptr418; + var $have_12 = $sub417; + } + } while (0); + var $have_12; + var $next_12; + HEAP32[$21 >> 2] = 0; + HEAP32[$mode >> 2] = 7; + var $next_13 = $next_12; + var $have_13 = $have_12; + var $hold_10 = $hold_9; + var $bits_10 = $bits_9; + __label__ = 94; + break; + } else if (__label__ == 227) { + var $156; + var $bits_38; + var $hold_38; + var $have_42; + var $next_42; + var $ret_4; + var $tobool1346 = ($156 | 0) == 0; + if ($tobool1346) { + var $_pre890 = HEAP32[$21 >> 2]; + var $next_44 = $next_42; + var $have_44 = $have_42; + var $hold_40 = $hold_38; + var $bits_40 = $bits_38; + var $160 = $_pre890; + } else { + var $next_43 = $next_42; + var $have_43 = $have_42; + var $hold_39 = $hold_38; + var $bits_39 = $bits_38; + while (1) { + var $bits_39; + var $hold_39; + var $have_43; + var $next_43; + var $cmp1351 = $bits_39 >>> 0 < $156 >>> 0; + if (!$cmp1351) { + break; + } + var $cmp1355 = ($have_43 | 0) == 0; + if ($cmp1355) { + var $ret_8 = $ret_4; + var $next_58 = $next_43; + var $have_58 = 0; + var $hold_54 = $hold_39; + var $bits_54 = $bits_39; + var $out_4 = $out_0; + break $_$12; + } + var $dec1359 = $have_43 - 1 | 0; + var $incdec_ptr1360 = $next_43 + 1 | 0; + var $157 = HEAPU8[$next_43]; + var $conv1361 = $157 & 255; + var $shl1362 = $conv1361 << $bits_39; + var $add1363 = $shl1362 + $hold_39 | 0; + var $add1364 = $bits_39 + 8 | 0; + var $next_43 = $incdec_ptr1360; + var $have_43 = $dec1359; + var $hold_39 = $add1363; + var $bits_39 = $add1364; + } + var $shl1371 = 1 << $156; + var $sub1372 = $shl1371 - 1 | 0; + var $and1373 = $sub1372 & $hold_39; + var $158 = HEAP32[$21 >> 2]; + var $add1375 = $158 + $and1373 | 0; + HEAP32[$21 >> 2] = $add1375; + var $shr1378 = $hold_39 >>> ($156 >>> 0); + var $sub1380 = $bits_39 - $156 | 0; + var $159 = HEAP32[$25 >> 2]; + var $add1385 = $159 + $156 | 0; + HEAP32[$25 >> 2] = $add1385; + var $next_44 = $next_43; + var $have_44 = $have_43; + var $hold_40 = $shr1378; + var $bits_40 = $sub1380; + var $160 = $add1375; + } + var $160; + var $bits_40; + var $hold_40; + var $have_44; + var $next_44; + HEAP32[$29 >> 2] = $160; + HEAP32[$mode >> 2] = 22; + var $ret_5_ph = $ret_4; + var $next_45_ph = $next_44; + var $have_45_ph = $have_44; + var $hold_41_ph = $hold_40; + var $bits_41_ph = $bits_40; + __label__ = 234; + break; + } + } while (0); + do { + if (__label__ == 94) { + var $bits_10; + var $hold_10; + var $have_13; + var $next_13; + var $99 = HEAP32[$17 >> 2]; + var $and435 = $99 & 4096; + var $tobool436 = ($and435 | 0) == 0; + do { + if ($tobool436) { + var $108 = HEAP32[$18 >> 2]; + var $cmp488 = ($108 | 0) == 0; + if ($cmp488) { + var $next_14 = $next_13; + var $have_14 = $have_13; + break; + } + var $comment492 = $108 + 36 | 0; + HEAP32[$comment492 >> 2] = 0; + var $next_14 = $next_13; + var $have_14 = $have_13; + } else { + var $cmp438 = ($have_13 | 0) == 0; + if ($cmp438) { + var $ret_8 = $ret_0; + var $next_58 = $next_13; + var $have_58 = 0; + var $hold_54 = $hold_10; + var $bits_54 = $bits_10; + var $out_4 = $out_0; + break $_$12; + } + var $copy_2 = 0; + while (1) { + var $copy_2; + var $inc443 = $copy_2 + 1 | 0; + var $arrayidx444 = $next_13 + $copy_2 | 0; + var $100 = HEAP8[$arrayidx444]; + var $101 = HEAP32[$18 >> 2]; + var $cmp447 = ($101 | 0) == 0; + do { + if (!$cmp447) { + var $comment = $101 + 36 | 0; + var $102 = HEAP32[$comment >> 2]; + var $cmp451 = ($102 | 0) == 0; + if ($cmp451) { + break; + } + var $103 = HEAPU32[$21 >> 2]; + var $comm_max = $101 + 40 | 0; + var $104 = HEAPU32[$comm_max >> 2]; + var $cmp456 = $103 >>> 0 < $104 >>> 0; + if (!$cmp456) { + break; + } + var $inc461 = $103 + 1 | 0; + HEAP32[$21 >> 2] = $inc461; + var $105 = HEAP32[$comment >> 2]; + var $arrayidx464 = $105 + $103 | 0; + HEAP8[$arrayidx464] = $100; + } + } while (0); + var $tobool467 = $100 << 24 >> 24 != 0; + var $cmp469 = $inc443 >>> 0 < $have_13 >>> 0; + var $or_cond32 = $tobool467 & $cmp469; + if (!$or_cond32) { + break; + } + var $copy_2 = $inc443; + } + var $106 = HEAP32[$17 >> 2]; + var $and474 = $106 & 512; + var $tobool475 = ($and474 | 0) == 0; + if (!$tobool475) { + var $107 = HEAP32[$16 >> 2]; + var $call478 = _crc32($107, $next_13, $inc443); + HEAP32[$16 >> 2] = $call478; + } + var $sub481 = $have_13 - $inc443 | 0; + var $add_ptr482 = $next_13 + $inc443 | 0; + if ($tobool467) { + var $ret_8 = $ret_0; + var $next_58 = $add_ptr482; + var $have_58 = $sub481; + var $hold_54 = $hold_10; + var $bits_54 = $bits_10; + var $out_4 = $out_0; + break $_$12; + } + var $next_14 = $add_ptr482; + var $have_14 = $sub481; + } + } while (0); + var $have_14; + var $next_14; + HEAP32[$mode >> 2] = 8; + var $next_15 = $next_14; + var $have_15 = $have_14; + var $hold_11 = $hold_10; + var $bits_11 = $bits_10; + __label__ = 107; + break; + } else if (__label__ == 234) { + var $bits_41_ph; + var $hold_41_ph; + var $have_45_ph; + var $next_45_ph; + var $ret_5_ph; + var $161 = HEAP32[$47 >> 2]; + var $shl1392 = 1 << $161; + var $sub1393 = $shl1392 - 1 | 0; + var $162 = HEAPU32[$48 >> 2]; + var $next_45 = $next_45_ph; + var $have_45 = $have_45_ph; + var $hold_41 = $hold_41_ph; + var $bits_41 = $bits_41_ph; + while (1) { + var $bits_41; + var $hold_41; + var $have_45; + var $next_45; + var $and1394 = $sub1393 & $hold_41; + var $arrayidx1396_1 = $162 + ($and1394 << 2) + 1 | 0; + var $tmp16 = HEAPU8[$arrayidx1396_1]; + var $conv1398 = $tmp16 & 255; + var $cmp1399 = $conv1398 >>> 0 > $bits_41 >>> 0; + if (!$cmp1399) { + break; + } + var $cmp1404 = ($have_45 | 0) == 0; + if ($cmp1404) { + var $ret_8 = $ret_5_ph; + var $next_58 = $next_45; + var $have_58 = 0; + var $hold_54 = $hold_41; + var $bits_54 = $bits_41; + var $out_4 = $out_0; + break $_$12; + } + var $dec1408 = $have_45 - 1 | 0; + var $incdec_ptr1409 = $next_45 + 1 | 0; + var $163 = HEAPU8[$next_45]; + var $conv1410 = $163 & 255; + var $shl1411 = $conv1410 << $bits_41; + var $add1412 = $shl1411 + $hold_41 | 0; + var $add1413 = $bits_41 + 8 | 0; + var $next_45 = $incdec_ptr1409; + var $have_45 = $dec1408; + var $hold_41 = $add1412; + var $bits_41 = $add1413; + } + var $arrayidx1396_0 = $162 + ($and1394 << 2) | 0; + var $tmp15 = HEAPU8[$arrayidx1396_0]; + var $arrayidx1396_2 = $162 + ($and1394 << 2) + 2 | 0; + var $tmp17 = HEAPU16[$arrayidx1396_2 >> 1]; + var $conv1418 = $tmp15 & 255; + var $and1419 = $conv1418 & 240; + var $cmp1420 = ($and1419 | 0) == 0; + if ($cmp1420) { + var $conv1425 = $tmp17 & 65535; + var $add1430 = $conv1398 + $conv1418 | 0; + var $shl1431 = 1 << $add1430; + var $sub1432 = $shl1431 - 1 | 0; + var $next_46 = $next_45; + var $have_46 = $have_45; + var $hold_42 = $hold_41; + var $bits_42 = $bits_41; + while (1) { + var $bits_42; + var $hold_42; + var $have_46; + var $next_46; + var $and1433 = $hold_42 & $sub1432; + var $shr1436 = $and1433 >>> ($conv1398 >>> 0); + var $add1437 = $shr1436 + $conv1425 | 0; + var $arrayidx1439_1 = $162 + ($add1437 << 2) + 1 | 0; + var $tmp13 = HEAPU8[$arrayidx1439_1]; + var $conv1443 = $tmp13 & 255; + var $add1444 = $conv1443 + $conv1398 | 0; + var $cmp1445 = $add1444 >>> 0 > $bits_42 >>> 0; + if (!$cmp1445) { + break; + } + var $cmp1450 = ($have_46 | 0) == 0; + if ($cmp1450) { + var $ret_8 = $ret_5_ph; + var $next_58 = $next_46; + var $have_58 = 0; + var $hold_54 = $hold_42; + var $bits_54 = $bits_42; + var $out_4 = $out_0; + break $_$12; + } + var $dec1454 = $have_46 - 1 | 0; + var $incdec_ptr1455 = $next_46 + 1 | 0; + var $164 = HEAPU8[$next_46]; + var $conv1456 = $164 & 255; + var $shl1457 = $conv1456 << $bits_42; + var $add1458 = $shl1457 + $hold_42 | 0; + var $add1459 = $bits_42 + 8 | 0; + var $next_46 = $incdec_ptr1455; + var $have_46 = $dec1454; + var $hold_42 = $add1458; + var $bits_42 = $add1459; + } + var $arrayidx1439_2 = $162 + ($add1437 << 2) + 2 | 0; + var $arrayidx1439_0 = $162 + ($add1437 << 2) | 0; + var $tmp14 = HEAP16[$arrayidx1439_2 >> 1]; + var $tmp12 = HEAP8[$arrayidx1439_0]; + var $shr1466 = $hold_42 >>> ($conv1398 >>> 0); + var $sub1469 = $bits_42 - $conv1398 | 0; + var $165 = HEAP32[$25 >> 2]; + var $add1475 = $165 + $conv1398 | 0; + HEAP32[$25 >> 2] = $add1475; + var $next_47 = $next_46; + var $have_47 = $have_46; + var $hold_43 = $shr1466; + var $bits_43 = $sub1469; + var $here_09_1 = $tmp12; + var $here_110_1 = $tmp13; + var $here_211_1 = $tmp14; + var $166 = $add1475; + } else { + var $_pre893 = HEAP32[$25 >> 2]; + var $next_47 = $next_45; + var $have_47 = $have_45; + var $hold_43 = $hold_41; + var $bits_43 = $bits_41; + var $here_09_1 = $tmp15; + var $here_110_1 = $tmp16; + var $here_211_1 = $tmp17; + var $166 = $_pre893; + } + var $166; + var $here_211_1; + var $here_110_1; + var $here_09_1; + var $bits_43; + var $hold_43; + var $have_47; + var $next_47; + var $conv1479 = $here_110_1 & 255; + var $shr1480 = $hold_43 >>> ($conv1479 >>> 0); + var $sub1483 = $bits_43 - $conv1479 | 0; + var $add1489 = $166 + $conv1479 | 0; + HEAP32[$25 >> 2] = $add1489; + var $conv1491 = $here_09_1 & 255; + var $and1492 = $conv1491 & 64; + var $tobool1493 = ($and1492 | 0) == 0; + if ($tobool1493) { + var $conv1499 = $here_211_1 & 65535; + HEAP32[$30 >> 2] = $conv1499; + var $and1502 = $conv1491 & 15; + HEAP32[$28 >> 2] = $and1502; + HEAP32[$mode >> 2] = 23; + var $ret_6 = $ret_5_ph; + var $next_48 = $next_47; + var $have_48 = $have_47; + var $hold_44 = $shr1480; + var $bits_44 = $sub1483; + var $167 = $and1502; + __label__ = 248; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str1170 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_5_ph; + var $next_0_be = $next_47; + var $put_0_be = $put_0; + var $have_0_be = $have_47; + var $left_0_be = $left_0; + var $hold_0_be = $shr1480; + var $bits_0_be = $sub1483; + var $out_0_be = $out_0; + __label__ = 268; + break; + } + } while (0); + $_$359 : do { + if (__label__ == 107) { + var $bits_11; + var $hold_11; + var $have_15; + var $next_15; + var $109 = HEAPU32[$17 >> 2]; + var $and498 = $109 & 512; + var $tobool499 = ($and498 | 0) == 0; + do { + if (!$tobool499) { + var $next_16 = $next_15; + var $have_16 = $have_15; + var $hold_12 = $hold_11; + var $bits_12 = $bits_11; + while (1) { + var $bits_12; + var $hold_12; + var $have_16; + var $next_16; + var $cmp503 = $bits_12 >>> 0 < 16; + if (!$cmp503) { + break; + } + var $cmp507 = ($have_16 | 0) == 0; + if ($cmp507) { + var $ret_8 = $ret_0; + var $next_58 = $next_16; + var $have_58 = 0; + var $hold_54 = $hold_12; + var $bits_54 = $bits_12; + var $out_4 = $out_0; + break $_$12; + } + var $dec511 = $have_16 - 1 | 0; + var $incdec_ptr512 = $next_16 + 1 | 0; + var $110 = HEAPU8[$next_16]; + var $conv513 = $110 & 255; + var $shl514 = $conv513 << $bits_12; + var $add515 = $shl514 + $hold_12 | 0; + var $add516 = $bits_12 + 8 | 0; + var $next_16 = $incdec_ptr512; + var $have_16 = $dec511; + var $hold_12 = $add515; + var $bits_12 = $add516; + } + var $111 = HEAP32[$16 >> 2]; + var $and523 = $111 & 65535; + var $cmp524 = ($hold_12 | 0) == ($and523 | 0); + if ($cmp524) { + var $next_17 = $next_16; + var $have_17 = $have_16; + var $hold_13 = 0; + var $bits_13 = 0; + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str5102 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_0; + var $next_0_be = $next_16; + var $put_0_be = $put_0; + var $have_0_be = $have_16; + var $left_0_be = $left_0; + var $hold_0_be = $hold_12; + var $bits_0_be = $bits_12; + var $out_0_be = $out_0; + __label__ = 268; + break $_$359; + } + var $next_17 = $next_15; + var $have_17 = $have_15; + var $hold_13 = $hold_11; + var $bits_13 = $bits_11; + } while (0); + var $bits_13; + var $hold_13; + var $have_17; + var $next_17; + var $112 = HEAPU32[$18 >> 2]; + var $cmp535 = ($112 | 0) == 0; + if (!$cmp535) { + var $shr53930 = $109 >>> 9; + var $and540 = $shr53930 & 1; + var $hcrc = $112 + 44 | 0; + HEAP32[$hcrc >> 2] = $and540; + var $113 = HEAP32[$18 >> 2]; + var $done543 = $113 + 48 | 0; + HEAP32[$done543 >> 2] = 1; + } + var $call545 = _crc32(0, 0, 0); + HEAP32[$16 >> 2] = $call545; + HEAP32[$adler >> 2] = $call545; + HEAP32[$mode >> 2] = 11; + var $ret_0_be = $ret_0; + var $next_0_be = $next_17; + var $put_0_be = $put_0; + var $have_0_be = $have_17; + var $left_0_be = $left_0; + var $hold_0_be = $hold_13; + var $bits_0_be = $bits_13; + var $out_0_be = $out_0; + __label__ = 268; + break; + } else if (__label__ == 248) { + var $167; + var $bits_44; + var $hold_44; + var $have_48; + var $next_48; + var $ret_6; + var $tobool1507 = ($167 | 0) == 0; + if ($tobool1507) { + var $next_50 = $next_48; + var $have_50 = $have_48; + var $hold_46 = $hold_44; + var $bits_46 = $bits_44; + } else { + var $next_49 = $next_48; + var $have_49 = $have_48; + var $hold_45 = $hold_44; + var $bits_45 = $bits_44; + while (1) { + var $bits_45; + var $hold_45; + var $have_49; + var $next_49; + var $cmp1512 = $bits_45 >>> 0 < $167 >>> 0; + if (!$cmp1512) { + break; + } + var $cmp1516 = ($have_49 | 0) == 0; + if ($cmp1516) { + var $ret_8 = $ret_6; + var $next_58 = $next_49; + var $have_58 = 0; + var $hold_54 = $hold_45; + var $bits_54 = $bits_45; + var $out_4 = $out_0; + break $_$12; + } + // XXX first chunk with a bug-causing difference + var $dec1520 = $have_49 - 1 | 0; + var $incdec_ptr1521 = $next_49 + 1 | 0; + var $168 = HEAPU8[$next_49]; + var $conv1522 = $168 & 255; + var $shl1523 = $conv1522 << $bits_45; + var $add1524 = $shl1523 + $hold_45 | 0; + var $add1525 = $bits_45 + 8 | 0; + var $next_49 = $incdec_ptr1521; + var $have_49 = $dec1520; + var $hold_45 = $add1524; + var $bits_45 = $add1525; + } + var $shl1532 = 1 << $167; + var $sub1533 = $shl1532 - 1 | 0; + var $and1534 = $sub1533 & $hold_45; + var $169 = HEAP32[$30 >> 2]; + var $add1536 = $169 + $and1534 | 0; + HEAP32[$30 >> 2] = $add1536; + var $shr1539 = $hold_45 >>> ($167 >>> 0); + var $sub1541 = $bits_45 - $167 | 0; + var $170 = HEAP32[$25 >> 2]; + var $add1546 = $170 + $167 | 0; + HEAP32[$25 >> 2] = $add1546; + var $next_50 = $next_49; + var $have_50 = $have_49; + var $hold_46 = $shr1539; + var $bits_46 = $sub1541; + } + var $bits_46; + var $hold_46; + var $have_50; + var $next_50; + HEAP32[$mode >> 2] = 24; + var $ret_7 = $ret_6; + var $next_51 = $next_50; + var $have_51 = $have_50; + var $hold_47 = $hold_46; + var $bits_47 = $bits_46; + __label__ = 254; + break; + } + } while (0); + $_$380 : do { + if (__label__ == 254) { + var $bits_47; + var $hold_47; + var $have_51; + var $next_51; + var $ret_7; + var $cmp1550 = ($left_0 | 0) == 0; + if ($cmp1550) { + var $ret_8 = $ret_7; + var $next_58 = $next_51; + var $have_58 = $have_51; + var $hold_54 = $hold_47; + var $bits_54 = $bits_47; + var $out_4 = $out_0; + break $_$12; + } + var $sub1554 = $out_0 - $left_0 | 0; + var $171 = HEAPU32[$30 >> 2]; + var $cmp1556 = $171 >>> 0 > $sub1554 >>> 0; + do { + if ($cmp1556) { + var $sub1560 = $171 - $sub1554 | 0; + var $172 = HEAPU32[$31 >> 2]; + var $cmp1561 = $sub1560 >>> 0 > $172 >>> 0; + do { + if ($cmp1561) { + var $173 = HEAP32[$32 >> 2]; + var $tobool1564 = ($173 | 0) == 0; + if ($tobool1564) { + break; + } + HEAP32[$msg >> 2] = STRING_TABLE.__str169 | 0; + HEAP32[$mode >> 2] = 29; + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $put_0; + var $have_0_be = $have_51; + var $left_0_be = $left_0; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + break $_$380; + } + } while (0); + var $174 = HEAPU32[$33 >> 2]; + var $cmp1570 = $sub1560 >>> 0 > $174 >>> 0; + if ($cmp1570) { + var $sub1574 = $sub1560 - $174 | 0; + var $175 = HEAP32[$34 >> 2]; + var $176 = HEAP32[$35 >> 2]; + var $sub1575 = $176 - $sub1574 | 0; + var $add_ptr1576 = $175 + $sub1575 | 0; + var $from_0 = $add_ptr1576; + var $copy_7 = $sub1574; + } else { + var $177 = HEAP32[$34 >> 2]; + var $sub1580 = $174 - $sub1560 | 0; + var $add_ptr1581 = $177 + $sub1580 | 0; + var $from_0 = $add_ptr1581; + var $copy_7 = $sub1560; + } + var $copy_7; + var $from_0; + var $178 = HEAPU32[$21 >> 2]; + var $cmp1584 = $copy_7 >>> 0 > $178 >>> 0; + if (!$cmp1584) { + var $from_1 = $from_0; + var $copy_8 = $copy_7; + var $180 = $178; + break; + } + var $from_1 = $from_0; + var $copy_8 = $178; + var $180 = $178; + } else { + var $idx_neg = -$171 | 0; + var $add_ptr1591 = $put_0 + $idx_neg | 0; + var $179 = HEAP32[$21 >> 2]; + var $from_1 = $add_ptr1591; + var $copy_8 = $179; + var $180 = $179; + } + } while (0); + var $180; + var $copy_8; + var $from_1; + var $cmp1594 = $copy_8 >>> 0 > $left_0 >>> 0; + var $copy_9 = $cmp1594 ? $left_0 : $copy_8; + var $sub1600 = $180 - $copy_9 | 0; + HEAP32[$21 >> 2] = $sub1600; + var $181 = $copy_8 ^ -1; + var $182 = $left_0 ^ -1; + var $183 = $181 >>> 0 > $182 >>> 0; + var $umax = $183 ? $181 : $182; + var $from_2 = $from_1; + var $put_1 = $put_0; + var $copy_10 = $copy_9; + while (1) { + var $copy_10; + var $put_1; + var $from_2; + var $incdec_ptr1602 = $from_2 + 1 | 0; + var $184 = HEAP8[$from_2]; + var $incdec_ptr1603 = $put_1 + 1 | 0; + HEAP8[$put_1] = $184; + var $dec1605 = $copy_10 - 1 | 0; + var $tobool1606 = ($dec1605 | 0) == 0; + if ($tobool1606) { + break; + } + var $from_2 = $incdec_ptr1602; + var $put_1 = $incdec_ptr1603; + var $copy_10 = $dec1605; + } + var $sub1598 = $left_0 - $copy_9 | 0; + var $scevgep_sum = $umax ^ -1; + var $scevgep632 = $put_0 + $scevgep_sum | 0; + var $185 = HEAP32[$21 >> 2]; + var $cmp1609 = ($185 | 0) == 0; + if (!$cmp1609) { + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $scevgep632; + var $have_0_be = $have_51; + var $left_0_be = $sub1598; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + break; + } + HEAP32[$mode >> 2] = 20; + var $ret_0_be = $ret_7; + var $next_0_be = $next_51; + var $put_0_be = $scevgep632; + var $have_0_be = $have_51; + var $left_0_be = $sub1598; + var $hold_0_be = $hold_47; + var $bits_0_be = $bits_47; + var $out_0_be = $out_0; + } + } while (0); + var $out_0_be; + var $bits_0_be; + var $hold_0_be; + var $left_0_be; + var $have_0_be; + var $put_0_be; + var $next_0_be; + var $ret_0_be; + var $_pre883 = HEAP32[$mode >> 2]; + var $ret_0 = $ret_0_be; + var $next_0 = $next_0_be; + var $put_0 = $put_0_be; + var $have_0 = $have_0_be; + var $left_0 = $left_0_be; + var $hold_0 = $hold_0_be; + var $bits_0 = $bits_0_be; + var $out_0 = $out_0_be; + var $49 = $_pre883; + } + var $out_4; + var $bits_54; + var $hold_54; + var $have_58; + var $next_58; + var $ret_8; + HEAP32[$next_out >> 2] = $put_0; + HEAP32[$avail_out >> 2] = $left_0; + HEAP32[$next_in >> 2] = $next_58; + HEAP32[$avail_in15 >> 2] = $have_58; + HEAP32[$11 >> 2] = $hold_54; + HEAP32[$13 >> 2] = $bits_54; + var $199 = HEAP32[$35 >> 2]; + var $tobool1755 = ($199 | 0) == 0; + do { + if ($tobool1755) { + var $200 = HEAPU32[$mode >> 2]; + var $cmp1758 = $200 >>> 0 < 26; + if (!$cmp1758) { + __label__ = 300; + break; + } + var $201 = HEAP32[$avail_out >> 2]; + var $cmp1762 = ($out_4 | 0) == ($201 | 0); + if ($cmp1762) { + __label__ = 300; + break; + } + __label__ = 298; + break; + } else { + __label__ = 298; + } + } while (0); + do { + if (__label__ == 298) { + var $call1765 = _updatewindow($strm, $out_4); + var $tobool1766 = ($call1765 | 0) == 0; + if ($tobool1766) { + break; + } + HEAP32[$mode >> 2] = 30; + var $retval_0 = -4; + break $_$2; + } + } while (0); + var $202 = HEAPU32[$avail_in15 >> 2]; + var $203 = HEAPU32[$avail_out >> 2]; + var $sub1774 = $out_4 - $203 | 0; + var $total_in = $strm + 8 | 0; + var $204 = HEAP32[$total_in >> 2]; + var $sub1772 = $10 - $202 | 0; + var $add1775 = $sub1772 + $204 | 0; + HEAP32[$total_in >> 2] = $add1775; + var $205 = HEAP32[$total_out >> 2]; + var $add1777 = $205 + $sub1774 | 0; + HEAP32[$total_out >> 2] = $add1777; + var $206 = HEAP32[$36 >> 2]; + var $add1779 = $206 + $sub1774 | 0; + HEAP32[$36 >> 2] = $add1779; + var $207 = HEAP32[$15 >> 2]; + var $tobool1781 = ($207 | 0) == 0; + var $tobool1783 = ($out_4 | 0) == ($203 | 0); + var $or_cond34 = $tobool1781 | $tobool1783; + if (!$or_cond34) { + var $208 = HEAP32[$17 >> 2]; + var $tobool1786 = ($208 | 0) == 0; + var $209 = HEAP32[$16 >> 2]; + var $210 = HEAP32[$next_out >> 2]; + var $idx_neg1790 = -$sub1774 | 0; + var $add_ptr1791 = $210 + $idx_neg1790 | 0; + if ($tobool1786) { + var $call1798 = _adler32($209, $add_ptr1791, $sub1774); + var $cond1800 = $call1798; + } else { + var $call1792 = _crc32($209, $add_ptr1791, $sub1774); + var $cond1800 = $call1792; + } + var $cond1800; + HEAP32[$16 >> 2] = $cond1800; + HEAP32[$adler >> 2] = $cond1800; + } + var $211 = HEAP32[$13 >> 2]; + var $212 = HEAP32[$24 >> 2]; + var $tobool1806 = ($212 | 0) != 0; + var $cond1807 = $tobool1806 ? 64 : 0; + var $213 = HEAP32[$mode >> 2]; + var $cmp1810 = ($213 | 0) == 11; + var $cond1812 = $cmp1810 ? 128 : 0; + var $cmp1815 = ($213 | 0) == 19; + if ($cmp1815) { + var $214 = 256; + } else { + var $cmp1818 = ($213 | 0) == 14; + var $phitmp = $cmp1818 ? 256 : 0; + var $214 = $phitmp; + } + var $214; + var $add1808 = $cond1807 + $211 | 0; + var $add1813 = $add1808 + $cond1812 | 0; + var $add1821 = $add1813 + $214 | 0; + var $data_type = $strm + 44 | 0; + HEAP32[$data_type >> 2] = $add1821; + var $cmp1822 = ($10 | 0) == ($202 | 0); + var $or_cond35 = $cmp1822 & $tobool1783; + var $cmp1828 = ($flush | 0) == 4; + var $or_cond36 = $or_cond35 | $cmp1828; + var $cmp1831 = ($ret_8 | 0) == 0; + var $or_cond37 = $or_cond36 & $cmp1831; + var $ret_9 = $or_cond37 ? -5 : $ret_8; + var $retval_0 = $ret_9; + } + } while (0); + var $retval_0; + STACKTOP = __stackBase__; + return $retval_0; + return null; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate"] diff --git a/tools/eliminator/eliminator.coffee b/tools/eliminator/eliminator.coffee index a4c98930..f83b4a52 100644 --- a/tools/eliminator/eliminator.coffee +++ b/tools/eliminator/eliminator.coffee @@ -107,8 +107,8 @@ class Eliminator # Maps a given single-def variable to the AST expression of its initial value. @initialValue = {} # Maps identifiers to single-def variables which reference it in their - # initial value. - @dependsOn = {} + # initial value, i.e., which other variables it affects. + @affects = {} # Runs the eliminator on a given function body updating the AST in-place. # @returns: The number of variables eliminated, or undefined if skipped. @@ -157,7 +157,7 @@ class Eliminator # Analyzes the initial values of single-def variables. Requires basic variable # stats to have been calculated. Fills the following member variables: - # dependsOn + # affects # dependsOnAGlobal # usesOnlySimpleNodes analyzeInitialValues: -> @@ -170,25 +170,38 @@ class Eliminator else if type is 'name' reference = node[1] if reference != 'undefined' - if not @dependsOn[reference]? then @dependsOn[reference] = {} + if not @affects[reference]? then @affects[reference] = {} if not @isLocal[reference] then @dependsOnAGlobal[varName] = true - @dependsOn[reference][varName] = true + @affects[reference][varName] = true return undefined return undefined - # Updates the dependency graph (@dependsOn) to its transitive closure and + # Updates the dependency graph (@affects) to its transitive closure and # synchronizes @dependsOnAGlobal to the new dependencies. calculateTransitiveDependencies: -> incomplete = true + todo = {} + for element of @affects + todo[element] = 1 + + #process.stdout.write 'pre ' + JSON.stringify(@affects, null, ' ') + '\n' + while incomplete incomplete = false - for target, sources of @dependsOn - for source of sources - for source2 of @dependsOn[source] - if not @dependsOn[target][source2] - if not @isLocal[target] then @dependsOnAGlobal[source2] = true - @dependsOn[target][source2] = true - incomplete = true + nextTodo = {} + for source, targets of @affects + for target of targets + if todo[target] + for target2 of @affects[target] + if not targets[target2] + if not @isLocal[source] then @dependsOnAGlobal[target2] = true + targets[target2] = true + nextTodo[source] = 1 + incomplete = true + todo = nextTodo + + #process.stdout.write 'post ' + JSON.stringify(@affects, null, ' ') + '\n' + return undefined # Analyzes the live ranges of single-def variables. Requires dependencies to @@ -211,8 +224,8 @@ class Eliminator while reference[0] != 'name' reference = reference[1] reference = reference[1] - if @dependsOn[reference]? - for varName of @dependsOn[reference] + if @affects[reference]? + for varName of @affects[reference] if isLive[varName] isLive[varName] = false @@ -264,8 +277,8 @@ class Eliminator if @isSingleDef[varName] isLive[varName] = true # Mark variables that depend on it as no longer live - if @dependsOn[varName]? - for varNameDep of @dependsOn[varName] + if @affects[varName]? + for varNameDep of @affects[varName] if isLive[varNameDep] isLive[varNameDep] = false return node diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index b51fe22e..2f6b2ff3 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -119,6 +119,8 @@ load('utility.js'); var FUNCTION = set('defun', 'function'); var LOOP = set('do', 'while', 'for'); var LOOP_FLOW = set('break', 'continue'); +var ASSIGN_OR_ALTER = set('assign', 'unary-postfix', 'unary-prefix'); +var CONTROL_FLOW = set('do', 'while', 'for', 'if', 'switch'); var NULL_NODE = ['name', 'null']; var UNDEFINED_NODE = ['unary-prefix', 'void', ['num', 0]]; @@ -1140,6 +1142,180 @@ function loopOptimizer(ast) { vacuum(ast); } +// Very simple 'registerization', coalescing of variables into a smaller number. +// We do not optimize when there are switches, so this pass only makes sense with +// relooping. +// TODO: Consider how this fits in with the rest of the optimization toolchain. Do +// we still need the eliminator? Closure? And in what order? Perhaps just +// closure simple? +function registerize(ast) { + traverseGeneratedFunctions(ast, function(fun) { + // Replace all var definitions with assignments; we will add var definitions at the top after we registerize + // We also mark local variables - i.e., having a var definition + var localVars = {}; + var hasSwitch = false; // we cannot optimize variables if there is a switch + traverse(fun, function(node, type) { + if (type == 'var') { + node[1].forEach(function(defined) { localVars[defined[0]] = 1 }); + var vars = node[1].filter(function(varr) { return varr[1] }); + if (vars.length > 1) { + var ret = ['stat', []]; + var curr = ret[1]; + for (var i = 0; i < vars.length-1; i++) { + curr[0] = 'seq'; + curr[1] = ['assign', true, ['name', vars[i][0]], vars[i][1]]; + if (i != vars.length-2) curr = curr[2] = []; + } + curr[2] = ['assign', true, ['name', vars[vars.length-1][0]], vars[vars.length-1][1]]; + return ret; + } else if (vars.length == 1) { + return ['stat', ['assign', true, ['name', vars[0][0]], vars[0][1]]]; + } else { + return emptyNode(); + } + } else if (type == 'switch') { + hasSwitch = true; + } + }); + vacuum(fun); + // Find the # of uses of each variable. + // While doing so, check if all a variable's uses are dominated in a simple + // way by a simple assign, if so, then we can assign its register to it + // just for its definition to its last use, and not to the entire toplevel loop, + // we call such variables "optimizable" + var varUses = {}; + var level = 1; + var levelDominations = {}; + var varLevels = {}; + var possibles = {}; + var unoptimizables = {}; + traverse(fun, function(node, type) { + if (type == 'name') { + var name = node[1]; + if (localVars[name]) { + if (!varUses[name]) varUses[name] = 0; + varUses[name]++; + if (possibles[name] && !varLevels[name]) unoptimizables[name] = 1; // used outside of simple domination + } + } else if (type == 'assign' && typeof node[1] != 'string') { + if (node[2] && node[2][0] == 'name') { + var name = node[2][1]; + // if local and not yet used, this might be optimizable if we dominate + // all other uses + if (localVars[name] && !varUses[name] && !varLevels[name]) { + possibles[name] = 1; + varLevels[name] = level; + if (!levelDominations[level]) levelDominations[level] = {}; + levelDominations[level][name] = 1; + } + } + } else if (type in CONTROL_FLOW) { + level++; + } + }, function(node, type) { + if (type in CONTROL_FLOW) { + // Invalidate all dominating on this level, further users make it unoptimizable + for (var name in levelDominations[level]) { + varLevels[name] = 0; + } + levelDominations[level] = null; + level--; + } + }); + var optimizables = {}; + if (!hasSwitch) { + for (var possible in possibles) { + if (!unoptimizables[possible]) optimizables[possible] = 1; + } + } + // Go through the function's code, assigning 'registers'. + // The only tricky bit is to keep variables locked on a register through loops, + // since they can potentially be returned to. Optimizable variables lock onto + // loops that they enter, unoptimizable variables lock in a conservative way + // into the topmost loop. + // Note that we cannot lock onto a variable in a loop if it was used and free'd + // before! (then they could overwrite us in the early part of the loop). For now + // we just use a fresh register to make sure we avoid this, but it could be + // optimized to check for safe registers (free, and not used in this loop level). + var varRegs = {}; // maps variables to the register they will use all their life + var freeRegs = []; + var nextReg = 1; + var fullNames = {}; + var loopRegs = {}; // for each loop nesting level, the list of bound variables + var loops = 0; // 0 is toplevel, 1 is first loop, etc + var saved = 0; + var activeOptimizables = {}; + var optimizableLoops = {}; + function decUse(name) { + if (!varUses[name]) return false; // no uses left, or not a relevant variable + if (optimizables[name]) activeOptimizables[name] = 1; + var reg = varRegs[name]; + if (!reg) { + // acquire register + if (optimizables[name] && freeRegs.length > 0) { + reg = freeRegs.pop(); + saved++; + } else { + reg = nextReg++; + fullNames[reg] = 'r' + reg; // TODO: even smaller names + } + varRegs[name] = reg; + } + varUses[name]--; + assert(varUses[name] >= 0); + if (varUses[name] == 0) { + if (optimizables[name]) delete activeOptimizables[name]; + // If we are not in a loop, or we are optimizable and not bound to a loop + // (we might have been in one but left it), we can free the register now. + if (loops == 0 || (optimizables[name] && !optimizableLoops[name])) { + // free register + freeRegs.push(reg); + } else { + // when the relevant loop is exited, we will free the register + var releventLoop = optimizables[name] ? (optimizableLoops[name] || 1) : 1; + if (!loopRegs[releventLoop]) loopRegs[releventLoop] = []; + loopRegs[releventLoop].push(reg); + } + } + return true; + } + traverse(fun, function(node, type) { // XXX we rely on traversal order being the same as execution order here + if (type == 'name') { + var name = node[1]; + if (decUse(name)) { + node[1] = fullNames[varRegs[name]]; + } + } else if (type in LOOP) { + loops++; + // Active optimizables lock onto this loop, if not locked onto one that encloses this one + for (var name in activeOptimizables) { + if (!optimizableLoops[name]) { + optimizableLoops[name] = loops; + } + } + } + }, function(node, type) { + if (type in LOOP) { + // Free registers that were locked to this loop + if (loopRegs[loops]) { + freeRegs = freeRegs.concat(loopRegs[loops]); + loopRegs[loops] = []; + } + loops--; + } + }); + // Add vars at the beginning + if (nextReg > 1) { + var vars = []; + for (var i = 1; i < nextReg; i++) { + vars.push([fullNames[i]]); + } + getStatements(fun).unshift(['var', vars]); + } + printErr(fun[1] + ': saved ' + saved + ' / ' + (saved + nextReg - 1) + ' vars through registerization'); // not totally accurate + }); +} + // Passes table var compress = false; @@ -1156,6 +1332,7 @@ var passes = { simplifyExpressionsPost: simplifyExpressionsPost, hoistMultiples: hoistMultiples, loopOptimizer: loopOptimizer, + registerize: registerize, compress: function() { compress = true; } }; diff --git a/tools/shared.py b/tools/shared.py index fb41f7ee..52b47ef6 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1,4 +1,4 @@ -import shutil, time, os, sys, json, tempfile, copy, shlex, atexit +import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess from subprocess import Popen, PIPE, STDOUT from tempfile import mkstemp @@ -61,6 +61,9 @@ def check_sanity(force=False): except: pass + print >> sys.stderr, '(Emscripten: Config file changed, clearing cache)' # LLVM may have changed, etc. + Cache.erase() + print >> sys.stderr, '(Emscripten: Running sanity checks)' if not check_engine(COMPILER_ENGINE): @@ -77,6 +80,11 @@ def check_sanity(force=False): print >> sys.stderr, 'FATAL: Cannot find %s, check the paths in %s' % (cmd, EM_CONFIG) sys.exit(0) + try: + subprocess.call(['java', '-version'], stdout=PIPE, stderr=PIPE) + except: + print >> sys.stderr, 'WARNING: java does not seem to exist, required for closure compiler. -O2 and above will fail.' + if not os.path.exists(CLOSURE_COMPILER): print >> sys.stderr, 'WARNING: Closure compiler (%s) does not exist, check the paths in %s. -O2 and above will fail' % (CLOSURE_COMPILER, EM_CONFIG) @@ -98,7 +106,6 @@ CLANG_CC=os.path.expanduser(os.path.join(LLVM_ROOT, 'clang')) CLANG_CPP=os.path.expanduser(os.path.join(LLVM_ROOT, 'clang++')) CLANG=CLANG_CPP LLVM_LINK=os.path.join(LLVM_ROOT, 'llvm-link') -LLVM_LD=os.path.join(LLVM_ROOT, 'llvm-ld') LLVM_AR=os.path.join(LLVM_ROOT, 'llvm-ar') LLVM_OPT=os.path.expanduser(os.path.join(LLVM_ROOT, 'opt')) LLVM_AS=os.path.expanduser(os.path.join(LLVM_ROOT, 'llvm-as')) @@ -117,6 +124,7 @@ EMAR = path_from_root('emar') EMLD = path_from_root('emld') EMRANLIB = path_from_root('emranlib') EMLIBTOOL = path_from_root('emlibtool') +EMCONFIG = path_from_root('em-config') EMMAKEN = path_from_root('tools', 'emmaken.py') AUTODEBUGGER = path_from_root('tools', 'autodebugger.py') BINDINGS_GENERATOR = path_from_root('tools', 'bindings_generator.py') @@ -174,7 +182,7 @@ except: # Force a simple, standard target as much as possible: target 32-bit linux, and disable various flags that hint at other platforms COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-U__i386__', '-U__x86_64__', '-U__i386', '-U__x86_64', '-U__SSE__', '-U__SSE2__', '-U__MMX__', '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87', '-DEMSCRIPTEN', '-U__STRICT_ANSI__', '-U__CYGWIN__', - '-D__STDC__', '-Xclang', '-triple=i386-pc-linux-gnu'] + '-D__STDC__', '-Xclang', '-triple=i386-pc-linux-gnu', '-D__IEEE_LITTLE_ENDIAN'] USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK') @@ -191,7 +199,7 @@ if USE_EMSDK: '-Xclang', '-isystem' + path_from_root('system', 'include', 'net'), '-Xclang', '-isystem' + path_from_root('system', 'include', 'SDL'), ] + [ - '-U__APPLE__' + '-U__APPLE__', '-U__linux__' ] COMPILER_OPTS += EMSDK_OPTS else: @@ -199,16 +207,25 @@ else: # Engine tweaks -#if 'strict' not in str(SPIDERMONKEY_ENGINE): # XXX temporarily disable strict mode until we sort out some stuff -# SPIDERMONKEY_ENGINE += ['-e', "options('strict')"] # Strict mode in SpiderMonkey. With V8 we check that fallback to non-strict works too - try: if 'gcparam' not in str(SPIDERMONKEY_ENGINE): + if type(SPIDERMONKEY_ENGINE) is str: + SPIDERMONKEY_ENGINE = [SPIDERMONKEY_ENGINE] SPIDERMONKEY_ENGINE += ['-e', "gcparam('maxBytes', 1024*1024*1024);"] # Our very large files need lots of gc heap except NameError: pass -WINDOWS = sys.platform.startswith ('win') +WINDOWS = sys.platform.startswith('win') + +# If we have 'env', we should use that to find python, because |python| may fail while |env python| may work +# (For example, if system python is 3.x while we need 2.x, and env gives 2.x if told to do so.) +ENV_PREFIX = [] +if not WINDOWS: + try: + assert 'Python' in Popen(['env', 'python', '-V'], stdout=PIPE, stderr=STDOUT).communicate()[0] + ENV_PREFIX = ['env'] + except: + pass # Temp file utilities @@ -501,11 +518,58 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e @staticmethod def link(files, target): + actual_files = [] + unresolved_symbols = set() # necessary for .a linking, see below + resolved_symbols = set() + temp_dir = None + for f in files: + if not Building.is_ar(f): + if Building.is_bitcode(f): + new_symbols = Building.llvm_nm(f) + resolved_symbols = resolved_symbols.union(new_symbols.defs) + unresolved_symbols = unresolved_symbols.union(new_symbols.undefs.difference(resolved_symbols)).difference(new_symbols.defs) + actual_files.append(f) + else: + # Extract object files from ar archives, and link according to gnu ld semantics + # (link in an entire .o from the archive if it supplies symbols still unresolved) + cwd = os.getcwd() + try: + temp_dir = os.path.join(EMSCRIPTEN_TEMP_DIR, 'ar_output_' + str(os.getpid())) + if not os.path.exists(temp_dir): + os.makedirs(temp_dir) + os.chdir(temp_dir) + contents = filter(lambda x: len(x) > 0, Popen([LLVM_AR, 't', f], stdout=PIPE).communicate()[0].split('\n')) + if len(contents) == 0: + print >> sys.stderr, 'Warning: Archive %s appears to be empty (recommendation: link an .so instead of .a)' % f + else: + for content in contents: # ar will silently fail if the directory for the file does not exist, so make all the necessary directories + dirname = os.path.dirname(content) + if dirname and not os.path.exists(dirname): + os.makedirs(dirname) + Popen([LLVM_AR, 'x', f], stdout=PIPE).communicate() # if absolute paths, files will appear there. otherwise, in this directory + contents = map(lambda content: os.path.join(temp_dir, content), contents) + contents = filter(os.path.exists, map(os.path.abspath, contents)) + needed = False # We add or do not add the entire archive. We let llvm dead code eliminate parts we do not need, instead of + # doing intra-dependencies between archive contents + for content in contents: + new_symbols = Building.llvm_nm(content) + # Link in the .o if it provides symbols, *or* this is a singleton archive (which is apparently an exception in gcc ld) + if new_symbols.defs.intersection(unresolved_symbols) or len(files) == 1: + needed = True + if needed: + for content in contents: + if Building.is_bitcode(content): + new_symbols = Building.llvm_nm(content) + resolved_symbols = resolved_symbols.union(new_symbols.defs) + unresolved_symbols = unresolved_symbols.union(new_symbols.undefs.difference(resolved_symbols)).difference(new_symbols.defs) + actual_files.append(content) + finally: + os.chdir(cwd) try_delete(target) - stub = os.path.join(EMSCRIPTEN_TEMP_DIR, 'stub_deleteme') + ('.exe' if WINDOWS else '') - output = Popen([LLVM_LD, '-disable-opt'] + files + ['-b', target, '-o', stub], stdout=PIPE).communicate()[0] - try_delete(stub) # clean up stub left by the linker + output = Popen([LLVM_LINK] + actual_files + ['-o', target], stdout=PIPE).communicate()[0] assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output + if temp_dir: + try_delete(temp_dir) # Emscripten optimizations that we run on the .ll file @staticmethod @@ -575,13 +639,15 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e commons = [] for line in output.split('\n'): if len(line) == 0: continue - status, symbol = filter(lambda seg: len(seg) > 0, line.split(' ')) - if status == 'U': - ret.undefs.append(symbol) - elif status != 'C': - ret.defs.append(symbol) - else: - ret.commons.append(symbol) + parts = filter(lambda seg: len(seg) > 0, line.split(' ')) + if len(parts) == 2: # ignore lines with absolute offsets, these are not bitcode anyhow (e.g. |00000630 t d_source_name|) + status, symbol = parts + if status == 'U': + ret.undefs.append(symbol) + elif status != 'C': + ret.defs.append(symbol) + else: + ret.commons.append(symbol) ret.defs = set(ret.defs) ret.undefs = set(ret.undefs) ret.commons = set(ret.commons) @@ -592,13 +658,13 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e if output_filename is None: output_filename = filename + '.o' try_delete(output_filename) - Popen(['python', EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate() + Popen(ENV_PREFIX + ['python', EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate() assert os.path.exists(output_filename), 'emcc could not create output file' @staticmethod def emar(action, output_filename, filenames, stdout=None, stderr=None, env=None): try_delete(output_filename) - Popen(['python', EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate() + Popen(ENV_PREFIX + ['python', EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate() if 'c' in action: assert os.path.exists(output_filename), 'emar could not create output file' @@ -609,7 +675,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # Run Emscripten settings = Settings.serialize() - compiler_output = timeout_run(Popen(['python', EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') + compiler_output = timeout_run(Popen(ENV_PREFIX + ['python', EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') #print compiler_output # Detect compilation crashes and errors diff --git a/tools/test-js-optimizer-regs-output.js b/tools/test-js-optimizer-regs-output.js new file mode 100644 index 00000000..a5e97f46 --- /dev/null +++ b/tools/test-js-optimizer-regs-output.js @@ -0,0 +1,228 @@ +function test() { + var r1, r2; + r1 = 0; + f(r1); + r1 += 1; + r2 = r1 + 2; + g(r1, r2); + f(r1); + r1 = cheez(); + r2 = r1 + 2; + g(r2, r2); + r2 = 200; + r2 = 203; + r2 = 205; + r1 = 208; + c(r2); + while (f()) { + r2 = 5; + r1 = 12; + gg(r2, r1 * 2); + r1 = 100; + gg(r1, 20); + } + r1 = f(), r2 = 100, r2 = 1e3, r2 = 1e5; + f(r1()); +} +function primes() { + var r1, r2, r3, r4, r5, r6, r7; + r1 = 2; + r2 = 0; + $_$2 : while (1) { + r3 = r1 | 0; + r4 = _sqrtf(r3); + r3 = 2; + $_$4 : while (1) { + r5 = r3 | 0; + r6 = r5 < r4; + if (!r6) { + r7 = 1; + break $_$4; + } + r6 = (r1 | 0) % (r3 | 0); + r5 = (r6 | 0) == 0; + if (r5) { + r7 = 0; + break $_$4; + } + r5 = r3 + 1 | 0; + r3 = r5; + } + r3 = r7 + r2 | 0; + r4 = r1 + 1 | 0; + r5 = (r3 | 0) < 1e5; + if (r5) { + r1 = r4; + r2 = r3; + } else { + break $_$2; + } + } + r2 = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r1, tempInt)); + return 1; + return null; +} +function atomic() { + var r1, r2, r3, r4; + r1 = STACKTOP; + STACKTOP += 4; + r2 = r1 >> 2; + HEAP32[r2] = 10; + r3 = (tempValue = HEAP32[r2], HEAP32[r2] == 10 && (HEAP32[r2] = 7), tempValue); + r4 = (r3 | 0) == 10 & 1; + r3 = HEAP32[r2]; + r2 = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = r3, HEAP32[tempInt + 4 >> 2] = r4, tempInt)); + STACKTOP = r1; + return 0; + return null; +} +function fcntl_open() { + var r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17; + r1 = STACKTOP; + STACKTOP += 84; + r2 = r1; + r3 = r1 + 72; + r4 = r3 | 0; + for (r5 = STRING_TABLE.__ZZ4mainE16nonexistent_name | 0, r6 = r4, r7 = r5 + 12; r5 < r7; r5++, r6++) { + HEAP8[r6] = HEAP8[r5]; + } + r5 = (r2 + 8 | 0) >> 2; + r8 = r2 >> 2; + r9 = r3 + 9 | 0; + r10 = r3 + 10 | 0; + r3 = 0; + while (1) { + r11 = HEAP32[__ZZ4mainE5modes + (r3 << 2) >> 2]; + r12 = r11 | 512; + r13 = r3 + 97 & 255; + r14 = 0; + while (1) { + r15 = (r14 & 1 | 0) == 0 ? r11 : r12; + r16 = (r14 & 2 | 0) == 0 ? r15 : r15 | 2048; + r15 = (r14 & 4 | 0) == 0 ? r16 : r16 | 1024; + r16 = (r14 & 8 | 0) == 0 ? r15 : r15 | 8; + r15 = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = r3, HEAP32[tempInt + 4 >> 2] = r14, tempInt)); + r15 = _open(STRING_TABLE.__str2 | 0, r16, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + r17 = (r15 | 0) != -1 & 1; + r15 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r17, tempInt)); + r17 = ___errno(); + r15 = HEAP32[r17 >> 2]; + r17 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + r15 = _stat(STRING_TABLE.__str2 | 0, r2); + r15 = HEAP32[r5] & -512; + r17 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + for (r6 = r8, r7 = r6 + 18; r6 < r7; r6++) { + HEAP32[r6] = 0; + } + r15 = _putchar(10); + r15 = ___errno(); + HEAP32[r15 >> 2] = 0; + r15 = _printf(STRING_TABLE.__str6 | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = r3, HEAP32[tempInt + 4 >> 2] = r14, tempInt)); + r15 = _open(STRING_TABLE.__str7 | 0, r16, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + r17 = (r15 | 0) != -1 & 1; + r15 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r17, tempInt)); + r17 = ___errno(); + r15 = HEAP32[r17 >> 2]; + r17 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + r15 = _stat(STRING_TABLE.__str7 | 0, r2); + r15 = HEAP32[r5] & -512; + r17 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + for (r6 = r8, r7 = r6 + 18; r6 < r7; r6++) { + HEAP32[r6] = 0; + } + r15 = _putchar(10); + r15 = ___errno(); + HEAP32[r15 >> 2] = 0; + HEAP8[r9] = r13; + HEAP8[r10] = r14 + 97 & 255; + r15 = _printf(STRING_TABLE.__str8 | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = r3, HEAP32[tempInt + 4 >> 2] = r14, tempInt)); + r15 = _open(r4, r16, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + r17 = (r15 | 0) != -1 & 1; + r15 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r17, tempInt)); + r17 = ___errno(); + r15 = HEAP32[r17 >> 2]; + r17 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + r15 = _stat(r4, r2); + r15 = HEAP32[r5] & -512; + r17 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r15, tempInt)); + for (r6 = r8, r7 = r6 + 18; r6 < r7; r6++) { + HEAP32[r6] = 0; + } + r16 = _putchar(10); + r16 = ___errno(); + HEAP32[r16 >> 2] = 0; + r16 = r14 + 1 | 0; + if ((r16 | 0) == 16) { + break; + } + r14 = r16; + } + r14 = r3 + 1 | 0; + if ((r14 | 0) == 3) { + break; + } + r3 = r14; + } + r3 = _puts(STRING_TABLE._str | 0); + r3 = _creat(STRING_TABLE.__str10 | 0, 511); + r6 = (r3 | 0) != -1 & 1; + r3 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r6, tempInt)); + r6 = ___errno(); + r3 = HEAP32[r6 >> 2]; + r6 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r3, tempInt)); + STACKTOP = r1; + return 0; + return null; +} +function ex() { + var r1, r2; + r1 = STACKTOP; + STACKTOP += 4; + r2 = r1; + r1 = _puts(STRING_TABLE._str17 | 0); + r1 = r2 | 0; + r2 = 0; + while (1) { + r1 = _printf(STRING_TABLE.__str15 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = r2, tempInt)); + ((function() { + try { + __THREW__ = false; + return __Z5magici(r2); + } catch (e) { + if (typeof e != "number") throw e; + if (ABORT) throw e; + __THREW__ = true; + return null; + } + }))(); + } +} +function switchey(x) { + var r1, r2, r3, r4, r5, r6, r7, r8; + r1 = 5; + while (1) { + switch (x = f(x, r1)) { + case 1: + g(r1); + r2 = x + 1; + x--; + break; + case 2: + g(r1 * 2); + r3 = x + 22; + r4 = r3 + 5; + x -= 20; + break; + default: + r5 = x + 22; + r6 = r3 + 5; + ch(r5, r6 * r3); + throw 99; + } + } + r7 = x + 1; + p(r1, r7); + r8 = x + 2; + pp(r8); +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["test", "primes", "atomic", "fcntl_open", "ex", "switchey"] diff --git a/tools/test-js-optimizer-regs.js b/tools/test-js-optimizer-regs.js new file mode 100644 index 00000000..2aa95b74 --- /dev/null +++ b/tools/test-js-optimizer-regs.js @@ -0,0 +1,233 @@ +function test() { + var i = 0; + f(i); + i+=1; + var j = i + 2; + g(i, j); + f(i); + var i2 = cheez(); + var j2 = i2 + 2; + g(j2, j2); + var k1 = 200; + var k2 = 203; + var k3 = 205; + var k4 = 208; + c(k3); + while (f()) { + var apple = 5; + var orange = 12; + gg(apple, orange*2); + var tangerine = 100; + gg(tangerine, 20); + } + var ck = f(), ck2 = 100, ck3 = 1000, ck4 = 100000; + f(ck()); +} +function primes() { + var __label__; + var $curri_01 = 2; + var $primes_02 = 0; + $_$2 : while (1) { + var $primes_02; + var $curri_01; + var $conv1 = $curri_01 | 0; + var $call = _sqrtf($conv1); + var $j_0 = 2; + $_$4 : while (1) { + var $j_0; + var $conv = $j_0 | 0; + var $cmp2 = $conv < $call; + if (!$cmp2) { + var $ok_0 = 1; + break $_$4; + } + var $rem = ($curri_01 | 0) % ($j_0 | 0); + var $cmp3 = ($rem | 0) == 0; + if ($cmp3) { + var $ok_0 = 0; + break $_$4; + } + var $inc = $j_0 + 1 | 0; + var $j_0 = $inc; + } + var $ok_0; + var $inc5_primes_0 = $ok_0 + $primes_02 | 0; + var $inc7 = $curri_01 + 1 | 0; + var $cmp = ($inc5_primes_0 | 0) < 1e5; + if ($cmp) { + var $curri_01 = $inc7; + var $primes_02 = $inc5_primes_0; + } else { + break $_$2; + } + } + var $call8 = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $curri_01, tempInt)); + return 1; + return null; +} +function atomic() { + var $x$s2; + var __stackBase__ = STACKTOP; + STACKTOP += 4; + var $x$s2 = __stackBase__ >> 2; + HEAP32[$x$s2] = 10; + var $0 = (tempValue = HEAP32[$x$s2], HEAP32[$x$s2] == 10 && (HEAP32[$x$s2] = 7), tempValue); + var $conv = ($0 | 0) == 10 & 1; + var $2 = HEAP32[$x$s2]; + var $call = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = $2, HEAP32[tempInt + 4 >> 2] = $conv, tempInt)); + STACKTOP = __stackBase__; + return 0; + return null; +} +function fcntl_open() { + var $1$s2; + var $st_mode$s2; + var __stackBase__ = STACKTOP; + STACKTOP += 84; + var $s = __stackBase__; + var $nonexistent_name = __stackBase__ + 72; + var $0 = $nonexistent_name | 0; + for (var $$src = STRING_TABLE.__ZZ4mainE16nonexistent_name | 0, $$dest = $0, $$stop = $$src + 12; $$src < $$stop; $$src++, $$dest++) { + HEAP8[$$dest] = HEAP8[$$src]; + } + var $st_mode$s2 = ($s + 8 | 0) >> 2; + var $1$s2 = $s >> 2; // critical variable, becomes r8 + var $arrayidx43 = $nonexistent_name + 9 | 0; + var $arrayidx46 = $nonexistent_name + 10 | 0; + var $i_04 = 0; + while (1) { + var $i_04; + var $2 = HEAP32[__ZZ4mainE5modes + ($i_04 << 2) >> 2]; + var $or = $2 | 512; + var $conv42 = $i_04 + 97 & 255; + var $j_03 = 0; + while (1) { + var $j_03; + var $flags_0 = ($j_03 & 1 | 0) == 0 ? $2 : $or; + var $flags_0_or7 = ($j_03 & 2 | 0) == 0 ? $flags_0 : $flags_0 | 2048; + var $flags_2 = ($j_03 & 4 | 0) == 0 ? $flags_0_or7 : $flags_0_or7 | 1024; + var $flags_2_or17 = ($j_03 & 8 | 0) == 0 ? $flags_2 : $flags_2 | 8; + var $call = _printf(STRING_TABLE.__str | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = $i_04, HEAP32[tempInt + 4 >> 2] = $j_03, tempInt)); + var $call19 = _open(STRING_TABLE.__str2 | 0, $flags_2_or17, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + var $conv = ($call19 | 0) != -1 & 1; + var $call21 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $conv, tempInt)); + var $call22 = ___errno(); + var $3 = HEAP32[$call22 >> 2]; + var $call23 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $3, tempInt)); + var $call24 = _stat(STRING_TABLE.__str2 | 0, $s); + var $and25 = HEAP32[$st_mode$s2] & -512; + var $call26 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $and25, tempInt)); + for (var $$dest = $1$s2, $$stop = $$dest + 18; $$dest < $$stop; $$dest++) { + HEAP32[$$dest] = 0; + } + var $putchar = _putchar(10); + var $call28 = ___errno(); + HEAP32[$call28 >> 2] = 0; + var $call29 = _printf(STRING_TABLE.__str6 | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = $i_04, HEAP32[tempInt + 4 >> 2] = $j_03, tempInt)); + var $call30 = _open(STRING_TABLE.__str7 | 0, $flags_2_or17, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + var $conv32 = ($call30 | 0) != -1 & 1; + var $call33 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $conv32, tempInt)); + var $call34 = ___errno(); + var $5 = HEAP32[$call34 >> 2]; + var $call35 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $5, tempInt)); + var $call36 = _stat(STRING_TABLE.__str7 | 0, $s); + var $and38 = HEAP32[$st_mode$s2] & -512; + var $call39 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $and38, tempInt)); + for (var $$dest = $1$s2, $$stop = $$dest + 18; $$dest < $$stop; $$dest++) { + HEAP32[$$dest] = 0; + } + var $putchar1 = _putchar(10); + var $call41 = ___errno(); + HEAP32[$call41 >> 2] = 0; + HEAP8[$arrayidx43] = $conv42; + HEAP8[$arrayidx46] = $j_03 + 97 & 255; + var $call47 = _printf(STRING_TABLE.__str8 | 0, (tempInt = STACKTOP, STACKTOP += 8, HEAP32[tempInt >> 2] = $i_04, HEAP32[tempInt + 4 >> 2] = $j_03, tempInt)); + var $call48 = _open($0, $flags_2_or17, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = 511, tempInt)); + var $conv50 = ($call48 | 0) != -1 & 1; + var $call51 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $conv50, tempInt)); + var $call52 = ___errno(); + var $7 = HEAP32[$call52 >> 2]; + var $call53 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $7, tempInt)); + var $call55 = _stat($0, $s); + var $and57 = HEAP32[$st_mode$s2] & -512; + var $call58 = _printf(STRING_TABLE.__str4 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $and57, tempInt)); + for (var $$dest = $1$s2, $$stop = $$dest + 18; $$dest < $$stop; $$dest++) { + HEAP32[$$dest] = 0; + } + var $putchar2 = _putchar(10); + var $call60 = ___errno(); + HEAP32[$call60 >> 2] = 0; + var $inc = $j_03 + 1 | 0; + if (($inc | 0) == 16) { + break; + } + var $j_03 = $inc; + } + var $inc62 = $i_04 + 1 | 0; + if (($inc62 | 0) == 3) { + break; + } + var $i_04 = $inc62; + } + var $puts = _puts(STRING_TABLE._str | 0); + var $call65 = _creat(STRING_TABLE.__str10 | 0, 511); + var $conv67 = ($call65 | 0) != -1 & 1; + var $call68 = _printf(STRING_TABLE.__str1 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $conv67, tempInt)); + var $call69 = ___errno(); + var $9 = HEAP32[$call69 >> 2]; + var $call70 = _printf(STRING_TABLE.__str3 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $9, tempInt)); + STACKTOP = __stackBase__; + return 0; + return null; +} +function ex() { + var __stackBase__ = STACKTOP; + STACKTOP += 4; + var $e1 = __stackBase__; + var $puts = _puts(STRING_TABLE._str17 | 0); + var $x41 = $e1 | 0; + var $i_04 = 0; + while (1) { + var $i_04; + var $call1 = _printf(STRING_TABLE.__str15 | 0, (tempInt = STACKTOP, STACKTOP += 4, HEAP32[tempInt >> 2] = $i_04, tempInt)); + ((function() { + try { + __THREW__ = false; + return __Z5magici($i_04); + } catch (e) { + if (typeof e != "number") throw e; + if (ABORT) throw e; + __THREW__ = true; + return null; + } + }))(); + } +} +function switchey(x) { + var a = 5; + while (1) { + switch (x = f(x, a)) { + case 1: + g(a); + var b = x+1; + x--; + break; + case 2: + g(a*2); + var c = x+22; + var d = c+5; + x -= 20; + break; + default: + var c1 = x+22; + var d2 = c+5; + ch(c1, d2*c); + throw 99; + } + } + var aa = x+1; + p(a, aa); + var aaa = x+2; + pp(aaa); +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["test", "primes", "atomic", "fcntl_open", "ex", "switchey"] |