/**
  * Calls glGetError() until no more errors are reported.
  * GL stores all the errors since the last call to glGetError().
  * These are returned one-by-one with calls to getGetError(). Each call clears an error flag from GL.
  * If GL_NO_ERROR is returned no errors have occured since the last call to glGetError().
  * Prints the original error code the operation which caused the error (passed in) and the string version of the error.
  */
 void AndroidPlatform::checkGlesError(const char* operation)
 {
     GLint error = 0;
     for (error = glGetError(); error != GL_NO_ERROR; error = glGetError())
     {
         LOGE("glError (0x%x) after `%s` \n", error, operation);
         LOGE("glError (0x%x) = `%s` \n", error, glErrorToString(error));
     }
 }
StelQGLTextureBackend::~StelQGLTextureBackend()
{
	invariant();
	renderer->ensureTextureNotBound(this);
	
	if (getStatus() == TextureStatus_Loaded)
	{
		const QSize size = getDimensions();
		renderer->getStatistics()[ESTIMATED_TEXTURE_MEMORY] -= 
			size.width() * size.height() * pixelBytes;
		renderer->makeGLContextCurrent();
		if (glIsTexture(glTextureID) == GL_FALSE)
		{
			qDebug() << "WARNING: in StelQGLTextureBackend::~StelQGLTextureBackend() "
			            "tried to delete invalid texture with ID=" << glTextureID << 
			            " Current GL ERROR status is " << glErrorToString(glGetError());
		}
		else if(ownsTexture)
		{
			// Texture was uploaded manually, not through the QGL context object.
			if(deleteManually)
			{
				glDeleteTextures(1, &glTextureID);
			}
			else
			{
				renderer->getGLContext()->deleteTexture(glTextureID);
			}
		}
		glTextureID = 0;
	}
	if (loader != NULL) 
	{
		loader->abort();
		// Don't forget that the loader has no parent.
		loader->deleteLater();
		loader = NULL;
	}
}