Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - OpenGL es2.0 question: (4 Items)
   
OpenGL es2.0 question  
I am having issue running an OGL v2 render engine in different threads. The use case is that an app would generate two 
instances of my render engine (for bb maps). The render engine itself has a couple of singletons serving OpenGL thread 
running and providing shader programs for different views.

The problem occurs (error# 1281, invalid value) when SECOND render thread tries to use the same shader program object 
(served by a singleton) by calling glUseProgram().

So my question is, how does OGL v2.0 work with different render threads in the same app process space? Do I have to 
create seperate shader programs for different render thread?

Any help is greatly appreciated.
Shawn 
Re: OpenGL es2.0 question  
You have to request sharing explicitly when calling eglCreateContext. There is a share_context argument.

Sent from my BlackBerry 10 smartphone on the Rogers network.
From: Shawn Zhang
Sent: Wednesday, June 19, 2013 19:57
To: opengles-graphics
Reply To: opengles-graphics@community.qnx.com
Subject: OpenGL es2.0 question


I am having issue running an OGL v2 render engine in different threads. The use case is that an app would generate two 
instances of my render engine (for bb maps). The render engine itself has a couple of singletons serving OpenGL thread 
running and providing shader programs for different views.

The problem occurs (error# 1281, invalid value) when SECOND render thread tries to use the same shader program object 
(served by a singleton) by calling glUseProgram().

So my question is, how does OGL v2.0 work with different render threads in the same app process space? Do I have to 
create seperate shader programs for different render thread?

Any help is greatly appreciated.
Shawn



_______________________________________________

OpenGL ES
http://community.qnx.com/sf/go/post102449
To cancel your subscription to this discussion, please e-mail opengles-graphics-unsubscribe@community.qnx.com
Attachment: HTML sf-attachment-mime14088 3.08 KB
Re: OpenGL es2.0 question  
Hi Etienne, thanks for the reply and the sharing context solved my problem. Now both instances of maps are rendered on 
screen.

Here comes the second question, if the first instance of the render engine is destroyed( so is the egl context 
associated with it) and the second EGL context that depends on the first becomes a dangling context? How to deal with 
this situation?

What is the best way to deal with it? It looks to me that if I don’t use singletons in my render engine, then both EGL 
context and shader program will be independent from each other (though co-exist in the same app process), would that 
work?

Again your help is greatly appreciated.
Shawn

Re: OpenGL es2.0 question  
You can have multiple independent contexts within a process at any time.
That's not a problem. You can only use one context in one thread at once,
though.

Normally, drivers will ref count resources that are shared between
contexts so that if you destroy a context that shares resources with
another, things should work just fine on the other context. That is not a
high runner use cases, however, so there is a lot less testing of these
scenarios than more traditional rendering set-ups.