1 | /************************************************************************
|
---|
2 | filename: OgreCEGUITexture.h
|
---|
3 | created: 11/5/2004
|
---|
4 | author: Paul D Turner
|
---|
5 |
|
---|
6 | purpose: Interface to Texture implemented via Ogre engine
|
---|
7 | *************************************************************************/
|
---|
8 | /*************************************************************************
|
---|
9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
11 |
|
---|
12 | This library is free software; you can redistribute it and/or
|
---|
13 | modify it under the terms of the GNU Lesser General Public
|
---|
14 | License as published by the Free Software Foundation; either
|
---|
15 | version 2.1 of the License, or (at your option) any later version.
|
---|
16 |
|
---|
17 | This library is distributed in the hope that it will be useful,
|
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | Lesser General Public License for more details.
|
---|
21 |
|
---|
22 | You should have received a copy of the GNU Lesser General Public
|
---|
23 | License along with this library; if not, write to the Free Software
|
---|
24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *************************************************************************/
|
---|
26 | #ifndef _OgreCEGUITexture_h_
|
---|
27 | #define _OgreCEGUITexture_h_
|
---|
28 |
|
---|
29 | #include <CEGUI/CEGUIBase.h>
|
---|
30 | #include <CEGUI/CEGUIRenderer.h>
|
---|
31 | #include <CEGUI/CEGUITexture.h>
|
---|
32 | #include "OgreCEGUIRenderer.h"
|
---|
33 |
|
---|
34 | // Start of CEGUI namespace section
|
---|
35 | namespace CEGUI
|
---|
36 | {
|
---|
37 | /*!
|
---|
38 | \brief
|
---|
39 | Texture class that is created by OgreCEGUIRenderer objects
|
---|
40 | */
|
---|
41 | class OGRE_GUIRENDERER_API OgreCEGUITexture : public Texture
|
---|
42 | {
|
---|
43 | private:
|
---|
44 | /*************************************************************************
|
---|
45 | Friends (to allow construction and destruction)
|
---|
46 | *************************************************************************/
|
---|
47 | friend Texture* OgreCEGUIRenderer::createTexture(void);
|
---|
48 | friend Texture* OgreCEGUIRenderer::createTexture(const String& filename, const String& resourceGroup);
|
---|
49 | friend Texture* OgreCEGUIRenderer::createTexture(float size);
|
---|
50 | friend void OgreCEGUIRenderer::destroyTexture(Texture* texture);
|
---|
51 |
|
---|
52 |
|
---|
53 | /*************************************************************************
|
---|
54 | Construction & Destruction (by Renderer object only)
|
---|
55 | *************************************************************************/
|
---|
56 | OgreCEGUITexture(Renderer* owner);
|
---|
57 | virtual ~OgreCEGUITexture(void);
|
---|
58 |
|
---|
59 | public:
|
---|
60 | /*!
|
---|
61 | \brief
|
---|
62 | Returns the current pixel width of the texture
|
---|
63 |
|
---|
64 | \return
|
---|
65 | ushort value that is the current width of the texture in pixels
|
---|
66 | */
|
---|
67 | virtual ushort getWidth(void) const {return d_width;}
|
---|
68 |
|
---|
69 |
|
---|
70 | /*!
|
---|
71 | \brief
|
---|
72 | Returns the current pixel height of the texture
|
---|
73 |
|
---|
74 | \return
|
---|
75 | ushort value that is the current height of the texture in pixels
|
---|
76 | */
|
---|
77 | virtual ushort getHeight(void) const {return d_height;}
|
---|
78 |
|
---|
79 |
|
---|
80 | /*!
|
---|
81 | \brief
|
---|
82 | Loads the specified image file into the texture. The texture is resized as required to hold the image.
|
---|
83 |
|
---|
84 | \param filename
|
---|
85 | The filename of the image file that is to be loaded into the texture
|
---|
86 |
|
---|
87 | \return
|
---|
88 | Nothing.
|
---|
89 | */
|
---|
90 | virtual void loadFromFile(const String& filename, const String& resourceGroup);
|
---|
91 |
|
---|
92 |
|
---|
93 | /*!
|
---|
94 | \brief
|
---|
95 | Loads (copies) an image in memory into the texture. The texture is resized as required to hold the image.
|
---|
96 |
|
---|
97 | \param buffPtr
|
---|
98 | Pointer to the buffer containing the image data
|
---|
99 |
|
---|
100 | \param buffWidth
|
---|
101 | Width of the buffer (in 0xAARRGGBB pixels)
|
---|
102 |
|
---|
103 | \param buffHeight
|
---|
104 | Height of the buffer (in 0xAARRGGBB pixels)
|
---|
105 |
|
---|
106 | \return
|
---|
107 | Nothing.
|
---|
108 | */
|
---|
109 | virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight);
|
---|
110 |
|
---|
111 |
|
---|
112 | /*!
|
---|
113 | \brief
|
---|
114 | Return a pointer to the internal Ogre::Texture object
|
---|
115 |
|
---|
116 | \return
|
---|
117 | Pointer to the Ogre::Texture object currently being used by this Texture object
|
---|
118 | */
|
---|
119 | Ogre::TexturePtr getOgreTexture(void) const {return d_ogre_texture;}
|
---|
120 |
|
---|
121 |
|
---|
122 | /*!
|
---|
123 | \brief
|
---|
124 | set the size of the internal Ogre texture. Previous Ogre texture is lost.
|
---|
125 |
|
---|
126 | \param size
|
---|
127 | pixel size of the new internal texture. This will be rounded up to a power of 2.
|
---|
128 |
|
---|
129 | \return
|
---|
130 | Nothing.
|
---|
131 | */
|
---|
132 | void setOgreTextureSize(uint size);
|
---|
133 |
|
---|
134 |
|
---|
135 | /*!
|
---|
136 | \brief
|
---|
137 | Set the internal Ogre::TexturePtr object.
|
---|
138 |
|
---|
139 | \param texture
|
---|
140 | Reference to an Ogre::TexturePtr object that is to be used by this Texture object.
|
---|
141 |
|
---|
142 | \return
|
---|
143 | Nothing.
|
---|
144 | */
|
---|
145 | void setOgreTexture(Ogre::TexturePtr& texture);
|
---|
146 |
|
---|
147 |
|
---|
148 | private:
|
---|
149 | /*************************************************************************
|
---|
150 | Implementation Functions
|
---|
151 | *************************************************************************/
|
---|
152 | // safely free Ogre::Texture texture (can be called multiple times with no ill effect)
|
---|
153 | void freeOgreTexture(void);
|
---|
154 |
|
---|
155 | // return a Ogre::string that contains a unique name.
|
---|
156 | Ogre::String getUniqueName(void);
|
---|
157 |
|
---|
158 |
|
---|
159 | /*************************************************************************
|
---|
160 | Implementation Data
|
---|
161 | *************************************************************************/
|
---|
162 | static uint32 d_texturenumber; //!< Counter used to provide unique texture names.
|
---|
163 |
|
---|
164 | Ogre::TexturePtr d_ogre_texture; //!< The 'real' texture.
|
---|
165 |
|
---|
166 | ushort d_width; //!< cached width of the texture
|
---|
167 | ushort d_height; //!< cached height of the texture
|
---|
168 |
|
---|
169 | bool d_isLinked; //!< True if we are linked to a texture we did not actually create.
|
---|
170 | };
|
---|
171 |
|
---|
172 |
|
---|
173 | } // End of CEGUI namespace section
|
---|
174 |
|
---|
175 |
|
---|
176 | #endif // end of guard _OgreCEGUITexture_h_
|
---|