diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-11-09 19:58:12 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-11-09 19:58:12 -0500 |
commit | 18b48eaa3fcee9bc8018348a93391fef9e68a630 (patch) | |
tree | 97ef22b70c9a783db4a0a74cfafba1eba83ea198 | |
parent | f14a257d9c4be96d547d43860c7247ea3ff31cc3 (diff) |
render: mesh: Clean up style a bit.
-rw-r--r-- | sly/render/mesh.scm | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/sly/render/mesh.scm b/sly/render/mesh.scm index 69f89ce..04a8ab2 100644 --- a/sly/render/mesh.scm +++ b/sly/render/mesh.scm @@ -22,12 +22,13 @@ ;;; Code: (define-module (sly render mesh) - #:use-module (system foreign) + #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (rnrs bytevectors) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-43) - #:use-module (rnrs bytevectors) + #:use-module (system foreign) #:use-module (gl) #:use-module (gl low-level) #:use-module (sly utils) @@ -36,14 +37,31 @@ #:use-module (sly render color) #:use-module (sly render shader) #:export (make-vertex-buffer - bytevector->vertex-buffer vector->vertex-buffer - vertex-buffer? index-buffer? - vertex-buffer-id vertex-buffer-type vertex-buffer-usage - vertex-buffer-data vertex-buffer-length - make-mesh build-mesh null-mesh + bytevector->vertex-buffer + vector->vertex-buffer + vertex-buffer? + index-buffer? + vertex-buffer-id + vertex-buffer-type + vertex-buffer-usage + vertex-buffer-data + vertex-buffer-length + vertex-buffer-attribute-size + apply-vertex-buffer + + generate-vertex-array + vertex-attrib-pointer + + make-mesh + build-mesh + null-mesh mesh? - mesh-id mesh-length mesh-ref - apply-mesh with-mesh)) + mesh-id + mesh-vertex-buffers + mesh-length + mesh-ref + apply-mesh + with-mesh)) ;;; ;;; Vertex Buffer @@ -70,7 +88,7 @@ (glGenBuffers 1 (bytevector->pointer bv)) (u32vector-ref bv 0))) -(define (bind-vertex-buffer vbo) +(define (apply-vertex-buffer vbo) (glBindBuffer (vertex-buffer-target vbo) (vertex-buffer-id vbo))) @@ -197,17 +215,17 @@ ;;; (define-record-type <mesh> - (%make-mesh id length vbos) + (%make-mesh id length vertex-buffers) mesh? (id mesh-id) (length mesh-length) - (vbos mesh-vbos)) + (vertex-buffers mesh-vertex-buffers)) (define-guardian mesh-guardian (lambda (mesh) ;; Delete vertex array and vertex buffers. (glDeleteVertexArrays 1 (u32vector (mesh-id mesh))) - (let ((buffers (mesh-vbos mesh))) + (let ((buffers (mesh-vertex-buffers mesh))) (glDeleteBuffers (length buffers) (list->u32vector (map (match-lambda @@ -247,7 +265,7 @@ (with-mesh mesh (vertex-attrib-pointer vertex-position-location position-buffer) (vertex-attrib-pointer vertex-texture-location texture-buffer) - (bind-vertex-buffer index-buffer)) + (apply-vertex-buffer index-buffer)) (mesh-guardian mesh) mesh)) @@ -258,4 +276,4 @@ (make-mesh index-buffer position-buffer texture-buffer))) (define (mesh-ref mesh key) - (assq-ref (mesh-vbos mesh) key)) + (assq-ref (mesh-vertex-buffers mesh) key)) |