20 #ifndef _STELTEXTUREBACKEND_HPP_
21 #define _STELTEXTUREBACKEND_HPP_
38 TextureStatus_Uninitialized,
43 TextureStatus_Loading,
55 inline QString textureStatusName(
const TextureStatus status)
59 case TextureStatus_Uninitialized:
return "TextureStatus_Uninitialized";
break;
60 case TextureStatus_Loaded:
return "TextureStatus_Loaded";
break;
61 case TextureStatus_Loading:
return "TextureStatus_Loading";
break;
62 case TextureStatus_Error:
return "TextureStatus_Error";
break;
63 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"Unknown texture status");
70 enum TextureLoadingMode
75 TextureLoadingMode_Normal,
80 TextureLoadingMode_Asynchronous,
86 TextureLoadingMode_LazyAsynchronous
132 Q_ASSERT_X(status == TextureStatus_Loaded, Q_FUNC_INFO,
133 "Trying to get dimensions of a texture that is not loaded. "
134 "Use StelTextureBackend::getStatus to determine if the texture "
135 "is loaded or not.");
159 , errorMessage(QString())
161 , status(TextureStatus_Uninitialized)
172 Q_ASSERT_X(status == TextureStatus_Uninitialized, Q_FUNC_INFO,
173 "Only a texture that has not yet been initialized can start loading");
174 status = TextureStatus_Loading;
187 Q_ASSERT_X(status == TextureStatus_Loading, Q_FUNC_INFO,
188 "Only a texture that has started loading can finish loading");
190 status = TextureStatus_Loaded;
202 if(status != TextureStatus_Loading)
204 qWarning() <<
"Unexpected error - texture " <<
path;
205 qWarning() <<
"Texture status: " << textureStatusName(status);
206 Q_ASSERT_X(
false, Q_FUNC_INFO,
207 "The only time an error can occur with a texture is during loading");
209 qWarning() <<
"Error occured during loading of texture " <<
path <<
211 errorMessage = error;
212 status = TextureStatus_Error;
218 QString errorMessage;
228 TextureStatus status;
231 void invariant()
const
233 Q_ASSERT_X(errorMessage.isEmpty() == (status != TextureStatus_Error),
235 "Error message must be empty when status is not Error and non-empty otherwise");
239 #endif // _STELTEXTUREBACKEND_HPP_