Ejemplo n.º 1
0
        private void GamePage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!pageLoaded)
            {
                manager = SharedGraphicsDeviceManager.Current;
                manager.PreferredBackBufferWidth  = (int)this.ActualWidth;
                manager.PreferredBackBufferHeight = (int)this.ActualHeight;
                manager.SwapChainPanel            = this;
                manager.ApplyChanges();

                gameTimer = new GameTimer();
                gameTimer.UpdateInterval = TimeSpan.FromTicks(166666);
                gameTimer.Update        += Update;
                gameTimer.Draw          += Draw;

                this.SizeChanged += GamePage_SizeChanged;

                // Le contenu est chargé une fois
                LoadContent();

                pageLoaded = true;
            }

            // L'initialisation doit se faire à chaque rechargement
            Initialize();
        }
Ejemplo n.º 2
0
 public Drawer(SharedGraphicsDeviceManager graphics, Texture2D spriteSheet)
 {
     this.graphics    = graphics;
     this.spriteSheet = spriteSheet;
     Height           = graphics.PreferredBackBufferHeight / GamePage.ScaleFactor;
     Width            = graphics.PreferredBackBufferWidth / GamePage.ScaleFactor;
     ResetOffset();
 }
Ejemplo n.º 3
0
        public static void Init(GraphicsDeviceManager graphics)
#endif
        {
            _graphics      = graphics;
            _realWidth     = graphics.PreferredBackBufferWidth;
            _realHeight    = graphics.PreferredBackBufferHeight;
            settingApplied = false;
        }
Ejemplo n.º 4
0
 public Drawer3D(SharedGraphicsDeviceManager graphics, Texture2D spriteSheet)
     : base(graphics, spriteSheet)
 {
     basicEffect = new BasicEffect(graphics.GraphicsDevice)
     {
         TextureEnabled     = true,
         VertexColorEnabled = true,
     };
 }
Ejemplo n.º 5
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            this.graphics = SharedGraphicsDeviceManager.Current;


            Initialize();
        }
Ejemplo n.º 6
0
        public Main()
        {
            Instance = this;

            //original resolution definition
#if WP7
            graphics = SharedGraphicsDeviceManager.Current;
            Content  = (Application.Current as App).Content;
#else
            graphics = new GraphicsDeviceManager(this);
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            graphics.IsFullScreen          = true;
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            InactiveSleepTime = TimeSpan.FromSeconds(1);
#endif
            graphics.PreferredBackBufferWidth  = DESIGN_WIDTH;
            graphics.PreferredBackBufferHeight = DESIGN_HEIGHT;
#if WP8
            switch (App.Current.Host.Content.ScaleFactor)
            {
            case 160:
                //wxga
                graphics.PreferredBackBufferWidth  = 1280;
                graphics.PreferredBackBufferHeight = 768;
                break;

            case 150:
                //720p
                graphics.PreferredBackBufferWidth  = 1280;
                graphics.PreferredBackBufferHeight = 720;
                break;
            }
#endif
#if ANDROID
            graphics.PreferredBackBufferWidth  = Activity.WindowManager.DefaultDisplay.Width;
            graphics.PreferredBackBufferHeight = Activity.WindowManager.DefaultDisplay.Height;
#endif
#if WINDOWS
            renderWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            renderHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
#endif

#if WINDOWS
            Window.IsBorderless = true;
            IsMouseVisible      = true;
#endif
            Content.RootDirectory = "Content";

            soundController = SoundController.CreateInstance(this);
        }
Ejemplo n.º 7
0
        public static void DrawLine(DetectionResult markerResult, Vector3 startPoint, Vector3 endPoint)
        {
            if (markerResult != null)
            {
                SharedGraphicsDeviceManager graphics = SharedGraphicsDeviceManager.Current;

                float aspectRatio = (float)graphics.GraphicsDevice.Viewport.AspectRatio;

                graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                graphics.GraphicsDevice.BlendState        = BlendState.Opaque;
                graphics.GraphicsDevice.SamplerStates[0]  = SamplerState.LinearWrap;

                Vector3 cameraPosition = new Vector3(0, 0, 150);

                BasicEffect basicEffect = new BasicEffect(graphics.GraphicsDevice);
                basicEffect.World      = Microsoft.Xna.Framework.Matrix.CreateScale(SCALE) * markerResult.Transformation.ToXnaMatrix();
                basicEffect.View       = Microsoft.Xna.Framework.Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                basicEffect.Projection = Microsoft.Xna.Framework.Matrix.CreatePerspectiveFieldOfView(Microsoft.Xna.Framework.MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);

                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();

                    VertexPositionColor[] primitiveList = new VertexPositionColor[2]
                    {
                        new VertexPositionColor(startPoint, Color.White), new VertexPositionColor(endPoint, Color.White)
                    };

                    // Initialize an array of indices of type short.
                    short[] lineListIndices = new short[2] {
                        0, 1
                    };

                    graphics.GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, primitiveList, 0, 1);
                }
            }
        }
Ejemplo n.º 8
0
 public static void Init(SharedGraphicsDeviceManager graphics)
Ejemplo n.º 9
0
 /// <summary>
 /// 加载XNA图像资源管理器
 /// </summary>
 private void XNA_Graphics_Loading()
 {
     this.graphics = SharedGraphicsDeviceManager.Current;
     this.timer    = new SystemTimer();
 }
Ejemplo n.º 10
0
 private void InitializeXnaApplication()
 {
     this.deviceManager = new SharedGraphicsDeviceManager();
 }