X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fvertex3d.cpp;h=649bc56e3f458d6a9d0510774cfaad8ff6c3c83a;hb=41a6ad96e81a8d8153c54877c4c12f61100677a9;hp=f6adab086d5371d8352dee98cfb0814c55a64c4a;hpb=f0d999bd6865a03c42a2d7378fd60c7a469201f2;p=guile-irrlicht.git diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp index f6adab0..649bc56 100644 --- a/src/vertex3d.cpp +++ b/src/vertex3d.cpp @@ -22,67 +22,59 @@ #include #include #include "color.h" +#include "gsubr.h" #include "vector2d.h" #include "vector3d.h" #include "vertex3d.h" -#include "wrapped.h" -extern "C" { +using namespace irr; - void - init_vertex3d (void) - { - init_vertex3d_type (); - scm_c_define_gsubr ("make-vertex3d", 4, 0, 0, (scm_t_subr)make_vertex3d); - scm_c_define_gsubr ("vertex3d-position", 1, 0, 0, (scm_t_subr)vertex3d_position); - scm_c_export ("make-vertex3d", "vertex3d-position", NULL); - } - - 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); - } +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 - vertex3d_position (SCM vertex) { - irr::video::S3DVertex* s3dvertex = unwrap_vertex3d (vertex); - return scm_from_vector3df (s3dvertex->Pos); - } +SCM +video_S3DVertex_Pos (SCM vertex) { + video::S3DVertex* s3dvertex = (video::S3DVertex*) scm_to_pointer (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)); - } - } +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); +} +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)); + } }