Stellarium 0.12.3
List of all members | Public Member Functions
StelTextureNew Class Reference

Texture interface. More...

#include <StelTextureNew.hpp>

Public Member Functions

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

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

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.

textureUnitTexture unit to used
QSize StelTextureNew::getDimensions ( ) const

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.

Texture width and height in pixels.

Definition at line 88 of file StelTextureNew.hpp.

const QString& StelTextureNew::getErrorMessage ( ) const

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

Error message if status is Error, empty string otherwise.

Definition at line 96 of file StelTextureNew.hpp.

TextureStatus StelTextureNew::getStatus ( ) const

Get the current texture status.

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

texture status.

Definition at line 76 of file StelTextureNew.hpp.

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