#ifndef NO_PRAGMA_ONCE #pragma once #endif #ifndef __TEXTURE_H #define __TEXTURE_H #include namespace CHCDemoEngine { /// class Texture { public: // available texture formats enum {FORMAT_INVALID, FORMAT_RGB, FORMAT_RGBA}; // texture uv modes enum {CLAMP, REPEAT, BORDER}; /** Constructor loading texture from file */ Texture(const std::string &filename); /** Destroys data. */ ~Texture(); /** Returns image data. */ void *GetImage() const; /** Returns width of texture. */ int GetWidth() const; /** Returns width of texture. */ int GetHeight() const; /** Returns texture format. Currently only RGBA supported. */ int GetFormat() const; /** Returns name of the texture */ std::string GetName() const; /** Returns byte size of a row of the image. */ int GetRowLength() const; /** Returns byte size of one pixel */ int GetPixelSize() const; /** Returns byte size of the image */ inline int GetByteSize() const; /** Bind the texture. */ void Bind() const; /** Sets the boundary mode for the s texture coordinate parameter. */ void SetBoundaryModeS(int mode) { mBoundaryModeS = mode; } /** Sets the boundary mode for the T texture coordinate parameter. */ void SetBoundaryModeT(int mode) { mBoundaryModeT = mode; } int GetBoundaryModeS() const { return mBoundaryModeS; } int GetBoundaryModeT() const { return mBoundaryModeT; } /** Creates the texture from the image */ void Create(); /** Returns id of this texture. */ int GetId() const { return mTexId; } protected: int mFormat; int mWidth; int mHeight; unsigned int mTexId; int mBoundaryModeS; int mBoundaryModeT; std::string mName; int mByteSize; void *mImage; bool mUseMipMap; }; inline int Texture::GetByteSize() const { return mByteSize; } } #endif // __TEXTURE_H