1
在iOS上,我始终认为它是而不是可能通过NSOperation子类在单独的线程上创建OpenGL纹理 - glTexImage2D。有人可以确认/否认。iOS上的OpenGL。 glTexImage2D可以在单独的线程上调用吗?
由于纹理创建可能会挂起GUI - 坏! - 有没有人想出一个他们满意的解决方法?
感谢,
道格
在iOS上,我始终认为它是而不是可能通过NSOperation子类在单独的线程上创建OpenGL纹理 - glTexImage2D。有人可以确认/否认。iOS上的OpenGL。 glTexImage2D可以在单独的线程上调用吗?
由于纹理创建可能会挂起GUI - 坏! - 有没有人想出一个他们满意的解决方法?
感谢,
道格
是的,看看CCTextureCache.m在cocos2d的iPhone。
cocos2d-iphone/cocos2d/CCTextureCache.m
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
// textures will be created on the main OpenGL context
// it seems that in SDK 2.2.x there can't be 2 threads creating textures at the same time
// the lock is used for this purpose: issue #472
[contextLock_ lock];
if(auxGLcontext == nil) {
auxGLcontext = [[EAGLContext alloc]
initWithAPI:kEAGLRenderingAPIOpenGLES1
sharegroup:[[[[CCDirector sharedDirector] openGLView] context] sharegroup]];
if(! auxGLcontext)
CCLOG(@"cocos2d: TextureCache: Could not create EAGL context");
}
if([EAGLContext setCurrentContext:auxGLcontext]) {
// load/create the texture
CCTexture2D *tex = [self addImage:async.data];
/* This method calls glTexImage2D. */
// The callback will be executed on the main thread
[async.target performSelectorOnMainThread:async.selector withObject:tex waitUntilDone:NO];
[EAGLContext setCurrentContext:nil];
} else {
CCLOG(@"cocos2d: TetureCache: EAGLContext error");
}
[contextLock_ unlock];
[autoreleasepool release];
CCCOOOOLLLL!感谢万卡指针卡萨奎! – dugla 2011-03-02 16:12:04