Inheritance: Microsoft.Xna.Framework.Graphics.Texture2D
Esempio n. 1
0
		private void Screenshot() {
			using( ResolveTexture2D screenshot = new ResolveTexture2D( graphics.GraphicsDevice, graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color ) ) {
				GraphicsDevice.ResolveBackBuffer( screenshot );

				screenshot.Save( "screenshot.jpg", ImageFileFormat.Jpg );
			}
		}
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(device);

            //Load the fx files
            extractEffect = Game.Content.Load<Effect>("BloomExtract");
            combineEffect = Game.Content.Load<Effect>("BloomCombine");
            gaussBlurEffect = Game.Content.Load<Effect>("GaussBlur");


            // Look up the resolution and format of our main backbuffer.
            PresentationParameters pp = device.PresentationParameters;

            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            SurfaceFormat format = pp.BackBufferFormat;

            //Set how the bloom will behave
            setBloomSetting(0.25f, 4f, 2f, 1f, 2f, 0f);

            // Create a texture for reading back the backbuffer contents.
            resolveTarget = new ResolveTexture2D(device, width, height, 1, format);

            //Can make the backbuffers smaller to increase efficiency, makes bloom less pronounced
            /**
            width /= 2;
            height /= 2;
            */ //for example 

            renderTarget1 = new RenderTarget2D(device, width, height, 1, format);
            renderTarget2 = new RenderTarget2D(device, width, height, 1, format);
        }
Esempio n. 3
0
 public XnaAviWriter(GraphicsDevice device)
 {
     _writer = new AviWriter();
     _device = device;
     _texture = new ResolveTexture2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color);
     _buffer = new Bitmap(_device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight);
     _bmpd = new BitmapData();
 }
Esempio n. 4
0
 /// <summary>
 /// Loads the appropriate effect
 /// </summary>
 /// <param name="content">Content manager needed to load the appropriate effect</param>
 /// <param name="filename">The name of the file containing the effect</param>
 public void LoadEffect(ContentManager content, string filename)
 {
     PresentationParameters pp = device.PresentationParameters;
     targetRenderedTo = new RenderTarget2D(device, pp.BackBufferWidth,
         pp.BackBufferHeight, 1, device.DisplayMode.Format);
     resolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth,
         pp.BackBufferHeight, 1, device.DisplayMode.Format);
     ppEffect = content.Load<Effect>(filename);
 }
Esempio n. 5
0
        public static Texture2D TakeScreenshot()
        {
            int w = Engine.Device.PresentationParameters.BackBufferWidth;
            int h = Engine.Device.PresentationParameters.BackBufferHeight;

            ResolveTexture2D screenshot = new ResolveTexture2D(Engine.Device, w, h, 1, Engine.Device.PresentationParameters.BackBufferFormat);
            Engine.Device.ResolveBackBuffer(screenshot);
            return screenshot;
        }
        public void Initialize(GraphicsDevice device)
        {
            PresentationParameters pp = device.PresentationParameters;

            NormalMap = new RenderTarget2D(device,
                pp.BackBufferWidth, pp.BackBufferHeight, 1,
                pp.BackBufferFormat, pp.MultiSampleType, pp.MultiSampleQuality);

            ResolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth, pp.BackBufferHeight,
                1, pp.BackBufferFormat);
        }
 public Texture2D CreateImage(Texture2D image, int x, int y, int w, int h)
 {
     Rectangle srcRect = new Rectangle(x, y, w, h);
     byte[] data = new byte[srcRect.Width * srcRect.Height * 4];
     image.GetData(0, srcRect, data, 0, data.Length);
     Texture2D result = new ResolveTexture2D(
         gdm.GraphicsDevice,
         srcRect.Width, srcRect.Height, 0, SurfaceFormat.Color);
     result.SetData(data);
     return result;
 }
 public void TakeScreenShot(string path)
 {
     this.spriteBatch.Begin();
     for (int num = 0; num != this.listSprite.Count; num++)
     {
         this.listSprite[num].Draw(this.spriteBatch);
     }
     this.spriteBatch.End();
     ResolveTexture2D resolveTexture2D = new ResolveTexture2D(base.GraphicsDevice, base.GraphicsDevice.PresentationParameters.BackBufferWidth, base.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color);
     base.GraphicsDevice.ResolveBackBuffer(resolveTexture2D);
     resolveTexture2D.Save(path, ImageFileFormat.Bmp);
 }
 public void LoadContent()
 {
     PresentationParameters pp = _graphicsDevice.PresentationParameters;
     SurfaceFormat surfaceFormat = pp.BackBufferFormat;
     int mipmapLevel = 1;
     int width = pp.BackBufferWidth;
     int height = pp.BackBufferHeight;
     _renderTargetA = new RenderTarget2D(_graphicsDevice, width,
             height, mipmapLevel, surfaceFormat);
     _renderTargetB = new RenderTarget2D(_graphicsDevice, width,
         height, mipmapLevel, surfaceFormat);
     _backbufferTexture = new ResolveTexture2D(_graphicsDevice, width,
         height, mipmapLevel, surfaceFormat);
 }
Esempio n. 10
0
        public ConwaysGameOfLife(int width, int height, GraphicsDevice graphicsDevice, Effect drawEffect)
        {
            this.width = width;
            this.height = height;
            gameState = new byte[width * height];
            nextState = new byte[width * height];
            random = new Random();
            gd = graphicsDevice;

            PresentationParameters pp = gd.PresentationParameters;
            resolveTex2D = new ResolveTexture2D(gd, pp.BackBufferWidth, pp.BackBufferHeight, 1, pp.BackBufferFormat);
            rt2d = new RenderTarget2D(gd, pp.BackBufferWidth, pp.BackBufferHeight, 1, pp.BackBufferFormat);

            this.drawEffect = drawEffect;

            // Finding the Texture index that for Conway's Game of Life.
            do{
                TextureIdex++;
            } while( gd.Textures[TextureIdex] != null);

            createDefaultTexture();
            //TextureFilter.Anisotropic
        }
Esempio n. 11
0
 public void ResolveBackBuffer(ResolveTexture2D resolveTarget)
 {
     GL.BindTexture(TextureTarget.Texture2D, resolveTarget.ID);
     GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, resolveTarget.Width, resolveTarget.Height);
 }
Esempio n. 12
0
        public void Reset()
        {
            // Look up the resolution and format of our main backbuffer.
            PresentationParameters pp = GraphicsDevice.PresentationParameters;

            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            SurfaceFormat format = pp.BackBufferFormat;

            if (resolveTarget.Width != width || resolveTarget.Height != height)
            {
                // Create a texture for reading back the backbuffer contents.
                resolveTarget = new ResolveTexture2D(game.GraphicsDevice, width, height, 1, format);
                resolveTarget2 = new ResolveTexture2D(game.GraphicsDevice, width, height, 1, format);
            }

            // Create two rendertargets for the bloom processing. These are half the
            // size of the backbuffer, in order to minimize fillrate costs. Reducing
            // the resolution in this way doesn't hurt quality, because we are going
            // to be blurring the bloom images in any case.
            width /= 2;
            height /= 2;

            if (renderTarget1.Width != width || renderTarget1.Height != height)
            {
                renderTarget1 = new RenderTarget2D(game.GraphicsDevice, width, height, 1, format);
                renderTarget2 = new RenderTarget2D(game.GraphicsDevice, width, height, 1, format);
            }

            GraphicsDevice.ResolveBackBuffer(resolveTarget);
        }
Esempio n. 13
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update( GameTime gameTime )
        {
            KeyboardState keyState = Keyboard.GetState();
            GamePadState padState = GamePad.GetState(PlayerIndex.One);

            // Allows the game to exit
            if ((padState.Buttons.Back == ButtonState.Pressed)
                || (keyState.IsKeyDown(Keys.Escape)))
            {
                this.Exit();
            }

            //Reset
            if (keyState.IsKeyDown(Keys.R))
            {
                gameResetKeyDown = true;
            }
            else if (keyState.IsKeyUp(Keys.R) && gameResetKeyDown)
            {
                gameResetKeyDown = false;

                //Reset The Game Here
                Reset();
            }

            CheckPauseMenu(keyState, Mouse.GetState());

            //Screenie
            if (keyState.IsKeyDown(Keys.PrintScreen))
            {
                gameScreenieKeyDown = true;
            }
            else if (keyState.IsKeyUp(Keys.PrintScreen) && gameScreenieKeyDown)
            {
                gameScreenieKeyDown = false;
                gamePaused = true;

                ResolveTexture2D screenShot = new ResolveTexture2D(graphics.GraphicsDevice, 400, 600, 0, SurfaceFormat.Vector4);

                graphics.GraphicsDevice.ResolveBackBuffer(screenShot);

                //Find A Place TO Save Screenshot :)
                ulong append = 0;

                if ( !Directory.Exists("Screenshots") )
                {
                    Directory.CreateDirectory("Screenshots");
                }

                while (File.Exists("Screenshots\\underAttackScreen-" + append + ".png"))
                {
                    append++;
                }

                screenShot.Save("Screenshots\\underAttackScreen-" + append + ".png", ImageFileFormat.Png);

            }

            if ((gameTime.TotalGameTime.TotalMilliseconds - lastAnimUpdate) > 100)
            {

                foreach (GameUnit unit in animations)
                {
                    if (unit.IsAnimating)
                    {
                        unit.CurrentFrame = unit.CurrentFrame + 1;
                        if (unit.CurrentFrame >= (sprites[unit.SpriteName].FrameCount))
                        {
                            deadAnims.Add(unit);
                        }
                    }
                }

                //Time Updating here too - ONLY when game is running
                if (!gameOver && !gamePaused)
                {
                    timePassed++;
                    timeParam.SetValue(timePassed / 20f);
                }
                lastAnimUpdate = gameTime.TotalGameTime.TotalMilliseconds;
            }

            if (!gameOver && !gamePaused)
            {

                //Count time alive
                timeAlive += gameTime.ElapsedGameTime.TotalSeconds;

                //Motion Input
                CheckPlayerInput(keyState);

                //Move all Units where auto-motion is req.
                MoveGameUnits();

                //Check For A Press And Release To Fire...Make Sure Every Release Is atleast 250 Ms apart
                if (keyState.IsKeyDown(Keys.Space) && !gameShootKeyDown && ((gameTime.TotalGameTime.TotalMilliseconds - lastShotUpdate) > 200) )
                {
                    gameShootKeyDown = true;
                }
                else if (keyState.IsKeyUp(Keys.Space) && gameShootKeyDown)
                {
                    GameUnit bullet = new GameUnit("bullet", playerOne.Position - new Vector2(0, 32), new Vector2(4f, 4f));
                    bullet.Velocity = new Vector2(0, -2);
                    units.Add(bullet);

                    //Update last shot time
                    lastShotUpdate = gameTime.TotalGameTime.TotalMilliseconds;

                    //Reset Press variable
                    gameShootKeyDown = false;
                }

                //Remove Dead Units
                foreach (GameUnit e in deadBullets)
                {
                    units.Remove(e);
                }

                foreach (GameUnit e in deadUnits)
                {
                    units.Remove(e);
                }

                foreach (GameUnit e in deadAnims)
                {
                    units.Remove(e);
                }

                //Clear already dead units.
                deadBullets.Clear();
                deadUnits.Clear();
                deadAnims.Clear();
            }
            base.Update(gameTime);
        }
Esempio n. 14
0
        /// <summary>
        /// Takes a screenshot.
        /// </summary>
        /// <param name="filename">The filename.</param>
        public void TakeScreenshot(string filename)
        {
            using (var texture2D = new ResolveTexture2D(
                mDevice, WIDTH, HEIGHT, 1, SurfaceFormat.Color))
            {
                mDevice.ResolveBackBuffer(texture2D);

                texture2D.Save(filename, ImageFileFormat.Bmp);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Initialize the GoblinXNA framework
            State.InitGoblin(graphics, Content, "");

            #if !USE_ARTAG
            State.ThreadOption = (ushort)(ThreadOptions.MarkerTracking);
            #endif

            // Initialize the scene graph
            scene = new Scene(this);

            // Set up the VUZIX's iWear VR920 for both stereo and orientation tracking
            SetupIWear();

            // If stereo mode is true, then setup stereo camera. If not stereo, we don't need to
            // setup a camera since it's automatically setup by Scene when marker tracker is
            // used. This stereo camera needs to be setup before setting up the marker tracker so
            // the stereo camera will have correct projection matrix computed by the marker tracker.
            if (stereoMode)
                SetupStereoCamera();

            // Set up optical marker tracking
            SetupMarkerTracking();

            // Set up the lights used in the scene
            CreateLights();

            // Create 3D objects
            CreateObjects();

            // Create the ground that represents the physical ground marker array
            CreateGround();

            // Use per pixel lighting for better quality (If you using non NVidia graphics card,
            // setting this to true may reduce the performance significantly)
            scene.PreferPerPixelLighting = true;

            // Enable shadow mapping
            // NOTE: In order to use shadow mapping, you will need to add 'PostScreenShadowBlur.fx'
            // and 'ShadowMap.fx' shader files as well as 'ShadowDistanceFadeoutMap.dds' texture file
            // to your 'Content' directory
            scene.EnableShadowMapping = true;

            // Show Frames-Per-Second on the screen for debugging
            State.ShowFPS = false; ;

            KeyboardInput.Instance.KeyPressEvent += new HandleKeyPress(HandleKeyPressEvent);

            if (stereoMode && (iTracker.ProductID == iWearDllBridge.IWRProductID.IWR_PROD_WRAP920))
            {
                sbsStereoScreenLeft = new ResolveTexture2D(GraphicsDevice, State.Width, State.Height, 1,
                GraphicsDevice.PresentationParameters.BackBufferFormat);
                sbsStereoScreenRight = new ResolveTexture2D(GraphicsDevice, State.Width, State.Height, 1,
                    GraphicsDevice.PresentationParameters.BackBufferFormat);
                spriteBatch = new SpriteBatch(GraphicsDevice);
            }

            base.Initialize();
        }
Esempio n. 16
0
 /****************************************FUNCTIONS***************************************/
 public void Initialize(ContentManager content)
 {
     SpriteBatch = new SpriteBatch(Core.Graphics.GraphicsDevice);
     vdPositionColor = new VertexDeclaration(Core.Graphics.GraphicsDevice, VertexPositionColor.VertexElements);
     vdPositionNormalTexture = new VertexDeclaration(Core.Graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements);
     GraphicsCaps = GraphicsAdapter.DefaultAdapter.GetCapabilities(DeviceType.Hardware);
     SceneTexture = new ResolveTexture2D(mGraphics.Peek.Device(), mGraphics.Peek.Device().PresentationParameters.BackBufferWidth,
         mGraphics.Peek.Device().PresentationParameters.BackBufferHeight, 1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat);
     SceneRenderTarget = CreateRenderTarget(1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat);
     mCamera.Peek.Initialize(Engine.TempVector3(0.0f, 0.0f, 0.0f));
 }
Esempio n. 17
0
        private void RebuildGraphicsDevice()
        {
            Graphics.GraphicsDevice.Reset();
            Graphics.PreferredBackBufferHeight = (int)this._v2BufferResolution.Y;
            Graphics.PreferredBackBufferWidth = (int)this._v2BufferResolution.X;
            SpriteBatchScale = Matrix.CreateScale((_v2BufferResolution / _v2SpriteResolution).X, (_v2BufferResolution / _v2SpriteResolution).Y, 1.0f);
            Graphics.ApplyChanges();

            SceneTexture.Dispose();
            SceneTexture = null;
            SceneRenderTarget.Dispose();
            SceneRenderTarget = null;
            SceneTexture = new ResolveTexture2D(mGraphics.Peek.Device(), Graphics.PreferredBackBufferWidth,
            Graphics.PreferredBackBufferHeight, 1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat);
            SceneRenderTarget = CreateRenderTarget(1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat);
        }
Esempio n. 18
0
 private void UpDownIcon_ValueChanged(object sender, EventArgs e)
 {
     try
     {
         if (this.IconBmp != null)
         {
             this.IconBmp.Dispose();
         }
         PresentationParameters presentationParameters = new PresentationParameters();
         presentationParameters.AutoDepthStencilFormat = DepthFormat.Depth24;
         presentationParameters.BackBufferCount = 1;
         presentationParameters.BackBufferFormat = SurfaceFormat.Color;
         presentationParameters.BackBufferHeight = 39;
         presentationParameters.BackBufferWidth = 39;
         presentationParameters.EnableAutoDepthStencil = true;
         presentationParameters.FullScreenRefreshRateInHz = 0;
         presentationParameters.IsFullScreen = false;
         presentationParameters.MultiSampleQuality = 0;
         presentationParameters.MultiSampleType = MultiSampleType.NonMaskable;
         presentationParameters.PresentationInterval = PresentInterval.One;
         presentationParameters.PresentOptions = PresentOptions.None;
         presentationParameters.RenderTargetUsage = RenderTargetUsage.DiscardContents;
         presentationParameters.SwapEffect = SwapEffect.Discard;
         GraphicsDevice graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, new Panel().Handle, presentationParameters);
         this.copiedIcon = new Sprite(graphicsDevice);
         int index = Convert.ToInt32(this.numericUpDownIcon.Value) / 169;
         int index2 = Convert.ToInt32(this.numericUpDownIcon.Value) % 169;
         this.copiedIcon.LoadTextureFromFile(this.ImportedContentFolder + "\\3DDATA\\Control\\RES\\" + this.ImportedTSI.listDDS[index].Path, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle(this.ImportedTSI.listDDS[index].ListDDS_element[index2].X, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Y, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Width, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Height));
         graphicsDevice.Clear(Microsoft.Xna.Framework.Graphics.Color.White);
         SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice);
         spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
         spriteBatch.Draw(this.copiedIcon.texture, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle?(this.copiedIcon.sourceRectangle), Microsoft.Xna.Framework.Graphics.Color.White);
         spriteBatch.End();
         using (ResolveTexture2D resolveTexture2D = new ResolveTexture2D(graphicsDevice, graphicsDevice.PresentationParameters.BackBufferWidth, graphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color))
         {
             graphicsDevice.ResolveBackBuffer(resolveTexture2D);
             resolveTexture2D.Save("Imported Icon.bmp", ImageFileFormat.Bmp);
         }
         this.pictureBox.ImageLocation = "Imported Icon.bmp";
         this.IconBmp = new Bitmap("Imported Icon.bmp");
         this.copiedIcon = new Sprite(this.textureControl.GraphicsDevice);
         this.copiedIcon.LoadTextureFromFile(this.ImportedContentFolder + "\\3DDATA\\Control\\RES\\" + this.ImportedTSI.listDDS[index].Path, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle(this.ImportedTSI.listDDS[index].ListDDS_element[index2].X, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Y, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Width + 1, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Height + 1));
     }
     catch
     {
     }
 }
Esempio n. 19
0
        private void MakeScreenshot()
        {
            try
            {
                //NOTE: This doesn't always work on all cards, especially if
                // desktop mode switches in fullscreen mode!

                screenshotNum++;
                // Make sure screenshots directory exists
                if (Directory.Exists(Directories.ScreenshotsDirectory) == false)
                    Directory.CreateDirectory(Directories.ScreenshotsDirectory);

                using (ResolveTexture2D dstTexture = new ResolveTexture2D(
                    BaseGame.Device,
                    BaseGame.Width, BaseGame.Height, 1,
                    SurfaceFormat.Color))
                {
                    // Get data with help of the resolve method
                    BaseGame.Device.ResolveBackBuffer(dstTexture);

                    dstTexture.Save(
                        ScreenshotNameBuilder(screenshotNum),
                        ImageFileFormat.Jpg);
                } // using
            } // try
            catch (Exception ex)
            {
                Log.Write("Failed to save Screenshot: " + ex.ToString());
            } // catch (ex)
        }
Esempio n. 20
0
        void InitializeTextures()
        {
            int width = GFX.Device.PresentationParameters.BackBufferWidth;
            int height = GFX.Device.PresentationParameters.BackBufferHeight;

            TexGen = GFX.Inst.ComputeTextureMatrix(new Vector2(width, height));

            ColorMap = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Color);
            DepthMap = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Single);
            NormalMap = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.HalfVector2);
            DataMap = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Color);
            LightMap = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Color);

            depthStencilScene = new DepthStencilBuffer(GFX.Device, width, height, GFX.Device.DepthStencilBuffer.Format);

            EmissiveMap = new RenderTarget2D(GFX.Device, width / 4, height / 4, 1, SurfaceFormat.Color);

            ParticleBuffer = new RenderTarget2D(GFX.Device, width / 8, height / 8, 1, SurfaceFormat.Color);

            BackBufferTexture = new ResolveTexture2D(GFX.Device, width, height, 1, SurfaceFormat.Color);

            CubeMap = new RenderTargetCube(GFX.Device, CubeMapSize, 1, SurfaceFormat.Color);
        }
Esempio n. 21
0
        public override void Initialize(ContentManager content, GraphicsDevice graphics)
        {
            spriteBatch = new SpriteBatch(graphics);

            if (Owner != null)
            {
                area = new Rectangle(1, 20, (int)Owner.Width - 1, 18);
                fontName = Owner.FontName;
                font = Owner.Font;
            }
            else
            {
                area = new Rectangle(0, 0, graphics.Viewport.Width, 17);
                font = content.Load<SpriteFont>(@"fonts\" + fontName);
            }

            itemArea.Height = font.LineSpacing;

            resolveTexture = new ResolveTexture2D(FormCollection.Graphics.GraphicsDevice,
                FormCollection.Graphics.GraphicsDevice.Viewport.Width,
                FormCollection.Graphics.GraphicsDevice.Viewport.Height,
                1,
                FormCollection.Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);

            pixelTex = new Texture2D(FormCollection.Graphics.GraphicsDevice, 1, 1);
            pixelTex.SetData<Color>(new Color[] { Color.White });

            for (int i = 0; i < items.Count; i++)
                if (items[i].SubMenu != null)
                    items[i].SubMenu.Initialize(content, graphics);

            base.Initialize(content, graphics);
        }
        public override void LoadContent()
        {
            loading.Enter();

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            resolvedBackbuffer = new ResolveTexture2D(GraphicsDevice,
                1280, 720,
                1, GraphicsDevice.DisplayMode.Format);

            twitchNoise = Content.Load<Texture2D>("Textures/Helpers/twitch_noise");
            twitchEffect = Content.Load<Effect>("Effects/twitch");
            twitchRenderTarget = new RenderTarget2D(GraphicsDevice, 128, 128, 1, GraphicsDevice.DisplayMode.Format, RenderTargetUsage.PreserveContents);

            WalkingSound = Content.Load<SoundEffect>("Sounds/footsteps");
            NoiseSound = Content.Load<SoundEffect>("Sounds/noise0").CreateInstance();
            NoiseSound.IsLooped = true;
            GameOverMusic = Content.Load<Song>("Music/gameover");

            for (int i = 0; i < Themes.Length; i++)
            {
                String type = (i == 0 ? "good" : "evil");

                Themes[i] = new Theme
                {
                    Background = Content.Load<Texture2D>("Textures/Backgrounds/" + type),
                    Parallax = {
                        Content.Load<Texture2D>("Textures/Backgrounds/stars1"),
                        Content.Load<Texture2D>("Textures/Backgrounds/stars2"),
                        Content.Load<Texture2D>("Textures/Backgrounds/stars3")
                    },
                    MonkeyM = new SpriteAnimationSwitcher("monkey_m", new String[] { "left", "right", "crash", "penalty", "stomp" }),
                    MonkeyF = new SpriteAnimationSwitcher("monkey_f", new String[] { "left", "right", "crash", "penalty", "stomp" }),
                    Panel = new SpriteAnimationSwitcher("score_" + type, new String[] { "score_000", "score_001", "score_002", "score_003", "score_004", "score_005" }),
                    Coconut = new SpriteAnimationSwitcher(type, new String[] { "coconut", "explosion" }),
                    Planet = new SpriteAnimationSwitcher(type, new String[] { "planet", "highlightandshadow" }),
                    Tree = new SpriteAnimationSwitcher("palme_" + type, new String[] { "palme" }),
                    SunTutorial = new SpriteAnimationSwitcher("SunTutorial", new String[] { "sun" }),
                    TutorialColor = (i == 0) ? Color.White : Color.Red,
                    BackgroundMusic = Content.Load<Song>("Music/space"),
                    SoundCreateCoconut = Content.Load<SoundEffect>(i == 0 ? "Sounds/plop" : "Sounds/missile"),
                    SoundJump = Content.Load<SoundEffect>("Sounds/jump"),
                    SoundStomp = Content.Load<SoundEffect>("Sounds/stomp"),
                    SoundExplode = Content.Load<SoundEffect>(i == 0 ? "Sounds/heart" : "Sounds/explosion"),
                    SoundMissile = Content.Load<SoundEffect>(i == 0 ? "Sounds/plop" : "Sounds/missile"),
                    SoundCollide = Content.Load<SoundEffect>("Sounds/collide_" + type),
                    //SoundMonkeyHit = Content.Load<SoundEffect>("Sounds/monkey"),
                    SoundMonkeyHit = Content.Load<SoundEffect>("Sounds/monkey_" + type),
                    //Beleuchtung = new SpriteAnimationSwitcher("beleuchtung_" + type, new String[] { "beleuchtung" }),
                };

                if (i == 1)
                {
                    Themes[i].Parallax.Insert(2, Content.Load<Texture2D>("Textures/Backgrounds/skull"));
                }
            }
            GameOverSprites = new SpriteAnimationSwitcher("game_over", new String[] { "game_over_m", "game_over_f" });
            CurrentTheme = Themes[0];

            MediaPlayer.Volume = bgMusicVolume;

            Planet prop1 = new Planet(PlayerIndex.One);
            prop1.Position = new Vector2(200, 350);
            Monkey monkey1 = new Monkey(prop1);
            Planets.Add(prop1);

            Planet prop2 = new Planet(PlayerIndex.Two);
            prop2.Position = new Vector2(1000, 350);
            Monkey monkey2 = new Monkey(prop2);
            Planets.Add(prop2);

            PlayerPanel1 = new PlayerPanel(monkey1);
            PlayerPanel2 = new PlayerPanel(monkey2);

            float panelY = 650f;
            float panelX = 120f;
            PlayerPanel1.Position = new Vector2(panelX, panelY);
            PlayerPanel2.Position = new Vector2(GraphicsDevice.Viewport.Width - PlayerPanel.Offset.X - panelX, panelY);

            SunlightDir = new Vector2(0.0f, -1.0f);
            Camera = new DriftingCamera();

            GameState = GameStates.Game;

            loading.Exit();
        }
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (this.starfield != null)
                 this.starfield.Dispose();
             if (this.DeepSpaceDone != null)
                 this.DeepSpaceDone.Dispose();
             if (this.EmpireDone != null)
                 this.EmpireDone.Dispose();
             if (this.DeepSpaceGateKeeper != null)
                 this.DeepSpaceGateKeeper.Dispose();
             if (this.ItemsToBuild != null)
                 this.ItemsToBuild.Dispose();
             if (this.WorkerBeginEvent != null)
                 this.WorkerBeginEvent.Dispose();
             if (this.WorkerCompletedEvent != null)
                 this.WorkerCompletedEvent.Dispose();
             if (this.anomalyManager != null)
                 this.anomalyManager.Dispose();
             if (this.bloomComponent != null)
                 this.bloomComponent.Dispose();
             if (this.ShipGateKeeper != null)
                 this.ShipGateKeeper.Dispose();
             if (this.SystemThreadGateKeeper != null)
                 this.SystemThreadGateKeeper.Dispose();
             if (this.FogMap != null)
                 this.FogMap.Dispose();
             if (this.MasterShipList != null)
                 this.MasterShipList.Dispose();
             if (this.EmpireGateKeeper != null)
                 this.EmpireGateKeeper.Dispose();
             if (this.BombList != null)
                 this.BombList.Dispose();
             if (this.flash != null)
                 this.flash.Dispose();
             if (this.lightning != null)
                 this.lightning.Dispose();
             if (this.neb_particles != null)
                 this.neb_particles.Dispose();
             if (this.photonExplosionParticles != null)
                 this.photonExplosionParticles.Dispose();
             if (this.projectileTrailParticles != null)
                 this.projectileTrailParticles.Dispose();
             if (this.sceneMap != null)
                 this.sceneMap.Dispose();
             if (this.shipListInfoUI != null)
                 this.shipListInfoUI.Dispose();
             if (this.smokePlumeParticles != null)
                 this.smokePlumeParticles.Dispose();
             if (this.sparks != null)
                 this.sparks.Dispose();
             if (this.star_particles != null)
                 this.star_particles.Dispose();
             if (this.engineTrailParticles != null)
                 this.engineTrailParticles.Dispose();
             if (this.explosionParticles != null)
                 this.explosionParticles.Dispose();
             if (this.explosionSmokeParticles != null)
                 this.explosionSmokeParticles.Dispose();
             if (this.fireTrailParticles != null)
                 this.fireTrailParticles.Dispose();
             if (this.fireParticles != null)
                 this.fireParticles.Dispose();
             if (this.flameParticles != null)
                 this.flameParticles.Dispose();
             if (this.beamflashes != null)
                 this.beamflashes.Dispose();
             if (this.dsbw != null)
                 this.dsbw.Dispose();
             if (this.SelectedShipList != null)
                 this.SelectedShipList.Dispose();
             if (this.NotificationManager != null)
                 this.NotificationManager.Dispose();
             if (this.FogMapTarget != null)
                 this.FogMapTarget.Dispose();
         }
         this.starfield = null;
         this.DeepSpaceDone = null;
         this.EmpireDone = null;
         this.DeepSpaceGateKeeper = null;
         this.ItemsToBuild = null;
         this.WorkerBeginEvent = null;
         this.WorkerCompletedEvent = null;
         this.anomalyManager = null;
         this.bloomComponent = null;
         this.ShipGateKeeper = null;
         this.SystemThreadGateKeeper = null;
         this.FogMap = null;
         this.MasterShipList = null;
         this.EmpireGateKeeper = null;
         this.BombList = null;
         this.flash = null;
         this.lightning = null;
         this.neb_particles = null;
         this.photonExplosionParticles = null;
         this.projectileTrailParticles = null;
         this.sceneMap = null;
         this.shipListInfoUI = null;
         this.smokePlumeParticles = null;
         this.sparks = null;
         this.star_particles = null;
         this.engineTrailParticles = null;
         this.explosionParticles = null;
         this.explosionSmokeParticles = null;
         this.fireTrailParticles = null;
         this.fireParticles = null;
         this.flameParticles = null;
         this.beamflashes = null;
         this.dsbw = null;
         this.SelectedShipList = null;
         this.NotificationManager = null;
         this.FogMapTarget = null;
     }
 }
        public void LoadGraphics()
        {
            this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f);
            this.Frustum = new BoundingFrustum(this.view * this.projection);
            this.mmHousing = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 276, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 256, 276, 256);
            this.MinimapDisplayRect = new Rectangle(this.mmHousing.X + 61, this.mmHousing.Y + 43, 200, 200);
            this.minimap = new MiniMap(this.mmHousing);
            this.mmButtons = new MinimapButtons(this.mmHousing, this.EmpireUI);
            this.mmShowBorders = new Rectangle(this.MinimapDisplayRect.X, this.MinimapDisplayRect.Y - 25, 32, 32);
            this.mmDSBW = new Rectangle(this.mmShowBorders.X + 32, this.mmShowBorders.Y, 64, 32);
            this.mmAutomation = new Rectangle(this.mmDSBW.X + this.mmDSBW.Width, this.mmShowBorders.Y, 96, 32);
            this.mmShipView = new Rectangle(this.MinimapDisplayRect.X - 32, this.MinimapDisplayRect.Y, 32, 105);
            this.mmGalaxyView = new Rectangle(this.mmShipView.X, this.mmShipView.Y + 105, 32, 105);
            this.SectorMap = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 300, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150);
            this.GalaxyMap = new Rectangle(this.SectorMap.X + this.SectorMap.Width, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150);
            this.SelectedStuffRect = new Rectangle(0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 247, 407, 242);
            this.ShipInfoUIElement = new ShipInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this);
            this.sInfoUI = new SystemInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this);
            this.pInfoUI = new PlanetInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this);
            this.shipListInfoUI = new ShipListInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this);
            this.vuiElement = new VariableUIElement(this.SelectedStuffRect, this.ScreenManager, this);
            this.SectorSourceRect = new Rectangle((this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 720) / 2, (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 720) / 2, 720, 720);
            this.EmpireUI = new EmpireUIOverlay(this.player, this.ScreenManager.GraphicsDevice, this);
            this.bloomComponent = new BloomComponent(this.ScreenManager);
            this.bloomComponent.LoadContent();
            this.aw = new AutomationWindow(this.ScreenManager, this);
            PresentationParameters presentationParameters = this.ScreenManager.GraphicsDevice.PresentationParameters;
            int backBufferWidth = presentationParameters.BackBufferWidth;
            int backBufferHeight = presentationParameters.BackBufferHeight;
            SurfaceFormat backBufferFormat = presentationParameters.BackBufferFormat;
            this.sceneMap = new ResolveTexture2D(this.ScreenManager.GraphicsDevice, backBufferWidth, backBufferHeight, 1, backBufferFormat);
            this.MainTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat);
            this.LightsTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat);
            this.MiniMapSector = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat);
            this.BorderRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat);
            this.StencilRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat);
            string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            if (this.loadFogPath == null)
            {
                this.FogMap = ResourceManager.TextureDict["Textures/UniverseFeather"];
            }
            else
            {
                using (FileStream fileStream = File.OpenRead(folderPath + "/StarDrive/Saved Games/Fog Maps/" + this.loadFogPath + ".png"))
                    this.FogMap = Texture2D.FromFile(this.ScreenManager.GraphicsDevice, (Stream)fileStream);
            }
            this.FogMapTarget = new RenderTarget2D(this.ScreenManager.GraphicsDevice, 512, 512, 1, backBufferFormat, this.ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleType, presentationParameters.MultiSampleQuality);
            this.basicFogOfWarEffect = this.ScreenManager.Content.Load<Effect>("Effects/BasicFogOfWar");
            this.LoadMenu();
            MuzzleFlashManager.universeScreen = this;
            DroneAI.universeScreen = this;
            MuzzleFlashManager.flashModel = this.ScreenManager.Content.Load<Model>("Model/Projectiles/muzzleEnergy");
            MuzzleFlashManager.FlashTexture = this.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/Textures/MuzzleFlash_01");
            ExplosionManager.universeScreen = this;
            FTLManager.universeScreen = this;
            FTLManager.FTLTexture = this.ScreenManager.Content.Load<Texture2D>("Textures/Ships/FTL");
            this.anomalyManager = new AnomalyManager();
            ShipDesignScreen.screen = this;
            Fleet.screen = this;
            Bomb.screen = this;
            Anomaly.screen = this;
            PlanetScreen.screen = this;
            MinimapButtons.screen = this;
            Projectile.contentManager = this.ScreenManager.Content;
            Projectile.universeScreen = this;
            ShipModule.universeScreen = this;
            Asteroid.universeScreen = this;
            Empire.universeScreen = this;
            SpaceJunk.universeScreen = this;
            ResourceManager.universeScreen = this;
            Planet.universeScreen = this;
            Weapon.universeScreen = this;
            Ship.universeScreen = this;
            ArtificialIntelligence.universeScreen = this;
            MissileAI.universeScreen = this;
            Moon.universeScreen = this;
            CombatScreen.universeScreen = this;
            FleetDesignScreen.screen = this;
            this.xnaPlanetModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/planet");
            this.atmoModel = this.ScreenManager.Content.Load<Model>("Model/sphere");
            this.AtmoEffect = this.ScreenManager.Content.Load<Effect>("Effects/PlanetHalo");
            this.cloudTex = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/earthcloudmap");
            this.RingTexture = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/planet_rings");
            this.ThrusterEffect = this.ScreenManager.Content.Load<Effect>("Effects/Thrust");
            this.listener = new AudioListener();
            this.SunModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane");
            this.NebModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane");
            this.ScreenRectangle = new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight);
            this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content);
            this.starfield.LoadContent();

            //fbedard: new button for ShipsInCombat
            this.ShipsInCombat = new UIButton();
            ShipsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 275, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height);
            ShipsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"];
            ShipsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"];
            ShipsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"];
            ShipsInCombat.Text = "Ships: 0";
            ShipsInCombat.Launches = "ShipsInCombat";

            //fbedard: new button for PlanetsInCombat
            this.PlanetsInCombat = new UIButton();
            PlanetsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 135, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height);
            PlanetsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"];
            PlanetsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"];
            PlanetsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"];
            PlanetsInCombat.Text = "Planets: 0";
            PlanetsInCombat.Launches = "PlanetsInCombat";
        }
Esempio n. 25
0
        private void TakeScreenshot()
        {
            int count = Directory.GetFiles(StorageContainer.TitleLocation+"\\", "ndump*.bmp").Length + 1;
            string name = "\\ndump" + count.ToString("000") + ".bmp";

            GraphicsDevice device = Engine.Device;
            using (ResolveTexture2D screenshot = new ResolveTexture2D(device, device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color))
            {
                device.ResolveBackBuffer(screenshot);
                screenshot.Save(StorageContainer.TitleLocation + name, ImageFileFormat.Bmp);
            }

            //MessageRenderer.Instance.PostHeaderMessage("Screenshot dumped to " + name, 3);
        }
Esempio n. 26
0
        public void Render()
        {
            if (resolveTexture.Width != FormCollection.Graphics.GraphicsDevice.Viewport.Width ||
                resolveTexture.Height != FormCollection.Graphics.GraphicsDevice.Viewport.Height)
            {
                resolveTexture = new ResolveTexture2D(FormCollection.Graphics.GraphicsDevice,
                FormCollection.Graphics.GraphicsDevice.Viewport.Width,
                FormCollection.Graphics.GraphicsDevice.Viewport.Height,
                1,
                FormCollection.Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);

                if(Owner == null)
                    area = new Rectangle(0, 0, FormCollection.Graphics.GraphicsDevice.Viewport.Width, 17);
            }

            FormCollection.Graphics.GraphicsDevice.SetRenderTarget(0, null);
            FormCollection.Graphics.GraphicsDevice.Clear(Color.TransparentBlack);
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            if (Owner != null)
                area.Width = (int)Owner.Width - 2;

            area.X = (int)Position.X + 1;
            area.Y = (int)Position.Y;
            spriteBatch.Draw(pixelTex, area, BackColor);

            itemPos.X = (int)Position.X + 5;
            itemPos.Y = (int)Position.Y;

            hoverIndex = -1;

            for (int i = 0; i < items.Count; i++)
            {
                itemArea.X = (int)(itemPos.X) - 4;
                itemArea.Y = (int)(itemPos.Y);
                itemArea.Width = (int)font.MeasureString(items[i].CleanText).X + 10;
                itemArea.Height = font.LineSpacing;

                if (Owner == null)
                    itemArea.X -= 1;

                Point cursorLoc;
                if (Owner == null)
                    cursorLoc = MouseHelper.Cursor.Location;
                else
                    cursorLoc = new Point(MouseHelper.Cursor.Location.X - (int)Owner.Position.X, MouseHelper.Cursor.Location.Y - (int)Owner.Position.Y);

                //Selected Item
                if (items[i].SubMenu != null && items[i].SubMenu.State != SubMenu.MenuState.Closed)
                {
                    spriteBatch.Draw(pixelTex, itemArea, Color.LightGray);
                    spriteBatch.DrawString(font, items[i].CleanText, itemPos, ForeColor);
                }
                //Hover Item
                else if (itemArea.Contains(cursorLoc))
                {
                    hoverIndex = i;
                    spriteBatch.Draw(pixelTex, itemArea, Color.Silver);
                    spriteBatch.DrawString(font, items[i].CleanText, itemPos, ForeColor);

                    openPos.X = itemArea.X + 1;
                    openPos.Y = itemArea.Y + itemArea.Height + 2;
                }
                //Normal Item
                else
                    spriteBatch.DrawString(font, items[i].CleanText, itemPos, ForeColor);

                if (indexToOpen == i)
                {
                    if (items[indexToOpen].EventHandler != null)
                        items[indexToOpen].EventHandler.Invoke(null, null);

                    if (items[indexToOpen].SubMenu != null && items[indexToOpen].SubMenu.State == SubMenu.MenuState.Closed)
                    {
                        openPos.X = itemArea.X + 1;
                        openPos.Y = itemArea.Y + itemArea.Height + 2;
                        CloseSubMenus();
                        items[indexToOpen].SubMenu.Open(openPos);
                        state = MenuState.Opened;
                        openedMenu = true;
                    }
                    else
                        Close();
                }

                if (items[i].Key != Microsoft.Xna.Framework.Input.Keys.None)
                {
                    Vector2 underscorePos = new Vector2(itemPos.X + font.MeasureString(items[i].CleanText.Substring(0, items[i].KeyIndex)).X, itemPos.Y);
                    spriteBatch.DrawString(font, "_", underscorePos, ForeColor);
                }

                itemPos.X += (int)font.MeasureString(items[i].CleanText).X + 10;
            }

            for (int i = 0; i < items.Count; i++)
                if (items[i].SubMenu != null && items[i].SubMenu.State != SubMenu.MenuState.Closed)
                    items[i].SubMenu.Draw(spriteBatch);

            spriteBatch.End();
            FormCollection.Graphics.GraphicsDevice.ResolveBackBuffer(resolveTexture, 0);
        }
Esempio n. 27
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        public void Load(GraphicsDevice device, ContentManager content)
        {
            GraphicsDevice = device;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            bloomExtractEffect = content.Load<Effect>("BloomExtract");
            bloomCombineEffect = content.Load<Effect>("BloomCombine");
            gaussianBlurEffect = content.Load<Effect>("GaussianBlur");


            // Look up the resolution and format of our main backbuffer.
            PresentationParameters pp = GraphicsDevice.PresentationParameters;

            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            SurfaceFormat format = pp.BackBufferFormat;

            // Create a texture for reading back the backbuffer contents.
            resolveTarget = new ResolveTexture2D(GraphicsDevice, width, height, 1, format);

            // Create two rendertargets for the bloom processing. These are half the
            // size of the backbuffer, in order to minimize fillrate costs. Reducing
            // the resolution in this way doesn't hurt quality, because we are going
            // to be blurring the bloom images in any case.
            width /= 4;
            height /= 4;

            renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1, format);
            renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1, format);
        }
Esempio n. 28
0
    /// <summary>
    /// This old way doesn't work that well.  Use the new way.
    /// </summary>
    private void checkScreenShotOld()
    {
        if( ScreenShot == true )
        {
          // stamp with time and dump to disk.
          string filename = SPW.path + DateTime.Now.ToString( "MMM_dd_yy__HH_mm_ss_ffffff" ) + ".png";

          sw[ "screenshot" ] = new StringItem( "Took screenshot:  " + filename + ".  Press '5'", 20, graphics.PreferredBackBufferHeight - 40 );

          ResolveTexture2D rt = new ResolveTexture2D( GraphicsDevice,
        graphics.PreferredBackBufferWidth,
        graphics.PreferredBackBufferHeight,
        1, SurfaceFormat.HalfVector4 );

          GraphicsDevice.ResolveBackBuffer( rt );

          // Put this on a seperate thread, maybe.
          rt.Save( filename, ImageFileFormat.Png );

          ScreenShot = false;
        }
    }
Esempio n. 29
0
            /// <summary>
            /// A collection of objects that represents inputted data in the form of a Line Graph
            /// </summary>
            /// <param name="values">Values to be inputted</param>
            public LineGraph(string XAxisTitle, string YAxisTitle, List<List<double>> values, List<string> lineLabels)
            {
                Manager.PauseRequest = true;
                while (!Manager.IsPaused)
                {
                    System.Threading.Thread.Sleep(10);
                }

                resolveTarget = new ResolveTexture2D(MyGame.graphics.GraphicsDevice
                , MyGame.GameWindow.Width
                , MyGame.GameWindow.Height
                , 1
                , MyGame.graphics.GraphicsDevice.DisplayMode.Format);
                this.XAxisTitle = XAxisTitle;
                this.YAxisTitle = YAxisTitle;
                this.lineLabels = lineLabels;
                Lines = Curve.CreateCurves(values, lineLabels);
                RefreshGraphAxes();
                RefreshGraphImage();

                Manager.PauseRequest = false;
            }
Esempio n. 30
0
        void OnDeviceReset(Object sender, EventArgs args)
        {
            Device.VertexDeclaration = new VertexDeclaration(Device, Vertex.VertexElements);
            Device.RenderState.AlphaTestEnable = true;
            Device.RenderState.AlphaFunction = CompareFunction.Greater;
            Device.RenderState.ReferenceAlpha = 0;

            m_renderer.OnDeviceReset(sender, args);

            if (m_screenshot == null || m_screenshot.IsDisposed == true || ScreenSize != new Point(m_screenshot.Width, m_screenshot.Height))
            {
                m_screenshot = new ResolveTexture2D(Device, Device.PresentationParameters.BackBufferWidth, Device.PresentationParameters.BackBufferHeight, 1, Device.PresentationParameters.BackBufferFormat);
            }
        }
Esempio n. 31
0
 public void ResolveBackBuffer(ResolveTexture2D resolveTexture)
 {
 }
Esempio n. 32
0
 private void LoadResolveTarget(GraphicsDevice a_graphicsDevice)
 {
     ResolvedTexture = new ResolveTexture2D(a_graphicsDevice, a_graphicsDevice.Viewport.Width,
                                            a_graphicsDevice.Viewport.Height, 1,
                                            a_graphicsDevice.DisplayMode.Format);
 }