Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TEXTURE_H
00020 #define TEXTURE_H
00021
00022
00023 #include <GL/glew.h>
00024 #include <GL/gl.h>
00025 #include <GL/glu.h>
00026 #include <rtc/rtcImage.h>
00027
00028
00029 namespace rtc {
00030
00031
00032 class Texture {
00033 public:
00034
00035 Texture(bool multi_use=false, int max_texture_size=1024);
00036
00037 virtual ~Texture();
00038
00039
00040 void create(int width, int height);
00041
00042 void update();
00043
00044 void createRGBA(int width, int height);
00045
00046 void updateRGBA();
00047
00048
00049 void draw();
00050 void draw2(double x1, double y1, double x2, double y2,
00051 double x3, double y3, double x4, double y4);
00052
00053
00054 bool loadFromImage(const char *filename);
00055 bool saveToImage(const char* filename);
00056 void unloadTexture();
00057
00058 void fromImage(const Image4uc& image);
00059 void fromImage(const Image3uc& image);
00060 void toImage(Image4uc& image);
00061
00062
00063 void bind(GLenum target=GL_TEXTURE0);
00064 void unbind();
00065
00066
00067 virtual bool write(std::ostream& os, bool ascii) const;
00068 virtual bool read(std::istream& is, bool ascii);
00069 public:
00070 bool multi_use;
00071 int max_texture_size;
00072 unsigned int texture_id;
00073 int texture_width;
00074 int texture_height;
00075 int image_width;
00076 int image_height;
00077 float max_u, max_v;
00078 unsigned char *texture_data;
00079
00080 GLenum bind_target;
00081 };
00082
00083
00084 }
00085
00086 #endif //TEXTURE_H