_eaglLayer = (CAEAGLLayer*) self.layer;
_eaglLayer.opaque = YES;
_eaglLayer.drawableProperties = @{kEAGLDrawablePropertyRetainedBacking : @(NO), kEAGLDrawablePropertyColorFormat:kEAGLColorFormatRGBA8 };
....
...
透明背景glClearColor(1.0,1.0,1.0,0.0);
- (void)render:(CADisplayLink*)displayLink {
[EAGLContext setCurrentContext:_context];
static float time = 0;
time += displayLink.duration * attractorIndexes.count*2;
if(startVoice)
[self changeTRMatrixFar];
//else
// [self changeTRMatrixNear];
glDisable(GL_DEPTH_TEST);
glEnable(GL_POINT_SPRITE_OES);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, self.frame.size.width, self.frame.size.height);
glUseProgram(programHandle);
当我拍摄快照时,我会得到一个UIImage,如果我将其转换为JPEG并保存到文件中我会得到一个白色方块,如果你保留在PNG中也会得到一个透明背景的空白方块,如果我将它带到屏幕快照(录制在视频结束时)video 背景因某种原因尚不清楚,有些半透明的人物。
如果我将这个快照带到后台:
UIGraphicsBeginImageContextWithOptions(backgroundImage.size, NO, 1.0);
context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, backgroundRect, backgroundImage.CGImage);
CGContextDrawImage(context, figureRect, attractorSnapshot.CGImage);
...
我得到颜色失真,只是做了一些额外的工件:image
我无法理解错误是什么?