Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://astro.uni-altai.ru/~aw/stellarium/api/classStelTextureNew.html
Дата изменения: Unknown Дата индексирования: Fri Feb 28 07:32:00 2014 Кодировка: Поисковые слова: gro j1655-40 |
Stellarium 0.12.3
|
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... | |
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.
Definition at line 62 of file StelTextureNew.hpp.
StelTextureNew::~StelTextureNew | ( | ) |
Destroy the texture.
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.
textureUnit | Texture unit to used |
|
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.
Definition at line 88 of file StelTextureNew.hpp.
|
inline |
Get a human-readable message describing the error that happened during loading (if any).
Definition at line 96 of file StelTextureNew.hpp.
|
inline |
Get the current texture status.
Used e.g. to determine if the texture has been loaded or if an error has occured.
Definition at line 76 of file StelTextureNew.hpp.