void StelTexture::onImageLoaded(QImage image)
{
	qImage = image;
	Q_ASSERT(!qImage.isNull());
	glLoad();
	isLoadingImage = false;
	loader->deleteLater();
	loader = NULL;
}
Example #2
0
Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
                                            const int width, const int height,
                                            const float alpha)
{
    if (!tmpImage)
        return nullptr;

    Image *const img = glLoad(tmpImage, width, height);
    if (img)
        img->setAlpha(alpha);
    return img;
}
bool StelTexture::bind(int slot)
{
	if (id != 0)
	{
		// The texture is already fully loaded, just bind and return true;
		glActiveTexture(GL_TEXTURE0 + slot);
		glBindTexture(GL_TEXTURE_2D, id);
		return true;
	}
	if (errorOccured)
		return false;

	// If the file is remote, start a network connection.
	if (loader == NULL && networkReply == NULL && fullPath.startsWith("http://")) {
		QNetworkRequest req = QNetworkRequest(QUrl(fullPath));
		// Define that preference should be given to cached files (no etag checks)
		req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
		req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1());
		networkReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
		connect(networkReply, SIGNAL(finished()), this, SLOT(onNetworkReply()));
		return false;
	}
	// The network connection is still running.
	if (networkReply != NULL)
		return false;
	// Not a remote file, start a loader from local file.
	if (loader == NULL)
	{
		loader = new QFuture<GLData>(QtConcurrent::run(loadFromPath, fullPath));
		return false;
	}
	// Wait until the loader finish.
	if (!loader->isFinished())
		return false;
	// Finally load the data in the main thread.
	glLoad(loader->result());
	delete loader;
	loader = NULL;
	return true;
}
Example #4
0
Image *OpenGLImageHelper::load(SDL_Surface *const tmpImage)
{
    return glLoad(tmpImage);
}
// Actually load the texture to openGL memory
bool StelTexture::glLoad(const QImage& image)
{
	return glLoad(imageToGLData(image));
}