Skip to content
Browse files

Add gl-extension check facility.

  • Loading branch information...
Shinmera committed Oct 7, 2019
1 parent af41fed commit 9b0faa09b32541fae6561ed3919e52a60ebc2b66
Showing with 19 additions and 2 deletions.
  1. +1 −0 context.lisp
  2. +3 −2 resources/framebuffer.lisp
  3. +15 −0 toolkit.lisp
@@ -111,6 +111,7 @@
(v:info :trial.context "Recreated context successfully.")
(make-current context)
(context-note-debug-info context)
(show context)))

(defmethod current-p ((context context) &optional (thread (bt:current-thread)))
@@ -64,8 +64,9 @@
(gl:read-buffer :none)))
(unless (and (width framebuffer) (height framebuffer))
(error "The framebuffer has no attachments and no default width and height set!"))
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-width (width framebuffer))
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-height (height framebuffer)))
(when-gl-extension :gl-arb-framebuffer-no-attachments
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-width (width framebuffer))
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-height (height framebuffer))))
(gl:bind-framebuffer :framebuffer 0)
(setf (data-pointer framebuffer) fbo)))))

@@ -675,3 +675,18 @@
(:signed :int)
(:unsigned :unsigned-int)
(:float :float)))))

(defvar *gl-extensions* ())

(defun cache-gl-extensions ()
(let ((*package* (find-package "KEYWORD")))
(setf *gl-extensions*
(loop for i from 0 below (gl:get* :num-extensions)
for name = (ignore-errors (gl:get-string-i :extensions i))
when name
collect (cffi:translate-name-from-foreign name *package*)))))

(defmacro when-gl-extension (extension &body body)
;; TODO: Optimise this by caching the test after first runtime.
`(when (find ,extension *gl-extensions*)

0 comments on commit 9b0faa0

Please sign in to comment.
You can’t perform that action at this time.