sanegl

view sanegl_attr.h @ 0:00b315b6db1e

sanegl initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Jun 2011 05:19:40 +0300
parents
children
line source
1 #ifndef SANEGL_ATTR_H_
2 #define SANEGL_ATTR_H_
4 #ifndef SANEGL_IMPL_
5 /* in the header file just expand to the prototypes */
6 #define GLATTR1(name, type, suffix, conv) \
7 void gl##name##1##suffix(GL##type x);
9 #define GLATTR2(name, type, suffix, conv) \
10 void gl##name##2##suffix(GL##type x, GL##type y);
12 #define GLATTR3(name, type, suffix, conv) \
13 void gl##name##3##suffix(GL##type x, GL##type y, GL##type z);
15 #define GLATTR4(name, type, suffix, conv) \
16 void gl##name##3##suffix(GL##type x, GL##type y, GL##type z, GL##type w);
18 #define GLATTR1V(name, type, suffix, conv) \
19 void gl##name##1##suffix##v(const GL##type *p);
21 #define GLATTR2V(name, type, suffix, conv) \
22 void gl##name##2##suffix##v(const GL##type *p);
24 #define GLATTR3V(name, type, suffix, conv) \
25 void gl##name##3##suffix##v(const GL##type *p);
27 #define GLATTR4V(name, type, suffix, conv) \
28 void gl##name##4##suffix##v(const GL##type *p);
29 #else
30 /* this full expansion will be performed in the implementation (sanegl.c) */
31 #define GLATTR1(name, type, suffix, conv) \
32 void gl##name##1##suffix(GL##type x) \
33 { gl##name##4f(conv(x), 0, 0, 1); }
35 #define GLATTR2(name, type, suffix, conv) \
36 void gl##name##2##suffix(GL##type x, GL##type y) \
37 { gl##name##4f(conv(x), conv(y), 0, 1); }
39 #define GLATTR3(name, type, suffix, conv) \
40 void gl##name##3##suffix(GL##type x, GL##type y, GL##type z) \
41 { gl##name##4f(conv(x), conv(y), conv(z), 1); }
43 #define GLATTR4(name, type, suffix, conv) \
44 void gl##name##3##suffix(GL##type x, GL##type y, GL##type z, GL##type w) \
45 { gl##name##4f(conv(x), conv(y), conv(z), conv(w)); }
47 #define GLATTR1V(name, type, suffix, conv) \
48 void gl##name##1##suffix##v(const GL##type *p) \
49 { gl##name##4f(conv(*p), 0, 0, 1); }
51 #define GLATTR2V(name, type, suffix, conv) \
52 void gl##name##2##suffix##v(const GL##type *p) \
53 { gl##name##4f(conv(p[0]), conv(p[1]), 0, 1); }
55 #define GLATTR3V(name, type, suffix, conv) \
56 void gl##name##3##suffix##v(const GL##type *p) \
57 { gl##name##4f(conv(p[0]), conv(p[1]), conv(p[2]), 1); }
59 #define GLATTR4V(name, type, suffix, conv) \
60 void gl##name##4##suffix##v(const GL##type *p) \
61 { gl##name##4f(conv(p[0]), conv(p[1]), conv(p[2]), conv(p[3])); }
62 #endif
64 /* n-arg functions */
65 GLATTR2(Vertex, float, f, (float))
66 GLATTR3(Vertex, float, f, (float))
68 GLATTR2(Vertex, double, d, (float))
69 GLATTR3(Vertex, double, d, (float))
70 GLATTR4(Vertex, double, d, (float))
72 GLATTR2(Vertex, int, i, (float))
73 GLATTR3(Vertex, int, i, (float))
74 GLATTR4(Vertex, int, i, (float))
76 GLATTR2(Vertex, short, s, (float))
77 GLATTR3(Vertex, short, s, (float))
78 GLATTR4(Vertex, short, s, (float))
80 GLATTR3(Color, float, f, (float))
81 GLATTR3(Color, double, d, (float))
82 GLATTR4(Color, double, d, (float))
84 GLATTR3(Color, byte, b, (1.0f / CHAR_MAX) * (float))
85 GLATTR4(Color, byte, b, (1.0f / CHAR_MAX) * (float))
87 GLATTR3(Color, ubyte, ub, (1.0f / UCHAR_MAX) * (float))
88 GLATTR4(Color, ubyte, ub, (1.0f / UCHAR_MAX) * (float))
90 GLATTR3(Color, short, s, (1.0f / SHRT_MAX) * (float))
91 GLATTR4(Color, short, s, (1.0f / SHRT_MAX) * (float))
93 GLATTR3(Color, ushort, us, (1.0f / USHRT_MAX) * (float))
94 GLATTR4(Color, ushort, us, (1.0f / USHRT_MAX) * (float))
96 GLATTR3(Color, int, i, (1.0f / INT_MAX) * (float))
97 GLATTR4(Color, int, i, (1.0f / INT_MAX) * (float))
99 GLATTR3(Color, uint, ui, (1.0f / UINT_MAX) * (float))
100 GLATTR4(Color, uint, ui, (1.0f / UINT_MAX) * (float))
102 GLATTR1(TexCoord, float, f, (float))
103 GLATTR2(TexCoord, float, f, (float))
104 GLATTR3(TexCoord, float, f, (float))
106 GLATTR1(TexCoord, double, d, (float))
107 GLATTR2(TexCoord, double, d, (float))
108 GLATTR3(TexCoord, double, d, (float))
109 GLATTR4(TexCoord, double, d, (float))
111 GLATTR1(TexCoord, int, i, (float))
112 GLATTR2(TexCoord, int, i, (float))
113 GLATTR3(TexCoord, int, i, (float))
114 GLATTR4(TexCoord, int, i, (float))
116 GLATTR1(TexCoord, short, s, (float))
117 GLATTR2(TexCoord, short, s, (float))
118 GLATTR3(TexCoord, short, s, (float))
119 GLATTR4(TexCoord, short, s, (float))
121 /* vector functions */
122 GLATTR2V(Vertex, float, f, (float))
123 GLATTR3V(Vertex, float, f, (float))
125 GLATTR2V(Vertex, double, d, (float))
126 GLATTR3V(Vertex, double, d, (float))
127 GLATTR4V(Vertex, double, d, (float))
129 GLATTR2V(Vertex, int, i, (float))
130 GLATTR3V(Vertex, int, i, (float))
131 GLATTR4V(Vertex, int, i, (float))
133 GLATTR2V(Vertex, short, s, (float))
134 GLATTR3V(Vertex, short, s, (float))
135 GLATTR4V(Vertex, short, s, (float))
137 GLATTR3V(Color, float, f, (float))
138 GLATTR3V(Color, double, d, (float))
139 GLATTR4V(Color, double, d, (float))
141 GLATTR1V(TexCoord, float, f, (float))
142 GLATTR2V(TexCoord, float, f, (float))
143 GLATTR3V(TexCoord, float, f, (float))
145 GLATTR1V(TexCoord, double, d, (float))
146 GLATTR2V(TexCoord, double, d, (float))
147 GLATTR3V(TexCoord, double, d, (float))
148 GLATTR4V(TexCoord, double, d, (float))
150 GLATTR1V(TexCoord, int, i, (float))
151 GLATTR2V(TexCoord, int, i, (float))
152 GLATTR3V(TexCoord, int, i, (float))
153 GLATTR4V(TexCoord, int, i, (float))
155 GLATTR1V(TexCoord, short, s, (float))
156 GLATTR2V(TexCoord, short, s, (float))
157 GLATTR3V(TexCoord, short, s, (float))
158 GLATTR4V(TexCoord, short, s, (float))
161 #endif /* SANEGL_ATTR_H_ */