goat3dgfx
view src/scene.cc @ 12:1868c5975f31
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 24 Nov 2013 18:18:38 +0200 |
parents | 1873dfd13f2d |
children | 25bf39105c82 |
line source
1 #include "scene.h"
2 #include "opengl.h"
3 #include "goat3d.h"
5 Scene::~Scene()
6 {
7 destroy();
8 }
10 void Scene::destroy()
11 {
12 for(size_t i=0; i<objects.size(); i++) {
13 delete objects[i];
14 }
15 objects.clear();
17 for(size_t i=0; i<meshes.size(); i++) {
18 delete meshes[i];
19 }
20 meshes.clear();
22 for(size_t i=0; i<curves.size(); i++) {
23 delete curves[i];
24 }
25 curves.clear();
26 }
28 bool Scene::load(const char *fname)
29 {
30 goat3d *goat = goat3d_create();
31 if(!goat) {
32 return false;
33 }
34 if(goat3d_load(goat, fname) == -1) {
35 return false;
36 }
38 int num_meshes = goat3d_get_mesh_count(goat);
39 for(int i=0; i<num_meshes; i++) {
40 goat3d_mesh *gmesh = goat3d_get_mesh(goat, i);
41 // TODO cont...
42 }
44 goat3d_free(goat);
45 return true;
46 }
48 bool Scene::save(const char *fname) const
49 {
50 return false; // TODO
51 }
53 void Scene::draw(long msec) const
54 {
55 for(size_t i=0; i<objects.size(); i++) {
56 objects[i]->draw(msec);
57 }
59 if(objects.empty()) {
60 printf("rendering meshes directly\n");
61 for(size_t i=0; i<meshes.size(); i++) {
62 meshes[i]->draw();
63 }
64 }
65 }