anchor.diff:      (:accum-green-bits :integer 1)
       (:accum-blue-bits :integer 1)
       (:accum-alpha-bits :integer 1)
  +    (:implementation-color-read-type :enum 1)
  +    (:implementation-color-read-format :enum 1)
  +    ;; 6.75
       (:list-base :integer 1)
       (:list-index :integer 1)
       (:list-mode :enum 1)
  
positive.code:     (:shading-language-version :string 1)
      (:vendor :string 1)
      (:version :string 1)
      (:max-texture-units :integer 1)
      (:max-vertex-attribs :integer 1)
      (:max-vertex-uniform-components :integer 1)
      (:max-varying-components :integer 1)
      (:max-combined-texture-image-units :integer 1)
      (:max-vertex-texture-image-units :integer 1)
      (:max-texture-image-units :integer 1)
      (:max-texture-coords :integer 1)
      (:max-fragment-uniform-components :integer 1)
      (:min-program-texel-offset :integer 1)
      (:max-program-texel-offset :integer 1)
      (:aux-buffers :integer 1)
      (:max-draw-buffers :integer 1)
      (:rgba-mode :boolean 1)
      (:index-mode :boolean 1)
      (:doublebuffer :boolean 1)
      (:stereo :boolean 1)
      (:sample-buffers :integer 1)
      (:samples :integer 1)
      (:max-color-attachments :integer 1)
      (:max-samples :integer 1)
      (:red-bits :integer 1)
      (:green-bits :integer 1)
      (:blue-bits :integer 1)
  
negative.code:         (map 'vector #'try-to-parse-enum result)
          (try-to-parse-enum result))))
  
  (defun get-enum-i (value index &optional (count (query-enum-size value)))
    (let ((result (get-integer-i value index count)))
      (if (vectorp result)
          (map 'vector #'try-to-parse-enum result)
          (try-to-parse-enum result))))
  
  (defun get-vertex-attrib-enum (index pname
                                 &optional (count (query-enum-size pname)))
    (let ((result (get-vertex-attrib-integer index pname count)))
      (if (vectorp result)
          (map 'vector #'try-to-parse-enum result)
          (try-to-parse-enum result))))
  
  
  (import-export %gl:get-string)
  (import-export %gl:get-string-i)
  
  (defun get-clip-plane (plane)
    (with-foreign-object (buf '%gl:double 4)
      (%gl:get-clip-plane plane buf)
      (let ((result (make-array 4 :element-type 'double-float)))
        (dotimes (i 4)
          (setf (aref result i) (mem-aref buf '%gl:double i)))
        result)))
  
  (defun get-multisample (pname index)
    (with-foreign-object (buf '%gl:float 2)
      (%gl:get-multisample-fv pname index buf)
      (let ((result (make-array 2 :element-type 'single-float)))
        (dotimes (i 2)
          (setf (aref result i) (mem-aref buf '%gl:float i)))
        result)))
  
  
  ;;; generic get that handles type and number of values for known enums
  ;;; fixme: better name?
  (defun get* (name &optional (index 0 indexp))
    (destructuring-bind (enum type size &optional max)
        (assoc name *query-enum-sizes*)
      (declare (ignore enum max))
      (when (keywordp size)
        (setf size (get-integer size 1)))
      (when (plusp size)
        (ecase type
          (:boolean (get-boolean name size))
          (:integer (get-integer name size))
          (:integer64 (get-integer-64 name size))
          (:float (get-float name size))
          (:enable (enabledp name))
          (:enum (get-enum name size))
          (:string (get-string name))
          (:pointer (get-pointer name size))
          (:error (get-error))
          (:clip-plane (get-clip-plane name))
          ;; queries that can be used indexed or unindexed
          ;; (indexed version usually needs newer GL version, so
          ;;  don't want to just call the indexed query with 0
          ;;  when no index was provided)
          (:integer/i (if indexp
                          (get-integer-i name index size)
                          (get-integer name size)))
          (:integer64/i (if indexp
                            (get-integer-64-i name index size)
                            (get-integer-64 name size)))
          (:float/i (if indexp
                        (get-float-i name index size)
                        (get-float name size)))
          (:enable/i (if indexp
                         (enabledp-i name index)
                         (enabledp name)))
          (:enum/i (if indexp
                       (get-enum-i name index size)
                       (get-enum name size)))
          (:boolean/i (if indexp
                          (get-boolean-i name index size)
                          (get-boolean name size)))
          (:extensions/i (if indexp
                             (get-string-i name index)
                             (get-string name)))
          (:draw-buffer/i
           (if indexp
               (get-enum (+ (foreign-enum-value '%gl:enum :draw-buffer0) index)
                         size)
               (get-enum name size)))
          ;; queries that require an index (but default to 0)
          (:integer-i (get-integer-i name index size))
          (:integer64-i (get-integer-64-i name index size))
          (:enum-i (get-enum-i name index size))
          (:boolean-i (get-boolean-i name index size))
          (:string-i (get-string-i name index))
          (:multisample-i (get-multisample name index))
          (:vertex-attrib-integer (get-vertex-attrib-integer index name size))
          (:vertex-attrib-enum (get-vertex-attrib-enum index name size))
          (:vertex-attrib-boolean (get-vertex-attrib-boolean index name size))
          (:vertex-attrib-pointer (get-vertex-attrib-pointer index name size))
          (:vertex-attrib-float (get-vertex-attrib-float index name size))
  
          ;; some fake 'indexed' queries for queries that usually use a set of
          ;; :foo0 .. :fooN enums, which can also be used as :foo0 + N
          (:clip-plane-i
           (get-clip-plane (+ (foreign-enum-value '%gl:enum :clip-plane0)
                              index)))
          (:clip-distance-i
           (enabledp (+ (foreign-enum-value '%gl:enum :clip-distance0) index))
           size)
          (:light-enable-i (enabledp (+ (foreign-enum-value '%gl:enum :light0)
                                        index))
                           size)))))
  
  ;;; compiler macro to open code values for enums known at compile time
  (define-compiler-macro get* (&whole form name &optional (index 0 indexp))
    (if (and (constantp name) (keywordp name)
             (assoc name *query-enum-sizes*))
        (destructuring-bind (enum type size &optional max)
            (assoc name *query-enum-sizes*)
          (declare (ignore enum max))
          `(let ((size ,(if (keywordp count) `(get-integer ,count 1) count)))
             (declare (ignorable size))
             ;; fixme: get rid of this duplicated code somehow?
             ,(ecase type
                (:boolean `(get-boolean ,name size))
                (:integer `(get-integer ,name size))
                (:integer64 `(get-integer-64 ,name size))
                (:float `(get-float ,name size))
                (:enable `(enabledp ,name))
                (:enum `(get-enum ,name size))
                (:string `(get-string ,name))
                (:pointer `(get-pointer ,name size))
                (:error `(get-error))
                (:clip-plane `(get-clip-plane ,name))
                ;; queries that can be used indexed or unindexed
                ;; (indexed version usually needs newer GL version, so
                ;;  don't want to just call the indexed query with 0
                ;;  when no index was provided)
                (:integer/i (if indexp
                                `(get-integer-i name ,index size)
                                `(get-integer ,name size)))
                (:integer64/i (if indexp
                                  `(get-integer-64-i ,name ,index size)
                                  `(get-integer-64 ,name size)))
                (:float/i (if indexp
                              `(get-float-i ,name ,index size)
                              `(get-float ,name size)))
                (:enable/i (if indexp
                               `(enabledp-i ,name ,index)
                               `(enabledp ,name)))
                (:enum/i (if indexp
                             `(get-enum-i ,name ,index size)
                             `(get-enum ,name size)))
                (:boolean/i (if indexp
                                `(get-boolean-i ,name ,index size)
                                `(get-boolean ,name size)))
                (:extensions/i (if indexp
                                   `(get-string-i ,name ,index)
                                   `(get-string ,name)))
                (:draw-buffer/i
                 (if indexp
                     `(get-enum `(+ ,(foreign-enum-value '%gl:enum :draw-buffer0) index)
                                size)
                     `(get-enum ,name size)))
                ;; queries that require an index (but default to 0)
                (:integer-i `(get-integer-i ,name ,index size))
                (:integer64-i `(get-integer-64-i ,name ,index size))
                (:enum-i `(get-enum-i ,name ,index size))
                (:boolean-i `(get-boolean-i ,name ,index size))
                (:string-i `(get-string-i ,name ,index))
                (:multisample-i `(get-multisample ,name ,index))
                (:vertex-attrib-integer `(get-vertex-attrib-integer ,index ,name size))
                (:vertex-attrib-enum `(get-vertex-attrib-enum ,index ,name size))
                (:vertex-attrib-boolean `(get-vertex-attrib-boolean ,index ,name size))
                (:vertex-attrib-pointer `(get-vertex-attrib-pointer ,index ,name size))
                (:vertex-attrib-float `(get-vertex-attrib-float ,index ,name size))
  
                ;; some fake 'indexed' queries for queries that usually use a set of
                ;; :foo0 .. :fooN enums, which can also be used as :foo0 + N
                (:clip-plane-i
                 `(get-clip-plane (+ ,(foreign-enum-value '%gl:enum :clip-plane0)
                                     ,index)))
                (:clip-distance-i
                 `(enabledp (+ ,(foreign-enum-value '%gl:enum :clip-distance0)
                               ,index))
                 size)
                (:light-enable-i `(enabledp (+ ,(foreign-enum-value '%gl:enum :light0)
                                               ,index))
                 size))))
        form))
  
  
  