@@ -69,6 +69,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
6969#import " Support/CCFileUtils.h"
7070#import " Support/ZipUtils.h"
7171#import " CCGL.h"
72+ #import " CCRenderDispatch.h"
7273
7374#pragma mark -
7475#pragma mark CCTexturePVR
@@ -505,6 +506,9 @@ - (BOOL)unpackPVRv3Data:(unsigned char*)dataPointer PVRLen:(NSUInteger)dataLengt
505506
506507- (BOOL )createGLTexture
507508{
509+ __block BOOL retVal = NO ;
510+
511+ CCRenderDispatch (NO , ^{
508512 GLsizei width = _width;
509513 GLsizei height = _height;
510514 GLenum err;
@@ -543,7 +547,7 @@ - (BOOL)createGLTexture
543547 {
544548 if ( compressed && ! [[CCConfiguration sharedConfiguration ] supportsPVRTC ] ) {
545549 CCLOGWARN (@" cocos2d: WARNING: PVRTC images are not supported" );
546- return NO ;
550+ retVal = NO ; return ;
547551 }
548552
549553 unsigned char *data = _mipmaps[i].address ;
@@ -561,14 +565,17 @@ - (BOOL)createGLTexture
561565 if (err != GL_NO_ERROR)
562566 {
563567 CCLOGWARN (@" cocos2d: TexturePVR: Error uploading compressed texture level: %u . glError: 0x%04X " , i, err);
564- return NO ;
568+ retVal = NO ; return ;
565569 }
566570
567571 width = MAX (width >> 1 , 1 );
568572 height = MAX (height >> 1 , 1 );
569573 }
570574
571- return YES ;
575+ retVal = YES ; return ;
576+ });
577+
578+ return retVal;
572579}
573580
574581
@@ -701,10 +708,11 @@ + (id)pvrTextureWithContentsOfURL:(NSURL *)url
701708- (void )dealloc
702709{
703710 CCLOGINFO ( @" cocos2d: deallocing %@ " , self);
704-
705- if (_name != 0 && ! _retainName )
706- glDeleteTextures (1 , &_name);
707-
711+
712+ if (_name != 0 && ! _retainName){
713+ GLuint name = _name;
714+ CCRenderDispatch (YES , ^{glDeleteTextures (1 , &name);});
715+ }
708716}
709717
710718@end
0 commit comments