Crazy Eddie's GUI System  0.8.5
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 Rectf& buffer_size,
148  const GLvoid* buffer) const;
149 
151  void loadCompressedTextureBuffer(const Rectf& buffer_size,
152  const GLvoid* 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_
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions...
GLenum d_format
Texture format.
Definition: RendererModules/OpenGLES/Texture.h:171
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition: Texture.h:61
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Renderer class to interface with OpenGLES.
Definition: RendererModules/OpenGLES/Renderer.h:66
Sizef d_dataSize
original pixel of size data loaded into texture
Definition: RendererModules/OpenGLES/Texture.h:163
bool d_isCompressed
Whether Texture format is a compressed format.
Definition: RendererModules/OpenGLES/Texture.h:175
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition: RendererModules/OpenGLES/Texture.h:165
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:52
Texture & createTexture(const String &name)
Create a 'null' Texture object.
uint8 * d_grabBuffer
cached image data for restoring the texture.
Definition: RendererModules/OpenGLES/Texture.h:161
Sizef d_size
Size of the texture.
Definition: RendererModules/OpenGLES/Texture.h:159
GLuint d_ogltexture
The OpenGLES texture we're wrapping.
Definition: RendererModules/OpenGLES/Texture.h:157
Texture implementation for the OpenGLESRenderer.
Definition: RendererModules/OpenGLES/Texture.h:39
const String d_name
Name of the texture given when it was created.
Definition: RendererModules/OpenGLES/Texture.h:169
OpenGLESRenderer & d_owner
OpenGLESRenderer that created and owns this OpenGLESTexture.
Definition: RendererModules/OpenGLES/Texture.h:167
GLenum d_subpixelFormat
Texture subpixel format.
Definition: RendererModules/OpenGLES/Texture.h:173
String class used within the GUI system.
Definition: String.h:62