// As ISurfaceHolderCallback public void SurfaceCreated(ISurfaceHolder holder) { lock(lockObject) { ExEnLog.WriteLine("ExEnAndroidSurfaceView.SurfaceCreated"); // Set initial display data surfaceWidth = Width; surfaceHeight = Height; orientation = ConvertOrientation(Width, Height, (SurfaceOrientation)activity.WindowManager.DefaultDisplay.Orientation); surfaceAvailable = true; Monitor.PulseAll(lockObject); // Signal game thread to reevaluate surface state } UpdateInputScaler(); }
// As ISurfaceHolderCallback public void SurfaceChanged(ISurfaceHolder holder, int format, int width, int height) { ExEnLog.WriteLine("ExEnAndroidSurfaceView.SurfaceChanged(format = " + format + ", width = " + width + ", height = " + height + ")"); lock(lockObject) { // Update display data surfaceChanged = true; surfaceWidth = width; surfaceHeight = height; // Android sillyness notes: // - getOrientation gets deprecated and renamed to getRotation in API level 8 // - Rotation is relative to the "natural" device orientation orientation = ConvertOrientation(surfaceWidth, surfaceHeight, (SurfaceOrientation)activity.WindowManager.DefaultDisplay.Orientation); // TODO, BUG: // If the device is flipped 180 degrees, Android is "helpful" by just // pretending nothing happened and silently flipping your display surface // I'm yet to find an event (that isn't a private API) that I can hook // to get a notification when this happens. So for now, simply assume that the // client game code doesn't really care about the difference between landscape-left/-right. // // Here's a Stack Overflow question, in case a solution is found: // http://stackoverflow.com/questions/7329823/android-event-for-all-interface-orientation-changes } UpdateInputScaler(); }
public void Change(ExEnInterfaceOrientation orientation, Point renderbufferSize, Point deviceSize) { this.orientation = orientation; this.renderbufferSize = renderbufferSize; this.deviceSize = deviceSize; Recalculate(); }
internal void InternalDeviceReady(ExEnAndroidSurfaceView gameView, int width, int height, ExEnInterfaceOrientation orientation) { Point size = new Point(width, height); if(GraphicsDevice == null) { GraphicsDevice = new GraphicsDevice(new ExEnScaler(orientation, size, size)); OnDeviceCreated(this, EventArgs.Empty); } else { // NOTE: Should the graphics device scaler be updated here? } }
public ExEnScaler(ExEnInterfaceOrientation orientation, Point renderbufferSize, Point deviceSize) { Change(orientation, renderbufferSize, deviceSize); }