gpuray_glsl

annotate src/texture.h @ 3:297dbc5080c4

cone intersection
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 09 Nov 2014 20:13:33 +0200
parents
children
rev   line source
nuclear@0 1 #ifndef TEXTURE_H_
nuclear@0 2 #define TEXTURE_H_
nuclear@0 3
nuclear@0 4 #include <string>
nuclear@0 5 #include "image.h"
nuclear@0 6
nuclear@0 7 struct HitPoint;
nuclear@0 8
nuclear@0 9 class Texture {
nuclear@0 10 public:
nuclear@0 11 enum class SampleMode { nearest, linear };
nuclear@0 12 enum class WrapMode { clamp, repeat };
nuclear@0 13
nuclear@0 14 protected:
nuclear@0 15 std::string name;
nuclear@0 16
nuclear@0 17 SampleMode sampling;
nuclear@0 18 WrapMode wrapping;
nuclear@0 19
nuclear@0 20 public:
nuclear@0 21 Texture();
nuclear@0 22 virtual ~Texture();
nuclear@0 23
nuclear@0 24 virtual void set_name(const char *name);
nuclear@0 25 virtual const char *get_name() const;
nuclear@0 26
nuclear@0 27 virtual Image *get_image(int idx = 0) = 0;
nuclear@0 28 virtual const Image *get_image(int idx = 0) const = 0;
nuclear@0 29
nuclear@0 30 virtual void set_sampling_mode(SampleMode mode);
nuclear@0 31 virtual SampleMode get_sampling_mode() const;
nuclear@0 32 virtual void set_wrapping_mode(WrapMode mode);
nuclear@0 33 virtual WrapMode get_wrapping_mode() const;
nuclear@0 34
nuclear@0 35 virtual bool load(const char *fname) = 0;
nuclear@0 36
nuclear@0 37 virtual Color sample(float u, float v, float w) const = 0;
nuclear@0 38 virtual Color sample(const HitPoint &hit) const;
nuclear@0 39 };
nuclear@0 40
nuclear@0 41 class Texture2D : public Texture {
nuclear@0 42 private:
nuclear@0 43 Image img;
nuclear@0 44
nuclear@0 45 public:
nuclear@0 46 virtual Image *get_image(int idx = 0);
nuclear@0 47 virtual const Image *get_image(int idx = 0) const;
nuclear@0 48
nuclear@0 49 virtual bool load(const char *fname);
nuclear@0 50
nuclear@0 51 virtual Color sample(float u, float v, float w) const;
nuclear@0 52
nuclear@0 53 friend Texture *load_texture(const char *fname);
nuclear@0 54 };
nuclear@0 55
nuclear@0 56 class TextureCube : public Texture {
nuclear@0 57 private:
nuclear@0 58 Image img[6];
nuclear@0 59
nuclear@0 60 public:
nuclear@0 61 TextureCube();
nuclear@0 62
nuclear@0 63 virtual Image *get_image(int idx = 0);
nuclear@0 64 virtual const Image *get_image(int idx = 0) const;
nuclear@0 65
nuclear@0 66 virtual bool load(const char *fname);
nuclear@0 67
nuclear@0 68 virtual Color sample(float u, float v, float w) const;
nuclear@0 69 virtual Color sample(const HitPoint &hit) const;
nuclear@0 70
nuclear@0 71 friend Texture *load_texture(const char *fname);
nuclear@0 72 };
nuclear@0 73
nuclear@0 74 Texture *load_texture(const char *fname);
nuclear@0 75
nuclear@0 76 #endif // TEXTURE_H_