SFML community forums

Help => Window => Topic started by: mercurio7891 on May 13, 2011, 08:53:27 am

Title: When is the global shared context created??
Post by: mercurio7891 on May 13, 2011, 08:53:27 am
Hi, does sfml creates a global context for sharing. When is this global context created? Is it created when a sf::Window is created?

e.g

Code: [Select]

On first create of sf::Window
    create shared global context
    create render context and share with the global context


regards
Title: When is the global shared context created??
Post by: Laurent on May 13, 2011, 08:57:06 am
Which version of SFML? Why do you want to know that?
Title: When is the global shared context created??
Post by: mercurio7891 on May 13, 2011, 09:06:00 am
for sfml2 :D

oh i was wondering say in the main thread if the global context is already created then i can create buffers etc and other opengl resource cache.

If not I would either create a sf::Context to do it which leads me to ask, would my created resources stay alive after the sf::Context dies??

Code: [Select]

void SetupResourceCache()
{
    sf::Context temp_context;
    create opengl buffer
    create opengl texture
}


would my buffer and textures resources stay valid after the function?? I would be terribly happy if it does :D

regards
Title: When is the global shared context created??
Post by: Laurent on May 13, 2011, 09:42:43 am
Quote
would my buffer and textures resources stay valid after the function??

Nop. You should instanciate a sf::Context at the beginning of your main() instead. This way you always have a valid OpenGL context in your main thread.