 (defn mat-identity
   "Creates an identity matrix."
   [size]
-  ((aget goog.math.Matrix "createIdentityMatrix") size))
+  ((.-createIdentityMatrix goog.math.Matrix) size))
 
 (defn mat-translation
   "Returns a 4x4 matrix representing a translation."

  (let [tex (.createTexture gl)
        image (js/Image.)
        atm (atom false)]
    (aset image "src" url)
    (aset image "onload" (fn []
                             (handle-tex-loaded image tex)
                             (reset! atm true)))
    [tex atm]))

(defn clear!
  "Clears the gl context."
  []
  (.clear gl (bit-or (.-COLOR_BUFFER_BIT gl) (.-DEPTH_BUFFER_BIT gl))))

;;;;; TEXTURE FUNCTIONS ;;;;;

(defn- handle-tex-loaded
  [image tex]
  (.bindTexture gl (.-TEXTURE_2D gl) tex)
  (.texImage2D gl (.-TEXTURE_2D gl) 0 (.-RGBA gl) (.-RGBA gl) (.-UNSIGNED_BYTE gl) image)
  (.texParameteri gl (.-TEXTURE_2D gl) (.-TEXTURE_MAG_FILTER gl) (.-LINEAR gl))
  (.texParameteri gl (.-TEXTURE_2D gl) (.-TEXTURE_MIN_FILTER gl) (.-LINEAR_MIPMAP_NEAREST gl))
  (.generateMipmap gl (.-TEXTURE_2D gl))
  (.bindTexture gl (.-TEXTURE_2D gl) nil))

(defn- is-tex-loaded?
  [[tex atm]]
