Run the same OpenGL program in two context

Started by
3 comments, last by cayo 10 years ago
Hi members,
I'm working with OpenGL in a modular academic project. In this project, some users will have different perspectives for visualization and, in this case, a user will can execute a pure OpenGL program on console (terminal) and execute a GTK program, simultaneously. This GTK program also displays the OpenGL program in one GtkDrawingArea content type. In both situations, the OpenGL program have a listener that receive informations of others modules (set of programs working with IPC context).
The goal:
I would like that both "instances" of the same OpenGL executable could display the same information from the IPC context, in real time. Today, i can't do it.
Anyone help me?
Thank you!
Advertisement

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 biggrin.png

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

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.

This is not correct.
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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


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 biggrin.png Googled around, StackOverflow has the calls needed http://stackoverflow.com/questions/452806/multiple-windows-in-opengl

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Hi guys,

Initially, i would like to thank for your reply.
I not sure if i understood this explanation but, my goal is have two "instances" of only one executable program int both context: one in console (run from command line to load a binary file), and other in GTK context (into a GtkDrawingArea component).
Look the real example in the screen shot on this link: http://www.cayo.com.br/Arquivos/screen.png
Note that in this example, the OpenGL application is running fine on the GTK application, and received / update all the time messages from IPC (look the paint simulating a speedometer). However, we can note that the OpenGL program that is being loading on console (pure OpenGL program) not receive and update messages from other modules via IPC.
How i do to both applications reproduce the same informations, synchronously? It's possible?

Thank you again!

This topic is closed to new replies.

Advertisement