Orxonox  0.0.5 Codename: Arcturus
OgreCEGUITexture.h
Go to the documentation of this file.
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 <CEGUIBase.h>
30 #include <CEGUIRenderer.h>
31 #include <CEGUITexture.h>
32 #include "OgreCEGUIRenderer.h"
33 
34 // Start of CEGUI namespace section
35 namespace CEGUI
36 {
41 class _OgrePrivate 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:
67  virtual ushort getWidth(void) const {return d_width;}
68 
69 
77  virtual ushort getHeight(void) const {return d_height;}
78 
79 
90  virtual void loadFromFile(const String& filename, const String& resourceGroup);
91 
92 
112  virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
113 
114 
122  Ogre::TexturePtr getOgreTexture(void) const {return d_ogre_texture;}
123 
124 
135  void setOgreTextureSize(uint size);
136 
137 
148  void setOgreTexture(Ogre::TexturePtr& texture);
149 
150 
151 private:
152  /*************************************************************************
153  Implementation Functions
154  *************************************************************************/
155  // safely free Ogre::Texture texture (can be called multiple times with no ill effect)
156  void freeOgreTexture(void);
157 
158  // return a Ogre::string that contains a unique name.
159  Ogre::String getUniqueName(void);
160 
161 
162  /*************************************************************************
163  Implementation Data
164  *************************************************************************/
165  static uint32 d_texturenumber;
166 
167  Ogre::TexturePtr d_ogre_texture;
168 
169  ushort d_width;
170  ushort d_height;
171 
172  bool d_isLinked;
173 };
174 
175 
176 } // End of CEGUI namespace section
177 
178 
179 #endif // end of guard _OgreCEGUITexture_h_
Ogre::TexturePtr getOgreTexture(void) const
Return a pointer to the internal Ogre::Texture object.
Definition: OgreCEGUITexture.h:122
virtual ushort getWidth(void) const
Returns the current pixel width of the texture.
Definition: OgreCEGUITexture.h:67
Texture class that is created by OgreCEGUIRenderer objects.
Definition: OgreCEGUITexture.h:41
virtual void destroyTexture(Texture *texture)
Definition: OgreCEGUIRenderer.cpp:406
ushort d_width
cached width of the texture
Definition: OgreCEGUITexture.h:169
static uint32 d_texturenumber
Counter used to provide unique texture names.
Definition: OgreCEGUITexture.h:165
ushort d_height
cached height of the texture
Definition: OgreCEGUITexture.h:170
bool d_isLinked
True if we are linked to a texture we did not actually create.
Definition: OgreCEGUITexture.h:172
Ogre::TexturePtr d_ogre_texture
The &#39;real&#39; texture.
Definition: OgreCEGUITexture.h:167
Definition: OgreCEGUIRenderer.cpp:46
virtual ushort getHeight(void) const
Returns the current pixel height of the texture.
Definition: OgreCEGUITexture.h:77
virtual Texture * createTexture(void)
Definition: OgreCEGUIRenderer.cpp:371