Blender V2.61 - r43446

BL_Texture.h

Go to the documentation of this file.
00001 
00006 #ifndef __BL_TEXTURE_H__
00007 #define __BL_TEXTURE_H__
00008 
00009 //  #include <vector>
00010 //  #include <map>
00011 
00012 #include "MT_Matrix4x4.h"
00013 #include "KX_Camera.h"
00014 
00015 // --
00016 struct Image;
00017 struct EnvMap;
00018 class BL_Material;
00019 class RAS_Rect;
00020 class RAS_ICanvas;
00021 //class RTData;
00022 
00023 #include "STR_String.h"
00024 
00025 class BL_Texture
00026 {
00027 private:
00028     unsigned int        mTexture;       // Bound texture unit data
00029     bool                mOk;            // ...
00030     bool                mNeedsDeleted;  // If generated
00031     unsigned int        mType;          // enum TEXTURE_2D | CUBE_MAP 
00032     int                 mUnit;          // Texture unit associated with mTexture
00033     unsigned int        mEnvState;      // cache textureEnv
00034     static unsigned int mDisableState;  // speed up disabling calls
00035 
00036     void InitNonPow2Tex(unsigned int *p,int x,int y,bool mipmap );
00037     void InitGLTex(unsigned int *p,int x,int y,bool mipmap );
00038 public:
00039     BL_Texture();
00040     ~BL_Texture( );
00041 
00042     bool Ok();
00043     int  GetUnit()          {return mUnit;}
00044     void SetUnit(int unit)  {mUnit = unit;}
00045 
00046     unsigned int GetTextureType() const;
00047     void DeleteTex();
00048 
00049     bool InitFromImage(int unit, Image *img, bool mipmap);
00050     bool InitCubeMap(int unit,EnvMap *cubemap );
00051 
00052     bool IsValid();
00053     void Validate();
00054 
00055     static void ActivateFirst();
00056     static void DisableAllTextures();
00057     static void ActivateUnit(int unit);
00058     static int GetMaxUnits();
00059     static int GetPow2(int x);
00060     static void SplitEnvMap(EnvMap *map);
00061 
00062 
00063     void ActivateTexture();
00064     void SetMapping(int mode);
00065     void DisableUnit();
00066     void setTexEnv(BL_Material *mat, bool modulate=false);
00067     unsigned int swapTexture (unsigned int newTex) {
00068         // swap texture codes
00069         unsigned int tmp = mTexture;
00070         mTexture = newTex;
00071         // return original texture code
00072         return tmp;
00073     }
00074 
00075 
00076 #ifdef WITH_CXX_GUARDEDALLOC
00077 public:
00078     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Texture"); }
00079     void operator delete( void *mem ) { MEM_freeN(mem); }
00080 #endif
00081 };
00082 
00083 #endif//__BL_TEXTURE_H__