The last component we need to wrap is a texture. Textures are represented as instances of the clGLTexture
class:
class clGLTexture: public iIntrusivounter { public: clGLTexture(); virtual ~clGLTexture();
Bind the texture to a specified OpenGL texture unit:
void Bind( int TextureUnit ) const;
Load texture pixels from an API-independent bitmap:
void LoadFromBitmap( const clPtr<clBitmap>& Bitmap );
Set the texture coordinates clamping mode:
void SetClamping( Lenum Clamping );
Deal with the data formats and dimensions of t texture:
private: void SetFormat( Lenum Target, Lenum InternalFormat, Lenum Format, int Width, int Height ); Luint FTexID; Lenum FInternalFormat; Lenum FFormat; };
The implementation is quite compact. Here it is:
clGLTexturelGLTexture() : FTexID( 0 ) , FIntelFormat( 0 ) , FFormat( 0 ) { } clGLTexture::~clGLTexture() { if ( FTexID ) { LGL3->glDeleteTextures( 1, &FTexID ); } } void clGLTexture...