20 #ifndef _STELTEXTUREBACKEND_HPP_
21 #define _STELTEXTUREBACKEND_HPP_
39 TextureStatus_Uninitialized,
44 TextureStatus_Loading,
56 inline QString textureStatusName(
const TextureStatus status)
60 case TextureStatus_Uninitialized:
return "TextureStatus_Uninitialized";
break;
61 case TextureStatus_Loaded:
return "TextureStatus_Loaded";
break;
62 case TextureStatus_Loading:
return "TextureStatus_Loading";
break;
63 case TextureStatus_Error:
return "TextureStatus_Error";
break;
64 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"Unknown texture status");
71 enum TextureLoadingMode
76 TextureLoadingMode_Normal,
81 TextureLoadingMode_Asynchronous,
87 TextureLoadingMode_LazyAsynchronous
133 Q_ASSERT_X(status == TextureStatus_Loaded, Q_FUNC_INFO,
134 "Trying to get dimensions of a texture that is not loaded. "
135 "Use StelTextureBackend::getStatus to determine if the texture "
136 "is loaded or not.");
160 , errorMessage(QString())
162 , status(TextureStatus_Uninitialized)
173 Q_ASSERT_X(status == TextureStatus_Uninitialized, Q_FUNC_INFO,
174 "Only a texture that has not yet been initialized can start loading");
175 status = TextureStatus_Loading;
188 Q_ASSERT_X(status == TextureStatus_Loading, Q_FUNC_INFO,
189 "Only a texture that has started loading can finish loading");
191 status = TextureStatus_Loaded;
203 if(status != TextureStatus_Loading)
205 qWarning() <<
"Unexpected error - texture " << QDir::toNativeSeparators(
path);
206 qWarning() <<
"Texture status: " << textureStatusName(status);
207 Q_ASSERT_X(
false, Q_FUNC_INFO,
208 "The only time an error can occur with a texture is during loading");
210 qWarning() <<
"Error occured during loading of texture " << QDir::toNativeSeparators(
path) <<
212 errorMessage = error;
213 status = TextureStatus_Error;
219 QString errorMessage;
229 TextureStatus status;
232 void invariant()
const
234 Q_ASSERT_X(errorMessage.isEmpty() == (status != TextureStatus_Error),
236 "Error message must be empty when status is not Error and non-empty otherwise");
240 #endif // _STELTEXTUREBACKEND_HPP_