#include <OSDLGLTexture.h>
Collaboration diagram for OSDL::Video::OpenGL::GLTexture:
The ownership of the source surface is not taken by GLtexture instances, since they have to convert it into their own specific format for OpenGL.
This converted surface can be kept by the GLtexture for future use.
It is recommended to do so, insofar as on some platforms some operations, such as resizing, destroy the OpenGL context, including bound textures.
In this case, they have to be reloaded, which is possible if they have kept their converted surface.
SetTextureMode should be called prior to any texture operation.
Definition at line 91 of file OSDLGLTexture.h.
Public Types | |
enum | TextureMode { Disabled, OneDim, TwoDim } |
Texture support can be disabled, or enabled for 1D or 2D textures. More... | |
enum | Textureflavour { None, Basic } |
Texture flavours are presets that can be chosen as a whole. More... | |
Public Member Functions | |
GLTexture (const std::string imageFilename, Textureflavour flavour=None) throw ( GLTextureException ) | |
Constructs a texture out of an image stored in a file. | |
GLTexture (Surface &sourceSurface, Textureflavour flavour=None) throw ( GLTextureException ) | |
Constructs a texture out of an existing surface. | |
virtual | ~GLTexture () throw () |
Virtual destructor, deallocates the owned internal surface, if any. | |
virtual bool | canBeUploaded () const throw () |
Tells whether this texture can be reloaded to the OpenGL context. | |
virtual void | upload () throw ( GLTextureException ) |
Uploads the internal texture to the OpenGL context. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw () |
Returns an user-friendly description of the state of this object. | |
void | SetTextureFlavour (Textureflavour flavour) throw ( GLTextureException ) |
Sets the current texture state according to specified flavour. | |
Static Public Member Functions | |
static TextureMode | GetTextureMode () throw () |
Returns the current texture mode. | |
static void | SetTextureMode (TextureMode newMode=TwoDim) throw () |
Sets the current texture mode. | |
Static Public Attributes | |
static TextureMode | CurrentTextureMode |
Stores the current texture mode. | |
Protected Member Functions | |
void | upload (Surface &sourceSurface, Textureflavour flavour) throw ( GLTextureException ) |
Uploads an adequately converted surface, copied from the specified one, and deallocates it iff no OpenGL context can be lost, otherwise keeps it in texture cache. | |
Protected Attributes | |
Surface * | _source |
The source surface from which this texture is made. | |
GLTextureIdentifier | _id |
Identifier given by OpenGL to reference this texture. | |
Private Member Functions | |
GLTexture (const GLTexture &source) throw () | |
Copy constructor made private to ensure that it will never be called. | |
GLTexture & | operator= (const GLTexture &source) throw () |
Assignment operator made private to ensure that it will never be called. |
Texture support can be disabled, or enabled for 1D or 2D textures.
Default is 'TwoDim', enabled for 2D textures.
Definition at line 106 of file OSDLGLTexture.h.
Texture flavours are presets that can be chosen as a whole.
'None' does not change state of texture settings, whereas 'Basic' sets classical settings for filters and texture coordinate management.
Definition at line 119 of file OSDLGLTexture.h.
GLTexture::GLTexture | ( | const std::string | imageFilename, | |
Textureflavour | flavour = None | |||
) | throw ( GLTextureException ) [explicit] |
Constructs a texture out of an image stored in a file.
imageFilename | the filename of the image, whose format (PNG, JPEG, etc.) will be auto-detected. | |
flavour | chooses the texture flavour to apply before loading this texture. Changes the texture settings if not 'None' (side-effect). |
Definition at line 46 of file OSDLGLTexture.cc.
References OSDL::Video::Surface::LoadImage().
GLTexture::GLTexture | ( | Surface & | sourceSurface, | |
Textureflavour | flavour = None | |||
) | throw ( GLTextureException ) [explicit] |
Constructs a texture out of an existing surface.
sourceSurface | the surface from which the texture will be defined. It cannot be 'const' since a temporary change to the surface has to be performed. Nevertheless the source surface is, after a successful call, actually unchanged. | |
flavour | chooses the texture flavour to apply before loading this texture. Changes the texture settings if not None (side-effect). |
Definition at line 87 of file OSDLGLTexture.cc.
GLTexture::~GLTexture | ( | ) | throw () [virtual] |
Virtual destructor, deallocates the owned internal surface, if any.
Definition at line 98 of file OSDLGLTexture.cc.
OSDL::Video::OpenGL::GLTexture::GLTexture | ( | const GLTexture & | source | ) | throw () [explicit, private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
bool GLTexture::canBeUploaded | ( | ) | const throw () [virtual] |
Tells whether this texture can be reloaded to the OpenGL context.
One necessary condition is that its source surface is available.
Definition at line 115 of file OSDLGLTexture.cc.
References _source.
Referenced by upload().
void GLTexture::upload | ( | ) | throw ( GLTextureException ) [virtual] |
Uploads the internal texture to the OpenGL context.
GLTextureException | if the texture could not be reloaded, for example if its source surface is not available anymore. |
Definition at line 123 of file OSDLGLTexture.cc.
References canBeUploaded().
const string GLTexture::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const throw () [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 145 of file OSDLGLTexture.cc.
References OSDL::Video::Pixels::toString().
GLTexture::TextureMode GLTexture::GetTextureMode | ( | ) | throw () [static] |
Returns the current texture mode.
Definition at line 171 of file OSDLGLTexture.cc.
References CurrentTextureMode.
void GLTexture::SetTextureMode | ( | TextureMode | newMode = TwoDim |
) | throw () [static] |
void GLTexture::SetTextureFlavour | ( | Textureflavour | flavour | ) | throw ( GLTextureException ) |
Sets the current texture state according to specified flavour.
GLTextureException | if the operation failed, including if no OpenGL support is available. |
Definition at line 188 of file OSDLGLTexture.cc.
References OSDL::Video::OpenGL::None, and OSDL::Video::Pixels::toString().
void GLTexture::upload | ( | Surface & | sourceSurface, | |
Textureflavour | flavour | |||
) | throw ( GLTextureException ) [protected] |
Uploads an adequately converted surface, copied from the specified one, and deallocates it iff no OpenGL context can be lost, otherwise keeps it in texture cache.
sourceSurface | the surface to upload. In all cases it will be copied and converted, therefore it will remain untouched. | |
flavour | the texture flavour to apply. See Textureflavour. |
Definition at line 253 of file OSDLGLTexture.cc.
References OSDL::Video::Surface::AlphaBlendingBlit, OSDL::Video::OpenGL::AlphaMask, OSDL::Video::OpenGL::BlueMask, OSDL::Video::OpenGL::GreenMask, OSDL::Video::OpenGL::RedMask, OSDL::Video::Surface::RLEColorkeyBlitAvailable, OSDL::Video::VideoModule::SoftwareSurface, and OSDL::Video::Pixels::toString().
GLTexture& OSDL::Video::OpenGL::GLTexture::operator= | ( | const GLTexture & | source | ) | throw () [private] |
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
Stores the current texture mode.
Default is 'TwoDim'.
Definition at line 238 of file OSDLGLTexture.h.
Referenced by GetTextureMode().
Surface* OSDL::Video::OpenGL::GLTexture::_source [protected] |
The source surface from which this texture is made.
Definition at line 296 of file OSDLGLTexture.h.
Referenced by canBeUploaded(), and ~GLTexture().
Identifier given by OpenGL to reference this texture.
Definition at line 303 of file OSDLGLTexture.h.
Referenced by ~GLTexture().