goat3dgfx

diff src/scene.cc @ 0:1873dfd13f2d

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 14 Nov 2013 05:27:09 +0200
parents
children 1868c5975f31
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/scene.cc	Thu Nov 14 05:27:09 2013 +0200
     1.3 @@ -0,0 +1,39 @@
     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 +	for(size_t i=0; i<curves.size(); i++) {
    1.25 +		delete curves[i];
    1.26 +	}
    1.27 +	curves.clear();
    1.28 +}
    1.29 +
    1.30 +void Scene::draw(long msec) const
    1.31 +{
    1.32 +	for(size_t i=0; i<objects.size(); i++) {
    1.33 +		objects[i]->draw(msec);
    1.34 +	}
    1.35 +
    1.36 +	if(objects.empty()) {
    1.37 +		printf("rendering meshes directly\n");
    1.38 +		for(size_t i=0; i<meshes.size(); i++) {
    1.39 +			meshes[i]->draw();
    1.40 +		}
    1.41 +	}
    1.42 +}