1
我想獲得一個OpenGL項目正確呈現到iPhone視網膜顯示,我似乎遇到了一些困難。我已經爲設備設置了內容縮放因子,但現在幀緩衝區未能創建。Open GL ES視網膜顯示設置
這些都是在EAGLView int的createFramebuffer方法的子類中完成的。
這是我的設置:
glGenFramebuffersOES(1,& viewFramebuffer); glGenRenderbuffersOES(1,& viewRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
self.contentScaleFactor = [[UIScreen mainScreen] scale];
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);//Depth
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
NSLog(@"scale Factor: %f",self.contentScaleFactor);
比例因子報告正確,但顯示不會呈現,並且緩衝區無法創建。我在這裏錯過了什麼嗎?
backingWidth和backingHeight在結尾處有什麼值?這些視圖的像素大小是否正確?你是通過'glCheckFramebufferStatus(GL_FRAMEBUFFER)'還是另一種方式檢查framebuffer的狀態? – 2012-08-16 20:06:29
檢查我得到的值:比例因子:2.000000 backingWidth:640 backingHeight:960。這些是我的顯示器的正確尺寸。而glCheckFramebufferStatus(GL_FRAMEBUFFER)不會返回GL_FRAMEBUFFER_COMPLETE_OES。 – jcb344 2012-08-16 20:30:19
@ jcb344我遇到類似的問題,你解決了這個問題嗎? – rraallvv 2013-03-24 05:23:43