]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
vertex3d
authorJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 11:15:17 +0000 (13:15 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 11:15:17 +0000 (13:15 +0200)
src/vertex3d.cpp
src/vertex3d.h

index 6ffc86dc3046eb4ca852ed9473d28f39ad98277d..d7629eafc43f5c7ba3ce720b819df45d5da4418d 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
 #include "color.h"
 #include "gsubr.h"
 #include "vector2d.h"
 #include "vector3d.h"
 #include "vertex3d.h"
-#include "wrapped.h"
+
+
+using namespace irr;
+
+
+SCM
+video_S3DVertex_make (SCM position,
+                      SCM normal,
+                      SCM color,
+                      SCM tcoords)
+{
+  video::S3DVertex* vertex =
+    new video::S3DVertex (scm_to_vector3df (position),
+                          scm_to_vector3df (normal),
+                          scm_to_color (color),
+                          scm_to_vector2df (tcoords));
+  return scm_from_pointer ((void*) vertex, NULL);
+}
+
+
+SCM
+video_S3DVertex_Pos (SCM vertex) {
+  video::S3DVertex* s3dvertex = (video::S3DVertex*) scm_to_pointer (vertex);
+  return scm_from_vector3df (s3dvertex->Pos);
+}
+
 
 extern "C" {
 
   void
   init_vertex3d (void)
   {
-    init_vertex3d_type ();
-    DEFINE_GSUBR ("make-vertex3d", 4, 0, 0, make_vertex3d);
-    DEFINE_GSUBR ("vertex3d-position", 1, 0, 0, vertex3d_position);
-  }
-
-  DEFINE_WRAPPED_TYPE (irr::video::S3DVertex*, "vertex3d",
-                       init_vertex3d_type, vertex3d_p,
-                       wrap_vertex3d, unwrap_vertex3d);
-
-  SCM
-  make_vertex3d (SCM position,
-                 SCM normal,
-                 SCM color,
-                 SCM tcoords)
-  {
-    irr::video::S3DVertex* vertex =
-      new irr::video::S3DVertex (scm_to_vector3df (position),
-                                 scm_to_vector3df (normal),
-                                 scm_to_color (color),
-                                 scm_to_vector2df (tcoords));
-    return wrap_vertex3d (vertex);
+    DEFINE_GSUBR ("video_S3DVertex_make", 4, 0, 0, video_S3DVertex_make);
+    DEFINE_GSUBR ("video_S3DVertex_Pos", 1, 0, 0, video_S3DVertex_Pos);
   }
 
-  SCM
-  vertex3d_position (SCM vertex) {
-    irr::video::S3DVertex* s3dvertex = unwrap_vertex3d (vertex);
-    return scm_from_vector3df (s3dvertex->Pos);
-  }
+}
 
-  irr::video::E_VERTEX_TYPE
-  scm_to_vertex_type (SCM vertex_type)
-  {
-    char* type = scm_to_utf8_stringn (scm_symbol_to_string (vertex_type), NULL);
-    if (!strcmp (type, "standard"))
-      {
-        return irr::video::EVT_STANDARD;
-      }
-    else if (!strcmp (type, "2tcoords"))
-      {
-        return irr::video::EVT_2TCOORDS;
-      }
-    else if (!strcmp (type, "tangents"))
-      {
-        return irr::video::EVT_TANGENTS;
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Wrong vertex_type: ~S",
-                   scm_list_1 (vertex_type), scm_list_1 (vertex_type));
-      }
-  }
 
+video::E_VERTEX_TYPE
+scm_to_vertex_type (SCM vertex_type)
+{
+  char* type = scm_to_utf8_stringn (scm_symbol_to_string (vertex_type), NULL);
+  if (!strcmp (type, "standard"))
+    {
+      return video::EVT_STANDARD;
+    }
+  else if (!strcmp (type, "2tcoords"))
+    {
+      return video::EVT_2TCOORDS;
+    }
+  else if (!strcmp (type, "tangents"))
+    {
+      return video::EVT_TANGENTS;
+    }
+  else
+    {
+      scm_error (scm_arg_type_key, NULL, "Wrong vertex_type: ~S",
+                 scm_list_1 (vertex_type), scm_list_1 (vertex_type));
+    }
 }
index 2fcf4f52431afa1b94ae011d419134597dde8f05..4e8bb2076e79c7f745457a62e70097c8e700f33d 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "wrapped.h"
 
 extern "C" {
-
   void
   init_vertex3d (void);
-
-  DECLARE_WRAPPED_TYPE (irr::video::S3DVertex*, init_vertex3d_type,
-                        vertex3d_p, wrap_vertex3d, unwrap_vertex3d);
-
-  SCM
-  make_vertex3d (SCM position,
-                 SCM normal,
-                 SCM color,
-                 SCM tcoords);
-
-  SCM
-  vertex3d_position (SCM vertex);
-
-  irr::video::E_VERTEX_TYPE
-  scm_to_vertex_type (SCM vertex_type);
-
 }
 
+irr::video::E_VERTEX_TYPE
+scm_to_vertex_type (SCM vertex_type);
+
 #endif