]> git.tdb.fi Git - libs/gl.git/blob - source/objectpass.cpp
01a6c2eb3e21bcae46fe34507f8a0b1027eea35c
[libs/gl.git] / source / objectpass.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include <msp/datafile/collection.h>
9 #include "objectpass.h"
10 #include "program.h"
11 #include "programdata.h"
12
13 using namespace std;
14
15 namespace Msp {
16 namespace GL {
17
18 ObjectPass::ObjectPass():
19         shprog(0),
20         shdata(0),
21         use_textures(true)
22 { }
23
24 ObjectPass::~ObjectPass()
25 {
26 }
27
28
29 ObjectPass::Loader::Loader(ObjectPass &p, Collection &c):
30         DataFile::CollectionObjectLoader<ObjectPass>(p, &c)
31 {
32         add("shader", &Loader::shader);
33         add("use_textures", &ObjectPass::use_textures);
34 }
35
36 void ObjectPass::Loader::shader(const string &n)
37 {
38         Program *shprog=coll->get<Program>(n);
39         if(shprog)  // Allow for unsupported shaders
40         {
41                 RefPtr<ProgramData> shdata=new ProgramData;
42                 load_sub(*shdata, *shprog);
43
44                 obj.shprog=shprog;
45                 if(obj.shdata)
46                         delete obj.shdata;
47                 obj.shdata=shdata.release();
48         }
49 }
50
51 } // namespace GL
52 } // namespace Msp