00001 #ifndef TEXTURE_H
00002 #define TEXTURE_H
00003
00004 #include "Component.h"
00005 #include "includeGL.h"
00006 #include <string>
00007 #include "CGLA/Vec4f.h"
00008 #include <SDL.h>
00009 #include "Ressource.h"
00010
00011 using namespace CGLA;
00012
00013
00014 class Texture:public Component, public Ressource{
00015 public :
00016 static const RTTI TYPE;
00017 virtual const RTTI& getType() const{ return TYPE; }
00018
00019 protected:
00020 GLuint glTexObject;
00021 std::string ressourceName;
00022 SDL_Surface * textureMemory;
00023
00024 SDL_Surface * flipSurface(SDL_Surface * surface);
00025 GLuint loadTexture(const char * filename,bool useMipMap);
00026
00027 public:
00028 Texture();
00029 ~Texture();
00030
00031 virtual void load(const string& name);
00032
00033 void bindTexture()const;
00034 GLuint getTexId()const;
00035
00036 Vec4f getPixel(int u, int v)const;
00037 Vec4f getPixel(float u, float v)const;
00038
00039 int width()const{return textureMemory->w;}
00040 int height()const{return textureMemory->h;}
00041
00042 private:
00043
00044 friend class boost::serialization::access;
00045 template<class Archive>
00046 void serialize(Archive& ar, const unsigned int version){
00047
00048 ar & boost::serialization::base_object<Component>(*this);
00049 ar & ressourceName;
00050 }
00051 };
00052
00053 #endif