20 #ifndef _STELTEXTURE_HPP_ 21 #define _STELTEXTURE_HPP_ 24 #include "StelOpenGL.hpp" 32 template <
class T>
class QFuture;
34 #ifndef GL_CLAMP_TO_EDGE 35 #define GL_CLAMP_TO_EDGE 0x812F 41 class StelTexture:
public QObject,
public QEnableSharedFromThis<StelTexture>
49 StelTextureParams(
bool qgenerateMipmaps=
false, GLint afiltering=GL_LINEAR, GLint awrapMode=GL_CLAMP_TO_EDGE,
bool qfilterMipmaps=
false) :
70 bool bind(
int slot=0);
74 inline void release()
const { gl->glBindTexture(GL_TEXTURE_2D, 0 ); }
115 void onNetworkReply();
124 GLData() : width(0), height(0), format(0), type(0) {}
133 static GLData imageToGLData(
const QImage &image);
134 static GLData loadFromPath(
const QString &path);
135 static GLData loadFromData(
const QByteArray& data);
141 void wrapGLTexture(GLuint texId);
144 static QByteArray convertToGLFormat(
const QImage& image, GLint* format, GLint* type);
148 void reportError(
const QString& errorMessage);
153 bool glLoad(
const QImage& image);
155 bool glLoad(
const GLData& data);
161 template <
typename T,
typename Param1,
typename Arg1>
162 void startAsyncLoader(T (*functionPointer)(Param1),
const Arg1 &arg1);
167 QOpenGLFunctions* gl;
171 QNetworkReply *networkReply;
186 QString errorMessage;
199 #endif // _STELTEXTURE_HPP_ bool isLoading() const
Return whether the image is currently being loaded.
Contains the parameters defining how a texture is created.
bool bind(int slot=0)
Bind the texture so that it can be used for openGL drawing (calls glBindTexture). ...
Define the StelTextureSP type.
const QString & getFullPath() const
Return the full path to the image file.
bool hasAlphaChannel() const
Returns whether the texture has an alpha channel (GL_RGBA or GL_LUMINANCE_ALPHA format) This only ret...
bool canBind() const
Return whether the texture can be binded, i.e. it is fully loaded.
GLint wrapMode
Define the wrapping mode to use. Must be one of GL_CLAMP_TO_EDGE, or GL_REPEAT.
const QString & getErrorMessage() const
Get the error message which caused the texture loading to fail.
void release() const
Releases the currently bound texture without testing if it is currently bound, i.e.
bool filterMipmaps
If true, mipmapped textures are filtered with GL_LINEAR_MIPMAP_LINEAR instead of GL_LINEAR_MIPMAP_NEA...
bool hasError() const
Returns true if a loading error occurred.
unsigned int getGlSize() const
Return texture memory size.
bool generateMipmaps
Define if mipmaps must be created.
void waitForLoaded()
Waits until the texture data is ready for usage (i.e.
GLint filtering
Define the scaling filter to use. Must be one of GL_NEAREST or GL_LINEAR.
virtual ~StelTexture()
Destructor.
void loadingProcessFinished(bool error)
Emitted when the texture is ready to be bind(), i.e.
bool getDimensions(int &width, int &height)
Return the width and heigth of the texture in pixels.