Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/OpenGLES/Texture.h
1 /***********************************************************************
2  created: Sun Jan 11 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIOpenGLESTexture_h_
28 #define _CEGUIOpenGLESTexture_h_
29 
30 #include "CEGUI/Base.h"
31 #include "CEGUI/Renderer.h"
32 #include "CEGUI/Texture.h"
33 #include "CEGUI/RendererModules/OpenGLES/Renderer.h"
34 
35 // Start of CEGUI namespace section
36 namespace CEGUI
37 {
39 class OPENGLES_GUIRENDERER_API OpenGLESTexture : public Texture
40 {
41 public:
47  void setOpenGLESTexture(GLuint tex, const Sizef& size);
48 
56  GLuint getOpenGLESTexture() const;
57 
78  void setTextureSize(const Sizef& sz);
79 
87  void grabTexture();
88 
94  void restoreTexture();
95 
96  // implement abstract members from base class.
97  const String& getName() const;
98  const Sizef& getSize() const;
99  const Sizef& getOriginalDataSize() const;
100  const Vector2f& getTexelScaling() const;
101  void loadFromFile(const String& filename, const String& resourceGroup);
102  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
103  PixelFormat pixel_format);
104  void blitFromMemory(const void* sourceData, const Rectf& area);
105  void blitToMemory(void* targetData);
106  bool isPixelFormatSupported(const PixelFormat fmt) const;
107 
108 protected:
109  // Friends (to allow construction and destruction)
111  friend Texture& OpenGLESRenderer::createTexture(const String&, const String&, const String&);
112  friend Texture& OpenGLESRenderer::createTexture(const String&, const Sizef&);
113  friend Texture& OpenGLESRenderer::createTexture(const String&, GLuint, const Sizef&);
114  friend void OpenGLESRenderer::destroyTexture(const String&);
116 
118  OpenGLESTexture(OpenGLESRenderer& owner, const String& name);
120  OpenGLESTexture(OpenGLESRenderer& owner, const String& name,
121  const String& filename, const String& resourceGroup);
123  OpenGLESTexture(OpenGLESRenderer& owner, const String& name,
124  const Sizef& size);
126  OpenGLESTexture(OpenGLESRenderer& owner, const String& name, GLuint tex,
127  const Sizef& size);
129  virtual ~OpenGLESTexture();
130 
132  void generateOpenGLESTexture();
133 
135  void updateCachedScaleValues();
136 
138  void cleanupOpenGLESTexture();
139 
141  void initPixelFormatFields(const PixelFormat fmt);
142 
144  void setTextureSize_impl(const Sizef& sz);
145 
147  void loadUncompressedTextureBuffer(const Sizef& buffer_size,
148  const void* buffer) const;
149 
151  void loadCompressedTextureBuffer(const Sizef& buffer_size,
152  const void* buffer) const;
153 
154  GLsizei getCompressedTextureSize(const Sizef& pixel_size) const;
155 
157  GLuint d_ogltexture;
161  uint8* d_grabBuffer;
169  const String d_name;
171  GLenum d_format;
176 };
177 
178 } // End of CEGUI namespace section
179 
180 
181 #endif // end of guard _CEGUIOpenGLESTexture_h_