annotate src/chunk.cc @ 33:f43f4849c86a
started writing blender exporter
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Sat, 05 Oct 2013 03:07:45 +0300 |
parents |
798df5111b56 |
children |
498ca7ac7047 |
rev |
line source |
nuclear@13
|
1 #include "goat3d.h"
|
nuclear@13
|
2 #include "chunk.h"
|
nuclear@13
|
3
|
nuclear@13
|
4 ChunkHeader chunk_header(int id)
|
nuclear@13
|
5 {
|
nuclear@13
|
6 ChunkHeader hdr;
|
nuclear@13
|
7 hdr.id = id;
|
nuclear@13
|
8 hdr.size = sizeof hdr;
|
nuclear@13
|
9 return hdr;
|
nuclear@13
|
10 }
|
nuclear@13
|
11
|
nuclear@13
|
12 bool write_chunk_header(const ChunkHeader *hdr, goat3d_io *io)
|
nuclear@13
|
13 {
|
nuclear@24
|
14 io->seek(-(long)hdr->size, SEEK_CUR, io->cls);
|
nuclear@24
|
15 if(io->write(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
|
nuclear@13
|
16 return false;
|
nuclear@13
|
17 }
|
nuclear@13
|
18 return true;
|
nuclear@13
|
19 }
|
nuclear@13
|
20
|
nuclear@13
|
21 bool read_chunk_header(ChunkHeader *hdr, goat3d_io *io)
|
nuclear@13
|
22 {
|
nuclear@24
|
23 if(io->read(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
|
nuclear@13
|
24 return false;
|
nuclear@13
|
25 }
|
nuclear@13
|
26 return true;
|
nuclear@13
|
27 }
|
nuclear@13
|
28
|
nuclear@13
|
29 void skip_chunk(const ChunkHeader *hdr, goat3d_io *io)
|
nuclear@13
|
30 {
|
nuclear@13
|
31 io->seek(hdr->size - sizeof *hdr, SEEK_CUR, io->cls);
|
nuclear@13
|
32 }
|