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

Revision 751, 2.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1#ifndef _IMGTEXTUREATLAS_H
2#define _IMGTEXTUREATLAS_H
3
4#include <IMGPrerequisites.h>
5#include <IMGUtil.h>
6#include <IMGTexture.h>
7
8namespace IMG {
9
10// Fordward declaration...
11class TextureAtlas;
12
13namespace boost
14{
15    void intrusive_ptr_add_ref(TextureAtlas * p);
16    void intrusive_ptr_release(TextureAtlas * p);
17};
18
19class _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:
28         enum CurrentTextureAtlas
29         {
30             TEXTURE_ATLAS_PING,
31         TEXTURE_ATLAS_PONG
32     };
33
34     Ogre::String mTextureAtlasName;
35
36         Ogre::Texture *mTextureAtlasPong;
37       
38         Ogre::SceneNode *mTextureAtlasSceneNode;
39
40     std::vector<TexturePtr> mTextureList;
41
42         unsigned int mCurrentTextureAtlas;
43
44         bool mFirstUpdate;
45
46  public:
47
48    TextureAtlas();
49
50    virtual ~TextureAtlas();
51
52        void debug();
53
54        void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour);
55
56        void update();
57
58        unsigned int getReference();
59
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:
82namespace 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
100typedef ::boost::intrusive_ptr<TextureAtlas> TextureAtlasPtr;
101
102}
103#endif
Note: See TracBrowser for help on using the repository browser.