title: Calling context with WebGL and CoffeeScript
body: <p>I think what Im asking is impossible but I'm using Coffeescript to create a simple WebGL Library. Im looking at textures and shaders and I have the following setup. In my example file I have this:</p>
  
  <pre><code>cgl = new CoffeeGL.App('webgl-canvas')
  
  shader = new CoffeeGL.Shader.Basic(cgl).bind()
  
  cgl.drawLoop = () -&gt;
  
    @gl.clearColor(0.15, 0.15, 0.15, 1.0)
    @gl.clear(@gl.COLOR_BUFFER_BIT | @gl.DEPTH_BUFFER_BIT)
  
    @updateCamera(c)
  
    @draw(n0) if n0?
  </code></pre>
  
  <p>Take a look at the Shader. It is passed an App. This App class is basically, an object that deals with the context. The GL context, the canvas and all of that is encapsulated nicely in a class. As a shader needs context throughout its life (same with textures and geometry that has been sent to the graphics card) it is given a context when it is created.</p>
  
  <p>This strikes me as not that elegant. Is it possible to create something like</p>
  
  <pre><code>cgl = new CoffeeGL.App('webgl-canvas')
  
  cgl.init = () -&gt;
  
      shader = new CoffeeGL.Shader.Basic().bind()
  
  cgl.drawLoop = () -&gt;
  
    @gl.clearColor(0.15, 0.15, 0.15, 1.0)
    @gl.clear(@gl.COLOR_BUFFER_BIT | @gl.DEPTH_BUFFER_BIT)
  
    @updateCamera(c)
  
    @draw(n0) if n0?
  </code></pre>
  
  <p>Where the context is actually gleened from that fact that its the context that is calling the constructor (or the compile or bind - doesnt have to be a contructor per-se)</p>
  
  <p>I figure, since Coffeescript (especially if you are using node.js to combine your scripts) wraps everything in a closure, that this is just not possible.</p>