tavli
diff src/image.h @ 4:b41ceead1708
procedural playing field texture mask
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 25 Jun 2015 05:58:35 +0300 |
parents | |
children | c2a2069a49ec |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/image.h Thu Jun 25 05:58:35 2015 +0300 1.3 @@ -0,0 +1,44 @@ 1.4 +#ifndef IMAGE_H_ 1.5 +#define IMAGE_H_ 1.6 + 1.7 +class Image { 1.8 +private: 1.9 + mutable int tex_width, tex_height; 1.10 + mutable unsigned int tex; 1.11 + mutable bool tex_valid; 1.12 + 1.13 +public: 1.14 + int width, height; 1.15 + unsigned char *pixels; 1.16 + 1.17 + Image(); 1.18 + ~Image(); 1.19 + 1.20 + Image(const Image &img); 1.21 + Image &operator =(const Image &img); 1.22 + 1.23 + bool create(int width, int height, unsigned char *pixels = 0); 1.24 + void destroy(); 1.25 + 1.26 + bool load(const char *fname); 1.27 + 1.28 + unsigned int texture() const; 1.29 + int texture_width() const; 1.30 + int texture_height() const; 1.31 + 1.32 + void invalidate_texture(); 1.33 +}; 1.34 + 1.35 +void clear_image(Image *img); 1.36 +void clear_image(Image *img, float r, float g, float b); 1.37 + 1.38 +enum ImgCombine { 1.39 + IMG_OP_ADD, 1.40 + IMG_OP_SUB, 1.41 + IMG_OP_MUL, 1.42 + IMG_OP_LERP 1.43 +}; 1.44 + 1.45 +bool combine_image(Image *dest, const Image *aimg, const Image *bimg, ImgCombine op = IMG_OP_LERP, float t = 0.5); 1.46 + 1.47 +#endif // IMAGE_H_