X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=irrlicht%2Fvideo.scm;h=0c334fe2d84344b7c101136ce55a7a3908448c5c;hb=6260608f2ca73178ffd580af1c26ee0c424aa047;hp=dc61f644279cb1e90e18e4c45fc2a42065d697b2;hpb=86e2a7367842fd005dda3b20454f370d4ebfcf2c;p=guile-irrlicht.git diff --git a/irrlicht/video.scm b/irrlicht/video.scm index dc61f64..0c334fe 100644 --- a/irrlicht/video.scm +++ b/irrlicht/video.scm @@ -22,10 +22,12 @@ #:use-module (ice-9 match) #:use-module (system foreign) #:use-module ((irrlicht bindings core) #:prefix ffi-core:) + #:use-module ((irrlicht bindings scene) #:prefix ffi-scene:) #:use-module ((irrlicht bindings video) #:prefix ffi-video:) #:use-module (irrlicht util) #:use-module (irrlicht util foreign) #:export (begin-scene + draw-vertex-primitive-list end-scene get-fps get-texture @@ -52,6 +54,57 @@ %null-pointer (ffi-core:rect->pointer source-rect)))) +(define* (draw-vertex-primitive-list driver vertices index-list + #:key + (v-type 'standard) + (p-type 'triangles)) + (define (make-c-vertices vertices) + (let ((vals (map (lambda (vertex) + (parse-c-struct (ffi-video:s3dvertex->pointer vertex) + ffi-video:s3dvertex)) + vertices)) + (types (make-list (length vertices) ffi-video:s3dvertex))) + (make-c-struct types vals))) + + (define (make-c-indices indices) + (let* ((vals (apply append indices)) + (types (make-list (length vals) int32))) + (make-c-struct types vals))) + + (let ((vertices-pointer (make-c-vertices vertices)) + (vertex-count (length vertices)) + (indices-pointer (make-c-indices index-list)) + (prim-count (length index-list)) + (vertex-type + (match v-type + ('standard ffi-video:EVT_STANDARD) + ('2tcoords ffi-video:EVT_2TCOORDS) + ('tangents ffi-video:EVT_TANGENTS))) + (primitive-type + (match p-type + ('points ffi-scene:EPT_POINTS) + ('strip ffi-scene:EPT_LINE_STRIP) + ('line-loop ffi-scene:EPT_LINE_LOOP) + ('lines ffi-scene:EPT_LINES) + ('triangle-strip ffi-scene:EPT_TRIANGLE_STRIP) + ('triangle-fan ffi-scene:EPT_TRIANGLE_FAN) + ('triangles ffi-scene:EPT_TRIANGLES) + ('quad-strip ffi-scene:EPT_QUAD_STRIP) + ('quads ffi-scene:EPT_QUADS) + ('polygon ffi-scene:EPT_POLYGON) + ('point-sprites ffi-scene:EPT_POINT_SPRITES)))) + + + (ffi-video:draw-vertex-primitive-list + driver + vertices-pointer + vertex-count + indices-pointer + prim-count + vertex-type + primitive-type + ffi-video:EIT_32BIT))) + (define (end-scene driver) (ffi-video:end-scene driver)) @@ -139,4 +192,8 @@ (bool->integer #t) ; useMipMaps )))) (ffi-video:pointer->smaterial - (make-c-struct+ ffi-video:smaterial material)))) + ;; (make-c-struct+ ffi-video:smaterial material)))) + (make-c-material)))) + +(define-public (make-c-material) + (ffi-video:make-c-material))