+ SCM
+ irr_video_beginScene (SCM wrapped_video_driver,
+ SCM rest)
+ {
+ SCM back_buffer = SCM_BOOL_T;
+ SCM z_buffer = SCM_BOOL_T;
+ SCM color = scm_list_4 (scm_from_uint32 (255),
+ scm_from_uint32 (0),
+ scm_from_uint32 (0),
+ scm_from_uint32 (0));
+ SCM video_data = SCM_BOOL_F;
+ SCM source_rect = SCM_BOOL_F;
+
+ scm_c_bind_keyword_arguments ("begin-scene", rest, (scm_t_keyword_arguments_flags)0,
+ scm_from_utf8_keyword ("back-buffer"), &back_buffer,
+ scm_from_utf8_keyword ("z-buffer"), &z_buffer,
+ scm_from_utf8_keyword ("color"), &color,
+ scm_from_utf8_keyword ("video-data"), &video_data,
+ scm_from_utf8_keyword ("source-rect"), &source_rect,
+ SCM_UNDEFINED);
+
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ irr::core::rect<irr::s32>* sourceRectAddress = 0;
+ if (!scm_is_false (source_rect))
+ {
+ irr::core::rect<irr::s32> sourceRect = scm_to_rect_s32 (source_rect);
+ sourceRectAddress = &sourceRect;
+ }
+ return scm_from_bool (driver->beginScene (scm_to_bool (back_buffer),
+ scm_to_bool (z_buffer),
+ scm_to_color (color),
+ irr::video::SExposedVideoData (),
+ sourceRectAddress));
+ }
+
+ SCM
+ irr_video_drawVertexPrimitiveList (SCM wrapped_video_driver,
+ SCM vertices,
+ SCM indices,
+ SCM rest)
+ {
+ SCM v_type = scm_from_utf8_symbol ("standard");
+ SCM p_type = scm_from_utf8_symbol ("triangles");
+
+ scm_c_bind_keyword_arguments ("draw-vertex-primitive-list", rest, (scm_t_keyword_arguments_flags)0,
+ scm_from_utf8_keyword ("vertex-type"), &v_type,
+ scm_from_utf8_keyword ("primitive-type"), &p_type,
+ SCM_UNDEFINED);
+
+ // Build vertex array
+ irr::u32 vertex_count = scm_to_uint32 (scm_length (vertices));
+ irr::video::S3DVertex s3d_vertices [vertex_count];
+ for (int i = 0; i < vertex_count; i++)
+ {
+ irr::video::S3DVertex* vertex = unwrap_vertex3d (scm_list_ref (vertices, scm_from_int (i)));
+ s3d_vertices[i] = irr::video::S3DVertex (vertex->Pos,
+ vertex->Normal,
+ vertex->Color,
+ vertex->TCoords);
+ }
+
+ // Build index array
+ irr::u32 index_count = scm_to_uint32 (scm_length (indices));
+ SCM flat_indices = scm_apply_0 (scm_eval_string (scm_from_utf8_string ("append")),
+ indices);
+ int flat_length = scm_to_int (scm_length (flat_indices));
+ irr::u32 c_indices [flat_length];
+ for (int i = 0; i < flat_length; i++)
+ {
+ c_indices[i] = scm_to_uint32 (scm_list_ref (flat_indices, scm_from_int (i)));
+ }
+
+ // Draw vertices
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ driver->drawVertexPrimitiveList (&s3d_vertices[0],
+ vertex_count,
+ &c_indices[0],
+ index_count,
+ scm_to_vertex_type (v_type),
+ scm_to_primitive_type (p_type),
+ irr::video::EIT_32BIT);
+ return SCM_UNSPECIFIED;
+ }
+
+ SCM
+ irr_video_endScene (SCM wrapped_video_driver)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ return scm_from_bool (driver->endScene ());
+ }
+
+ SCM
+ irr_video_getFPS (SCM wrapped_video_driver)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ return scm_from_int32 (driver->getFPS ());
+ }
+
+ SCM
+ irr_video_getTexture (SCM wrapped_video_driver,
+ SCM filename)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ irr::video::ITexture* texture = driver->getTexture (scm_to_utf8_stringn (filename, NULL));
+ return wrap_texture (texture);
+ }
+
+ SCM
+ irr_video_setMaterial (SCM wrapped_video_driver,
+ SCM material)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ driver->setMaterial (*(unwrap_material (material)));
+ return SCM_UNSPECIFIED;
+ }
+
+ SCM
+ irr_video_setTransform (SCM wrapped_video_driver,
+ SCM state,
+ SCM mat)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ driver->setTransform (scm_to_transformation_state (state),
+ scm_to_matrix4 (mat));
+ return SCM_UNSPECIFIED;
+ }
+