diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2012-04-04 19:02:12 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2012-04-04 19:02:12 -0400 |
commit | 4d5959797f43380b7c5bd9a542a64cf8e9f23742 (patch) | |
tree | db88095f130f833c2b17301df1ab243b489ac706 /src/library_glut.js | |
parent | 109f8aa1e4b6247bb7dd2bd6559283ee4c6eb909 (diff) |
More GLUT love
Diffstat (limited to 'src/library_glut.js')
-rw-r--r-- | src/library_glut.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/library_glut.js b/src/library_glut.js index 30d27d17..c81a705f 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -15,6 +15,8 @@ var LibraryGLUT = { lastY: 0, buttons: 0, modifiers: 0, + initWindowWidth: 256, + initWindowHeight: 256, savePosition: function(event) { /* TODO maybe loop here ala http://www.quirksmode.org/js/findpos.html */ @@ -189,15 +191,32 @@ var LibraryGLUT = { }, glutInitWindowSize: function(width, height) { - Module['canvas'].width = width; - Module['canvas'].height = height; + Module['canvas'].width = GLUT.initWindowWidth = width; + Module['canvas'].height = GLUT.initWindowHeight = height; }, glutGet: function(type) { switch (type) { + case 100: /* GLUT_WINDOW_X */ + return 0; /* TODO */ + case 101: /* GLUT_WINDOW_Y */ + return 0; /* TODO */ + case 102: /* GLUT_WINDOW_WIDTH */ + return Module['canvas'].width; + case 103: /* GLUT_WINDOW_HEIGHT */ + return Module['canvas'].height; + case 500: /* GLUT_INIT_WINDOW_X */ + return 0; /* TODO */ + case 501: /* GLUT_INIT_WINDOW_Y */ + return 0; /* TODO */ + case 502: /* GLUT_INIT_WINDOW_WIDTH */ + return GLUT.initWindowWidth; + case 503: /* GLUT_INIT_WINDOW_HEIGHT */ + return GLUT.initWindowHeight; case 700: /* GLUT_ELAPSED_TIME */ var now = Date.now(); return now - GLUT.initTime; + default: throw "glutGet(" + type + ") not implemented yet"; } @@ -308,6 +327,16 @@ var LibraryGLUT = { return 1; }, + glutReshapeWindow: function(width, height) { + Module['canvas'].width = width; + Module['canvas'].height = height; + if (GLUT.reshapeFunc) { + FUNCTION_TABLE[GLUT.reshapeFunc](width, height); + } + }, + + glutPositionWindow: function(x, y) {/* TODO */}, + glutInitDisplayMode: function(mode) {}, glutSwapBuffers: function() {}, @@ -344,10 +373,7 @@ var LibraryGLUT = { window.removeEventListener("mouseup", GLUT.onMouseButtonUp, true); }); - if (GLUT.reshapeFunc) { - FUNCTION_TABLE[GLUT.reshapeFunc](Module['canvas'].width, - Module['canvas'].height); - } + _glutReshapeWindow(Module['canvas'].width, Module['canvas'].height); _glutPostRedisplay(); throw 'GLUT mainloop should never return'; }, |