[Kstars-devel] Re: Planet textures with OpenGL

Akarsh Simha akarshsimha at gmail.com
Thu Apr 7 08:29:08 CEST 2011


On Tue, Apr 05, 2011 at 10:04:17PM +0400, Alexey Khudyakov wrote:
> On 04.04.2011 11:05, Akarsh Simha wrote:
> > Hi
> >
> > I finally did some research on this problem. It seems to me that the
> > reason why planet textures do not display in OpenGL is because they
> > are "bound" too early.
> >
> > ...
> >
> > Does this sound okay? Harry, shall I go ahead and make this change?
> >
> To my understanding there are no clear understanding of what causes 
> problem. We may end up with hiding problem under rug instead of fixing 
> it. It's better to try to understand what's going on first.
> 
> I will look into it. Not sooner that saturday though. At any rate I need 
> to understand how OpenGL textures work. It look like a good case to 
> improve understaning.

Hi Alexey,

I agree with you. It's not good to hide problems under the carpet.

My understanding of this entire thing is very fuzzy -- particularly, I
don't understand what a context really is and whether I need a valid
context to bind textures.

But here's an observation:

QGLContext::setDevice( QPaintDevice *pd ) is an internal function
that's called on a QGLContext by a QGLWidget when the QGLWidget takes
ownership of the QGLContext.

Now, QGLContext::setDevice() also resets the GL context if it was
already valid, and creates a new one.

I read this somewhere on the internet (don't know how far it's true):

"If the GL context was destroyed, all textures become white. All
textures have to be generated again."

This might be what's happening. To check if this is true, I put in an
arbitrary reset() and create() on the context in the middle of the
painting, and suddenly, all textures were replaced by colored (colored
because we tint the white textures while painting them) squares.

Regards
Akarsh


More information about the Kstars-devel mailing list