goat3d

view src/chunk.cc @ 47:498ca7ac7047

- placed all the implementation stuff in the g3dimpl namespace - added animation stuff to the public API - started writing animation saving/loading
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 28 Dec 2013 06:47:39 +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 }