(bind-func draw_scene
(lambda (degree shader model:float* view:float* projection:float*)
(let ((mata:float* (salloc 4))
(matd:float* (salloc 4))
(mats:float* (salloc 4))
(tmp_matrix:float* (salloc 16)))
(pfill! mata 0.0 0.0 0.0 1.0)
(pfill! matd 0.0 0.0 1.0 1.0)
(pfill! mats 1.0 1.0 1.0 1.0)
(shader_update_material shader mata matd mats 50.0)
;; static cube
(shader_update_matrices shader model view projection)
(cube_whole)
;; rotating cube
(mcopy model 4 4 tmp_matrix) ;; like pushing matrix i.e. (glPushMatrix)
(translate_matrix model -2.0 0.0 1.0)
(translate_matrix model 0.5 0.5 0.5)
(rotate_matrix model (dtof (* 0.1 degree)) 1.0 1.0 1.0)
(translate_matrix model -0.5 -0.5 -0.5)
(shader_update_matrices shader model view projection)
(cube_whole)
(mcopy tmp_matrix 4 4 model) ;; like popping matrix
;; sphere 1
(translate_matrix model 1.0 2.0 -2.0)
(shader_update_matrices shader model view projection)
(glutSolidSphere 1.0 50 50)
;; sometimes easier just to reverse something
;; rather than copying the matrix
(translate_matrix model -1.0 -2.0 2.0)
;; wall colour
(pfill! mata 0.0 0.0 0.0 1.0)
(pfill! matd 1.0 0.3 0.2 1.0)
(pfill! mats 0.5 0.5 0.5 1.0)
(shader_update_material shader mata matd mats 50.0)
;; backwall
(mcopy model 4 4 tmp_matrix)
(translate_matrix model -5.0 -2.0 -5.0)
(scale_matrix model 10.0 10.0 0.01)
(shader_update_matrices shader model view projection)
(cube_whole)
(mcopy tmp_matrix 4 4 model)
;; floor
(mcopy model 4 4 tmp_matrix)
(translate_matrix model -5.0 -2.0 -5.0)
(scale_matrix model 10.0 0.01 10.0)
(shader_update_matrices shader model view projection)
(cube_whole)
(mcopy tmp_matrix 4 4 model)
void)))