tavli
annotate 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 |
rev | line source |
---|---|
nuclear@4 | 1 #ifndef IMAGE_H_ |
nuclear@4 | 2 #define IMAGE_H_ |
nuclear@4 | 3 |
nuclear@4 | 4 class Image { |
nuclear@4 | 5 private: |
nuclear@4 | 6 mutable int tex_width, tex_height; |
nuclear@4 | 7 mutable unsigned int tex; |
nuclear@4 | 8 mutable bool tex_valid; |
nuclear@4 | 9 |
nuclear@4 | 10 public: |
nuclear@4 | 11 int width, height; |
nuclear@4 | 12 unsigned char *pixels; |
nuclear@4 | 13 |
nuclear@4 | 14 Image(); |
nuclear@4 | 15 ~Image(); |
nuclear@4 | 16 |
nuclear@4 | 17 Image(const Image &img); |
nuclear@4 | 18 Image &operator =(const Image &img); |
nuclear@4 | 19 |
nuclear@4 | 20 bool create(int width, int height, unsigned char *pixels = 0); |
nuclear@4 | 21 void destroy(); |
nuclear@4 | 22 |
nuclear@4 | 23 bool load(const char *fname); |
nuclear@4 | 24 |
nuclear@4 | 25 unsigned int texture() const; |
nuclear@4 | 26 int texture_width() const; |
nuclear@4 | 27 int texture_height() const; |
nuclear@4 | 28 |
nuclear@4 | 29 void invalidate_texture(); |
nuclear@4 | 30 }; |
nuclear@4 | 31 |
nuclear@4 | 32 void clear_image(Image *img); |
nuclear@4 | 33 void clear_image(Image *img, float r, float g, float b); |
nuclear@4 | 34 |
nuclear@4 | 35 enum ImgCombine { |
nuclear@4 | 36 IMG_OP_ADD, |
nuclear@4 | 37 IMG_OP_SUB, |
nuclear@4 | 38 IMG_OP_MUL, |
nuclear@4 | 39 IMG_OP_LERP |
nuclear@4 | 40 }; |
nuclear@4 | 41 |
nuclear@4 | 42 bool combine_image(Image *dest, const Image *aimg, const Image *bimg, ImgCombine op = IMG_OP_LERP, float t = 0.5); |
nuclear@4 | 43 |
nuclear@4 | 44 #endif // IMAGE_H_ |