저는 아이폰 OS 6과 7에서 잘 작동하는 애들 그리기 앱을 가지고 있습니다. 현재 어스 8.1에서 앱이 어떻게 작동 하는지를 시험 할 때 버그 만 발견했습니다.OpenRGB 레이어가 presentRenderBuffer에서 검은 색으로 변합니다.
드로잉 컨텍스트가 올바르게 초기화되었지만 선을 그릴 때 갑자기 배경이 검정색으로 바뀌지 만 선은 내가 사용하는 다른 셰이더 (연필, 브러쉬, 마커)로 올바르게 그려집니다. ..) 어떤 문제 재치가 여기
화면이 검은 색- (void)renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end
{
static GLfloat* vertexBuffer = NULL;
static NSUInteger vertexMax = 64;
NSUInteger vertexCount = 0,
count,
i;
[EAGLContext setCurrentContext:context];
glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer);
// Convert locations from Points to Pixels
CGFloat scale = self.contentScaleFactor;
start.x *= scale;
start.y *= scale;
end.x *= scale;
end.y *= scale;
// Allocate vertex array buffer
if(vertexBuffer == NULL)
vertexBuffer = malloc(vertexMax * 2 * sizeof(GLfloat));
// Add points to the buffer so there are drawing points every X pixels
count = MAX(ceilf(sqrtf((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y))/kBrushPixelStep), 1);
for(i = 0; i < count; ++i) {
if(vertexCount == vertexMax) {
vertexMax = 2 * vertexMax;
vertexBuffer = realloc(vertexBuffer, vertexMax * 2 * sizeof(GLfloat));
}
vertexBuffer[2 * vertexCount + 0] = start.x + (end.x - start.x) * ((GLfloat)i/(GLfloat)count);
vertexBuffer[2 * vertexCount + 1] = start.y + (end.y - start.y) * ((GLfloat)i/(GLfloat)count);
vertexCount += 1;
}
// Load data to the Vertex Buffer Object
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, vertexCount*2*sizeof(GLfloat), vertexBuffer, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, 0);
// Draw
// glUseProgram(program[PROGRAM_POINT].id);
glDrawArrays(GL_POINTS, 0, vertexCount);
// Display the buffer
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER];
self.mustSave = YES;
}
간다 코드입니다 그리고 이것은 initGL 코드
- (BOOL)initGL
{
// Generate IDs for a framebuffer object and a color renderbuffer
glGenFramebuffers(1, &viewFramebuffer);
glGenRenderbuffers(1, &viewRenderbuffer);
glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
// This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer)
// allowing us to draw into a buffer that will later be rendered to screen wherever the layer is (which corresponds with our view).
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(id<EAGLDrawable>)self.layer];
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);
// For this sample, we do not need a depth buffer. If you do, this is how you can create one and attach it to the framebuffer:
// glGenRenderbuffers(1, &depthRenderbuffer);
// glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, backingWidth, backingHeight);
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
return NO;
}
// Setup the view port in Pixels
glViewport(0, 0, backingWidth, backingHeight);
// Create a Vertex Buffer Object to hold our data
glGenBuffers(1, &vboId);
// Load the brush texture
brushTexture = [self textureFromName:kStrokePatternPencil];
// Load shaders
[self setupShaders];
// Enable blending and set a blending function appropriate for premultiplied alpha pixel data
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
return YES;
}
입니다 내가 무시하고있는 IOS 8?
그리고 유지 된 백업을 사용하도록 설정하면 모바일 GPU에서 상당한 성능 저하가 발생합니다. kEAGLDrawablePropertyRetainedBacking은 true로 설정됩니다. 일반적으로 모든 프레임에서 전체 장면을 다시 그릴 수 있도록 렌더러를 설계하는 것이 좋습니다. – rickster
죄송합니다.이 속성으로 컨텍스트를 초기화하는 initGL 메서드를 붙여 넣지는 않겠지 만 처리하고 있습니다. – Rotten