• Context.js

  • ¶
    var sys = require('pex-sys');
    
    var currentGLContext = null;
    
    var Context = {
    };
    
    Object.defineProperty(Context, 'currentContext', {
      get: function() { 
        if (currentGLContext) {
          return currentGLContext;
        }
        else if (sys.Window.currentWindow) {
          return sys.Window.currentWindow.gl;
        }
        else {
          return null;
        }
      },
      set: function(gl) {
        currentGLContext = gl;
      },
      enumerable: true,
      configurable: true
    });
    
    module.exports = Context;