I have my AVCaptureSession configured and this function is called every time videoBuffer is refreshed:
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
I try to save my texture with:
CCTexture2D *CCtext = [CCTexture alloc] initWithData:rawImage pixelFormat:kCCTexture2DPixelFormat_RGBA8888 pixelsWide:width pixelsHigh:height contentSize:CGSizeMake(width, height)];
[Controller setCameraTexture:CCtext]
OR
globalCCTexture = [CCTexture alloc] initWithImage:rawImage];
[Controller setCameraTexture:globalCCTexture]
I also try to alloc memory in init function and only write here. I also try
[Controller performSelectorOnMainThread:@selector(setCameraTexture:) withObject: (id) globalCCTexture waitUntilDone:YES];
I Always get white texture inside my CCTexture2D. I have manually opened CGImage and filled graphical information with "0" [ black ] but i still have totally white square.
Fact 1: Capturing code is working in other project, without cocos2d with this drawing:
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject: (id) rawUIImage waitUntilDone:Yes];
Fact 2: If i just try to load a static resource in this function, i still get white screen in my CCTexture2d;
Fact 3: If i load a static resource in init of the same class - it works.
I guess it's some memory issue i don't understand.
Give me some ideas, please. I'm in despair. Spend like 15 hours non-stop on a 5-minute problem.