X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fvertex3d.cpp;h=e0ca2d2cab1ee198e0fd6798ab2740d1f346023c;hb=3bb58c2b45af12c0f9c9eac648e67ac6fa90e104;hp=d7629eafc43f5c7ba3ce720b819df45d5da4418d;hpb=d52f560e9d3693c7810cfb351cf124b1c32e6d72;p=guile-irrlicht.git diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp index d7629ea..e0ca2d2 100644 --- a/src/vertex3d.cpp +++ b/src/vertex3d.cpp @@ -26,64 +26,61 @@ #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) +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); + return scm_from_irr_pointer ("", (void*) vertex); } - SCM -video_S3DVertex_Pos (SCM vertex) { - video::S3DVertex* s3dvertex = (video::S3DVertex*) scm_to_pointer (vertex); +S3DVertex_Pos (SCM vertex) { + video::S3DVertex* s3dvertex = (video::S3DVertex*) scm_to_irr_pointer (vertex); return scm_from_vector3df (s3dvertex->Pos); } - -extern "C" { - - void - init_vertex3d (void) - { - DEFINE_GSUBR ("video_S3DVertex_make", 4, 0, 0, video_S3DVertex_make); - DEFINE_GSUBR ("video_S3DVertex_Pos", 1, 0, 0, video_S3DVertex_Pos); - } - +void +init_vertex3d (void) +{ + DEFINE_GSUBR ("S3DVertex_make", 4, 0, 0, S3DVertex_make); + DEFINE_GSUBR ("S3DVertex_Pos", 1, 0, 0, S3DVertex_Pos); } - 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")) + char* type_name = scm_to_utf8_string (scm_symbol_to_string (vertex_type)); + video::E_VERTEX_TYPE type; + + if (!strcmp (type_name, "standard")) { - return video::EVT_STANDARD; + type = video::EVT_STANDARD; } - else if (!strcmp (type, "2tcoords")) + else if (!strcmp (type_name, "2tcoords")) { - return video::EVT_2TCOORDS; + type = video::EVT_2TCOORDS; } - else if (!strcmp (type, "tangents")) + else if (!strcmp (type_name, "tangents")) { - return video::EVT_TANGENTS; + type = 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)); } + + free (type_name); + return type; }