goat3d

view src/chunk.cc @ 38:60f2037680ee

split the exporter into two files to make it more readable (and maybe make an importer too at some point?)
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 07 Oct 2013 20:02:57 +0300
parents 798df5111b56
children 498ca7ac7047
line source
1 #include "goat3d.h"
2 #include "chunk.h"
4 ChunkHeader chunk_header(int id)
5 {
6 ChunkHeader hdr;
7 hdr.id = id;
8 hdr.size = sizeof hdr;
9 return hdr;
10 }
12 bool write_chunk_header(const ChunkHeader *hdr, goat3d_io *io)
13 {
14 io->seek(-(long)hdr->size, SEEK_CUR, io->cls);
15 if(io->write(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
16 return false;
17 }
18 return true;
19 }
21 bool read_chunk_header(ChunkHeader *hdr, goat3d_io *io)
22 {
23 if(io->read(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
24 return false;
25 }
26 return true;
27 }
29 void skip_chunk(const ChunkHeader *hdr, goat3d_io *io)
30 {
31 io->seek(hdr->size - sizeof *hdr, SEEK_CUR, io->cls);
32 }