QGLContext::bindTexture changes the current GL context; can't change it back

155 views
Skip to first unread message

Brady Brenot

unread,
Feb 10, 2012, 3:49:15 AM2/10/12
to andro...@googlegroups.com
I'm trying to get Stellarium working with necessitas, but I've hit an odd thing. After QGLContext::bindTexture returns, once finds that the current context (found from QGLContext::currentContext()) has changed. Attempting to change it back (QGLContext::makeCurrent()) has no effect, the old context is still valid (QGLContext::isValid()), and the QGLWidget's context is still the old one. I've also checked to see if the two contexts are sharing (QGLContext::areSharing), but that's a negative.

I can take out the assert checking if the context matches what we expect and the program works. No crashes, no weirdness (that I've noticed so far). Is this safe?

From  http://bazaar.launchpad.net/~brady.brenot/stellarium/android-port/view/head:/src/core/StelPainter.cpp :

690
			if (isNoPowerOfTwoAllowed)
691
				strImage = QPixmap(newTex->subTexWidth, newTex->subTexHeight);
692
			else
693
				strImage = QPixmap(StelUtils::getBiggerPowerOfTwo(newTex->subTexWidth), StelUtils::getBiggerPowerOfTwo(newTex->subTexHeight));
694
			newTex->width = strImage.width();
695
			newTex->height = strImage.height();
696
697
			strImage.fill(Qt::transparent);
698
699
			QPainter painter(&strImage);
700
			painter.setFont(qPainter->font());
701
			painter.setRenderHints(QPainter::TextAntialiasing, true);
702
			painter.setPen(Qt::white);
703
			painter.drawText(-strRect.x(), -strRect.y(), str);
704
705
			// Create and bind texture, and add it to the list of cached textures
706
			newTex->texture = StelPainter::glContext->bindTexture(strImage, GL_TEXTURE_2D, GL_RGBA, QGLContext::NoBindOption);
707
			

faenil

unread,
Feb 10, 2012, 9:05:34 AM2/10/12
to andro...@googlegroups.com
could you create two context in Qt for Android?

check if the second context gets created, because create() always returns false to me...

I have tried creating a QGLContext and a QGLPixelBuffer, and both fail

Brady Brenot

unread,
Feb 10, 2012, 1:29:38 PM2/10/12
to andro...@googlegroups.com
I know there's a post mentioning that only one QGLWidget is supported. I'm not intentionally trying to create a second context, we only need one.

I've got a feeling that it's just returning an erroneous current context. If I just ignore it and keep on sending GL commands, and specifically using the old context when required (e.g. for QGLContext::bind), everything still works. So this doesn't seem to be blocking me in any way, it's just odd and doesn't conform to what the other platforms do.

Brady Brenot

unread,
Feb 10, 2012, 10:08:00 PM2/10/12
to andro...@googlegroups.com
I forgot to mention: when that function is going, necessitas prints

setFullScreen false
setFullScreen false
Reply all
Reply to author
Forward
0 new messages