]> git.tdb.fi Git - libs/gl.git/blob - source/objectpass.cpp
Support specifying elements in PrimitiveBuilder
[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 "objectpass.h"
9 #include "program.h"
10 #include "programdata.h"
11
12 using namespace std;
13
14 namespace Msp {
15 namespace GL {
16
17 ObjectPass::ObjectPass():
18         shprog(0),
19         shdata(0)
20 { }
21
22 ObjectPass::~ObjectPass()
23 {
24 }
25
26
27 ObjectPass::Loader::Loader(ObjectPass &p, Collection &c):
28         pass(p),
29         coll(c)
30 {
31         add("shader", &Loader::shader);
32         add("use_textures", &ObjectPass::use_textures);
33 }
34
35 void ObjectPass::Loader::shader(const string &n)
36 {
37         Program *shprog=coll.get<Program>(n);
38         if(shprog)  // Allow for unsupported shaders
39         {
40                 RefPtr<ProgramData> shdata=new ProgramData;
41                 load_sub(*shdata, *shprog);
42
43                 pass.shprog=shprog;
44                 if(pass.shdata)
45                         delete pass.shdata;
46                 pass.shdata=shdata.release();
47         }
48 }
49
50 } // namespace GL
51 } // namespace Msp