erebus
diff liberebus/src/texture.h @ 2:474a0244f57d
fixed specialization mistake
fixed line endings
added makefiles
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 28 Apr 2014 06:31:10 +0300 |
parents | 4abdce1361b9 |
children |
line diff
1.1 --- a/liberebus/src/texture.h Mon Apr 28 05:58:22 2014 +0300 1.2 +++ b/liberebus/src/texture.h Mon Apr 28 06:31:10 2014 +0300 1.3 @@ -1,30 +1,30 @@ 1.4 -#ifndef TEXTURE_H_ 1.5 -#define TEXTURE_H_ 1.6 - 1.7 -#include "image.h" 1.8 -#include "color.h" 1.9 - 1.10 -class Texture { 1.11 -public: 1.12 - Image<float> img; 1.13 - 1.14 - inline Color lookup(float u, float v) const; 1.15 - 1.16 - bool load(const char *fname) { return img.load(fname); } 1.17 -}; 1.18 - 1.19 - 1.20 -inline Color Texture::lookup(float u, float v) const 1.21 -{ 1.22 - int xsz = img.get_width(); 1.23 - int ysz = img.get_height(); 1.24 - 1.25 - int x = (float)u / (float)xsz; 1.26 - int y = (float)v / (float)ysz; 1.27 - 1.28 - float *pix = img.get_pixels() + ((y % ysz) * xsz + (x % xsz)) * 4; 1.29 - return Color(pix[0], pix[1], pix[2]); 1.30 -} 1.31 - 1.32 - 1.33 -#endif // TEXTURE_H_ 1.34 \ No newline at end of file 1.35 +#ifndef TEXTURE_H_ 1.36 +#define TEXTURE_H_ 1.37 + 1.38 +#include "image.h" 1.39 +#include "color.h" 1.40 + 1.41 +class Texture { 1.42 +public: 1.43 + Image<float> img; 1.44 + 1.45 + inline Color lookup(float u, float v) const; 1.46 + 1.47 + bool load(const char *fname) { return img.load(fname); } 1.48 +}; 1.49 + 1.50 + 1.51 +inline Color Texture::lookup(float u, float v) const 1.52 +{ 1.53 + int xsz = img.get_width(); 1.54 + int ysz = img.get_height(); 1.55 + 1.56 + int x = (float)u / (float)xsz; 1.57 + int y = (float)v / (float)ysz; 1.58 + 1.59 + float *pix = img.get_pixels() + ((y % ysz) * xsz + (x % xsz)) * 4; 1.60 + return Color(pix[0], pix[1], pix[2]); 1.61 +} 1.62 + 1.63 + 1.64 +#endif // TEXTURE_H_