               RenderingHints)
     (org.lwjgl BufferUtils LWJGLUtil)
     (java.nio FloatBuffer ByteBuffer)
+    (java.nio.charset Charset)
     (org.lwjgl.opengl Display ContextAttribs
-                      PixelFormat DisplayMode
-                      GL11 GL12 GL13 GL15 GL20)
+                      PixelFormat DisplayMode Util
+                      GL11 GL12 GL13 GL15 GL20 GL30)
     (org.lwjgl.input Keyboard)
     (org.lwjgl.util.vector Matrix4f Vector3f)
     (java.io File)


(defn- init-display [title screen-width screen-height]
  (let [pixel-format       (PixelFormat.)
        context-attributes (ContextAttribs. 2 1)
        icon-image         (ImageIO/read (File. "images/icon.png"))
        icon-image-16      (scale-image icon-image 16,  -1)
        icon-image-32      (scale-image icon-image 32,  -1)

    "NONE"
    (.getName #^Field (some
                       #(if (= enum-value (.get #^Field % nil)) % nil)
                       (mapcat get-fields [GL11 GL12 GL13 GL15 GL20 GL30])))))

(defn- except-gl-errors
  [msg]
  (let [error (GL11/glGetError)
        error-string (str "OpenGL Error(" error "):"
                          (gl-enum-name error) ": " msg " - "
                          (Util/translateGLErrorString error))]
    (if (not (zero? error))
      (throw (Exception. error-string)))))

