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

Revision 745, 2.6 KB checked in by igarcia, 18 years ago (diff)
Line 
1#ifndef _IMGTEXTURE_H
2#define _IMGTEXTURE_H
3
4#include <IMGPrerequisites.h>
5
6namespace IMG
7{
8
9// Forward declarations
10class _IMGExport Texture;
11
12
13namespace boost
14{
15    void intrusive_ptr_add_ref(Texture * p);
16    void intrusive_ptr_release(Texture * p);
17};
18
19class _IMGExport Texture
20{
21
22private:
23    long references;
24    friend void boost::intrusive_ptr_add_ref(Texture * p);
25    friend void boost::intrusive_ptr_release(Texture * p);
26
27  protected:
28         Ogre::Texture *mTexture;
29
30         Ogre::Material *mMaterial;
31
32     Ogre::Rectangle2D *mRectangle2D;
33
34         unsigned int mWidth;
35
36         unsigned int mHeight;
37
38         Ogre::String mTextureName;
39
40         Ogre::ColourValue mAvgColour;
41
42         Ogre::ColourValue mBackgroundColour;
43
44         bool mCalculatedAvgColour;
45
46         Ogre::Camera *mCamera;
47
48         Ogre::PixelFormat mPixelFormat;
49
50  public:
51     Texture();
52
53     virtual ~Texture();
54
55         void setRenderTargetListener(Ogre::RenderTargetListener *renderTargetListener);
56
57         virtual void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera);
58
59         Ogre::ColourValue getAvgColour();
60
61         void calculateAvgColour();
62
63         void setBackgroundColour(Ogre::ColourValue colour);
64
65         Ogre::ColourValue getBackgroundColour();
66
67         virtual void load(Ogre::String folderName, Ogre::String filename);
68
69         virtual void save(Ogre::String folderName, Ogre::String filename);
70
71         virtual void update();
72
73         void setCorners(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom);
74
75         Ogre::Rectangle2D* getRectangle2D();
76
77         Ogre::Vector2 getMinTexCoord();
78
79         Ogre::Vector2 getMaxTexCoord();
80
81     void setWidth(unsigned int width);
82
83     unsigned int getWidth();
84
85     void setHeight(unsigned int height);
86
87     unsigned int getHeight();
88
89     void setTextureName(Ogre::String textureName);
90
91     Ogre::String getTextureName();
92
93         void setMaterial(Ogre::Material *material);
94
95         Ogre::Material* getMaterial();
96
97         void bind(Ogre::String textureName);
98
99         void setCamera(Ogre::Camera *camera);
100
101         void setFormat(Ogre::PixelFormat pixelFormat);
102
103};
104
105// class specific addref/release implementation
106// the two function overloads must be in the boost namespace on most compilers:
107namespace boost
108{
109 inline void intrusive_ptr_add_ref(Texture * p)
110  {
111    // increment reference count of object *p
112    ++(p->references);
113  }
114
115
116
117 inline void intrusive_ptr_release(Texture * p)
118  {
119   // decrement reference count, and delete object when reference count reaches 0
120   if (--(p->references) == 0)
121     delete p;
122  }
123} // namespace boost
124
125typedef ::boost::intrusive_ptr<Texture> TexturePtr;
126
127}
128#endif
Note: See TracBrowser for help on using the repository browser.