]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
SMaterial and vertices
authorJavier Sancho <jsf@jsancho.org>
Mon, 3 Feb 2020 14:54:52 +0000 (15:54 +0100)
committerJavier Sancho <jsf@jsancho.org>
Mon, 3 Feb 2020 14:54:52 +0000 (15:54 +0100)
irrlicht/bindings/core.scm
irrlicht/bindings/video.scm
irrlicht/core.scm
irrlicht/video.scm

index 140506b47a0ab40414007ed2280f920f67e7875c..a5f06fd8a2ea651fe38390bf40367c93e242ee24 100644 (file)
     (format port "#<aabbox3df ~x>"
             (pointer-address (aabbox3df->pointer box)))))
 
-(export aabbox3df->pointer)
+(export pointer->aabbox3df
+        aabbox3df->pointer)
 
 (define-public aabbox3df
   (list vector3df vector3df))
 
-(define-public (make-aabbox3df)
-  (pointer->aabbox3df
-   (make-c-struct aabbox3df '((0 0 0) (0 0 0)))))
-
 (define-foreign aabbox3d-add-internal-point
   void "irr_core_aabbox3d_addInternalPoint" (list '* '*))
 
index 0bdf0f0c908b2fbff0bdc2fd71a01fc80ad51f06..8740d209673a541d6bf3251a46071eb9799c3983 100644 (file)
   #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
   #:use-module (irrlicht util foreign))
 
-;; E_DRIVER_TYPE enum
+;; irr_video_E_BLEND_OPERATION enum
+(define-public EBO_NONE         0)
+(define-public EBO_ADD          1)
+(define-public EBO_SUBTRACT     2)
+(define-public EBO_REVSUBTRACT  3)
+(define-public EBO_MIN          4)
+(define-public EBO_MAX          5)
+(define-public EBO_MIN_FACTOR   6)
+(define-public EBO_MAX_FACTOR   7)
+(define-public EBO_MIN_ALPHA    8)
+(define-public EBO_MAX_ALPHA    9)
+
+;; irr_video_E_COMPARISON_FUNC enum
+(define-public ECFN_NEVER         0)
+(define-public ECFN_LESSEQUAL     1)
+(define-public ECFN_EQUAL         2)
+(define-public ECFN_LESS          3)
+(define-public ECFN_NOTEQUAL      4)
+(define-public ECFN_GREATEREQUAL  5)
+(define-public ECFN_GREATER       6)
+(define-public ECFN_ALWAYS        7)
+
+;; irr_video_E_COLOR_PLANE enum
+(define-public ECP_NONE   0)
+(define-public ECP_ALPHA  1)
+(define-public ECP_RED    2)
+(define-public ECP_GREEN  4)
+(define-public ECP_BLUE   8)
+(define-public ECP_RGB   14)
+(define-public ECP_ALL   15)
+
+;; irr_video_E_ANTI_ALIASING_MODE enum
+(define-public EAAM_OFF                 0)
+(define-public EAAM_SIMPLE              1)
+(define-public EAAM_QUALITY             3)
+(define-public EAAM_LINE_SMOOTH         4)
+(define-public EAAM_POINT_SMOOTH        8)
+(define-public EAAM_FULL_BASIC         15)
+(define-public EAAM_ALPHA_TO_COVERAGE  16)
+
+;; irr_video_E_COLOR_MATERIAL enum
+(define-public ECM_NONE                 0)
+(define-public ECM_DIFFUSE              1)
+(define-public ECM_AMBIENT              2)
+(define-public ECM_EMISSIVE             3)
+(define-public ECM_SPECULAR             4)
+(define-public ECM_DIFFUSE_AND_AMBIENT  5)
+
+;; irr_video_E_DRIVER_TYPE enum
 (define-public EDT_NULL            0)
 (define-public EDT_SOFTWARE        1)
 (define-public EDT_BURNINGSVIDEO   2)
 (define-public EMF_BLEND_OPERATION   #x40000)
 (define-public EMF_POLYGON_OFFSET    #x80000)
 
+;; irr_video_E_POLYGON_OFFSET enum
+(define-public EPO_BACK  0)
+(define-public EPO_FRONT 1)
+
+;;irr_video_E_MATERIAL_TYPE enum
+(define-public EMT_SOLID                                   0)
+(define-public EMT_SOLID_2_LAYER                           1)
+(define-public EMT_LIGHTMAP                                2)
+(define-public EMT_LIGHTMAP_ADD                            3)
+(define-public EMT_LIGHTMAP_M2                             4)
+(define-public EMT_LIGHTMAP_M4                             5)
+(define-public EMT_LIGHTMAP_LIGHTING                       6)
+(define-public EMT_LIGHTMAP_LIGHTING_M2                    7)
+(define-public EMT_LIGHTMAP_LIGHTING_M4                    8)
+(define-public EMT_DETAIL_MAP                              9)
+(define-public EMT_SPHERE_MAP                             10)
+(define-public EMT_REFLECTION_2_LAYER                     11)
+(define-public EMT_TRANSPARENT_ADD_COLOR                  12)
+(define-public EMT_TRANSPARENT_ALPHA_CHANNEL              13)
+(define-public EMT_TRANSPARENT_ALPHA_CHANNEL_REF          14)
+(define-public EMT_TRANSPARENT_VERTEX_ALPHA               15)
+(define-public EMT_TRANSPARENT_REFLECTION_2_LAYER         16)
+(define-public EMT_NORMAL_MAP_SOLID                       17)
+(define-public EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR       18)
+(define-public EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA    19)
+(define-public EMT_PARALLAX_MAP_SOLID                     20)
+(define-public EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR     21)
+(define-public EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA  22)
+(define-public EMT_ONETEXTURE_BLEND                       23)
+(define-public EMT_FORCE_32BIT                    #x7fffffff)
+
 
 ;; scolor struct
 (define-public scolor
     (format port "#<s3dvertex ~x>"
             (pointer-address (s3dvertex->pointer vertex)))))
 
-(export s3dvertex->pointer)
+(export pointer->s3dvertex
+        s3dvertex->pointer)
 
 (define-public s3dvertex
   (list ffi-core:vector3df
         scolor
         ffi-core:vector2df))
 
-(define-public (make-s3dvertex position normal color t-coords)
-  (pointer->s3dvertex
-   (make-c-struct s3dvertex (list position normal color t-coords))))
-
-(define-public (vertex-position vertex)
-  (let ((data (parse-c-struct (s3dvertex->pointer vertex) s3dvertex)))
-    (car data)))
-
 ;; smateriallayer struct
 (define-public smateriallayer
   (list '* uint8 uint8 uint8 uint8 uint8 int8 '* '*))
     (format port "#<smaterial ~x>"
             (pointer-address (smaterial->pointer material)))))
 
-(export smaterial->pointer)
+(export pointer->smaterial
+        smaterial->pointer)
 
 (define-public smaterial
   (list smateriallayer smateriallayer smateriallayer smateriallayer  ; textureLayer[4]
          (uint8 1)  ; normalizeNormals:1
          (uint8 1)  ; useMipMaps:1
         )))
-
-;; (define-public (make-material #:key
-;;                               (wireframe #f)
-;;                               (lighting #t))
-;;   material)
index 7bc62084e77dd0b630a72d395c74b139f86e5a77..a0cb97327691d68fe78d85d1939c0c7a7ded0245 100644 (file)
 
 
 (define-module (irrlicht core)
+  #:use-module (system foreign)
   #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
-  #:export (aabbox3d-reset!)
-  #:re-export ((ffi-core:make-aabbox3df . make-aabbox3df)))
+  #:export (make-aabbox3df
+            aabbox3d-reset!))
+
+(define (make-aabbox3df)
+  (ffi-core:pointer->aabbox3df
+   (make-c-struct ffi-core:aabbox3df '((0 0 0) (0 0 0)))))
 
 (define (aabbox3d-reset! box init-value)
   (ffi-core:aabbox3d-reset
index b0f48d999957b95dd1a2cca85b00989b093718ee..a394c01b667de8580b8dd1877f599b8fd385a9eb 100644 (file)
   #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
   #:use-module ((irrlicht bindings video) #:prefix ffi-video:)
   #:use-module (irrlicht util)
+  #:use-module (irrlicht util foreign)
   #:export (begin-scene
             end-scene
             get-fps
             get-texture
-            get-video-driver-name)
-  #:re-export ((ffi-video:make-s3dvertex . make-s3dvertex)
-               (ffi-video:vertex-position . vertex-position)))
+            get-video-driver-name
+            make-s3dvertex
+            vertex-position
+            make-material))
 
 (define* (begin-scene driver
                       #:key
 (define (get-video-driver-name driver)
   (pointer->string
    (ffi-video:get-video-driver-name driver)))
+
+;; s3d vertices
+(define (make-s3dvertex position normal color t-coords)
+  (ffi-video:pointer->s3dvertex
+   (make-c-struct ffi-video:s3dvertex
+                  (list position normal color t-coords))))
+
+(define (vertex-position vertex)
+  (let ((data (parse-c-struct (ffi-video:s3dvertex->pointer vertex)
+                              ffi-video:s3dvertex)))
+    (car data)))
+
+;; smaterial
+(define* (make-material #:key (wireframe #f) (lighting #t))
+  (let ((material
+         (list
+          ;; textureLayer[4]
+          (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
+          (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
+          (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
+          (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer)
+          ffi-video:EMT_SOLID         ; materialType
+          (list 255 255 255 255)      ; ambientColor
+          (list 255 255 255 255)      ; diffuseColor
+          (list 0 0 0 0)              ; emissiveColor
+          (list 255 255 255 255)      ; specularColor
+          0                           ; shininess
+          0                           ; materialTypeParam
+          0                           ; materialTypeParam2
+          1                           ; thickness
+          ffi-video:ECFN_LESSEQUAL    ; zBuffer
+          ffi-video:EAAM_SIMPLE       ; antiAliasing
+          (list
+           ffi-video:ECP_ALL          ; colorMask
+           ffi-video:ECM_DIFFUSE      ; colorMaterial
+           ffi-video:EBO_NONE         ; blendOperation
+           0                          ; polygonOffsetFactor
+           ffi-video:EPO_FRONT        ; polygonOffsetDirection
+           (bool->integer wireframe)  ; wireframe
+           (bool->integer #f)         ; pointCloud
+           (bool->integer #t)         ; gouraudShading
+           (bool->integer lighting)   ; lighting
+           (bool->integer #t)         ; zWriteEnable
+           (bool->integer #t)         ; backfaceCulling
+           (bool->integer #f)         ; frontfaceCulling
+           (bool->integer #f)         ; fogEnable
+           (bool->integer #f)         ; normalizeNormals
+           (bool->integer #t)         ; useMipMaps
+           ))))
+    (ffi-video:pointer->smaterial
+     (make-c-struct+ ffi-video:smaterial material))))