00001
00002 #ifndef _TP_TEXTUREUNIT_H
00003 #define _TP_TEXTUREUNIT_H
00004
00005 #include "GL/GLPlatform.h"
00006 #include "GL/TPProgramName.h"
00007
00008
00009 namespace gk {
00010
00011 class GLTexture;
00012 class GLSampler;
00013
00014 class TextureUnitState
00015 {
00016 GLTexture *m_texture;
00017 GLSampler *m_sampler;
00018 int m_index;
00019
00020 TextureUnitState( const int index )
00021 :
00022 m_texture(NULL),
00023 m_sampler(NULL),
00024 m_index(index)
00025 {}
00026
00027 public:
00028 TextureUnitState( )
00029 :
00030 m_texture(NULL),
00031 m_sampler(NULL),
00032 m_index(-1)
00033 {}
00034
00035 TextureUnitState& setIndex( const int index )
00036 {
00037 m_index= index;
00038 return *this;
00039 }
00040
00041 int getIndex( )
00042 {
00043 return m_index;
00044 }
00045
00046 TextureUnitState& setTextureUnit( const ProgramSampler& unit, GLTexture *texture, GLSampler *sampler );
00047 TextureUnitState& reset( );
00048
00049 TextureUnitState& setTexture( const ProgramSampler& unit, GLTexture *texture );
00050 TextureUnitState& resetTexture( );
00051 GLTexture *getTexture( )
00052 {
00053 return m_texture;
00054 }
00055
00056 TextureUnitState& setSampler( const ProgramSampler& unit, GLSampler *sampler );
00057 TextureUnitState& resetSampler( );
00058 GLSampler *getSampler( )
00059 {
00060 return m_sampler;
00061 }
00062
00063
00064 static int init( );
00065 };
00066
00067 enum
00068 {
00069 UNIT0= 0,
00070 UNIT1= 1,
00071 UNIT2= 2,
00072 UNIT3= 3,
00073 UNIT4= 4,
00074 UNIT5= 5,
00075 UNIT6= 6,
00076 UNIT7= 7
00077 };
00078
00079 extern TextureUnitState TextureUnits[16];
00080 extern TextureUnitState ActiveTextureUnits[16];
00081 extern int ActiveUnit;
00082 extern int TextureUnitCount;
00083
00084 TextureUnitState& setTexture( const ProgramSampler& unit, GLTexture *texture );
00085 TextureUnitState& setSampler( const ProgramSampler& unit, GLSampler *sampler );
00086 TextureUnitState& setTextureUnit( const ProgramSampler& unit, GLTexture *texture, GLSampler *sampler );
00087 TextureUnitState& resetTexture( const ProgramSampler& unit );
00088 TextureUnitState& resetSampler( const ProgramSampler& unit );
00089 TextureUnitState& resetTextureUnit( const ProgramSampler& unit );
00090
00091 }
00092
00093 #endif