2011-11-29 5 views
1

내가 OpenGL을 ES와는 FFmpeg를 사용하여 이미지의 비디오를 만들려고 해요,하지만 (4.3) 아이 패드에 내가 glReadPixels는 OpenGL ES glReadPixels EXC_BAD_ACCESS

-(NSData *) glToUIImage { 

    int numberOfComponents = NUMBER_OF_COMPONENTS; //4 
    int width = PICTURE_WIDTH; 
    int height = PICTURE_HEIGHT; 

    NSInteger myDataLength = width * height * numberOfComponents; 

    NSMutableData * buffer= [NSMutableData dataWithLength :myDataLength];  

    [self checkForGLError]; 

    GLenum type = NUMBER_OF_COMPONENTS == 3 ? GL_RGB : GL_RGBA; //RGBA 
    glReadPixels(0, 0, width, height, type, GL_UNSIGNED_BYTE, [buffer mutableBytes]); //EXC_BAD_ACCESS here 

    return buffer; 
} 
그것은 아이폰 4에 노력하고 있습니다

(4.3)에 충돌이 및 아이팟 터치,하지만 아이폰 3G (3.0) 및 iPad (4.3)에 문제가 있습니다. 이 문제에 대해 저를 도울 수 있습니까?

또한 iPhone 3G (3.0) 및 iPad (4.3)에 비디오에 문제가 있습니다. 처음 5-20 개의 비디오 프레임에 쓰레기가 있습니다. 최적화와 관련한 문제 일 수 있습니까? 아니면 건축?

EDITED 스택 :

#0 0x33be3964 in void BlockNxN<64ul, 16ul, 1, BLOCK_CONVERTER_NULL_32>(unsigned long, int, int, unsigned long, int, int, unsigned int, unsigned int, unsigned int, unsigned int)() 
#1 0x33be1c76 in glrBIFDetile() 
#2 0x33b586b2 in sgxGetImage(SGXImageReadParams const*)() 
#3 0x33b50d38 in gldReadPixels() 
#4 0x31813e16 in glReadPixels_Exec() 
#5 0x31e3c518 in glReadPixels() 

답변

2

내가 알아 냈어요!

약 2 주 후에이 문제가 해결되었습니다.

당신은 [(EAGLView *)eagleView presentFramebuffer];

전에 glReadPixels()를 호출해야합니다 그리고 당신은 픽셀을 읽기 전에 그래서 당신은 colorRenderbuffer을 바인드해야합니다. 최종 방법 목록 :

int numberOfComponents = NUMBER_OF_COMPONENTS; 
int width = PICTURE_WIDTH; 
int height = PICTURE_HEIGHT; 

NSInteger myDataLength = width * height * numberOfComponents; 


NSMutableData * buffer= [NSMutableData dataWithLength :myDataLength]; 
glBindRenderbuffer(GL_RENDERBUFFER_OES, [((EAGLView *)eagleView) colorRenderbuffer]); 
[self checkForGLError]; 
glPixelStorei(GL_PACK_ALIGNMENT, 4); // force 4 byte alignment 

glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, [buffer mutableBytes]); 
return buffer; 
+0

충돌로 인해 8 시간 이상 소요되었습니다./감사합니다. –