diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2012-03-27 20:34:11 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2012-03-27 20:34:11 -0400 |
commit | 053a246c4c016dd635b0bb4308c9378f2ead7bbd (patch) | |
tree | 29a59b68ef655f7d289922cfa495ba03c4e19dea /src | |
parent | fa1693c22354607b9714f046b3eed5dcf4f58a4c (diff) |
Add glutMotionFunc()
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 44b1612c..9fa1cd66 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -438,16 +438,20 @@ var LibraryGLUT = { specialFunc: null, specialUpFunc: null, reshapeFunc: null, + motionFunc: null, passiveMotionFunc: null, mouseFunc: null, lastX: 0, lastY: 0, + buttons: 0, onMousemove: function(event) { GLUT.lastX = event['clientX']; GLUT.lastY = event['clientY']; - if (GLUT.passiveMotionFunc) { + if (GLUT.buttons == 0 && GLUT.passiveMotionFunc) { FUNCTION_TABLE[GLUT.passiveMotionFunc](GLUT.lastX, GLUT.lastY); + } else if (GLUT.buttons != 0 && GLUT.motionFunc) { + FUNCTION_TABLE[GLUT.motionFunc](GLUT.lastX, GLUT.lastY); } }, @@ -506,6 +510,7 @@ var LibraryGLUT = { onMouseButtonDown: function(event){ GLUT.lastX = event['clientX']; GLUT.lastY = event['clientY']; + GLUT.buttons |= (1 << event['button']); if(GLUT.mouseFunc){ FUNCTION_TABLE[GLUT.mouseFunc](event['button'], 0/*GLUT_DOWN*/, GLUT.lastX, GLUT.lastY); @@ -515,6 +520,7 @@ var LibraryGLUT = { onMouseButtonUp: function(event){ GLUT.lastX = event['clientX']; GLUT.lastY = event['clientY']; + GLUT.buttons &= ~(1 << event['button']); if(GLUT.mouseFunc) { FUNCTION_TABLE[GLUT.mouseFunc](event['button'], 1/*GLUT_UP*/, GLUT.lastX, GLUT.lastY); @@ -596,6 +602,10 @@ var LibraryGLUT = { GLUT.reshapeFunc = func; }, + glutMotionFunc: function(func) { + GLUT.motionFunc = func; + }, + glutPassiveMotionFunc: function(func) { GLUT.passiveMotionFunc = func; }, |