Screen.SetResolution(2048, 1536) causes OGLES error on iPad 4

For me, using Screen.SetResolution() to set the retina resolution 2048x1536 causes an OGLES error on iPad 4. The initial resolution is the iPad resolution 1024x768. This used to work some time ago.

I have the following code to change the resolution in a debug GUI:

Resolution resolution = Screen.currentResolution;

if (GUILayout.Button("x2"))
{
	Screen.SetResolution(
		2 * resolution.width,
		2 * resolution.height,
		Screen.fullScreen);
}

if (GUILayout.Button("/2"))
{
	Screen.SetResolution(
		resolution.width / 2,
		resolution.height / 2,
		Screen.fullScreen);
}

The error message is

OpenGLES error 0x0502 in […]Classes/Unity/GlesHelper.mm:125

The application doesn’t crash, the resolution is set correctly, but the z-test seems to be inverted.

Is Screen.SetResolution() supposed to work on iOS retina devices, or is this perhaps a bug introduced on some of the Unity 4.1.x versions?

no, this should work, though we have found some corner case bugs in 4.1 since the release. Can you please bug report with small repro project?

Submitted a bug report with ticket

536575_s3qslfihpbbnttgo

Includes a minimal test project.

Thanks for repro - i’ve identified the issue (it will be fixed in something like 4.2)
As a workaround i would suggest you to change your logic a bit: start in native res, and lower if needed (on older devices).
P.S. The problem was with going non-native to native res.

Thanks for the quick response! Workaround works :slight_smile:

Hello!
Sorry to re-hash an old thread, but @Alexey I’ve got a very similar problem, yet I already start at native resolution.

Here’s the thread: Changes between "Development" and "Deployment" iOS? I'm getting odd bugs - Unity Engine - Unity Discussions

Nutshell: Getting the OpenGLES error when I resize the screen in the game. However, I start at full resolution for the device.