Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Run the same OpenGL program in two context


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 cayo   Members   -  Reputation: 123

Like
0Likes
Like

Posted 10 April 2014 - 04:21 PM

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!


Sponsor:

#2 TheChubu   Crossbones+   -  Reputation: 4755

Like
0Likes
Like

Posted 10 April 2014 - 06:56 PM

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


Edited by TheChubu, 10 April 2014 - 07:34 PM.

"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


#3 L. Spiro   Crossbones+   -  Reputation: 14215

Like
2Likes
Like

Posted 10 April 2014 - 07:10 PM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#4 TheChubu   Crossbones+   -  Reputation: 4755

Like
1Likes
Like

Posted 10 April 2014 - 07:26 PM


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


Edited by TheChubu, 10 April 2014 - 07:34 PM.

"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


#5 cayo   Members   -  Reputation: 123

Like
0Likes
Like

Posted 10 April 2014 - 10:06 PM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS