(bind-func update_cube
(lambda (tex:Texture*)
(glActiveTexture GL_TEXTURE0)
(glBindTexture GL_TEXTURE_CUBE_MAP (id tex))
(gl_print_error "error binding texture cube data")
;; front
(glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 0)))
;; back
(glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 1)))
;; top
(glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 2)))
;; bottom
(glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 3)))
;; left
(glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_X 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 4)))
;; right
(glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0
(if (= (type tex) GL_BGRA) GL_RGBA (type tex)) ;; this is internal type
(width tex)
(height tex)
0
(type tex) ;; this is external type (i.e. conversion from external to internal required)
GL_UNSIGNED_BYTE
(pref-ptr (data tex) (* (width tex) (height tex) 4 5)))
(glBindTexture GL_TEXTURE_CUBE_MAP 0)
(gl_print_error "could not update cube!")
void))