From aeb6fafbcbc87b699b75193b28eda6a0eb1073b9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 16 Aug 2014 22:01:01 -0400 Subject: Support meshes with no texture. * sly/mesh.scm (draw-mesh): Don't bind texture if there isn't one. --- sly/mesh.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sly/mesh.scm b/sly/mesh.scm index 76f0993..3855330 100644 --- a/sly/mesh.scm +++ b/sly/mesh.scm @@ -178,6 +178,12 @@ (%make-mesh vao (vector-length indices) shader texture))) (define (draw-mesh mesh uniforms) + (define (draw) + (glDrawElements (begin-mode triangles) + (mesh-length mesh) + (data-type unsigned-int) + %null-pointer)) + (with-shader-program (mesh-shader mesh) (for-each (lambda (uniform) (match uniform @@ -187,8 +193,6 @@ name value)))) uniforms) (with-vertex-array (mesh-vao mesh) - (with-texture (mesh-texture mesh) - (glDrawElements (begin-mode triangles) - (mesh-length mesh) - (data-type unsigned-int) - %null-pointer))))) + (if (texture? (mesh-texture mesh)) + (with-texture (mesh-texture mesh) (draw)) + (draw))))) -- cgit v1.2.3