public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters) { gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle; device.InitDefaultRenderTarget(presentationParameters); backBuffer = device.DefaultRenderTarget; DepthStencilBuffer = device.windowProvidedDepthTexture; }
public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters) { gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle; device.InitDefaultRenderTarget(presentationParameters); backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource); }
public NSTimerTimeSource(iPhoneOSGameView view, double updatesPerSecond) { this.view = view; // Can't use TimeSpan.FromSeconds() as that only has 1ms // resolution, and we need better (e.g. 60fps doesn't fit nicely // in 1ms resolution, but does in ticks). timeout = new TimeSpan((long)(((1.0 * TimeSpan.TicksPerSecond) / updatesPerSecond) + 0.5)); }
/// <summary> /// Initializes a new instance of the <see cref="GameContext" /> class. /// </summary> /// <param name="mainWindows">The main windows of the game</param> /// <param name="gameView">The view in which the game is rendered</param> /// <param name="gameViewController">The paradox game main controller</param> /// <param name="requestedWidth">Width of the requested.</param> /// <param name="requestedHeight">Height of the requested.</param> public GameContext(UIWindow mainWindows, iPhoneOSGameView gameView, ParadoxGameController gameViewController, int requestedWidth = 0, int requestedHeight = 0) { MainWindow = mainWindows; GameView = gameView; GameViewController = gameViewController; RequestedWidth = requestedWidth; RequestedHeight = requestedHeight; ContextType = AppContextType.iOS; }
internal override void Initialize(GameContext gameContext) { GameContext = gameContext; gameForm = gameContext.GameView; nativeWindow = new WindowHandle(AppContextType.iOS, gameForm); gameForm.Load += gameForm_Load; gameForm.Unload += gameForm_Unload; gameForm.RenderFrame += gameForm_RenderFrame; // get the OpenGL ES version var contextAvailable = false; foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile)) { var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version); EAGLContext contextTest = null; try { contextTest = new EAGLContext(contextRenderingApi); // delete extra context if (contextTest != null) contextTest.Dispose(); gameForm.ContextRenderingApi = contextRenderingApi; contextAvailable = true; } catch (Exception) { // TODO: log message } } if (!contextAvailable) throw new Exception("Graphics context could not be created."); gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8; //gameForm.LayerRetainsBacking = false; // Setup the initial size of the window var width = gameContext.RequestedWidth; if (width == 0) { width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor); } var height = gameContext.RequestedHeight; if (height == 0) { height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor); } gameForm.Size = new Size(width, height); //gameForm.Resize += OnClientSizeChanged; }
public CADisplayLinkTimeSource (iPhoneOSGameView view, int frameInterval) { this.view = view; if (displayLink != null) displayLink.Invalidate (); displayLink = CADisplayLink.Create (this, selRunIteration); displayLink.FrameInterval = frameInterval; displayLink.Paused = true; }
public override void Initialize() { view = Game.Context.GameView; window = Game.Context.MainWindow; var gameController = Game.Context.GameViewController; window.UserInteractionEnabled = true; window.MultipleTouchEnabled = true; gameController.TouchesBeganDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesMovedDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesEndedDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesCancelledDelegate += (touchesSet, _) => HandleTouches(touchesSet); view.Resize += OnResize; OnResize(null, EventArgs.Empty); }
internal override void Initialize(GameContext gameContext) { GameContext = gameContext; gameForm = gameContext.GameView; nativeWindow = new WindowHandle(AppContextType.iOS, gameForm); gameForm.Load += gameForm_Load; gameForm.Unload += gameForm_Unload; gameForm.RenderFrame += gameForm_RenderFrame; // get the OpenGL ES version var contextAvailable = false; foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile)) { var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version); EAGLContext contextTest = null; try { contextTest = new EAGLContext(contextRenderingApi); // delete extra context if (contextTest != null) contextTest.Dispose(); gameForm.ContextRenderingApi = contextRenderingApi; contextAvailable = true; break; } catch (Exception) { // TODO: log message } } if (!contextAvailable) throw new Exception("Graphics context could not be created."); gameForm.LayerColorFormat = EAGLColorFormat.RGBA8; //gameForm.LayerRetainsBacking = false; }
public override void Initialize() { base.Initialize(); view = Game.Context.GameView; window = Game.Context.MainWindow; var gameController = Game.Context.GameViewController; window.UserInteractionEnabled = true; window.MultipleTouchEnabled = true; gameController.TouchesBeganDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesMovedDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesEndedDelegate += (touchesSet, _) => HandleTouches(touchesSet); gameController.TouchesCancelledDelegate += (touchesSet, _) => HandleTouches(touchesSet); view.Resize += OnResize; OnResize(null, EventArgs.Empty); // create sensor managers motionManager = new CMMotionManager(); locationManager = new CLLocationManager(); // set desired sampling intervals motionManager.AccelerometerUpdateInterval = 1/DesiredSensorUpdateRate; motionManager.GyroUpdateInterval = 1/DesiredSensorUpdateRate; motionManager.DeviceMotionUpdateInterval = 1/DesiredSensorUpdateRate; // Determine supported sensors Accelerometer.IsSupported = motionManager.AccelerometerAvailable; Compass.IsSupported = CLLocationManager.HeadingAvailable; Gyroscope.IsSupported = motionManager.GyroAvailable; UserAcceleration.IsSupported = motionManager.DeviceMotionAvailable; Gravity.IsSupported = motionManager.DeviceMotionAvailable; Orientation.IsSupported = motionManager.DeviceMotionAvailable; }
/// <summary> /// Initializes current struct with a UIWindow <paramref name="w"/>, a GameView <paramref name="g"/>and a controller <paramref name="c"/>. /// </summary> public iOSWindow(UIWindow w, iPhoneOSGameView g, XenkoGameController c) { MainWindow = w; GameView = g; GameViewController = c; }
public NSTimerTimeSource(iPhoneOSGameView view, double updatesPerSecond) { this.view = view; // Can't use TimeSpan.FromSeconds() as that only has 1ms // resolution, and we need better (e.g. 60fps doesn't fit nicely // in 1ms resolution, but does in ticks). timeout = new TimeSpan ((long) (((1.0 * TimeSpan.TicksPerSecond) / updatesPerSecond) + 0.5)); }
public CADisplayLinkTimeSource(iPhoneOSGameView view, int frameInterval) { this.view = view; if (displayLink != null) displayLink.Invalidate (); displayLink = CADisplayLink.Create (this, selRunIteration); displayLink.FrameInterval = frameInterval; displayLink.Paused = true; }
protected override void Destroy() { if (gameForm != null) { GraphicsDevice.UnbindGraphicsContext(gameForm.GraphicsContext); var view = gameForm as IAnimatedGameView; if (view != null) { view.StopAnimating(); gameForm.Close(); } else { gameForm.Close(); gameForm.Dispose(); } gameForm = null; } base.Destroy(); }