~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to src/library_glfw.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
      if (event.charCode) {
121
121
        var char = GLFW.getUnicodeChar(event.charCode);
122
122
        if (char !== null && GLFW.charFunc) {
123
 
          event.preventDefault();
124
123
          Runtime.dynCall('vii', GLFW.charFunc, [event.charCode, 1]);
125
124
        }
126
125
      }
130
129
      var key = GLFW.DOMToGLFWKeyCode(event.keyCode);
131
130
      if (key && GLFW.keyFunc) {
132
131
        GLFW.keys[key] = status;
133
 
        event.preventDefault();
134
132
        Runtime.dynCall('vii', GLFW.keyFunc, [key, status]);
135
133
      }
136
134
    },
137
135
 
138
136
    onKeydown: function(event) {
139
137
      GLFW.onKeyChanged(event, 1);//GLFW_PRESS
 
138
      // This logic comes directly from the sdl implementation. We cannot
 
139
      // call preventDefault on all keydown events otherwise onKeyPress will
 
140
      // not get called
 
141
      if (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */) {
 
142
        event.preventDefault();
 
143
      }
140
144
    },
141
145
 
142
146
    onKeyup: function(event) {
354
358
      throw "Invalid glfwOpenWindow mode.";
355
359
    }
356
360
 
357
 
    Module.ctx = Browser.createContext(Module['canvas'], true, true);
 
361
    var contextAttributes = {
 
362
      antialias: (GLFW.params[0x00020013] > 1), //GLFW_FSAA_SAMPLES
 
363
      depth: (GLFW.params[0x00020009] > 0), //GLFW_DEPTH_BITS
 
364
      stencil: (GLFW.params[0x0002000A] > 0) //GLFW_STENCIL_BITS
 
365
    }
 
366
    Module.ctx = Browser.createContext(Module['canvas'], true, true, contextAttributes);
358
367
    return 1; //GL_TRUE
359
368
  },
360
369