SFML community forums

Help => Window => Topic started by: mercurio7891 on April 12, 2011, 12:51:22 pm

Title: opengl resources and context sharing
Post by: mercurio7891 on April 12, 2011, 12:51:22 pm
hi, is it possible for resources to be shared?? suppose I have one render context created on thread 1, and in thread 2 I attempt to do a glBindBuffer command etc. would it work??

regards
Title: opengl resources and context sharing
Post by: Groogy on April 12, 2011, 01:31:59 pm
I think you can, though I'd wait for Laurent to answer.
Title: opengl resources and context sharing
Post by: Laurent on April 12, 2011, 01:32:55 pm
All OpenGL contexts in SFML are shared.
Title: opengl resources and context sharing
Post by: mercurio7891 on April 12, 2011, 03:06:14 pm
does that mean i need a dummy context in my worker thread for the sharing to work?? e.g
Code: [Select]

Thread1 (main thread):
create sfml window and main context
set main context as active
lock
draw vbo_one
unlock

Thread2 (worker thread):
create a dummy context and set it as active //is this step neccessary for sharing?
lock
update vbo_two and stuff
unlock


would it work if i don't have a dummy context? i.e just start calling gl calls on the worker thread, without creating a dummy context or setting any active context.

regards
Title: opengl resources and context sharing
Post by: Laurent on April 12, 2011, 03:19:05 pm
Quote
would it work if i don't have a dummy context? i.e just start calling gl calls on the worker thread, without creating a dummy context or setting any active context.

No, you always need an active context to call OpenGL functions.
Title: opengl resources and context sharing
Post by: mercurio7891 on April 12, 2011, 03:44:19 pm
ahh thanks, i was hoping i could get away without the dummy context, as I was lazy and don't want to maintain a similar states across all context. :)

regards