goat3d

view src/chunk.cc @ 51:fa5c52ea9d59

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 17 Jan 2014 18:16:09 +0200
parents 6b651613bd9f
children dad392c710df
line source
1 #include "goat3d.h"
2 #include "chunk.h"
4 using namespace g3dimpl;
6 ChunkHeader chunk_header(int id)
7 {
8 ChunkHeader hdr;
9 hdr.id = id;
10 hdr.size = sizeof hdr;
11 return hdr;
12 }
14 bool g3dimpl::write_chunk_header(const ChunkHeader *hdr, goat3d_io *io)
15 {
16 io->seek(-(long)hdr->size, SEEK_CUR, io->cls);
17 if(io->write(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
18 return false;
19 }
20 return true;
21 }
23 bool g3dimpl::read_chunk_header(ChunkHeader *hdr, goat3d_io *io)
24 {
25 if(io->read(hdr, sizeof *hdr, io->cls) < (long)sizeof *hdr) {
26 return false;
27 }
28 return true;
29 }
31 void g3dimpl::skip_chunk(const ChunkHeader *hdr, goat3d_io *io)
32 {
33 io->seek(hdr->size - sizeof *hdr, SEEK_CUR, io->cls);
34 }