source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGTextureAtlas.h @ 745

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