     unless browserSupportsRequiredFeatures()
       throw new Error "This browser does not support WebGL"
 
+    @_contextRequiresSetup = true
+    @_fragmentShaderIsDirty = false
+    @_vertexShaderIsDirty = false
+    @_geometryIsDirty = false
+    @_renderIsDirty = false
+
     # The number of vertices drawn
     @vertexCount = 4
 
+    # GLSL source code for the fragment shader
     @fragmentShaderSource = DEFAULT_FSHADER_SOURCE
+
+    # GLSL source code for the vertex shader
     @vertexShaderSource = DEFAULT_VSHADER_SOURCE
 
     @canvas.addEventListener "webglcontextcreationerror", (event) =>
       @trace.error event.statusMessage
 
-    # @type WebGLRenderingContext
-    @gl = null
-
     @_createContext()
+
+    unless @gl
+      throw new Error("Could not create WebGL context for canvas")
 
     # A string mode anme as used by WebGL's drawArrays method, i.e. one of:
     # POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP or TRIANGLE_FAN


  _setVertexShaderSource: (value) ->
    @_vertexShaderSource = value
    @_scheduleFrame()



    gl.enableVertexAttribArray VERTEX_INDEX_ATTRIBUTE_LOCATION


  _render: ->
    gl = @gl

