Run the same OpenGL program in two context
I'm pretty sure you cant. Resources are allocated per-context, and context work in a single thread at a time.
This prevents any sort of multi threading since you cant:
a. Do GL calls against a single context in multiple threads.
b. Do GL calls in different contexts and share the results between them.
So if you want to draw in two different windows, AFAIK, you'll have to use different contexts and replicate the work from one to the other. Or you can handle everything in a single application that draws to two different places in the same window and context.
EDIT: NVM, you can switch windows as L Spiro said
This is not correct.This prevents any sort of multi threading since you cant:
a. Do GL calls against a single context in multiple threads.
…
So if you want to draw in two different windows, AFAIK, you'll have to use different contexts and replicate the work from one to the other. Or you can handle everything in a single application that draws to two different places in the same window and context.
You were correct when you stated that a single context can be used on a single thread at a time.
Which means you can make calls on a single context from multiple threads. You have to manage synchronization manually since you can’t access a context simultaneously, but you can switch the context to different threads and use it on each thread one-at-a-time.
So if you want to render into multiple windows (which does not necessarily imply they are running on different threads, but let’s say they are), make a single context, set it active on thread A, render into window A, make it active on thread B. and render into window B.
A context can be active on any thread, but only one thread at a time.
It is painful to manually juggle the context with critical sections etc. but it works perfectly fine.
L. Spiro
So if you want to render into multiple windows (which does not necessarily imply they are running on different threads, but let’s say they are), make a single context, set it active on thread A, render into window A, make it active on thread B. and render into window B.
So what you're saying is that a same context can render to a different window?
EDIT: Well I didn't knew that. TBH I shy away from context management/creation so its no wonder I didn't knew Googled around, StackOverflow has the calls needed http://stackoverflow.com/questions/452806/multiple-windows-in-opengl
Hi guys,
Thank you again!