aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-08 16:08:19 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-08 16:08:19 -0700
commita9feb9802616b71d6f334620fdb2487bb64676f3 (patch)
tree07b6aaff71ef7656beea77b38c3f7e2bf6e958cb
parent52fc56f0c99a3e87ae38da19b903630dc4262be9 (diff)
beginning of SDL_GL_GetProcAddress
-rw-r--r--src/library_gl.js15
-rw-r--r--src/library_sdl.js18
-rw-r--r--src/runtime.js7
3 files changed, 34 insertions, 6 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 4b7e17c8..a54b3650 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -56,6 +56,21 @@ var LibraryGL = {
} while (true);
return false;
},
+
+ getProcAddress: function(original) {
+ // remove 'gl' and initial caps
+ var small = original.substr(2);
+ small = small[0].toLowerCase() + small.substr(1);
+ console.log('SDL_GL_GetProcAddress: ' + original);
+ var func = Module.ctx[small];
+ if (!func) {
+ console.log('WARNING: getProcAddress failed for ' + original + ' ==> ' + small);
+ return 0;
+ }
+ return Runtime.addFunction(function() {
+ return func.apply(Module.ctx, arguments);
+ });
+ }
},
glGetString: function(name_) {
diff --git a/src/library_sdl.js b/src/library_sdl.js
index e44795d2..672619ad 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -476,10 +476,6 @@ mergeInto(LibraryManager.library, {
return -1; // -1 == all modes are ok. TODO
},
- SDL_GL_SetAttribute: function(attr, value) {
- // TODO
- },
-
SDL_SetVideoMode: function(width, height, depth, flags) {
['mousedown', 'mouseup', 'mousemove'].forEach(function(event) {
Module['canvas'].addEventListener(event, SDL.receiveEvent, true);
@@ -682,8 +678,6 @@ mergeInto(LibraryManager.library, {
SDL.surfaces[surf].alpha = alpha;
},
- SDL_GL_SwapBuffers: function() {},
-
SDL_GetTicks: function() {
return Math.floor(Date.now() - SDL.startTime);
},
@@ -977,6 +971,18 @@ mergeInto(LibraryManager.library, {
_boxRGBA(surf, x1, y1, x1, y1, r, g, b, a);
},
+ // GL
+
+ SDL_GL_SetAttribute: function(attr, value) {
+ console.log('TODO: SDL_GL_SetAttribute');
+ },
+
+ SDL_GL_GetProcAddress: function(name_) {
+ return GL.getProcAddress(Pointer_stringify(name_));
+ },
+
+ SDL_GL_SwapBuffers: function() {},
+
// Misc
SDL_InitSubSystem: function(flags) { return 0 },
diff --git a/src/runtime.js b/src/runtime.js
index 852d08d8..0e4b7b2d 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -306,6 +306,13 @@ var Runtime = {
});
}
return ret;
+ },
+
+ addFunction: function(func) {
+ var ret = FUNCTION_TABLE.length;
+ FUNCTION_TABLE.push(func);
+ FUNCTION_TABLE.push(0);
+ return ret;
}
};