Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
 {
     gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle;
     device.InitDefaultRenderTarget(presentationParameters);
     backBuffer         = device.DefaultRenderTarget;
     DepthStencilBuffer = device.windowProvidedDepthBuffer;
 }
Ejemplo n.º 3
0
        public override void Initialize(GameContext <iOSWindow> gameContext)
        {
            view   = gameContext.Control.GameView;
            window = gameContext.Control.MainWindow;

            var gameController = gameContext.Control.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;
        }
Ejemplo n.º 4
0
        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;

            gameForm.ContextRenderingApi = MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2;
            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;
        }
Ejemplo n.º 5
0
 /// <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;
 }
Ejemplo n.º 6
0
 private UIViewController GetViewController(iPhoneOSGameView form)
 {
     for (UIResponder uiResponder = form; uiResponder != null; uiResponder = uiResponder.NextResponder)
     {
         UIViewController uiViewController = uiResponder as UIViewController;
         if (uiViewController != null)
         {
             return(uiViewController);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
        protected override void Initialize(GameContext <iOSWindow> gameContext)
        {
            gameForm     = gameContext.Control.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm, gameForm.Handle);

            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;

            currentOrientation = UIApplication.SharedApplication.StatusBarOrientation;
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 /// <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, StrideGameController c)
 {
     MainWindow         = w;
     GameView           = g;
     GameViewController = c;
 }
Ejemplo n.º 11
0
        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;
        }