SFML community forums

Help => Window => Topic started by: greeniekin on October 14, 2012, 03:50:29 pm

Title: Why so many glContexts?
Post by: greeniekin on October 14, 2012, 03:50:29 pm
I have been trying to port sfml to android.

I have worked out the cmake toolchain stuff aswell as getting sfml_system going and some fun with gles aswell.

I have been trying to get sfml_window working(even though the models of android and sfml_window do not match)

Though I have been very confused with some strange results. I noticed that it seems to be coming from having many GLcontexts.

So far the only sfml_window object i use is sf::window yet 2 contexts exist before the windows constructor even gets called.

It appears the first one is created by GlContext::globalInit()

the second is created by by sf::priv::GlContext* getInternalContext()

the third appears to be created by the window constructor which is really the one I thought that makes sense.

Title: Re: Why so many glContexts?
Post by: Laurent on October 14, 2012, 06:54:33 pm
There's always one hidden context that exist, so that when you destroy your window you don't lose OpenGL resources (shaders/textures/etc.).

The other one is probably unnecessary in your simple use case. The OpenGL context management is currently complicated (it's a long story...), and I think it could be optimized. But this is not a high priority task.
Title: Re: Why so many glContexts?
Post by: greeniekin on October 15, 2012, 10:19:54 am
Ok. well I have simply made it so if a shared context is given it will not bother to make it's own context and just copy the values for context from the shared one. as there is always one and only one window open on a native android activity.

The only other way I could think of is by creating pbuffer. Though I do not think there is any need for that.