conworlds

diff src/scene.cc @ 13:283cdfa7dda2

added a crapload of code from goat3dgfx
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 24 Aug 2014 09:41:24 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/scene.cc	Sun Aug 24 09:41:24 2014 +0300
     1.3 @@ -0,0 +1,34 @@
     1.4 +#include "scene.h"
     1.5 +#include "opengl.h"
     1.6 +
     1.7 +Scene::~Scene()
     1.8 +{
     1.9 +	destroy();
    1.10 +}
    1.11 +
    1.12 +void Scene::destroy()
    1.13 +{
    1.14 +	for(size_t i=0; i<objects.size(); i++) {
    1.15 +		delete objects[i];
    1.16 +	}
    1.17 +	objects.clear();
    1.18 +
    1.19 +	for(size_t i=0; i<meshes.size(); i++) {
    1.20 +		delete meshes[i];
    1.21 +	}
    1.22 +	meshes.clear();
    1.23 +}
    1.24 +
    1.25 +void Scene::draw(long msec) const
    1.26 +{
    1.27 +	for(size_t i=0; i<objects.size(); i++) {
    1.28 +		objects[i]->draw(msec);
    1.29 +	}
    1.30 +
    1.31 +	// if there are no objects in the scene, just draw the meshes instead
    1.32 +	if(objects.empty()) {
    1.33 +		for(size_t i=0; i<meshes.size(); i++) {
    1.34 +			meshes[i]->draw();
    1.35 +		}
    1.36 +	}
    1.37 +}