- Home /
Question by
Philanthropist · Feb 05, 2013 at 04:52 PM ·
iosorientationgl
GL.LoadProjectionMatrix and Screen.Orientation out of sync
Currently in Update() I'm using the following code to draw a texture from a native plugin on iOS. I'm using Screen.Orientation to set drawing coordinates which accommodates for the different coordinate systems that are associated with the different orientations. However it seems that Screen.Orientation updates one frame later than the projection matrix implied by GL.LoadPixelMatrix() which causes a disturbing visual glitch for one frame. How can I get my drawn texture to be rotated immediately when the device orientation changes.
GL.PushMatrix();
GL.LoadPixelMatrix();
switch(Screen.orientation) {
default:
case ScreenOrientation.LandscapeLeft:
screenRect = screenRectLandscapeLeft;
break;
case ScreenOrientation.LandscapeRight:
screenRect = screenRectLandscapeRight;
break;
case ScreenOrientation.PortraitUpsideDown:
screenRect = screenRectPortraitUpsideDown;
break;
case ScreenOrientation.Portrait:
screenRect = screenRectPortrait;
break;
}
Graphics.DrawTexture(screenRect, videoTexture, videoTextureCoordinates, 0, 0, 0, 0);
GL.PopMatrix();
Comment