OSDL::Video::OpenGL::GLTexture Class Reference

#include <OSDLGLTexture.h>

Collaboration diagram for OSDL::Video::OpenGL::GLTexture:

[legend]
List of all members.

Detailed Description

Encapsulates an OpenGL texture, constructed directly or not from a surface.

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.

Note:
OpenGL support must have been selected and be available at configure time so that these OpenGL services can be used.

SetTextureMode should be called prior to any texture operation.

See also:
'http://osdl.sourceforge.net', then 'Documentation', 'Rendering', 'OpenGL + SDL' for further implementation details.

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.
GLTextureoperator= (const GLTexture &source) throw ()
 Assignment operator made private to ensure that it will never be called.


Member Enumeration Documentation

enum OSDL::Video::OpenGL::GLTexture::TextureMode

Texture support can be disabled, or enabled for 1D or 2D textures.

Default is 'TwoDim', enabled for 2D textures.

Enumerator:
Disabled 
OneDim 
TwoDim 

Definition at line 106 of file OSDLGLTexture.h.

enum OSDL::Video::OpenGL::GLTexture::Textureflavour

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.

Enumerator:
None 
Basic 

Definition at line 119 of file OSDLGLTexture.h.


Constructor & Destructor Documentation

GLTexture::GLTexture ( const std::string  imageFilename,
Textureflavour  flavour = None 
) throw ( GLTextureException ) [explicit]

Constructs a texture out of an image stored in a file.

Parameters:
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).
The internal surface, corresponding to the image, will be, if needed, automatically kept back and managed by this texture, so that it can be reloaded in an OpenGL context if necessary, in case it is lost.

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.

Parameters:
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).
The internal surface, corresponding to the image, will be, if needed, automatically kept back and managed by this texture, so that it can be reloaded in an OpenGL context if necessary, in case it is lost.

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.

References _id, and _source.

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.


Member Function Documentation

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.

See also:
reload

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.

Exceptions:
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.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

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]

Sets the current texture mode.

Definition at line 179 of file OSDLGLTexture.cc.

void GLTexture::SetTextureFlavour ( Textureflavour  flavour  )  throw ( GLTextureException )

Sets the current texture state according to specified flavour.

Exceptions:
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.

Parameters:
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.
The internal surface, corresponding to the image, will be, if needed, automatically kept back and managed by this texture, so that it can be reloaded in an OpenGL context if necessary, in case it is lost.

Note:
sourceSurface cannot be 'const' since per-surface alpha setting has to be modified temporarily, even if this method has eventually no side-effect on this surface.

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.


Member Data Documentation

GLTexture::TextureMode GLTexture::CurrentTextureMode [static]

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.

Note:
A non-null source pointer implies that the texture owns this surface.

Definition at line 296 of file OSDLGLTexture.h.

Referenced by canBeUploaded(), and ~GLTexture().

GLTextureIdentifier OSDL::Video::OpenGL::GLTexture::_id [protected]

Identifier given by OpenGL to reference this texture.

Definition at line 303 of file OSDLGLTexture.h.

Referenced by ~GLTexture().


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 14:47:32 2007 for OSDL by  doxygen 1.5.1