1 #ifndef TEXTURE_HXX
2 #define TEXTURE_HXX
3
4 #include "Image.hxx"
5
6 // A class for bitmap textures. We did not use any of them...
7 class Texture : public Image
8 {
9 public:
10 Texture(int resX, int resY) : Image(resX,resY)
11 {};
12
13 Texture(char *fileName) : Image(1,1)
14 { ReadPPM(fileName); };
15
16 Vec3f GetTexel(float u, float v)
17 {
18 /* find texel indices */
19
20 int px = (int)floor(resX * u);
21 int py = (int)floor(resY * v);
22
23 /* texture repeat wrap */
24
25 px = ((px % resX) + resX) % resX;
26 py = ((py % resY) + resY) % resY;
27
28 return (*this)[resY-py-1][px];
29 };
30 };
31
32 #endif
syntax highlighted by Code2HTML, v. 0.9.1