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

#include <OSDLGLTexture.h>

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

Collaboration graph
[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 anyway 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.
See also:
'http://osdl.sourceforge.net', then 'Documentation', 'Rendering', 'OpenGL + SDL' for further implementation details.

Definition at line 88 of file OSDLGLTexture.h.


Public Types

enum  TextureDimensionality { Disabled, OneDim, TwoDim }
 Texture support can be disabled, or enabled for 1D or 2D textures. More...
enum  TextureFlavour { None, Basic, For2D }
 Texture flavours are presets that can be chosen as a whole. More...

Public Member Functions

 GLTexture (const std::string imageFilename, TextureFlavour flavour) throw ( GLTextureException )
 Constructs a texture out of an image stored in a file.
 GLTexture (Surface &sourceSurface, TextureFlavour flavour) 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 uploaded 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.

Static Public Member Functions

static TextureDimensionality GetTextureDimensionality () throw ()
 Returns the current texture dimensionality.
static void SetTextureDimensionality (TextureDimensionality Dimensionality=TwoDim) throw ()
 Sets the current texture dimensionality.
static void SetTextureFlavour (TextureFlavour textureFlavour) throw ( GLTextureException )
 Sets the current texture state according to specified texture flavour.
static void SetTextureEnvironmentParameter (GLEnumeration targetEnvironment, GLEnumeration environmentParameter, GLfloat parameterValue) throw ( GLTextureException )
 Sets a parameter of a texture environment.
static void SetTextureEnvironmentParameter (GLEnumeration targetEnvironment, GLEnumeration environmentParameter, const GLfloat *parameterValues) throw ( GLTextureException )
 Sets the parameters of a texture environment.

Static Public Attributes

static TextureDimensionality CurrentTextureDimensionality
 Stores the current texture dimensionality.

Protected Member Functions

void upload (Surface &sourceSurface) 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.
TextureFlavour _flavour
 Stores the current texture flavour.
Length _width
 The width of the texture, in pixels.
Length _height
 The height of the texture, in pixels.

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

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 103 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, and 'For2D' selects settings appropriate for 2D rendering.

Enumerator:
None 
Basic 
For2D 

Definition at line 117 of file OSDLGLTexture.h.


Constructor & Destructor Documentation

GLTexture::GLTexture ( const std::string  imageFilename,
TextureFlavour  flavour 
) 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 the texture flavour that should be used.
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, should the context be lost.

Definition at line 86 of file OSDLGLTexture.cc.

References OSDL::Video::OpenGL::GLTextureException::GLTextureException(), OSDL::Video::Surface::LoadImage(), and LOG_DEBUG_TEXTURE.

GLTexture::GLTexture ( Surface sourceSurface,
TextureFlavour  flavour 
) 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 the texture flavour that should be used.
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, should the context be lost.

Definition at line 132 of file OSDLGLTexture.cc.

References LOG_DEBUG_TEXTURE.

GLTexture::~GLTexture (  )  throw () [virtual]

Virtual destructor, deallocates the owned internal surface, if any.

Definition at line 149 of file OSDLGLTexture.cc.

References _id, _source, and LOG_DEBUG_TEXTURE.

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 uploaded to the OpenGL context.

One necessary condition is that its source surface is available.

See also:
upload

Definition at line 168 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 177 of file OSDLGLTexture.cc.

References canBeUploaded(), and LOG_DEBUG_TEXTURE.

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 202 of file OSDLGLTexture.cc.

References _height, _id, _source, _width, and OSDL::Video::Pixels::toString().

Referenced by OSDL::Rendering::Sprite::toString().

GLTexture::TextureDimensionality GLTexture::GetTextureDimensionality (  )  throw () [static]

Returns the current texture dimensionality.

Definition at line 232 of file OSDLGLTexture.cc.

References CurrentTextureDimensionality.

void GLTexture::SetTextureDimensionality ( TextureDimensionality  Dimensionality = TwoDim  )  throw () [static]

Sets the current texture dimensionality.

Definition at line 241 of file OSDLGLTexture.cc.

References CurrentTextureDimensionality.

Referenced by SetTextureFlavour().

void GLTexture::SetTextureFlavour ( TextureFlavour  textureFlavour  )  throw ( GLTextureException ) [static]

Sets the current texture state according to specified texture flavour.

Parameters:
textureFlavour the selected texture flavour.
Exceptions:
GLTextureException if the operation failed, including if no OpenGL support is available.

Definition at line 251 of file OSDLGLTexture.cc.

References Basic, OSDL::Video::OpenGL::OpenGLContext::EnableFeature(), For2D, None, SetTextureDimensionality(), SetTextureEnvironmentParameter(), OSDL::Video::Pixels::toString(), and TwoDim.

Referenced by OSDL::Video::OpenGL::OpenGLContext::set2DFlavour(), and upload().

void GLTexture::SetTextureEnvironmentParameter ( GLEnumeration  targetEnvironment,
GLEnumeration  environmentParameter,
GLfloat  parameterValue 
) throw ( GLTextureException ) [static]

Sets a parameter of a texture environment.

Parameters:
targetEnvironment the texture environment to set.
environmentParameter the symbolic name of a texture environment parameter.
parameterValue a single symbolic constant, a single floating-point number, or an RGBA color.
Exceptions:
GLTextureException should an error occur.

Definition at line 374 of file OSDLGLTexture.cc.

Referenced by SetTextureFlavour().

void GLTexture::SetTextureEnvironmentParameter ( GLEnumeration  targetEnvironment,
GLEnumeration  environmentParameter,
const GLfloat *  parameterValues 
) throw ( GLTextureException ) [static]

Sets the parameters of a texture environment.

Parameters:
targetEnvironment the texture environment to set.
environmentParameter the symbolic name of a texture environment parameter.
parameterValue pointer to a parameter array that contains either a single symbolic constant, single floating-point number, or an RGBA color.
Exceptions:
GLTextureException should an error occur.

Definition at line 436 of file OSDLGLTexture.cc.

void GLTexture::upload ( Surface sourceSurface  )  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.
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 502 of file OSDLGLTexture.cc.

References _flavour, _height, _id, _width, OSDL::Video::Surface::AlphaBlendingBlit, OSDL::Video::OpenGL::AlphaMask, OSDL::Video::Pixels::AlphaTransparent, OSDL::Video::OpenGL::BlueMask, OSDL::Video::Surface::getPixels(), OSDL::Video::OpenGL::GreenMask, OSDL::Video::OpenGL::RedMask, OSDL::Video::Surface::RLEColorkeyBlitAvailable, SetTextureFlavour(), 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

Initial value:

Stores the current texture dimensionality.

Default is 'TwoDim'.

Definition at line 233 of file OSDLGLTexture.h.

Referenced by GetTextureDimensionality(), and SetTextureDimensionality().

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 335 of file OSDLGLTexture.h.

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

Identifier given by OpenGL to reference this texture.

Definition at line 342 of file OSDLGLTexture.h.

Referenced by toString(), upload(), and ~GLTexture().

Stores the current texture flavour.

Note:
Needed, as a side-effect of uploading a texture is to create a new (blank) target texture, whose settings therefore need to be set specifically set.

Definition at line 353 of file OSDLGLTexture.h.

Referenced by upload().

The width of the texture, in pixels.

Definition at line 357 of file OSDLGLTexture.h.

Referenced by toString(), and upload().

The height of the texture, in pixels.

Definition at line 360 of file OSDLGLTexture.h.

Referenced by toString(), and upload().


The documentation for this class was generated from the following files:

Generated on Fri Aug 1 14:46:26 2008 for OSDL by  doxygen 1.5.5