$search
00001 /* 00002 * Copyright (C) 2008 00003 * Robert Bosch LLC 00004 * Research and Technology Center North America 00005 * Palo Alto, California 00006 * 00007 * All rights reserved. 00008 * 00009 *------------------------------------------------------------------------------ 00010 * project ....: PUMA: Probablistic Unsupervised Model Acquisition 00011 * file .......: Texture.h 00012 * authors ....: Benjamin Pitzer 00013 * organization: Robert Bosch LLC 00014 * creation ...: 10/13/2006 00015 * modified ...: $Date: 2009-01-29 16:51:00 -0800 (Thu, 29 Jan 2009) $ 00016 * changed by .: $Author: wg75pal $ 00017 * revision ...: $Revision: 771 $ 00018 */ 00019 #ifndef TEXTURE_H 00020 #define TEXTURE_H 00021 00022 //== INCLUDES ================================================================== 00023 #include <GL/glew.h> 00024 #include <GL/gl.h> 00025 #include <GL/glu.h> 00026 #include <rtc/rtcImage.h> 00027 00028 //== NAMESPACES ================================================================ 00029 namespace rtc { 00030 00031 //== CLASS DEFINITION ========================================================== 00032 class Texture { 00033 public: 00034 // c'tor 00035 Texture(bool multi_use=false, int max_texture_size=1024); 00036 // d'tor 00037 virtual ~Texture(); 00038 00039 // create empty texture 00040 void create(int width, int height); 00041 // update texture 00042 void update(); 00043 // create empty RGBA texture 00044 void createRGBA(int width, int height); 00045 // update RGBA texture 00046 void updateRGBA(); 00047 00048 // draw texture 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 // load texture from image 00054 bool loadFromImage(const char *filename); 00055 bool saveToImage(const char* filename); 00056 void unloadTexture(); 00057 // create texture from image 00058 void fromImage(const Image4uc& image); 00059 void fromImage(const Image3uc& image); 00060 void toImage(Image4uc& image); 00061 00062 // bind/unbind 00063 void bind(GLenum target=GL_TEXTURE0); 00064 void unbind(); 00065 00066 // stream IO 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 } // namespace rtc 00085 //============================================================================== 00086 #endif //TEXTURE_H