Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/gui/OgreCEGUITexture.h @ 1784

Last change on this file since 1784 was 1784, checked in by rgrieder, 16 years ago
  • removed obsolete Convert.h includes (possibly from old XML loading)
  • replaced tabs in audio library, plus minor code cleanup because removing the tabs screwed layout
  • replaced all "#define name number" with "const Type name = number" if possible
  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
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
35namespace CEGUI
36{
37/*!
38\brief
39    Texture class that is created by OgreCEGUIRenderer objects
40*/
41class _OgrePrivate OgreCEGUITexture : public Texture
42{
43private:
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
59public:
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 pixels as specified by \a pixelFormat )
102   
103    \param buffHeight
104        Height of the buffer (in pixels as specified by \a pixelFormat )
105   
106    \param pixelFormat
107    PixelFormat value describing the format contained in \a buffPtr
108   
109    \return
110        Nothing.
111    */
112    virtual void        loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
113
114
115    /*!
116    \brief
117        Return a pointer to the internal Ogre::Texture object
118
119    \return
120        Pointer to the Ogre::Texture object currently being used by this Texture object
121    */
122    Ogre::TexturePtr    getOgreTexture(void) const              {return d_ogre_texture;}
123
124
125    /*!
126    \brief
127        set the size of the internal Ogre texture.  Previous Ogre texture is lost.
128
129    \param size
130        pixel size of the new internal texture.  This will be rounded up to a power of 2.
131
132    \return
133        Nothing.
134    */
135    void        setOgreTextureSize(uint size);
136
137
138    /*!
139    \brief
140        Set the internal Ogre::TexturePtr object.
141
142    \param texture
143        Reference to an Ogre::TexturePtr object that is to be used by this Texture object.
144
145    \return
146        Nothing.
147    */
148    void        setOgreTexture(Ogre::TexturePtr& texture);
149
150
151private:
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;        //!< Counter used to provide unique texture names.
166
167    Ogre::TexturePtr            d_ogre_texture;         //!< The 'real' texture.
168
169    ushort                                      d_width;                        //!< cached width of the texture
170    ushort                                      d_height;                       //!< cached height of the texture
171
172    bool        d_isLinked;             //!< True if we are linked to a texture we did not actually create.
173};
174
175
176} // End of  CEGUI namespace section
177
178
179#endif  // end of guard _OgreCEGUITexture_H__
Note: See TracBrowser for help on using the repository browser.