[731] | 1 | #ifndef _IMGTEXTUREATLAS_H |
---|
| 2 | #define _IMGTEXTUREATLAS_H |
---|
| 3 | |
---|
| 4 | #include <IMGPrerequisites.h> |
---|
[751] | 5 | #include <IMGUtil.h> |
---|
[731] | 6 | #include <IMGTexture.h> |
---|
| 7 | |
---|
| 8 | namespace IMG { |
---|
| 9 | |
---|
| 10 | // Fordward declaration... |
---|
| 11 | class TextureAtlas; |
---|
| 12 | |
---|
| 13 | namespace boost
|
---|
| 14 | {
|
---|
| 15 | void intrusive_ptr_add_ref(TextureAtlas * p);
|
---|
| 16 | void intrusive_ptr_release(TextureAtlas * p);
|
---|
| 17 | }; |
---|
| 18 | |
---|
| 19 | class _IMGExport TextureAtlas : public Texture |
---|
| 20 | { |
---|
| 21 | |
---|
| 22 | private:
|
---|
| 23 | long references;
|
---|
| 24 | friend void boost::intrusive_ptr_add_ref(TextureAtlas * p);
|
---|
| 25 | friend void boost::intrusive_ptr_release(TextureAtlas * p); |
---|
| 26 | |
---|
| 27 | protected: |
---|
[745] | 28 | enum CurrentTextureAtlas
|
---|
| 29 | {
|
---|
| 30 | TEXTURE_ATLAS_PING,
|
---|
| 31 | TEXTURE_ATLAS_PONG
|
---|
| 32 | }; |
---|
| 33 | |
---|
[731] | 34 | Ogre::String mTextureAtlasName; |
---|
| 35 | |
---|
[745] | 36 | Ogre::Texture *mTextureAtlasPong; |
---|
[731] | 37 | |
---|
| 38 | Ogre::SceneNode *mTextureAtlasSceneNode; |
---|
| 39 | |
---|
| 40 | std::vector<TexturePtr> mTextureList; |
---|
| 41 | |
---|
[745] | 42 | unsigned int mCurrentTextureAtlas; |
---|
[731] | 43 | |
---|
[745] | 44 | bool mFirstUpdate; |
---|
| 45 | |
---|
[731] | 46 | public: |
---|
| 47 | |
---|
| 48 | TextureAtlas(); |
---|
| 49 | |
---|
| 50 | virtual ~TextureAtlas(); |
---|
| 51 | |
---|
[745] | 52 | void debug(); |
---|
[731] | 53 | |
---|
[751] | 54 | void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour); |
---|
[731] | 55 | |
---|
| 56 | void update(); |
---|
| 57 | |
---|
[745] | 58 | unsigned int getReference(); |
---|
| 59 | |
---|
[731] | 60 | void setTextureAtlasSceneNode(Ogre::SceneNode *textureAtlasSceneNode); |
---|
| 61 | |
---|
| 62 | Ogre::SceneNode* getTextureAtlasSceneNode(); |
---|
| 63 | |
---|
| 64 | void save(Ogre::String folderName, Ogre::String filename, Ogre::PixelFormat pixelFormat); |
---|
| 65 | |
---|
| 66 | void addTexture(TexturePtr texture); |
---|
| 67 | |
---|
| 68 | TexturePtr getTexture(unsigned int iTexture); |
---|
| 69 | |
---|
| 70 | void removeTexture(unsigned int iTexture); |
---|
| 71 | |
---|
| 72 | void setTextureAtlasName(Ogre::String textureAtlasName); |
---|
| 73 | |
---|
| 74 | Ogre::String getTextureAtlasName(); |
---|
| 75 | |
---|
| 76 | unsigned int getNumTextures(); |
---|
| 77 | |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | // class specific addref/release implementation
|
---|
| 81 | // the two function overloads must be in the boost namespace on most compilers:
|
---|
| 82 | namespace boost
|
---|
| 83 | {
|
---|
| 84 | inline void intrusive_ptr_add_ref(TextureAtlas * p)
|
---|
| 85 | {
|
---|
| 86 | // increment reference count of object *p
|
---|
| 87 | ++(p->references);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | inline void intrusive_ptr_release(TextureAtlas * p)
|
---|
| 93 | {
|
---|
| 94 | // decrement reference count, and delete object when reference count reaches 0
|
---|
| 95 | if (--(p->references) == 0)
|
---|
| 96 | delete p;
|
---|
| 97 | }
|
---|
| 98 | } // namespace boost
|
---|
| 99 |
|
---|
| 100 | typedef ::boost::intrusive_ptr<TextureAtlas> TextureAtlasPtr; |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | #endif |
---|