;; where texture is expected to be a CUBE texture
(bind-func shader_update_envmap
(lambda (shader:ShaderProgram* textureUnit texture:Texture*)
(if (or (null? texture) (< (id texture) 1))
(begin
(glUniform1i (glGetUniformLocation (id shader) "isEnvMapped") 0)
(glUniform1f (glGetUniformLocation (id shader) "envMapWeight") ENV_MAP_WEIGHT)
(glUniform1i (glGetUniformLocation (id shader) "envMap") textureUnit)
void)
(begin
(bind_cube texture textureUnit)
(glUniform1i (glGetUniformLocation (id shader) "isEnvMapped") 1)
(glUniform1f (glGetUniformLocation (id shader) "envMapWeight") ENV_MAP_WEIGHT)
(glUniform1i (glGetUniformLocation (id shader) "envMap") textureUnit)
void))
(gl_print_error "Error setting up envmap!")
void))