summaryrefslogtreecommitdiff
path: root/materialsystem/genshadermacro.pl
blob: 0f51d65edf64d4b61e086113265b06136a2425fe (plain) (blame)
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
101
102
103
104
105
for( $i = 0; $i < 16; $i++ )
{
	print "\#define SHADER_CLASS$i(name,help";
	for( $j = 0; $j < $i; $j++ )
	{
		print ",p$j,p$j" . "type,p$j" . "default,p$j" . "help\\\n\t\t";
	}
	print ")\\\n";
	print "\tstatic const char *s_HelpString = help;\\\n";
	print "\tstatic const char *s_ParamNames[] = {";
	if( $i == 0 )
	{
		print "NULL";
	}
	else
	{
		for( $j = 0; $j < $i; $j++ )
		{
			print "\\\n\t\t\"\$\" #p$j";
			if( $j != $i - 1 )
			{
				print ",";
			}
		}
	}
	print "\\\n\t};\\\n";

	print "\tstatic ShaderParamType_t s_ParamType[] = {";
	if( $i == 0 )
	{
		print "SHADER_PARAM_TYPE_INTEGER";
	}
	else
	{
		for( $j = 0; $j < $i; $j++ )
		{
			print "\\\n\t\tp$j" . "type";
			if( $j != $i - 1 )
			{
				print ",";
			}
		}
	}
	print "\\\n\t};\\\n";

	print "\tstatic const char *s_ParamDefault[] = {";
	if( $i == 0 )
	{
		print "\"\"";
	}
	else
	{
		for( $j = 0; $j < $i; $j++ )
		{
			print "\\\n\t\tp$j" . "default";
			if( $j != $i - 1 )
			{
				print ",";
			}
		}
	}
	print "\\\n\t};\\\n";

	print "\tstatic const char *s_ParamHelp[] = {";
	if( $i == 0 )
	{
		print "\"\"";
	}
	else
	{
		for( $j = 0; $j < $i; $j++ )
		{
			print "\\\n\t\tp$j" . "help";
			if( $j != $i - 1 )
			{
				print ",";
			}
		}
	}
	print "\\\n\t};\\\n";


	print "\\\n\tenum {";
	if( $i == 0 )
	{
		print "DUMMY_PARAM";
	}
	else	
	{
		for( $j = 0; $j < $i; $j++ )
		{
			print "\\\n\t\tp$j";
			if( $j == 0 )
			{
				print " = NUM_SHADER_MATERIAL_VARS";
			}
			if( $j != $i - 1 )
			{
				print ",";
			}
		}
	}
	print "\\\n\t};\\\n";
	print "\tstatic const char *s_Name = #name;\\\n\tclass CShader_ ## name : public Shader_t\n\n";
}