Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
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
36namespace CEGUI
37{
39class OPENGLES_GUIRENDERER_API OpenGLESTexture : public Texture
40{
41public:
47 void setOpenGLESTexture(GLuint tex, const Sizef& size);
48
56 GLuint getOpenGLESTexture() const;
57
78 void setTextureSize(const Sizef& sz);
79
88
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
108protected:
109 // Friends (to allow construction and destruction)
110 friend Texture& OpenGLESRenderer::createTexture(const String&);
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&);
115 friend void OpenGLESRenderer::destroyTexture(Texture&);
116
121 const String& filename, const String& resourceGroup);
124 const Sizef& size);
126 OpenGLESTexture(OpenGLESRenderer& owner, const String& name, GLuint tex,
127 const Sizef& size);
130
133
136
139
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
171 GLenum d_format;
176};
177
178} // End of CEGUI namespace section
179
180
181#endif // end of guard _CEGUIOpenGLESTexture_h_
Renderer class to interface with OpenGLES.
Definition RendererModules/OpenGLES/Renderer.h:67
Texture implementation for the OpenGLESRenderer.
Definition RendererModules/OpenGLES/Texture.h:40
OpenGLESTexture(OpenGLESRenderer &owner, const String &name, GLuint tex, const Sizef &size)
Constructor that wraps an existing GL texture.
void setTextureSize(const Sizef &sz)
set the size of the internal texture.
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition RendererModules/OpenGLES/Texture.h:165
void grabTexture()
Grab the texture to a local buffer.
GLenum d_subpixelFormat
Texture subpixel format.
Definition RendererModules/OpenGLES/Texture.h:173
void blitFromMemory(const void *sourceData, const Rectf &area)
Performs an area memory blit to the texture.
const Sizef & getSize() const
Returns the current pixel size of the texture.
OpenGLESTexture(OpenGLESRenderer &owner, const String &name)
Basic constructor.
void setOpenGLESTexture(GLuint tex, const Sizef &size)
set the openGL texture that this Texture is based on to the specified texture, with the specified siz...
void restoreTexture()
Restore the texture from the locally buffered copy previously create by a call to grabTexture.
bool isPixelFormatSupported(const PixelFormat fmt) const
Return whether the specified pixel format is supported by the system for the CEGUI::Texture implement...
const Sizef & getOriginalDataSize() const
Returns the original pixel size of the data loaded into the texture.
void setTextureSize_impl(const Sizef &sz)
internal texture resize function (does not reset format or other fields)
void loadFromMemory(const void *buffer, const Sizef &buffer_size, PixelFormat pixel_format)
Loads (copies) an image in memory into the texture. The texture is resized as required to hold the im...
const String d_name
Name of the texture given when it was created.
Definition RendererModules/OpenGLES/Texture.h:169
void initPixelFormatFields(const PixelFormat fmt)
initialise the internal format flags for the given CEGUI::PixelFormat.
void generateOpenGLESTexture()
generate the OpenGLES texture and set some initial options.
void cleanupOpenGLESTexture()
clean up the GL texture, or the grab buffer if it had been grabbed
GLenum d_format
Texture format.
Definition RendererModules/OpenGLES/Texture.h:171
virtual ~OpenGLESTexture()
Destructor.
Sizef d_dataSize
original pixel of size data loaded into texture
Definition RendererModules/OpenGLES/Texture.h:163
GLuint getOpenGLESTexture() const
Return the internal OpenGLES texture id used by this Texture object.
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
void loadCompressedTextureBuffer(const Rectf &buffer_size, const GLvoid *buffer) const
load uncompressed data from buffer to GL texture.
void loadFromFile(const String &filename, const String &resourceGroup)
Loads the specified image file into the texture. The texture is resized as required to hold the image...
void loadUncompressedTextureBuffer(const Rectf &buffer_size, const GLvoid *buffer) const
load uncompressed data from buffer to GL texture.
Sizef d_size
Size of the texture.
Definition RendererModules/OpenGLES/Texture.h:159
uint8 * d_grabBuffer
cached image data for restoring the texture.
Definition RendererModules/OpenGLES/Texture.h:161
const Vector2f & getTexelScaling() const
Returns pixel to texel scale values that should be used for converting pixel values to texture co-ord...
OpenGLESTexture(OpenGLESRenderer &owner, const String &name, const String &filename, const String &resourceGroup)
Constructor that creates a Texture from an image file.
const String & getName() const
Returns the name given to the texture when it was created.
OpenGLESRenderer & d_owner
OpenGLESRenderer that created and owns this OpenGLESTexture.
Definition RendererModules/OpenGLES/Texture.h:167
bool d_isCompressed
Whether Texture format is a compressed format.
Definition RendererModules/OpenGLES/Texture.h:175
void blitToMemory(void *targetData)
Performs a complete blit from the texture surface to memory.
OpenGLESTexture(OpenGLESRenderer &owner, const String &name, const Sizef &size)
Constructor that creates a Texture with a given size.
GLuint d_ogltexture
The OpenGLES texture we're wrapping.
Definition RendererModules/OpenGLES/Texture.h:157
String class used within the GUI system.
Definition String.h:64
Abstract base class specifying the required interface for Texture objects.
Definition Texture.h:54
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition Texture.h:62
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1