StelTexture.hpp   StelTexture.hpp 
skipping to change at line 41 skipping to change at line 41
class QNetworkReply; class QNetworkReply;
template <class T> class QFuture; template <class T> class QFuture;
#ifndef GL_CLAMP_TO_EDGE #ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F #define GL_CLAMP_TO_EDGE 0x812F
#endif #endif
//! @class StelTexture //! @class StelTexture
//! Base texture class. For creating an instance, use StelTextureMgr::creat eTexture() and StelTextureMgr::createTextureThread() //! Base texture class. For creating an instance, use StelTextureMgr::creat eTexture() and StelTextureMgr::createTextureThread()
//! @sa StelTextureSP //! @sa StelTextureSP
class StelTexture: public QObject, protected QOpenGLFunctions class StelTexture: public QObject, public QEnableSharedFromThis<StelTexture >
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Contains the parameters defining how a texture is created. //! Contains the parameters defining how a texture is created.
struct StelTextureParams struct StelTextureParams
{ {
StelTextureParams(bool qgenerateMipmaps=false, GLint afilter ing=GL_LINEAR, GLint awrapMode=GL_CLAMP_TO_EDGE, bool qfilterMipmaps=false) : StelTextureParams(bool qgenerateMipmaps=false, GLint afilter ing=GL_LINEAR, GLint awrapMode=GL_CLAMP_TO_EDGE, bool qfilterMipmaps=false) :
generateMipmaps(qgenerateMipmaps), generateMipmaps(qgenerateMipmaps),
filterMipmaps(qfilterMipmaps), filterMipmaps(qfilterMipmaps),
skipping to change at line 70 skipping to change at line 70
//! Define the wrapping mode to use. Must be one of GL_CLAMP _TO_EDGE, or GL_REPEAT. //! Define the wrapping mode to use. Must be one of GL_CLAMP _TO_EDGE, or GL_REPEAT.
GLint wrapMode; GLint wrapMode;
}; };
//! Destructor //! Destructor
virtual ~StelTexture(); virtual ~StelTexture();
//! Bind the texture so that it can be used for openGL drawing (call s glBindTexture). //! Bind the texture so that it can be used for openGL drawing (call s glBindTexture).
//! If the texture is lazyly loaded, this starts the loading and ret urn false immediately. //! If the texture is lazyly loaded, this starts the loading and ret urn false immediately.
//! @return true if the binding successfully occured, false if the t exture is not yet loaded. //! @return true if the binding successfully occured, false if the t exture is not yet loaded.
bool bind(int slot=0); bool bind(int slot=0);
//! Releases the currently bound texture without testing if it is cu
rrently bound,
//! i.e. it simply calls glBindTexture(GL_TEXTURE_2D, 0)
inline void release() const { gl->glBindTexture(GL_TEXTURE_2D, 0 );
}
//! Waits until the texture data is ready for usage (i.e. bind will
return true after this).
//! Do not use this for potentially network loaded textures.
void waitForLoaded();
//! Return whether the texture can be binded, i.e. it is fully loade d //! Return whether the texture can be binded, i.e. it is fully loade d
bool canBind() const {return id!=0;} bool canBind() const {return id!=0;}
//! Return the width and heigth of the texture in pixels //! Return the width and heigth of the texture in pixels
bool getDimensions(int &width, int &height); bool getDimensions(int &width, int &height);
//! Returns whether the texture has an alpha channel (GL_RGBA or GL_ LUMINANCE_ALPHA format) //! 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 l oaded. //! This only returns valid information after the texture is fully l oaded.
bool hasAlphaChannel() const { return alphaChannel ; } bool hasAlphaChannel() const { return alphaChannel ; }
//! Get the error message which caused the texture loading to fail //! Get the error message which caused the texture loading to fail
//! @return the human friendly error message or empty string if no e rrors occured //! @return the human friendly error message or empty string if no e rrors occured
const QString& getErrorMessage() const {return errorMessage;} const QString& getErrorMessage() const {return errorMessage;}
//! Returns true if a loading error occurred
bool hasError() const { return errorOccured; }
//! Return the full path to the image file. //! Return the full path to the image file.
//! If the texture was downloaded from a remote location, this funct ion return the full URL. //! If the texture was downloaded from a remote location, this funct ion return the full URL.
const QString& getFullPath() const {return fullPath;} const QString& getFullPath() const {return fullPath;}
//! Return whether the image is currently being loaded //! Return whether the image is currently being loaded
bool isLoading() const {return (loader || networkReply) && !canBind( );} bool isLoading() const {return (loader || networkReply) && !canBind( );}
//! Return texture memory size //! Return texture memory size
unsigned int getGlSize() const {return glSize;} unsigned int getGlSize() const {return glSize;}
skipping to change at line 114 skipping to change at line 124
private slots: private slots:
void onNetworkReply(); void onNetworkReply();
private: private:
friend class StelTextureMgr; friend class StelTextureMgr;
//! structure returned by the loader threads, containing all the //! structure returned by the loader threads, containing all the
//! data and information to create the OpenGL texture. //! data and information to create the OpenGL texture.
struct GLData struct GLData
{ {
GLData() : data(NULL), width(0), height(0), format(0), type( GLData() : width(0), height(0), format(0), type(0) {}
0) {} QString loaderError; //! can contain an error message if dat
a is null
QByteArray data; QByteArray data;
int width; int width;
int height; int height;
GLint format; GLint format;
GLint type; GLint type;
}; };
//! Those static methods can be called by QtConcurrent::run //! Those static methods can be called by QtConcurrent::run
static GLData imageToGLData(const QImage &image); static GLData imageToGLData(const QImage &image);
static GLData loadFromPath(const QString &path); static GLData loadFromPath(const QString &path);
static GLData loadFromData(const QByteArray& data); static GLData loadFromData(const QByteArray& data);
//! Private constructor //! Private constructor
StelTexture(StelTextureMgr* mgr); StelTexture(StelTextureMgr* mgr);
//! Wrap an existing GL texture with this object
void wrapGLTexture(GLuint texId);
//! Convert a QImage into opengl compatible format. //! Convert a QImage into opengl compatible format.
static QByteArray convertToGLFormat(const QImage& image, GLint* form at, GLint* type); static QByteArray convertToGLFormat(const QImage& image, GLint* form at, GLint* type);
//! This method should be called if the texture loading failed for a ny reasons //! This method should be called if the texture loading failed for a ny reasons
//! @param errorMessage the human friendly error message //! @param errorMessage the human friendly error message
void reportError(const QString& errorMessage); void reportError(const QString& errorMessage);
//! Load the texture already in the RAM to the openGL memory //! Load the texture already in the RAM to the openGL memory
//! This function uses openGL routines and must be called in the mai n thread //! This function uses openGL routines and must be called in the mai n thread
//! @return false if an error occured //! @return false if an error occured
bool glLoad(const QImage& image); bool glLoad(const QImage& image);
//! Same as glLoad(QImage), but with an image already in OpenGl form at //! Same as glLoad(QImage), but with an image already in OpenGl form at
bool glLoad(const GLData& data); bool glLoad(const GLData& data);
//! Starts the loading process if it has not already started.
//! Returns true if the data was loaded, false if not yet ready.
bool load();
template <typename T, typename Param1, typename Arg1>
void startAsyncLoader(T (*functionPointer)(Param1), const Arg1 &arg1
);
//! The parent texture manager //! The parent texture manager
StelTextureMgr* textureMgr; StelTextureMgr* textureMgr;
QOpenGLFunctions* gl;
StelTextureParams loadParams; StelTextureParams loadParams;
//! Used to handle the connection for remote textures. //! Used to handle the connection for remote textures.
QNetworkReply *networkReply; QNetworkReply *networkReply;
//! The loader object //! The loader object
QFuture<GLData>* loader; QFuture<GLData>* loader;
//! The URL where to download the file //! The URL where to download the file
QString fullPath; QString fullPath;
skipping to change at line 169 skipping to change at line 191
//! True if this texture contains an alpha channel //! True if this texture contains an alpha channel
bool alphaChannel; bool alphaChannel;
//! Human friendly error message if loading failed //! Human friendly error message if loading failed
QString errorMessage; QString errorMessage;
//! OpenGL id //! OpenGL id
GLuint id; GLuint id;
//! Cached average luminance
float avgLuminance;
GLsizei width; //! Texture image width GLsizei width; //! Texture image width
GLsizei height; //! Texture image height GLsizei height; //! Texture image height
//! Size in GL memory //! Size in GL memory
unsigned int glSize; unsigned int glSize;
}; };
#endif // _STELTEXTURE_HPP_ #endif // _STELTEXTURE_HPP_
 End of changes. 9 change blocks. 
7 lines changed or deleted 30 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/