Stellarium  0.19.3
Data Structures | Signals | Public Member Functions | Friends
StelTexture Class Reference

Base texture class. More...

#include <StelTexture.hpp>

Data Structures

struct  StelTextureParams
 Contains the parameters defining how a texture is created. More...
 

Signals

void loadingProcessFinished (bool error)
 Emitted when the texture is ready to be bind(), i.e. More...
 

Public Member Functions

virtual ~StelTexture ()
 Destructor.
 
bool bind (uint slot=0)
 Bind the texture so that it can be used for openGL drawing (calls glBindTexture). More...
 
void release () const
 Releases the currently bound texture without testing if it is currently bound, i.e. More...
 
void waitForLoaded ()
 Waits until the texture data is ready for usage (i.e. More...
 
bool canBind () const
 Return whether the texture can be binded, i.e. it is fully loaded.
 
bool getDimensions (int &width, int &height)
 Return the width and heigth of the texture in pixels.
 
bool hasAlphaChannel () const
 Returns whether the texture has an alpha channel (GL_RGBA or GL_LUMINANCE_ALPHA format) This only returns valid information after the texture is fully loaded. More...
 
const QString & getErrorMessage () const
 Get the error message which caused the texture loading to fail. More...
 
bool hasError () const
 Returns true if a loading error occurred.
 
const QString & getFullPath () const
 Return the full path to the image file. More...
 
bool isLoading () const
 Return whether the image is currently being loaded.
 
unsigned int getGlSize () const
 Return texture memory size.
 

Friends

class StelTextureMgr
 

Detailed Description

For creating an instance, use StelTextureMgr::createTexture() and StelTextureMgr::createTextureThread()

See also
StelTextureSP

Member Function Documentation

◆ bind()

bool StelTexture::bind ( uint  slot = 0)

If the texture is lazyly loaded, this starts the loading and return false immediately.

Returns
true if the binding successfully occured, false if the texture is not yet loaded.

◆ getErrorMessage()

const QString& StelTexture::getErrorMessage ( ) const
inline
Returns
the human friendly error message or empty string if no errors occured

◆ getFullPath()

const QString& StelTexture::getFullPath ( ) const
inline

If the texture was downloaded from a remote location, this function return the full URL.

◆ hasAlphaChannel()

bool StelTexture::hasAlphaChannel ( ) const
inline

◆ loadingProcessFinished

void StelTexture::loadingProcessFinished ( bool  error)
signal

when downloaded, imageLoading and glLoading is over or when an error occured and the texture will never be available In case of error, you can query what the problem was by calling getErrorMessage()

Parameters
erroris equal to true if an error occured while loading the texture

◆ release()

void StelTexture::release ( ) const
inline

it simply calls glBindTexture(GL_TEXTURE_2D, 0)

◆ waitForLoaded()

void StelTexture::waitForLoaded ( )

bind will return true after this). Do not use this for potentially network loaded textures.