Esempio n. 1
0
        /// <summary>
        /// Initialize
        /// </summary>
        protected override void Initialize()
        {
#if !XBOX360
            // Add screenshot capturer. Note: Don't do this in constructor,
            // we need the correct window name for screenshots!
            this.Components.Add(new ScreenshotCapturer(this));
#endif

            base.Initialize();

            GameSettings.Initialize();
            ApplyResolutionChange();

            Sound.SetVolumes(GameSettings.Default.SoundVolume, 
                GameSettings.Default.MusicVolume);
            
            //Init the static screens
            Highscores.Initialize();

            // Replaces static Constructors with simple inits.
            Log.Initialize();

            // Set depth format
            backBufferDepthFormat = graphicsManager.PreferredDepthStencilFormat;

            // Update resolution if it changes
            graphicsManager.DeviceReset += graphics_DeviceReset;
            graphics_DeviceReset(null, EventArgs.Empty);

            // Create matrices for our shaders, this makes it much easier
            // to manage all the required matrices since there is no fixed
            // function support and theirfore no Device.Transform class.
            WorldMatrix = Matrix.Identity;

            // ViewMatrix is updated in camera class
            ViewMatrix = Matrix.CreateLookAt(
                new Vector3(0, 0, 250), Vector3.Zero, Vector3.Up);

            // Projection matrix is set by DeviceReset

            // Init global manager classes, which will be used all over the place ^^
            lineManager2D = new LineManager2D();
            lineManager3D = new LineManager3D();
            ui = new UIRenderer();
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize
        /// </summary>
        protected override void Initialize()
        {
            #if !XBOX360
            // Add screenshot capturer. Note: Don't do this in constructor,
            // we need the correct window name for screenshots!
            this.Components.Add(new ScreenshotCapturer(this));
            #endif

            base.Initialize();

            // Set device and resolution
            device = graphicsManager.GraphicsDevice;
            width = device.Viewport.Width;//Window.ClientBounds.Width;
            height = device.Viewport.Height;//Window.ClientBounds.Height;

            RenderToTexture.InitializeDepthBufferFormatAndMultisampling(
                graphicsManager.PreferredDepthStencilFormat);

            // Update resolution if it changes
            Window.ClientSizeChanged += new EventHandler(Window_ClientSizeChanged);
            graphicsManager.DeviceReset += new EventHandler(graphics_DeviceReset);
            graphics_DeviceReset(null, EventArgs.Empty);

            // Create matrices for our shaders, this makes it much easier
            // to manage all the required matrices since there is no fixed
            // function support and theirfore no Device.Transform class.
            WorldMatrix = Matrix.Identity;
            aspectRatio = (float)width / (float)height;
            ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(
                FieldOfView, aspectRatio, NearPlane, FarPlane);

            // ViewMatrix is updated in camera class
            ViewMatrix = Matrix.CreateLookAt(
                new Vector3(0, 0, 250), Vector3.Zero, Vector3.Up);

            // Init global manager classes, which will be used all over the place ^^
            lineManager2D = new LineManager2D();
            lineManager3D = new LineManager3D();
            ui = new UIRenderer();
        }