Stellarium  HEAD
Public Member Functions | Friends
StelTextureMgr Class Reference

Manage textures loading. More...

#include <StelTextureMgr.hpp>

Public Member Functions

StelTextureSP createTexture (const QString &filename, const StelTexture::StelTextureParams &params=StelTexture::StelTextureParams())
 Load an image from a file and create a new texture from it. More...
 
StelTextureSP createTexture (const QImage &image, const StelTexture::StelTextureParams &params=StelTexture::StelTextureParams())
 Create a texture from a QImage.
 
StelTextureSP createTextureThread (const QString &url, const StelTexture::StelTextureParams &params=StelTexture::StelTextureParams(), bool lazyLoading=true)
 Load an image from a file and create a new texture from it in a new thread. More...
 
StelTextureSP wrapperForGLTexture (GLuint texId)
 Creates or finds a StelTexture wrapper for the specified OpenGL texture object. More...
 
StelTextureSP getDitheringTexture (const int samplerToBindTo)
 Creates or gets existing dither pattern texture. More...
 

Friends

class StelTexture
 
class ImageLoader
 
class StelApp
 

Detailed Description

Manage textures loading.

It provides method for loading images in a separate thread.

Member Function Documentation

◆ createTexture()

StelTextureSP StelTextureMgr::createTexture ( const QString &  filename,
const StelTexture::StelTextureParams params = StelTexture::StelTextureParams() 
)

Load an image from a file and create a new texture from it.

Parameters
filenamethe texture file name, can be absolute path if starts with '/' otherwise the file will be looked for in Stellarium's standard textures directories.
paramsthe texture creation parameters.
Note
If filename is invalid, this creates a fuchsia-colored (magenta) replacement texture to signify "great error". Create an empty StelTextureSP yourself if you have no valid filename.
If image is larger than maximum allowed texture size, it will be automatically rescaled to fit and a warning printed to the logfile.

◆ createTextureThread()

StelTextureSP StelTextureMgr::createTextureThread ( const QString &  url,
const StelTexture::StelTextureParams params = StelTexture::StelTextureParams(),
bool  lazyLoading = true 
)

Load an image from a file and create a new texture from it in a new thread.

Note
This method is safe to be called from threads other than the main thread.
Parameters
urlthe texture file name or URL, can be absolute path if starts with '/' otherwise the file will be looked for in Stellarium's standard textures directories.
paramsthe texture creation parameters.
lazyLoadingdefine whether the texture should be actually loaded only when needed, i.e. when bind() is called the first time.

◆ getDitheringTexture()

StelTextureSP StelTextureMgr::getDitheringTexture ( const int  samplerToBindTo)

Creates or gets existing dither pattern texture.

Parameters
samplerToBindToThe sampler unit that the texture will be bound to. E.g. for GL_TEXTURE3 this value should be 3. This parameter is necessary because glTexImage2D needs the texture to be bound to a sampler unit.

◆ wrapperForGLTexture()

StelTextureSP StelTextureMgr::wrapperForGLTexture ( GLuint  texId)

Creates or finds a StelTexture wrapper for the specified OpenGL texture object.

The wrapper takes ownership of the texture and will delete it if it is destroyed.

Parameters
texIDThe OpenGL texture ID which should be wrapped. If this is already a StelTexture, the existing wrapper will be returned.
Returns
the existing or new wrapper for the texture with the given GL name. Returns a null pointer if the texture name is invalid.