libg3d Reference Manual | ||||
---|---|---|---|---|
#include <g3d/iff.h> #define G3D_IFF_PAD1 #define G3D_IFF_PAD2 #define G3D_IFF_PAD4 #define G3D_IFF_PAD8 #define G3D_IFF_LE #define G3D_IFF_LEN16 #define G3D_IFF_SUBCHUNK_LEN16 #define G3D_IFF_MKID (a,b,c,d) gboolean g3d_iff_check (G3DStream *stream, guint32 *id, gsize *len); gsize g3d_iff_read_chunk (G3DStream *stream, guint32 *id, gsize *len, guint32 flags); gpointer g3d_iff_handle_chunk (G3DIffGlobal *global, G3DIffLocal *plocal, G3DIffChunkInfo *chunks, guint32 flags); gboolean g3d_iff_chunk_matches (guint32 id, gchar *tid); gboolean g3d_iff_read_ctnr (G3DIffGlobal *global, G3DIffLocal *local, G3DIffChunkInfo *chunks, guint32 flags); gchar* g3d_iff_id_to_text (guint32 id); FILE* g3d_iff_open (const gchar *filename, guint32 *id, guint32 *len); int g3d_iff_readchunk (FILE *f, guint32 *id, guint32 *len, guint32 flags); gboolean (*G3DIffChunkCallback) (G3DIffGlobal *global, G3DIffLocal *local); #define g3d_iff_chunk_callback G3DIffChunkInfo; #define g3d_iff_chunk_info G3DIffGlobal; #define g3d_iff_gdata G3DIffLocal; #define g3d_iff_ldata
#define G3D_IFF_SUBCHUNK_LEN16 0x10
All chunks except the toplevel ones have 16-bit sizes.
#define G3D_IFF_MKID(a,b,c,d)
Generate an IFF chunk identifier from character representation, e.g. G3D_IFF_MKID('F','O','R','M').
|
first byte |
|
second byte |
|
third byte |
|
fourth byte |
gboolean g3d_iff_check (G3DStream *stream, guint32 *id, gsize *len);
Checks a stream for a valid IFF signature and reads the top level container.
|
stream containing IFF file to check |
|
top level ID (out) |
|
length of top level container (out) |
Returns : |
TRUE on success (valid IFF), FALSE else |
gsize g3d_iff_read_chunk (G3DStream *stream, guint32 *id, gsize *len, guint32 flags);
Reads one chunk header from an IFF file.
|
stream to read from |
|
ID of chunk (out) |
|
length of chunk (excluding header) (out) |
|
flags |
Returns : |
real length of chunk including header and possible padding byte |
gpointer g3d_iff_handle_chunk (G3DIffGlobal *global, G3DIffLocal *plocal, G3DIffChunkInfo *chunks, guint32 flags);
Handle an IFF chunk based on chunk description.
|
global data |
|
local data of parent chunk, must not be NULL |
|
chunk description list |
|
IFF flags |
Returns : |
level object for siblings, may be NULL. |
gboolean g3d_iff_chunk_matches (guint32 id, gchar *tid);
Check whether id
and tid
match.
|
IFF identifier |
|
textual representation of identifier |
Returns : |
TRUE on match, FALSE else. |
gboolean g3d_iff_read_ctnr (G3DIffGlobal *global, G3DIffLocal *local, G3DIffChunkInfo *chunks, guint32 flags);
Read subchunks in current chunk and handle them appropriately.
|
global data |
|
local data of current chunk, must not be NULL |
|
chunk description list |
|
IFF flags |
Returns : |
TRUE on success, FALSE else. |
gchar* g3d_iff_id_to_text (guint32 id);
Get the text representation of an IFF chunk identifier.
|
an IFF identifier |
Returns : |
a newly allocated string containing the text identifier. |
FILE* g3d_iff_open (const gchar *filename, guint32 *id, guint32 *len);
Opens an IFF file, checks it and reads its top level container.
|
file name of IFF file |
|
top level ID (out) |
|
length of top level container (out) |
Returns : |
the file pointer of open file or NULL in case of an error |
int g3d_iff_readchunk (FILE *f, guint32 *id, guint32 *len, guint32 flags);
Reads one chunk header from an IFF file.
|
the open IFF file pointer |
|
ID of chunk (out) |
|
length of chunk (excluding header) (out) |
|
flags |
Returns : |
real length of chunk including header and possible padding byte |
gboolean (*G3DIffChunkCallback) (G3DIffGlobal *global, G3DIffLocal *local);
IFF callback function prototype.
|
the global data |
|
the local data |
Returns : |
TRUE on success, FALSE else. |
#define g3d_iff_chunk_callback G3DIffChunkCallback
IFF chunk callback (deprecated).
typedef struct { gchar *id; gchar *description; gboolean container; G3DIffChunkCallback callback; } G3DIffChunkInfo;
A chunk type description.
gchar * |
identifier of chunk |
gchar * |
human-readable description of chunk type |
gboolean |
TRUE if this chunk contains sub-chunks |
G3DIffChunkCallback |
function to be called if such a chunk is found |
typedef struct { G3DContext *context; G3DModel *model; G3DStream *stream; guint32 flags; gpointer user_data; FILE *f; long int max_fpos; } G3DIffGlobal;
The plugin-global data to be given to IFF callback functions.
G3DContext * |
a valid context |
G3DModel * |
a model |
G3DStream * |
the stream to read model from |
guint32 |
IFF flags |
gpointer |
to be used by plugin |
FILE * |
file to read model from (DEPRECATED) |
long int |
maximum file position (DEPRECATED) |
typedef struct { guint32 id; guint32 parent_id; gpointer object; gint32 level; gpointer level_object; gint32 nb; gboolean finalize; } G3DIffLocal;
The function-local data for IFF callback functions.
guint32 |
chunk identifier |
guint32 |
parent chunk identifier |
gpointer |
an object set by parent callbacks, may be NULL |
gint32 |
level of chunk |
gpointer |
object shared by callbacks on the same level, may be NULL |
gint32 |
number of bytes remaining in chunk, has to be decremented after correctly after reading from stream |
gboolean |
for container chunks the callback function is called before
and after processing possible sub-chunks, the second time finalize is set
to TRUE
|