sanegl

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sanegl_attr.h	Thu Jun 23 05:19:40 2011 +0300
     1.3 @@ -0,0 +1,161 @@
     1.4 +#ifndef SANEGL_ATTR_H_
     1.5 +#define SANEGL_ATTR_H_
     1.6 +
     1.7 +#ifndef SANEGL_IMPL_
     1.8 +/* in the header file just expand to the prototypes */
     1.9 +#define GLATTR1(name, type, suffix, conv)	\
    1.10 +	void gl##name##1##suffix(GL##type x);
    1.11 +
    1.12 +#define GLATTR2(name, type, suffix, conv)	\
    1.13 +	void gl##name##2##suffix(GL##type x, GL##type y);
    1.14 +
    1.15 +#define GLATTR3(name, type, suffix, conv) \
    1.16 +	void gl##name##3##suffix(GL##type x, GL##type y, GL##type z);
    1.17 +
    1.18 +#define GLATTR4(name, type, suffix, conv)	\
    1.19 +	void gl##name##3##suffix(GL##type x, GL##type y, GL##type z, GL##type w);
    1.20 +
    1.21 +#define GLATTR1V(name, type, suffix, conv) \
    1.22 +	void gl##name##1##suffix##v(const GL##type *p);
    1.23 +
    1.24 +#define GLATTR2V(name, type, suffix, conv) \
    1.25 +	void gl##name##2##suffix##v(const GL##type *p);
    1.26 +
    1.27 +#define GLATTR3V(name, type, suffix, conv) \
    1.28 +	void gl##name##3##suffix##v(const GL##type *p);
    1.29 +
    1.30 +#define GLATTR4V(name, type, suffix, conv) \
    1.31 +	void gl##name##4##suffix##v(const GL##type *p);
    1.32 +#else
    1.33 +/* this full expansion will be performed in the implementation (sanegl.c) */
    1.34 +#define GLATTR1(name, type, suffix, conv)	\
    1.35 +	void gl##name##1##suffix(GL##type x) \
    1.36 +		{ gl##name##4f(conv(x), 0, 0, 1); }
    1.37 +
    1.38 +#define GLATTR2(name, type, suffix, conv)	\
    1.39 +	void gl##name##2##suffix(GL##type x, GL##type y) \
    1.40 +		{ gl##name##4f(conv(x), conv(y), 0, 1); }
    1.41 +
    1.42 +#define GLATTR3(name, type, suffix, conv)	\
    1.43 +	void gl##name##3##suffix(GL##type x, GL##type y, GL##type z) \
    1.44 +		{ gl##name##4f(conv(x), conv(y), conv(z), 1); }
    1.45 +
    1.46 +#define GLATTR4(name, type, suffix, conv)	\
    1.47 +	void gl##name##3##suffix(GL##type x, GL##type y, GL##type z, GL##type w) \
    1.48 +		{ gl##name##4f(conv(x), conv(y), conv(z), conv(w)); }
    1.49 +
    1.50 +#define GLATTR1V(name, type, suffix, conv) \
    1.51 +	void gl##name##1##suffix##v(const GL##type *p) \
    1.52 +		{ gl##name##4f(conv(*p), 0, 0, 1); }
    1.53 +
    1.54 +#define GLATTR2V(name, type, suffix, conv) \
    1.55 +	void gl##name##2##suffix##v(const GL##type *p) \
    1.56 +		{ gl##name##4f(conv(p[0]), conv(p[1]), 0, 1); }
    1.57 +
    1.58 +#define GLATTR3V(name, type, suffix, conv) \
    1.59 +	void gl##name##3##suffix##v(const GL##type *p) \
    1.60 +		{ gl##name##4f(conv(p[0]), conv(p[1]), conv(p[2]), 1); }
    1.61 +
    1.62 +#define GLATTR4V(name, type, suffix, conv) \
    1.63 +	void gl##name##4##suffix##v(const GL##type *p) \
    1.64 +		{ gl##name##4f(conv(p[0]), conv(p[1]), conv(p[2]), conv(p[3])); }
    1.65 +#endif
    1.66 +
    1.67 +/* n-arg functions */
    1.68 +GLATTR2(Vertex, float, f, (float))
    1.69 +GLATTR3(Vertex, float, f, (float))
    1.70 +
    1.71 +GLATTR2(Vertex, double, d, (float))
    1.72 +GLATTR3(Vertex, double, d, (float))
    1.73 +GLATTR4(Vertex, double, d, (float))
    1.74 +
    1.75 +GLATTR2(Vertex, int, i, (float))
    1.76 +GLATTR3(Vertex, int, i, (float))
    1.77 +GLATTR4(Vertex, int, i, (float))
    1.78 +
    1.79 +GLATTR2(Vertex, short, s, (float))
    1.80 +GLATTR3(Vertex, short, s, (float))
    1.81 +GLATTR4(Vertex, short, s, (float))
    1.82 +
    1.83 +GLATTR3(Color, float, f, (float))
    1.84 +GLATTR3(Color, double, d, (float))
    1.85 +GLATTR4(Color, double, d, (float))
    1.86 +
    1.87 +GLATTR3(Color, byte, b, (1.0f / CHAR_MAX) * (float))
    1.88 +GLATTR4(Color, byte, b, (1.0f / CHAR_MAX) * (float))
    1.89 +
    1.90 +GLATTR3(Color, ubyte, ub, (1.0f / UCHAR_MAX) * (float))
    1.91 +GLATTR4(Color, ubyte, ub, (1.0f / UCHAR_MAX) * (float))
    1.92 +
    1.93 +GLATTR3(Color, short, s, (1.0f / SHRT_MAX) * (float))
    1.94 +GLATTR4(Color, short, s, (1.0f / SHRT_MAX) * (float))
    1.95 +
    1.96 +GLATTR3(Color, ushort, us, (1.0f / USHRT_MAX) * (float))
    1.97 +GLATTR4(Color, ushort, us, (1.0f / USHRT_MAX) * (float))
    1.98 +
    1.99 +GLATTR3(Color, int, i, (1.0f / INT_MAX) * (float))
   1.100 +GLATTR4(Color, int, i, (1.0f / INT_MAX) * (float))
   1.101 +
   1.102 +GLATTR3(Color, uint, ui, (1.0f / UINT_MAX) * (float))
   1.103 +GLATTR4(Color, uint, ui, (1.0f / UINT_MAX) * (float))
   1.104 +
   1.105 +GLATTR1(TexCoord, float, f, (float))
   1.106 +GLATTR2(TexCoord, float, f, (float))
   1.107 +GLATTR3(TexCoord, float, f, (float))
   1.108 +
   1.109 +GLATTR1(TexCoord, double, d, (float))
   1.110 +GLATTR2(TexCoord, double, d, (float))
   1.111 +GLATTR3(TexCoord, double, d, (float))
   1.112 +GLATTR4(TexCoord, double, d, (float))
   1.113 +
   1.114 +GLATTR1(TexCoord, int, i, (float))
   1.115 +GLATTR2(TexCoord, int, i, (float))
   1.116 +GLATTR3(TexCoord, int, i, (float))
   1.117 +GLATTR4(TexCoord, int, i, (float))
   1.118 +
   1.119 +GLATTR1(TexCoord, short, s, (float))
   1.120 +GLATTR2(TexCoord, short, s, (float))
   1.121 +GLATTR3(TexCoord, short, s, (float))
   1.122 +GLATTR4(TexCoord, short, s, (float))
   1.123 +
   1.124 +/* vector functions */
   1.125 +GLATTR2V(Vertex, float, f, (float))
   1.126 +GLATTR3V(Vertex, float, f, (float))
   1.127 +
   1.128 +GLATTR2V(Vertex, double, d, (float))
   1.129 +GLATTR3V(Vertex, double, d, (float))
   1.130 +GLATTR4V(Vertex, double, d, (float))
   1.131 +
   1.132 +GLATTR2V(Vertex, int, i, (float))
   1.133 +GLATTR3V(Vertex, int, i, (float))
   1.134 +GLATTR4V(Vertex, int, i, (float))
   1.135 +
   1.136 +GLATTR2V(Vertex, short, s, (float))
   1.137 +GLATTR3V(Vertex, short, s, (float))
   1.138 +GLATTR4V(Vertex, short, s, (float))
   1.139 +
   1.140 +GLATTR3V(Color, float, f, (float))
   1.141 +GLATTR3V(Color, double, d, (float))
   1.142 +GLATTR4V(Color, double, d, (float))
   1.143 +
   1.144 +GLATTR1V(TexCoord, float, f, (float))
   1.145 +GLATTR2V(TexCoord, float, f, (float))
   1.146 +GLATTR3V(TexCoord, float, f, (float))
   1.147 +
   1.148 +GLATTR1V(TexCoord, double, d, (float))
   1.149 +GLATTR2V(TexCoord, double, d, (float))
   1.150 +GLATTR3V(TexCoord, double, d, (float))
   1.151 +GLATTR4V(TexCoord, double, d, (float))
   1.152 +
   1.153 +GLATTR1V(TexCoord, int, i, (float))
   1.154 +GLATTR2V(TexCoord, int, i, (float))
   1.155 +GLATTR3V(TexCoord, int, i, (float))
   1.156 +GLATTR4V(TexCoord, int, i, (float))
   1.157 +
   1.158 +GLATTR1V(TexCoord, short, s, (float))
   1.159 +GLATTR2V(TexCoord, short, s, (float))
   1.160 +GLATTR3V(TexCoord, short, s, (float))
   1.161 +GLATTR4V(TexCoord, short, s, (float))
   1.162 +
   1.163 +
   1.164 +#endif	/* SANEGL_ATTR_H_ */