I have an application that draws a scene in OpenGL ES 2.0. Everything is correctly displayed on the iPhone and iPad simulators, as well as on real devices, until I try to use the retina screen. Retina devices are still drawing, but with the same resolution as older devices.
On new devices, I get only a black screen. On the retina simulators, I get a pink screen. The program will not even use the value that I set with glClearColor ();
I can correctly set the scale factor for the device using the following code:
_eaglLayer = (CAEAGLLayer *)self.layer; _eaglLayer.opaque = YES; self.contentScaleFactor = [[UIScreen mainScreen] scale]; _eaglLayer.contentsScale = [[UIScreen mainScreen] scale];
And I can correctly create the render buffer here:
glGenRenderbuffers(1, &_depthRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width, self.frame.size.height);
I set the viewport size as follows:
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &_backingWidth); glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &_backingHeight); ... glViewport(0, 0, _backingWidth, _backingHeight);
All this code works on older devices, and it works flawlessly if I comment out the lines:
self.contentScaleFactor = [[UIScreen mainScreen] scale]; _eaglLayer.contentsScale = [[UIScreen mainScreen] scale];
I registered the scale when loading the view, and it correctly sets the value to 2.0 on retina devices or 1.0 on older devices.
I tried a number of different solutions and scale factor adjustment methods, but to no avail. I know something that I just donβt see, but I canβt find it. Suggestions?