rev |
line source |
nuclear@2
|
1 #ifndef SCENE_H_
|
nuclear@2
|
2 #define SCENE_H_
|
nuclear@2
|
3
|
nuclear@2
|
4 #include "mesh.h"
|
nuclear@2
|
5
|
nuclear@2
|
6 struct scenefile;
|
nuclear@3
|
7 struct scnfile_io;
|
nuclear@2
|
8
|
nuclear@2
|
9 #ifdef __cplusplus
|
nuclear@2
|
10 extern "C" {
|
nuclear@2
|
11 #endif
|
nuclear@2
|
12
|
nuclear@2
|
13 int scnfile_init(struct scenefile *scn);
|
nuclear@2
|
14 void scnfile_destroy(struct scenefile *scn);
|
nuclear@2
|
15
|
nuclear@2
|
16 struct scenefile *scnfile_create(void);
|
nuclear@2
|
17 void scnfile_free(struct scenefile *scn);
|
nuclear@2
|
18
|
nuclear@2
|
19
|
nuclear@2
|
20 int scnfile_add_mesh(struct scenefile *scn, struct mesh *mesh);
|
nuclear@2
|
21
|
nuclear@2
|
22
|
nuclear@2
|
23 int scnfile_load(struct scenefile *scn, const char *fname);
|
nuclear@3
|
24 int scnfile_read_file(struct scenefile *scn, FILE *fp);
|
nuclear@3
|
25 int scnfile_read(struct scenefile *scn, struct scnfile_io *io);
|
nuclear@2
|
26
|
nuclear@2
|
27 int scnfile_find_mesh(struct scenefile *scn, const char *fname);
|
nuclear@2
|
28 struct mesh *scnfile_mesh(struct scenefile *scn, int idx);
|
nuclear@2
|
29 int scnfile_count(struct scenefile *scn);
|
nuclear@2
|
30
|
nuclear@3
|
31
|
nuclear@3
|
32 /* These functions can be used to fill an scnfile_io struct before it's passed to
|
nuclear@3
|
33 * one of the user-defined i/o image reading/writing functions (scnfile_read/scnfile_write).
|
nuclear@3
|
34 *
|
nuclear@3
|
35 * User-defined i/o functions:
|
nuclear@3
|
36 *
|
nuclear@3
|
37 * - size_t read_func(void *buffer, size_t bytes, void *user_ptr)
|
nuclear@3
|
38 * Must try to fill the buffer with the specified number of bytes, and return
|
nuclear@3
|
39 * the number of bytes actually read.
|
nuclear@3
|
40 *
|
nuclear@3
|
41 * - size_t write_func(void *buffer, size_t bytes, void *user_ptr)
|
nuclear@3
|
42 * Must write the specified number of bytes from the supplied buffer and return
|
nuclear@3
|
43 * the number of bytes actually written.
|
nuclear@3
|
44 *
|
nuclear@3
|
45 * - long seek_func(long offset, int whence, void *user_ptr)
|
nuclear@3
|
46 * Must seek offset bytes from: the beginning of the file if whence is SEEK_SET,
|
nuclear@3
|
47 * the current position if whence is SEEK_CUR, or the end of the file if whence is
|
nuclear@3
|
48 * SEEK_END, and return the resulting file offset from the beginning of the file.
|
nuclear@3
|
49 * (i.e. seek_func(0, SEEK_CUR, user_ptr); must be equivalent to an ftell).
|
nuclear@3
|
50 *
|
nuclear@3
|
51 * All three functions get the user-data pointer set through scnfile_io_set_user_data
|
nuclear@3
|
52 * as their last argument.
|
nuclear@3
|
53 *
|
nuclear@3
|
54 * Note: obviously you don't need to set a write function if you're only going
|
nuclear@3
|
55 * to call scnfile_read, or the read and seek function if you're only going to call
|
nuclear@3
|
56 * scnfile_write.
|
nuclear@3
|
57 *
|
nuclear@3
|
58 * Note: if the user-supplied write function is buffered, make sure to flush
|
nuclear@3
|
59 * (or close the file) after scnfile_write returns.
|
nuclear@3
|
60 */
|
nuclear@3
|
61 void scnfile_io_user_data(struct scnfile_io *io, void *uptr);
|
nuclear@3
|
62 void scnfile_io_read_func(struct scnfile_io *io, size_t (*read)(void*, size_t, void*));
|
nuclear@3
|
63 void scnfile_io_write_func(struct scnfile_io *io, size_t (*write)(void*, size_t, void*));
|
nuclear@3
|
64 void scnfile_io_seek_func(struct scnfile_io *io, long (*seek)(long, int, void*));
|
nuclear@3
|
65
|
nuclear@3
|
66
|
nuclear@2
|
67 #ifdef __cplusplus
|
nuclear@2
|
68 }
|
nuclear@2
|
69 #endif
|
nuclear@2
|
70
|
nuclear@2
|
71 #endif /* SCENE_H_ */
|