Crazy Eddies GUI System  0.6.2
opengltexture.h
1 /***********************************************************************
2  filename: opengltexture.h
3  created: 9/4/2004
4  author: Mark Strom
5  mwstrom@gmail.com
6 
7  purpose: Interface to Texture implemented via Opengl
8 *************************************************************************/
9 /***************************************************************************
10  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining
13  * a copy of this software and associated documentation files (the
14  * "Software"), to deal in the Software without restriction, including
15  * without limitation the rights to use, copy, modify, merge, publish,
16  * distribute, sublicense, and/or sell copies of the Software, and to
17  * permit persons to whom the Software is furnished to do so, subject to
18  * the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be
21  * included in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29  * OTHER DEALINGS IN THE SOFTWARE.
30  ***************************************************************************/
31 #ifndef _opengltexture_h_
32 #define _opengltexture_h_
33 
34 #include "CEGUIBase.h"
35 #include "CEGUIRenderer.h"
36 #include "CEGUITexture.h"
37 #include "openglrenderer.h"
38 
39 #include <list>
40 
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
50 class OPENGL_GUIRENDERER_API OpenGLTexture : public Texture
51 {
52 private:
53  /*************************************************************************
54  Friends (to allow construction and destruction)
55  *************************************************************************/
57  friend Texture* OpenGLRenderer::createTexture(const String& filename, const String& resourceGroup);
58  friend Texture* OpenGLRenderer::createTexture(float size);
59  friend void OpenGLRenderer::destroyTexture(Texture* texture);
60 
61 
62  /*************************************************************************
63  Construction & Destruction (by Renderer object only)
64  *************************************************************************/
65  OpenGLTexture(Renderer* owner);
66  virtual ~OpenGLTexture(void);
67 
68 public:
76  virtual ushort getWidth(void) const {return d_width;}
77 
85  virtual ushort getHeight(void) const {return d_height;}
86 
87  virtual ushort getOriginalWidth(void) const { return d_orgWidth; }
88  virtual ushort getOriginalHeight(void) const { return d_orgHeight; }
89 
90  virtual float getXScale(void) const { return d_xScale; }
91  virtual float getYScale(void) const { return d_yScale; }
92 
106  virtual void loadFromFile(const String& filename, const String& resourceGroup);
107 
108 
128  virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
129 
130 
138  GLuint getOGLTexid(void) const {return d_ogltexture;}
139 
140 
151  void setOGLTextureSize(uint size);
152 
153 
154  /************************************************************************
155  Grab/restore
156  *************************************************************************/
162  void grabTexture(void);
163 
164 
169  void restoreTexture(void);
170 
171 
172 private:
174  void updateCachedScaleValues();
175 
177  uint getSizeNextPOT(uint size) const;
178 
179  /*************************************************************************
180  Implementation Data
181  *************************************************************************/
182  GLuint d_ogltexture;
183  ushort d_width;
184  ushort d_height;
185  uint8* d_grabBuffer;
186 
187  ushort d_orgWidth;
189  ushort d_orgHeight;
191  float d_xScale;
193  float d_yScale;
194 };
195 
196 } // End of CEGUI namespace section
197 
198 
199 #endif // end of guard _opengltexture_h_