aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-11 13:34:08 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-11 13:45:21 -0700
commit332e7a0ffb65a4b86efa8bb2d10110515feb2d4e (patch)
treec74ed11a8e883a700519dabd3c4cb200ac9cf9b5 /src
parent36b98fa522ef3946168379f5b555fa7aabdbabfe (diff)
include glMatrix when glBegin is used
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js6
-rw-r--r--src/library_gl.js7
2 files changed, 12 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 8e688d8d..904517e1 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -375,11 +375,15 @@ function JSify(data, functionsOnly, givenFunctions) {
processItem: function(item) {
function addFromLibrary(ident) {
if (ident in addedLibraryItems) return '';
+ addedLibraryItems[ident] = true;
+
+ // dependencies can be JS functions, which we just run
+ if (typeof ident == 'function') return ident();
+
// Don't replace implemented functions with library ones (which can happen when we add dependencies).
// Note: We don't return the dependencies here. Be careful not to end up where this matters
if (('_' + ident) in Functions.implementedFunctions) return '';
- addedLibraryItems[ident] = true;
var snippet = LibraryManager.library[ident];
var redirectedIdent = null;
var deps = LibraryManager.library[ident + '__deps'] || [];
diff --git a/src/library_gl.js b/src/library_gl.js
index dbde945c..3c33ec2c 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -14,6 +14,8 @@ var LibraryGL = {
uniforms: {},
shaders: {},
+ matrix: {},
+
// Linear lookup in one of the tables (buffers, programs, etc.). TODO: consider using a weakmap to make this faster, if it matters
scan: function(table, object) {
for (var item in table) {
@@ -834,6 +836,11 @@ var LibraryGL = {
}
return Runtime.addFunction(func);
}
+ },
+
+ glBegin__deps: ['$GL', function() { return 'GL.matrix.lib = ' + read('gl-matrix.js') }],
+ glBegin: function() {
+ Module.print('TODO');
}
};