-
Notifications
You must be signed in to change notification settings - Fork 7
/
brfShader.cpp
100 lines (85 loc) · 2.03 KB
/
brfShader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* OpenBRF -- by marco tarini. Provided under GNU General Public License */
#include <vector>
#include <stdio.h>
#include <vcg/space/point4.h>
#include <vcg/space/point3.h>
#include <vcg/space/point2.h>
using namespace vcg;
#include "brfShader.h"
#include "saveLoad.h"
BrfShaderOpt::BrfShaderOpt()
{
map=colorOp=alphaOp=flags=0;
}
BrfShader::BrfShader()
{
}
//FILE *fff=wfopen("prova.txt","wt");
bool BrfShaderOpt::Load(FILE*f, int /*verbose*/){
//map, colorOp, alphaOp, flags
LoadInt(f,map);
LoadUint(f,colorOp);
LoadUint(f,alphaOp);
LoadUint(f,flags);
//fprintf(fff,"%d %u %u %u\n",map,colorOp, alphaOp, flags);
return true;
}
void BrfShaderOpt::Save(FILE*f) const{
//map, colorOp, alphaOp, flags
SaveInt(f,map);
SaveUint(f,colorOp);
SaveUint(f,alphaOp);
SaveUint(f,flags);
}
void BrfShader::SetDefault(){
requires = 0;
sprintf(technique,"%s",name);
fallback[0]=0;
flags = 0;
BrfShaderOpt o;
o.map = 0;
o.flags = 0;
o.alphaOp = 1;
o.colorOp = 2;
opt.clear();
opt.push_back(o);
}
bool BrfShader::Skip(FILE*f){
if (!LoadString(f, name)) return false;
::Skip(f,8);
if (!LoadString(f, technique)) return false;
unsigned int k;
LoadUint(f , k);
assert(k<=1);
if (k) { if (!LoadString(f , fallback)) return false;}
else fallback[0]=0;
SkipVectorF<BrfShaderOpt>(f);
return true;
}
bool BrfShader::Load(FILE*f, int verbose){
if (!LoadString(f, name)) return false;
if (verbose>0) printf("loading \"%s\"...\n",name);
LoadUint(f , flags);
LoadUint(f , requires);
if (!LoadString(f, technique)) return false;
unsigned int k;
LoadUint(f , k);
assert(k<=1);
if (k) { if (!LoadString(f , fallback)) return false; }
else fallback[0]=0;
//fprintf(fff,"--%s--\n",technique);
if (!LoadVector(f,opt)) return false;
return true;
}
void BrfShader::Save(FILE*f) const{
SaveString(f, name);
SaveUint(f , flags);
SaveUint(f , requires);
SaveString(f, technique);
if (fallback[0]==0) SaveUint(f,0);
else {
SaveUint(f,1);
SaveString(f, fallback);
}
SaveVector(f,opt);
}