Ejemplo n.º 1
0
        //RenderTarget2D mBackBuffer;
        //SpriteBatch SpriteBatch;

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

            mMachine        = ((App)Application.Current).GetMachine();
            mRuntime        = mMachine.GetRuntime();
            mOpenGLESModule = mRuntime.GetModule <MoSync.OpenGLESModule>();
            //mOpenGLESModule.InitWithGraphicsDevice(SharedGraphicsDeviceManager.Current.GraphicsDevice);
            MoSyncGraphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;
            MoSyncGraphicsDevice.PresentationParameters.IsFullScreen           = true;
            SharedGraphicsDeviceManager.Current.SynchronizeWithVerticalRetrace = false;
            mOpenGLESModule.InitWithGraphicsDevice(MoSyncGraphicsDevice);

            // TODO: use this.content to load your game content here
//			mBackBuffer = new RenderTarget2D(MoSyncGraphicsDevice, SharedGraphicsDeviceManager.DefaultBackBufferWidth, SharedGraphicsDeviceManager.DefaultBackBufferHeight);
//			SpriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
//			MoSyncGraphicsDevice.SetRenderTarget(mBackBuffer);

#if USE_THREAD_LOCKED_VERSION
            mOpenGLESModule.SetOnUpdateScreenAction(() =>
            {
                mShouldDrawFrame = true;
                if (!mOnDrawInitialized)
                {
                    timer.Draw += OnDraw;
                }
                mOnDrawInitialized = true;
                DrawRequiredEvent.Set();
                DrawCompleteEvent.WaitOne();
                mShouldDrawFrame = false;
            });

            MoSync.Util.SetPreRunOnMainThreadAction(() =>
            {
                mShouldDrawFrame   = false;
                timer.FrameAction -= PreDraw;
                DrawRequiredEvent.Set();
            });

            MoSync.Util.SetPostRunOnMainThreadAction(() =>
            {
                mShouldDrawFrame   = false;
                timer.FrameAction += PreDraw;
                DrawRequiredEvent.Set();
            });
#else
            mOpenGLESModule.SetOnUpdateScreenAction(() =>
            {
                timer.Draw += OnDraw;
            });
#endif

            base.OnNavigatedTo(e);

            // Start the timer
            timer.Start();
        }
Ejemplo n.º 2
0
		//RenderTarget2D mBackBuffer;
		//SpriteBatch SpriteBatch;

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

			mMachine = ((App)Application.Current).GetMachine();
			mRuntime = mMachine.GetRuntime();
			mOpenGLESModule = mRuntime.GetModule<MoSync.OpenGLESModule>();
			//mOpenGLESModule.InitWithGraphicsDevice(SharedGraphicsDeviceManager.Current.GraphicsDevice);
			MoSyncGraphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;
			MoSyncGraphicsDevice.PresentationParameters.IsFullScreen = true;
			SharedGraphicsDeviceManager.Current.SynchronizeWithVerticalRetrace = false;
			mOpenGLESModule.InitWithGraphicsDevice(MoSyncGraphicsDevice);

            // TODO: use this.content to load your game content here
//			mBackBuffer = new RenderTarget2D(MoSyncGraphicsDevice, SharedGraphicsDeviceManager.DefaultBackBufferWidth, SharedGraphicsDeviceManager.DefaultBackBufferHeight);
//			SpriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
//			MoSyncGraphicsDevice.SetRenderTarget(mBackBuffer);

#if USE_THREAD_LOCKED_VERSION
			mOpenGLESModule.SetOnUpdateScreenAction(() =>
			{
				mShouldDrawFrame = true;
				if (!mOnDrawInitialized)
					timer.Draw += OnDraw;
				mOnDrawInitialized = true;
				DrawRequiredEvent.Set();
				DrawCompleteEvent.WaitOne();
				mShouldDrawFrame = false;
			});

			MoSync.Util.SetPreRunOnMainThreadAction(() =>
			{
				mShouldDrawFrame = false;
				timer.FrameAction -= PreDraw;
				DrawRequiredEvent.Set();
			});

			MoSync.Util.SetPostRunOnMainThreadAction(() =>
			{
				mShouldDrawFrame = false;
				timer.FrameAction += PreDraw;
				DrawRequiredEvent.Set();
			});
#else
			mOpenGLESModule.SetOnUpdateScreenAction(() =>
			{
				timer.Draw += OnDraw;
			});
#endif

			base.OnNavigatedTo(e);

			// Start the timer
			timer.Start();
        }
Ejemplo n.º 3
0
        public static Machine CreateNativeMachine(Core core, String resourceFile)
        {
            StreamResourceInfo resourcesResInfo = Application.GetResourceStream(new Uri(resourceFile, UriKind.Relative));
            Stream resources = null;
            if (resourcesResInfo != null && resourcesResInfo.Stream != null)
                resources = resourcesResInfo.Stream;

            MoSync.Machine mosyncMachine = new MoSync.Machine(true);
            mosyncMachine.Init(core, resources);
            if (resources != null)
                resources.Close();
            return mosyncMachine;
        }
Ejemplo n.º 4
0
        public static Machine CreateNativeMachine(Core core, String resourceFile)
        {
            StreamResourceInfo resourcesResInfo = Application.GetResourceStream(new Uri(resourceFile, UriKind.Relative));
            Stream             resources        = null;

            if (resourcesResInfo != null && resourcesResInfo.Stream != null)
            {
                resources = resourcesResInfo.Stream;
            }

            MoSync.Machine mosyncMachine = new MoSync.Machine(true);
            mosyncMachine.Init(core, resources);
            //if (resources != null)
            //resources.Close();
            return(mosyncMachine);
        }
Ejemplo n.º 5
0
        public static Machine CreateMachineLib(String resourceFile)
        {
            MoSync.Machine mosyncMachine = new MoSync.Machine(false, true);

            StreamResourceInfo resourcesResInfo = Application.GetResourceStream(new Uri(resourceFile, UriKind.Relative));

            Stream resources = null;

            if (resourcesResInfo != null && resourcesResInfo.Stream != null)
            {
                resources = resourcesResInfo.Stream;
            }

            Core core = new MoSync.CoreNative();

            (core as MoSync.CoreNative).InitData();
            mosyncMachine.InitLib(core, resources);

            return(mosyncMachine);
        }
Ejemplo n.º 6
0
 public static Machine CreateInterpretedMachine(String programFile, String resourceFile)
 {
     MoSync.Machine mosyncMachine = new MoSync.Machine(false);
     mosyncMachine.LoadProgram(programFile, resourceFile);
     return(mosyncMachine);
 }
Ejemplo n.º 7
0
        public static Machine CreateMachineLib(String resourceFile)
        {
            MoSync.Machine mosyncMachine = new MoSync.Machine(false, true);

            StreamResourceInfo resourcesResInfo = Application.GetResourceStream(new Uri(resourceFile, UriKind.Relative));

            Stream resources = null;
            if (resourcesResInfo != null && resourcesResInfo.Stream != null)
                resources = resourcesResInfo.Stream;

            Core core = new MoSync.CoreNative();
            (core as MoSync.CoreNative).InitData();
            mosyncMachine.InitLib(core, resources);

            return mosyncMachine;
        }
Ejemplo n.º 8
0
 public static Machine CreateInterpretedMachine(String programFile, String resourceFile)
 {
     MoSync.Machine mosyncMachine = new MoSync.Machine(false, false);
     mosyncMachine.LoadProgram(programFile, resourceFile);
     return mosyncMachine;
 }