Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
RendererModules/OpenGL/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 _CEGUIOpenGLTexture_h_
28#define _CEGUIOpenGLTexture_h_
29
30#include "../../Base.h"
31#include "../../Renderer.h"
32#include "../../Texture.h"
33#include "CEGUI/RendererModules/OpenGL/RendererBase.h"
34
35#if defined(_MSC_VER)
36# pragma warning(push)
37# pragma warning(disable : 4251)
38#endif
39
40// Start of CEGUI namespace section
41namespace CEGUI
42{
44class OPENGL_GUIRENDERER_API OpenGLTexture : public Texture
45{
46public:
52 void setOpenGLTexture(GLuint tex, const Sizef& size);
53
61 GLuint getOpenGLTexture() const;
62
83 void setTextureSize(const Sizef& sz);
84
93
100
101 // implement abstract members from base class.
102 const String& getName() const;
103 const Sizef& getSize() const;
105 const Vector2f& getTexelScaling() const;
106 void loadFromFile(const String& filename, const String& resourceGroup);
107 void loadFromMemory(const void* buffer, const Sizef& buffer_size,
108 PixelFormat pixel_format);
109 void blitFromMemory(const void* sourceData, const Rectf& area);
110 void blitToMemory(void* targetData);
111 bool isPixelFormatSupported(const PixelFormat fmt) const;
112
113protected:
114 // Friends (to allow construction and destruction)
115 friend Texture& OpenGLRendererBase::createTexture(const String&);
116 friend Texture& OpenGLRendererBase::createTexture(const String&, const String&, const String&);
117 friend Texture& OpenGLRendererBase::createTexture(const String&, const Sizef&);
118 friend Texture& OpenGLRendererBase::createTexture(const String&, GLuint, const Sizef&);
119 friend void OpenGLRendererBase::destroyTexture(Texture&);
120 friend void OpenGLRendererBase::destroyTexture(const String&);
121
126 const String& filename, const String& resourceGroup);
129 const Sizef& size);
132 GLuint tex, const Sizef& size);
134 virtual ~OpenGLTexture();
135
138
141
144
145 GLint internalFormat() const;
146
149
151 void setTextureSize_impl(const Sizef& sz);
152
153 void loadUncompressedTextureBuffer(const Rectf& dest_area,
154 const GLvoid* buffer) const;
155
156 void loadCompressedTextureBuffer(const Rectf& dest_area,
157 const GLvoid* buffer) const;
158
159 GLsizei getCompressedTextureSize(const Sizef& pixel_size) const;
160
176 GLenum d_format;
181};
182
183} // End of CEGUI namespace section
184
185#if defined(_MSC_VER)
186# pragma warning(pop)
187#endif
188
189#endif // end of guard _CEGUIOpenGLTexture_h_
Common base class used for other OpenGL (desktop or ES) based renderer modules.
Definition RendererBase.h:54
Texture implementation for the OpenGLRenderer.
Definition RendererModules/OpenGL/Texture.h:45
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
void setTextureSize(const Sizef &sz)
set the size of the internal texture.
Sizef d_size
Size of the texture.
Definition RendererModules/OpenGL/Texture.h:164
void grabTexture()
Grab the texture to a local buffer.
OpenGLRendererBase & d_owner
OpenGLRenderer that created and owns this OpenGLTexture.
Definition RendererModules/OpenGL/Texture.h:172
void setOpenGLTexture(GLuint tex, const Sizef &size)
set the openGL texture that this Texture is based on to the specified texture, with the specified siz...
const Sizef & getSize() const
Returns the current pixel size of the texture.
GLuint d_ogltexture
The OpenGL texture we're wrapping.
Definition RendererModules/OpenGL/Texture.h:162
void blitToMemory(void *targetData)
Performs a complete blit from the texture surface to memory.
bool d_isCompressed
Whether Texture format is a compressed format.
Definition RendererModules/OpenGL/Texture.h:180
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...
const Vector2f & getTexelScaling() const
Returns pixel to texel scale values that should be used for converting pixel values to texture co-ord...
GLenum d_subpixelFormat
Texture subpixel format.
Definition RendererModules/OpenGL/Texture.h:178
const Sizef & getOriginalDataSize() const
Returns the original pixel size of the data loaded into the texture.
void cleanupOpenGLTexture()
clean up the GL texture, or the grab buffer if it had been grabbed
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...
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition RendererModules/OpenGL/Texture.h:170
const String & getName() const
Returns the name given to the texture when it was created.
GLenum d_format
Texture format.
Definition RendererModules/OpenGL/Texture.h:176
OpenGLTexture(OpenGLRendererBase &owner, const String &name, const String &filename, const String &resourceGroup)
Constructor that creates a Texture from an image file.
OpenGLTexture(OpenGLRendererBase &owner, const String &name, GLuint tex, const Sizef &size)
Constructor that wraps an existing GL texture.
GLuint getOpenGLTexture() const
Return the internal OpenGL texture id used by this Texture object.
void generateOpenGLTexture()
generate the OpenGL texture and set some initial options.
virtual ~OpenGLTexture()
Destructor.
uint8 * d_grabBuffer
cached image data for restoring the texture.
Definition RendererModules/OpenGL/Texture.h:166
OpenGLTexture(OpenGLRendererBase &owner, const String &name)
Basic constructor.
const String d_name
The name given for this texture.
Definition RendererModules/OpenGL/Texture.h:174
void blitFromMemory(const void *sourceData, const Rectf &area)
Performs an area memory blit to the texture.
void setTextureSize_impl(const Sizef &sz)
internal texture resize function (does not reset format or other fields)
void restoreTexture()
Restore the texture from the locally buffered copy previously create by a call to grabTexture.
OpenGLTexture(OpenGLRendererBase &owner, const String &name, const Sizef &size)
Constructor that creates a Texture with a given size.
Sizef d_dataSize
original size of pixel data loaded into texture
Definition RendererModules/OpenGL/Texture.h:168
void initInternalPixelFormatFields(const PixelFormat fmt)
initialise the internal format flags for the given CEGUI::PixelFormat.
bool isPixelFormatSupported(const PixelFormat fmt) const
Return whether the specified pixel format is supported by the system for the CEGUI::Texture implement...
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