Add glsl version directive to the shader according to the supported version

This commit is contained in:
Renaud Casenave-Péré 2015-04-04 23:45:23 +02:00
parent a7fd8e4842
commit 8b96f8166f

View file

@ -28,6 +28,10 @@
"Configure the verbosity of the compiler. "Configure the verbosity of the compiler.
if non-nil, the dsl will be printed in comments together with the glsl code.") if non-nil, the dsl will be printed in comments together with the glsl code.")
(defvar *version-profiles* '(("1.30" . "#version 130
#extension ARB_explicit_attrib_location : require")
("3.30" . "#version 330 core")))
(defvar *glsl-symbols* '(gl-position "gl_Position") (defvar *glsl-symbols* '(gl-position "gl_Position")
"Keep a table of reserved glsl symbols.") "Keep a table of reserved glsl symbols.")
@ -113,6 +117,7 @@ the forms comprised of these keywords will be printed in comments."
(defun glsl-compile (lambda-list body) (defun glsl-compile (lambda-list body)
(format nil "~a~%~%~{~a~}~%void main ()~%{~%~a}~%" (format nil "~a~%~%~{~a~}~%void main ()~%{~%~a}~%"
(cdr (assoc gl-utils:*glsl-version* *version-profiles* :test #'equal))
(mapcar #'handle-preamble lambda-list) (mapcar #'handle-preamble lambda-list)
(let ((*current-indent* 2)) (let ((*current-indent* 2))
(walk `(progn ,body) *form-handlers* #'default-handler *env*)))) (walk (cons 'progn body) *form-handlers* #'default-handler *env*))))