Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-09-2008, 09:59 AM   #2 (permalink)
nuudles
New Member
 
Join Date: Oct 2008
Posts: 10
Default

Quote:
Originally Posted by axlsd View Post
Hello everybody,

my application has a NSTimer for rendering, I want to load my textures and other data in a parallel thread while timer renders a loading screen.

My problem is:
if I try to create a texture2d (using a code very similiar to crash landing example) starting an NSThread, glGenTextures call freezes my application and I can understand why..

Any help is appreciated, thanks.
I actually got this working, but it's a big pain. What you're dealing with is the fact that your texture thread doesn't have an OpenGL context. You can create a new one for it, but then any texture you create in that context won't be shared between that context and your main thread's context. You have to use something called an EAGLSharegroup to link the contexts together so they can share resources. You can do this by changing your EAGLView code to initialize its context like this:

Code:
EAGLSharegroup *sharegroup = [[EAGLSharegroup alloc] init];
context = [[EAGLContext alloc] initWithAPI:EAGLRenderingAPIOpenGLES1 sharegroup:sharegroup];
Once this is done, go into your thread and create a context using the above call with the same sharegroup. You'll have to initialize the context with whatever OpenGL initializations you want, but you should be able to get it to work.

Note:
This code does not work in the Simulator. The EAGLContext initialization with a sharegroup crashes the Simulator. The code does, however, work on the device itself, so keep that in mind. I'd opened a bug report regarding this bug, 6367125, and currently it is in the Open state.
nuudles is offline   Reply With Quote
 

» Advertisements
» Online Users: 732
18 members and 714 guests
adivoget15, aniuco, AppAnnex, bradte16, chits12345, chrisfromnz, dana0550, Dani77, deepak.hws, Domele, handmachine, Harisstimolth5, iSkythe, JamesCahall, Janyeok, Oral B, Relwakbanzela, salehamahbub
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,794
Threads: 89,205
Posts: 380,606
Top Poster: BrianSlick (7,129)
Welcome to our newest member, adivoget15
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.