 (declare frag-shader-picker)
 
 (defn create-shader [gl]
+  ;; make sure that needed extensions are addeded
   (let [vs (shaders/create-shader gl shader/vertex-shader vertex-shader)
-        fs (shaders/create-shader gl shader/fragment-shader frag-shader)]
+        fs (shaders/create-shader gl shader/fragment-shader
+                                  (if (.getExtension gl "EXT_frag_depth")
+                                    (str "#define have_frag_depth\n\n" frag-shader)
+                                    frag-shader))]
     (shaders/create-program gl vs fs)))
 
 


(def frag-shader
  "
  precision mediump float;

  uniform vec4 planes[6];

          }
      }


      float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0);
  	  float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0);
      float c = 1.0 - (a + b);

   	  if(c < 0.0){
   	      discard;
   	  }      
#if defined have_frag_depth
      gl_FragDepthEXT = gl_FragCoord.z + 0.002*(1.0-pow(c, 1.0)) * gl_FragCoord.w;
#endif
      gl_FragColor = vec4(mix(out_color, out_intensity, intensityBlend), 1.0);
  }")

