[Kstars-devel] Re: Planet textures with OpenGL

Akarsh Simha akarshsimha at gmail.com
Sat Apr 9 03:45:24 CEST 2011


> So is mine. I have following hyothesis. Aquired texture IDs becomes
> invalid when context is reset and planets aquire them before it's
> transferred to QGLWidget.

Yes, I tend to agree.

> IMHO the best way to deal with the problem is to aquire texture ID
> when they are used for first time. So they will be generated after
> transfer of ownership.

There might be a better way. Looking at the code,
QContextPrivate::bindTexture() is supposed to check if the texture
already has a texture ID and then bind it. It does maintain a cache of
textures. If my understanding is correct, ideally, it should
invalidate that cache as well when the context is reset. So maybe it
is best to solve this in QGLContextPrivate itself. I need to ask on
#qt or something and I plan to do it this weekend.

> Maybe TextureManager should not own context at all and have it
> passed in as parameter. This way we can avoid transfering of context
> at all.

That sounds good to me! We have a Q_ASSERT( m_context ) whenever we
try to bind a texture and we can have a TextureManager::setContext(
QGLContext * ), and we can pass the context of the QGLWidget.

<snip>
> If one wants to use QImage he don't need context. If he wants to use
> openGL he already have context. 
</snip>

Makes sense!

Regards
Akarsh


More information about the Kstars-devel mailing list