conworlds
annotate src/scene.cc @ 20:782ff06817fb
merged ...
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 26 Aug 2014 18:42:53 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@13 | 1 #include "scene.h" |
nuclear@13 | 2 #include "opengl.h" |
nuclear@13 | 3 |
nuclear@13 | 4 Scene::~Scene() |
nuclear@13 | 5 { |
nuclear@13 | 6 destroy(); |
nuclear@13 | 7 } |
nuclear@13 | 8 |
nuclear@13 | 9 void Scene::destroy() |
nuclear@13 | 10 { |
nuclear@13 | 11 for(size_t i=0; i<objects.size(); i++) { |
nuclear@13 | 12 delete objects[i]; |
nuclear@13 | 13 } |
nuclear@13 | 14 objects.clear(); |
nuclear@13 | 15 |
nuclear@13 | 16 for(size_t i=0; i<meshes.size(); i++) { |
nuclear@13 | 17 delete meshes[i]; |
nuclear@13 | 18 } |
nuclear@13 | 19 meshes.clear(); |
nuclear@13 | 20 } |
nuclear@13 | 21 |
nuclear@13 | 22 void Scene::draw(long msec) const |
nuclear@13 | 23 { |
nuclear@13 | 24 for(size_t i=0; i<objects.size(); i++) { |
nuclear@13 | 25 objects[i]->draw(msec); |
nuclear@13 | 26 } |
nuclear@13 | 27 |
nuclear@13 | 28 // if there are no objects in the scene, just draw the meshes instead |
nuclear@13 | 29 if(objects.empty()) { |
nuclear@13 | 30 for(size_t i=0; i<meshes.size(); i++) { |
nuclear@13 | 31 meshes[i]->draw(); |
nuclear@13 | 32 } |
nuclear@13 | 33 } |
nuclear@13 | 34 } |