nuclear@2: #ifndef SCENE_H_ nuclear@2: #define SCENE_H_ nuclear@2: nuclear@2: #include "mesh.h" nuclear@2: nuclear@2: struct scenefile; nuclear@3: struct scnfile_io; nuclear@2: nuclear@2: #ifdef __cplusplus nuclear@2: extern "C" { nuclear@2: #endif nuclear@2: nuclear@2: int scnfile_init(struct scenefile *scn); nuclear@2: void scnfile_destroy(struct scenefile *scn); nuclear@2: nuclear@2: struct scenefile *scnfile_create(void); nuclear@2: void scnfile_free(struct scenefile *scn); nuclear@2: nuclear@2: nuclear@2: int scnfile_add_mesh(struct scenefile *scn, struct mesh *mesh); nuclear@2: nuclear@2: nuclear@2: int scnfile_load(struct scenefile *scn, const char *fname); nuclear@3: int scnfile_read_file(struct scenefile *scn, FILE *fp); nuclear@3: int scnfile_read(struct scenefile *scn, struct scnfile_io *io); nuclear@2: nuclear@2: int scnfile_find_mesh(struct scenefile *scn, const char *fname); nuclear@2: struct mesh *scnfile_mesh(struct scenefile *scn, int idx); nuclear@2: int scnfile_count(struct scenefile *scn); nuclear@2: nuclear@3: nuclear@3: /* These functions can be used to fill an scnfile_io struct before it's passed to nuclear@3: * one of the user-defined i/o image reading/writing functions (scnfile_read/scnfile_write). nuclear@3: * nuclear@3: * User-defined i/o functions: nuclear@3: * nuclear@3: * - size_t read_func(void *buffer, size_t bytes, void *user_ptr) nuclear@3: * Must try to fill the buffer with the specified number of bytes, and return nuclear@3: * the number of bytes actually read. nuclear@3: * nuclear@3: * - size_t write_func(void *buffer, size_t bytes, void *user_ptr) nuclear@3: * Must write the specified number of bytes from the supplied buffer and return nuclear@3: * the number of bytes actually written. nuclear@3: * nuclear@3: * - long seek_func(long offset, int whence, void *user_ptr) nuclear@3: * Must seek offset bytes from: the beginning of the file if whence is SEEK_SET, nuclear@3: * the current position if whence is SEEK_CUR, or the end of the file if whence is nuclear@3: * SEEK_END, and return the resulting file offset from the beginning of the file. nuclear@3: * (i.e. seek_func(0, SEEK_CUR, user_ptr); must be equivalent to an ftell). nuclear@3: * nuclear@3: * All three functions get the user-data pointer set through scnfile_io_set_user_data nuclear@3: * as their last argument. nuclear@3: * nuclear@3: * Note: obviously you don't need to set a write function if you're only going nuclear@3: * to call scnfile_read, or the read and seek function if you're only going to call nuclear@3: * scnfile_write. nuclear@3: * nuclear@3: * Note: if the user-supplied write function is buffered, make sure to flush nuclear@3: * (or close the file) after scnfile_write returns. nuclear@3: */ nuclear@3: void scnfile_io_user_data(struct scnfile_io *io, void *uptr); nuclear@3: void scnfile_io_read_func(struct scnfile_io *io, size_t (*read)(void*, size_t, void*)); nuclear@3: void scnfile_io_write_func(struct scnfile_io *io, size_t (*write)(void*, size_t, void*)); nuclear@3: void scnfile_io_seek_func(struct scnfile_io *io, long (*seek)(long, int, void*)); nuclear@3: nuclear@3: nuclear@2: #ifdef __cplusplus nuclear@2: } nuclear@2: #endif nuclear@2: nuclear@2: #endif /* SCENE_H_ */