Texture interface. More...
|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...|
StelTextureNew replaces StelTexture - it is named differently to avoid silently breaking code.
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.
Destroy the texture.
|void StelTextureNew::bind||(||const int||textureUnit = ||)|
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.
|textureUnit||Texture unit to used|