diff options
-rw-r--r-- | chickadee/render/shader.scm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/chickadee/render/shader.scm b/chickadee/render/shader.scm index 9d5bc51..5442097 100644 --- a/chickadee/render/shader.scm +++ b/chickadee/render/shader.scm @@ -532,13 +532,23 @@ them into a GPU shader program." ((= type (version-2-0 sampler-2d)) sampler-2d) (else (error "unsupported OpenGL type" type)))) + (define (camel->snake str) + (list->string + (let loop ((i 0)) + (if (< i (string-length str)) + (let ((c (string-ref str i))) + (if (char-set-contains? char-set:upper-case c) + (cons* #\- (char-downcase c) (loop (+ i 1))) + (cons c (loop (+ i 1))))) + '())))) (define (uniform-name->symbol name) ;; array uniform names have a suffix like "[0]" that needs to be ;; removed to produce the actual uniform variable name that our ;; shader interface will recognize. (string->symbol (let ((i (string-contains name "["))) - (if i (substring name 0 i) name)))) + (camel->snake + (if i (substring name 0 i) name))))) (define (parse-array-index name) (let* ((start (string-contains name "[")) (end (- (string-length name) 1))) |