/*! * \ingroup file */ Lib3dsBool lib3ds_file_write(Lib3dsFile *file, FILE *f) { Lib3dsChunk c; c.chunk=LIB3DS_M3DMAGIC; if (!lib3ds_chunk_write_start(&c,f)) { LIB3DS_ERROR_LOG; return(LIB3DS_FALSE); } { /*---- LIB3DS_M3D_VERSION ----*/ Lib3dsChunk c; c.chunk=LIB3DS_M3D_VERSION; c.size=10; lib3ds_chunk_write(&c,f); lib3ds_dword_write(file->mesh_version, f); } if (!mdata_write(file, f)) { return(LIB3DS_FALSE); } if (!kfdata_write(file, f)) { return(LIB3DS_FALSE); } if (!lib3ds_chunk_write_end(&c,f)) { return(LIB3DS_FALSE); } return(LIB3DS_TRUE); }
/*! * Write 3ds file data from a Lib3dsFile object to a file. * * \param file The Lib3dsFile object to be written. * \param io A Lib3dsIo object previously set up by the caller. * * \return LIB3DS_TRUE on success, LIB3DS_FALSE on failure. */ int lib3ds_file_write(Lib3dsFile *file, Lib3dsIo *io) { Lib3dsChunk c; Lib3dsIoImpl *impl; lib3ds_io_setup(io); impl = (Lib3dsIoImpl*)io->impl; if (setjmp(impl->jmpbuf) != 0) { lib3ds_io_cleanup(io); return FALSE; } c.chunk = CHK_M3DMAGIC; lib3ds_chunk_write_start(&c, io); { /*---- LIB3DS_M3D_VERSION ----*/ Lib3dsChunk c; c.chunk = CHK_M3D_VERSION; c.size = 10; lib3ds_chunk_write(&c, io); lib3ds_io_write_dword(io, file->mesh_version); } mdata_write(file, io); kfdata_write(file, io); lib3ds_chunk_write_end(&c, io); memset(impl->jmpbuf, 0, sizeof(impl->jmpbuf)); lib3ds_io_cleanup(io); return TRUE; }