Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why so many glContexts?  (Read 1412 times)

0 Members and 1 Guest are viewing this topic.

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Why so many glContexts?
« 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.

« Last Edit: October 14, 2012, 04:20:50 pm by greeniekin »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Why so many glContexts?
« Reply #1 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.
Laurent Gomila - SFML developer

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Why so many glContexts?
« Reply #2 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.
« Last Edit: October 15, 2012, 11:19:29 am by greeniekin »