diff options
author | David Thompson <dthompson2@worcester.edu> | 2020-07-12 08:19:45 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2020-08-24 15:04:51 -0400 |
commit | 1967f72de20cc0c176375b4a1b704b322ef7dcd1 (patch) | |
tree | 52ce29506beca39970b0d576c32e1a2c6d208981 /chickadee/render/gpu.scm | |
parent | 89563f5a727386da2175394813ee09601e7220e8 (diff) |
render: gpu: Query GL context for GL and GLSL versions.
Diffstat (limited to 'chickadee/render/gpu.scm')
-rw-r--r-- | chickadee/render/gpu.scm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/chickadee/render/gpu.scm b/chickadee/render/gpu.scm index 66510fc..554e263 100644 --- a/chickadee/render/gpu.scm +++ b/chickadee/render/gpu.scm @@ -16,8 +16,11 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee render gpu) + #:use-module (chickadee render gl) + #:use-module (gl enums) #:use-module (oop goops) #:use-module (srfi srfi-9) + #:use-module (system foreign) #:export (make-gpu-state gpu-state-ref gpu-state-set! @@ -30,6 +33,8 @@ current-gpu gpu? gpu-gl-context + gpu-gl-version + gpu-glsl-version gpu-blend-mode gpu-depth-test gpu-framebuffer @@ -91,6 +96,8 @@ from the GPU's memory." (define-record-type <gpu> (%make-gpu gl-context + gl-version + glsl-version blend-mode depth-test framebuffer @@ -101,6 +108,8 @@ from the GPU's memory." viewport) gpu? (gl-context gpu-gl-context) + (gl-version gpu-gl-version) + (glsl-version gpu-glsl-version) (blend-mode %gpu-blend-mode) (depth-test %gpu-depth-test) (framebuffer %gpu-framebuffer) @@ -113,6 +122,8 @@ from the GPU's memory." (define current-gpu (make-parameter #f)) (define (make-gpu gl-context) + (define (extract-version attr) + (car (string-split (pointer->string (gl-get-string attr)) #\space))) (let ((textures (make-vector 32)) ;; Lazily resolve bindings to avoid circular dependencies. (blend-module (resolve-interface '(chickadee render blend))) @@ -120,7 +131,9 @@ from the GPU's memory." (framebuffer-module (resolve-interface '(chickadee render framebuffer))) (shader-module (resolve-interface '(chickadee render shader))) (texture-module (resolve-interface '(chickadee render texture))) - (viewport-module (resolve-interface '(chickadee render viewport)))) + (viewport-module (resolve-interface '(chickadee render viewport))) + (gl-version (extract-version (string-name version))) + (glsl-version (extract-version (version-2-0 shading-language-version)))) ;; Create state for 32 texture units. (let loop ((i 0)) (when (< i 32) @@ -131,7 +144,8 @@ from the GPU's memory." (module-ref texture-module 'null-texture)))) (loop (+ i 1)))) (%make-gpu gl-context - ;; Use @ and @@ to avoid circular module dependencies. + gl-version + glsl-version (make-gpu-state (module-ref blend-module 'apply-blend-mode) 'replace) (make-gpu-state (module-ref blend-module 'apply-depth-test) |