[2757] | 1 | #ifndef NO_PRAGMA_ONCE
|
---|
| 2 | #pragma once
|
---|
| 3 | #endif
|
---|
| 4 |
|
---|
| 5 | #ifndef __TEXTURE_H
|
---|
| 6 | #define __TEXTURE_H
|
---|
| 7 |
|
---|
| 8 | #include <string>
|
---|
| 9 |
|
---|
[2776] | 10 | namespace CHCDemoEngine
|
---|
[2757] | 11 | {
|
---|
| 12 |
|
---|
| 13 | ///
|
---|
| 14 | class Texture
|
---|
| 15 | {
|
---|
| 16 | public:
|
---|
[3147] | 17 |
|
---|
[3212] | 18 | // available texture formats
|
---|
[3147] | 19 | enum {FORMAT_INVALID, FORMAT_RGB, FORMAT_RGBA};
|
---|
[3212] | 20 | // texture uv modes
|
---|
[3147] | 21 | enum {CLAMP, REPEAT};
|
---|
| 22 |
|
---|
| 23 |
|
---|
[2757] | 24 | /** Constructor loading texture from file
|
---|
| 25 | */
|
---|
| 26 | Texture(const std::string &filename);
|
---|
| 27 | /** Destroys data.
|
---|
| 28 | */
|
---|
| 29 | ~Texture();
|
---|
| 30 | /** Returns image data.
|
---|
| 31 | */
|
---|
| 32 | void *GetImage() const;
|
---|
| 33 | /** Returns width of texture.
|
---|
| 34 | */
|
---|
| 35 | int GetWidth() const;
|
---|
| 36 | /** Returns width of texture.
|
---|
| 37 | */
|
---|
| 38 | int GetHeight() const;
|
---|
| 39 | /** Returns texture format. Currently only RGBA supported.
|
---|
| 40 | */
|
---|
| 41 | int GetFormat() const;
|
---|
| 42 | /** Returns name of the texture
|
---|
| 43 | */
|
---|
| 44 | std::string GetName() const;
|
---|
[3147] | 45 | /** Returns byte size of a row of the image.
|
---|
| 46 | */
|
---|
[2757] | 47 | int GetRowLength() const;
|
---|
[3147] | 48 | /** Returns byte size of one pixel
|
---|
| 49 | */
|
---|
[2757] | 50 | int GetPixelSize() const;
|
---|
[3147] | 51 | /** Returns byte size of the image
|
---|
| 52 | */
|
---|
[2768] | 53 | inline int GetByteSize() const;
|
---|
[2757] | 54 | /** Bind the texture.
|
---|
| 55 | */
|
---|
| 56 | void Bind() const;
|
---|
[3147] | 57 | /** Sets the boundary mode for the s texture coordinate parameter.
|
---|
| 58 | */
|
---|
[2846] | 59 | void SetBoundaryModeS(int mode) { mBoundaryModeS = mode; }
|
---|
[3147] | 60 | /** Sets the boundary mode for the T texture coordinate parameter.
|
---|
| 61 | */
|
---|
[2846] | 62 | void SetBoundaryModeT(int mode) { mBoundaryModeT = mode; }
|
---|
[2768] | 63 |
|
---|
[2846] | 64 | int GetBoundaryModeS() const { return mBoundaryModeS; }
|
---|
| 65 | int GetBoundaryModeT() const { return mBoundaryModeT; }
|
---|
[2768] | 66 |
|
---|
[2846] | 67 | /** Creates the texture from the image
|
---|
| 68 | */
|
---|
| 69 | void Create();
|
---|
[2964] | 70 | /** Returns id of this texture.
|
---|
| 71 | */
|
---|
| 72 | int GetId() const { return mTexId; }
|
---|
[2846] | 73 |
|
---|
| 74 |
|
---|
[2757] | 75 | protected:
|
---|
| 76 |
|
---|
| 77 | int mFormat;
|
---|
| 78 | int mWidth;
|
---|
| 79 | int mHeight;
|
---|
| 80 |
|
---|
| 81 | unsigned int mTexId;
|
---|
| 82 |
|
---|
[2846] | 83 | int mBoundaryModeS;
|
---|
| 84 | int mBoundaryModeT;
|
---|
| 85 |
|
---|
[2757] | 86 | std::string mName;
|
---|
| 87 |
|
---|
[2768] | 88 | int mByteSize;
|
---|
[2757] | 89 | void *mImage;
|
---|
[2850] | 90 |
|
---|
| 91 | bool mUseMipMap;
|
---|
[2757] | 92 | };
|
---|
| 93 |
|
---|
[2768] | 94 |
|
---|
| 95 | inline int Texture::GetByteSize() const
|
---|
| 96 | {
|
---|
| 97 | return mByteSize;
|
---|
[2757] | 98 | }
|
---|
| 99 |
|
---|
[2768] | 100 | }
|
---|
| 101 |
|
---|
[2757] | 102 | #endif // __TEXTURE_H
|
---|