Stellarium 0.12.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure

StelTextureNew Class Reference

Texture interface. More...

#include <StelTextureNew.hpp>

List of all members.

Public Member Functions

 ~StelTextureNew ()
 Destroy the texture.
TextureStatus getStatus () const
 Get the current texture status.
QSize getDimensions () const
 Get texture dimensions in pixels.
const QString & getErrorMessage () const
 Get a human-readable message describing the error that happened during loading (if any).
void bind (const int textureUnit=0)
 Bind the texture so that it can be used for drawing.

Detailed Description

Texture interface.

StelTextureNew replaces StelTexture - it is named differently to avoid silently breaking code.

Constructed by StelRenderer::createTexture(). To use the texture, it can be bound by the bind() member function. The texture must be destroyed before the StelRenderer that constructed it.

A texture can be in one of 4 states, depending on how it is loaded. These are Uninitialized, Loading, Loaded, Error.

Immediately after construction, a texture is in Uninitialized state. If load mode specified with createTextureBackend is Normal, it is immediately loaded (internally, it's in Loading state), and one createTextureBackend is done, its state changes to Loaded on success or Error if loading failed.

The loading stage (and no other stage) might fail, resulting in Error state. If in Error state, error message can be retrieved by getErrorMessage. A texture with the Error state can still be bound, but a placeholder texture will be used internally instead.

If load mode is Asynchronous, the texture is loaded in a background thread, and during loading its state is Loading. Again, loading might fail.

If load mode is LazyAsynchronous, loading only starts once the texture is bound (used) for the first time.

Implementation-wise, StelTextureNew is a very thin wrapper around StelTextureBackend. They are kept separate so their lifetimes can be independent. Destruction of a StelTextureNew doesn't necessarily destroy the underlying backend, allowing for texture caching.

See also:
TextureStatus

Definition at line 62 of file StelTextureNew.hpp.


Constructor & Destructor Documentation

StelTextureNew::~StelTextureNew (  ) 

Destroy the texture.


Member Function Documentation

void StelTextureNew::bind ( const int  textureUnit = 0  ) 

Bind the texture so that it can be used for drawing.

If the texture is lazily loaded and has not been loaded yet, it will start loading.

If the texture is in any state other than Loaded (i.e; even in Error state), a placeholder (checkers) texture is used instead, so bind() can be called even if the texture is still loading, if you don't mind that a placeholder will be shown for a short moment.

Use getStatus() to determine whether the texture is loaded or not.

Parameters:
textureUnit Texture unit to used
QSize StelTextureNew::getDimensions (  )  const [inline]

Get texture dimensions in pixels.

Can only be called when the texture is in the Loaded status (this is asserted). Use getStatus() to determine whether or not this is the case.

Returns:
Texture width and height in pixels.

Definition at line 88 of file StelTextureNew.hpp.

const QString& StelTextureNew::getErrorMessage (  )  const [inline]

Get a human-readable message describing the error that happened during loading (if any).

Returns:
Error message if status is Error, empty string otherwise.

Definition at line 96 of file StelTextureNew.hpp.

TextureStatus StelTextureNew::getStatus (  )  const [inline]

Get the current texture status.

Used e.g. to determine if the texture has been loaded or if an error has occured.

Returns:
texture status.

Definition at line 76 of file StelTextureNew.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Jan 31 14:05:47 2013 for Stellarium by  doxygen 1.6.3