Esempio n. 1
0
        public void draw(Matrix view, Matrix projection, Vector3 playerPosition)
        {
            SamplerState samplerState = new SamplerState();
            samplerState.AddressU = TextureAddressMode.Clamp;
            samplerState.AddressV = TextureAddressMode.Clamp;
            Game1.getGraphics().GraphicsDevice.SamplerStates[0] = samplerState;

            DepthStencilState dss = new DepthStencilState();
            dss.DepthBufferEnable = false;
            Game1.getGraphics().GraphicsDevice.DepthStencilState = dss;

            Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
            skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
            foreach (ModelMesh mesh in skyboxModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(playerPosition);
                    //effect.CurrentTechnique = effect.Techniques["Textured"];
                    effect.LightingEnabled = true;
                    effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
                    effect.EmissiveColor = new Vector3(0.4f, 0.4f, 0.4f);
                    effect.TextureEnabled = true;
                    effect.Texture = skyboxTextures;
                    effect.World = worldMatrix;
                    effect.View = view;
                    effect.Projection = projection;

                }
                mesh.Draw();
            }
            dss = new DepthStencilState();
            dss.DepthBufferEnable = true;
            Game1.getGraphics().GraphicsDevice.DepthStencilState = dss;
        }
Esempio n. 2
0
        private void DrawSkybox()
        {
            SamplerState ss = new SamplerState();
              ss.AddressU = TextureAddressMode.Clamp;
              ss.AddressV = TextureAddressMode.Clamp;

              Engine.Video.GraphicsDevice.SamplerStates[0] = ss;

              DepthStencilState dss = new DepthStencilState();
              dss.DepthBufferEnable = false;
              Engine.Video.GraphicsDevice.DepthStencilState = dss;

              Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
              skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);

              int i = 0;
              foreach(ModelMesh mesh in skyboxModel.Meshes) {
            foreach(Effect currentEffect in mesh.Effects) {
              Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index];
              currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"];
              currentEffect.Parameters["xWorld"].SetValue(worldMatrix);
              currentEffect.Parameters["xView"].SetValue(camera.ViewMatrix);
              currentEffect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
              currentEffect.Parameters["xTexture"].SetValue(skyboxTextures[i++]);
            }

            mesh.Draw();
              }

              dss = new DepthStencilState();
              dss.DepthBufferEnable = true;
              Engine.Video.GraphicsDevice.DepthStencilState = dss;
        }
Esempio n. 3
0
        public override void draw(Matrix projection, Matrix camera)
        {
            SamplerState samplerState = new SamplerState();
            samplerState.AddressU = TextureAddressMode.Clamp;
            samplerState.AddressV = TextureAddressMode.Clamp;
            Game1.getGraphics().GraphicsDevice.SamplerStates[0] = samplerState;

            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.LightingEnabled = true;

                    effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
                    effect.EmissiveColor = new Vector3(1, 1, 1);
                    //effect.DirectionalLight0.Enabled = true;
                    effect.DirectionalLight0.Direction = new Vector3(0, 1, 0);
                    effect.DirectionalLight0.DiffuseColor = new Vector3(1, 0, 0);
                    //effect.DirectionalLight1.Direction = new Vector3(1, 1, 0);
                    //effect.DirectionalLight1.DiffuseColor = new Vector3(0, 1, 0);
                    effect.TextureEnabled = true;
                    effect.Texture = textur;
                    effect.View = camera;
                    effect.Projection = projection;
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY((float)rotation) * Matrix.CreateScale((float)0.5) * Matrix.CreateTranslation(position);
                }
                mesh.Draw();
            }
        }
Esempio n. 4
0
 public EffectState(Effect effect, SamplerState sampler, RasterizerState raster, DepthStencilState stencil, bool texture)
 {
     Effect = effect;
     Sampler = sampler;
     Raster = raster;
     TextureOverride = texture;
 }
Esempio n. 5
0
        public ImperativeRenderer(
            IBatchContainer container,
            DefaultMaterialSet materials,
            int layer = 0, 
            RasterizerState rasterizerState = null,
            DepthStencilState depthStencilState = null,
            BlendState blendState = null,
            SamplerState samplerState = null,
            bool worldSpace = true,
            bool useZBuffer = false,
            bool autoIncrementSortKey = false,
            bool autoIncrementLayer = false
        )
        {
            if (container == null)
                throw new ArgumentNullException("container");
            if (materials == null)
                throw new ArgumentNullException("materials");

            Container = container;
            Materials = materials;
            Layer = layer;
            RasterizerState = rasterizerState;
            DepthStencilState = depthStencilState;
            BlendState = blendState;
            SamplerState = samplerState;
            UseZBuffer = useZBuffer;
            WorldSpace = worldSpace;
            AutoIncrementSortKey = autoIncrementSortKey;
            AutoIncrementLayer = autoIncrementLayer;
            NextSortKey = 0;
            PreviousBatch = null;
        }
Esempio n. 6
0
        public void DrawSkybox(Camera camera, Vector3 shipPosition)
        {
            //A TextureAddressMode.Clamp state removes the seams between the cube.
            SamplerState ss = new SamplerState();
            ss.AddressU = TextureAddressMode.Clamp;
            ss.AddressV = TextureAddressMode.Clamp;
            _device.SamplerStates[0] = ss;

            //Removes the ZBuffer so no size can be set for the skybox.
            DepthStencilState dss = new DepthStencilState();
            dss.DepthBufferEnable = false;
            _device.DepthStencilState = dss;

            Matrix[] transforms = new Matrix[_skyboxModel.Bones.Count]; //Represents the position of each model bone.
            _skyboxModel.CopyAbsoluteBoneTransformsTo(transforms); //Models have a method that populates an array.

            foreach (ModelMesh mesh in _skyboxModel.Meshes)
            {
                //BasicEffect is a simplified version of it's parent class Effect.  Effects allow objects to be placed on screen.
                foreach (BasicEffect basicEffect in mesh.Effects)
                {
                    basicEffect.Projection = camera.Projection;
                    basicEffect.View = camera.View;
                    basicEffect.World =  Matrix.CreateScale(80) * mesh.ParentBone.Transform * Matrix.CreateTranslation(shipPosition); //Positions the mesh in the correct place relavent to the world.

                }
                mesh.Draw();
            }

            //Reenabling the ZBuffer.
            dss = new DepthStencilState();
            dss.DepthBufferEnable = true;
            _device.DepthStencilState = dss;
        }
Esempio n. 7
0
 public TagRenderer(int tag)
 {
     Tag = tag;
     BlendState = BlendState.AlphaBlend;
     SamplerState = SamplerState.LinearClamp;
     Camera = new Camera();
 }
Esempio n. 8
0
        /// <summary>
        /// Starts the specified batch.
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="useCamera">if set to <c>true</c> camera matrix will be applied.</param>
        /// <param name="sortMode">The sort mode.</param>
        /// <param name="blendState">State of the blend.</param>
        /// <param name="samplerState">State of the sampler.</param>
        /// <param name="depthStencilState">State of the depth stencil.</param>
        /// <param name="rasterizerState">State of the rasterizer.</param>
        /// <param name="effect">The effect.</param>
        /// <param name="transform">The transformation matrix.</param>
        public static void Start(this SpriteBatch batch,
            bool useCamera = false,
            SpriteSortMode sortMode = SpriteSortMode.Deferred,
            BlendState blendState = null,
            SamplerState samplerState = null,
            DepthStencilState depthStencilState = null,
            RasterizerState rasterizerState = null,
            Effect effect = null,
            Matrix? transform = null)
        {
            Matrix matrix = AlmiranteEngine.IsWinForms ? Matrix.Identity : AlmiranteEngine.Settings.Resolution.Matrix;

            if (useCamera)
            {
                matrix = AlmiranteEngine.Camera.Matrix * matrix;
            }

            if (transform.HasValue)
            {
                matrix = transform.Value * matrix;
            }

            BatchExtensions._sortMode = sortMode;
            BatchExtensions._blendState = blendState;
            BatchExtensions._samplerState = samplerState;
            BatchExtensions._depthStencilState = depthStencilState;
            BatchExtensions._rasterizerState = rasterizerState;
            BatchExtensions._effect = effect;
            BatchExtensions._matrix = matrix;

            batch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, matrix);
        }
 public TagExcludeRenderer(int excludeTag)
 {
     ExcludeTag = excludeTag;
     BlendState = BlendState.AlphaBlend;
     SamplerState = SamplerState.LinearClamp;
     Camera = new Camera();
 }
Esempio n. 10
0
        /// <summary>
        /// Begins a new sprite and text batch with the specified render state.
        /// </summary>
        /// <param name="sortMode">The drawing order for sprite and text drawing. <see cref="SpriteSortMode.Deferred"/> by default.</param>
        /// <param name="blendState">State of the blending. Uses <see cref="BlendState.AlphaBlend"/> if null.</param>
        /// <param name="samplerState">State of the sampler. Uses <see cref="SamplerState.LinearClamp"/> if null.</param>
        /// <param name="depthStencilState">State of the depth-stencil buffer. Uses <see cref="DepthStencilState.None"/> if null.</param>
        /// <param name="rasterizerState">State of the rasterization. Uses <see cref="RasterizerState.CullCounterClockwise"/> if null.</param>
        /// <param name="effect">A custom <see cref="Effect"/> to override the default sprite effect. Uses default sprite effect if null.</param>
        /// <param name="transformMatrix">An optional matrix used to transform the sprite geometry. Uses <see cref="Matrix.Identity"/> if null.</param>
        /// <exception cref="InvalidOperationException">Thrown if <see cref="Begin"/> is called next time without previous <see cref="End"/>.</exception>
        /// <remarks>This method uses optional parameters.</remarks>
        /// <remarks>The <see cref="Begin"/> Begin should be called before drawing commands, and you cannot call it again before subsequent <see cref="End"/>.</remarks>
        public void Begin
        (
             SpriteSortMode sortMode = SpriteSortMode.Deferred,
             BlendState blendState = null,
             SamplerState samplerState = null,
             DepthStencilState depthStencilState = null,
             RasterizerState rasterizerState = null,
             Effect effect = null,
             Matrix? transformMatrix = null
        )
        {
            if (_beginCalled)
                throw new InvalidOperationException("Begin cannot be called again until End has been successfully called.");

            // defaults
            _sortMode = sortMode;
            _blendState = blendState ?? BlendState.AlphaBlend;
            _samplerState = samplerState ?? SamplerState.LinearClamp;
            _depthStencilState = depthStencilState ?? DepthStencilState.None;
            _rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise;
            _effect = effect;
            _matrix = transformMatrix ?? Matrix.Identity;

            // Setup things now so a user can change them.
            if (sortMode == SpriteSortMode.Immediate)
            {
                Setup();
            }

            _beginCalled = true;
        }
Esempio n. 11
0
        /// <summary>
        /// Does the actual drawing of the skybox with our skybox effect.
        /// There is no world matrix, because we're assuming the skybox won't
        /// be moved around.  The size of the skybox can be changed with the size
        /// variable.
        /// </summary>
        /// <param name="view">The view matrix for the effect</param>
        /// <param name="projection">The projection matrix for the effect</param>
        /// <param name="cameraPosition">The position of the camera</param>
        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice device = game.GraphicsDevice;
            SamplerState ss = new SamplerState();
            ss.AddressU = TextureAddressMode.Clamp;
            ss.AddressV = TextureAddressMode.Clamp;
            device.SamplerStates[0] = ss;

            DepthStencilState dss = new DepthStencilState();
            dss.DepthBufferEnable = false;
            device.DepthStencilState = dss;

            Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
            skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
            int i = 0;
            foreach (ModelMesh mesh in skyboxModel.Meshes)
            {
                foreach (BasicEffect currentEffect in mesh.Effects)
                {
                    Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(camera.position);

                    currentEffect.World = worldMatrix;
                    currentEffect.View = camera.view;
                    currentEffect.Projection = camera.projection;
                    currentEffect.TextureEnabled=true;
                    currentEffect.Texture = skyboxTextures[i++];

                }
                mesh.Draw();
            }

            dss = new DepthStencilState();
            dss.DepthBufferEnable = true;
            device.DepthStencilState = dss;
        }
        public void DrawPolygons(Vector2 position, float angle, float scale,
            Texture2D texture, VertexPositionTexture[] vertices, BlendState blendMode)
        {
            effect.World = Matrix.CreateRotationZ(angle) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(new Vector3(position, 0));
            effect.Texture = texture;

            GraphicsDevice device = GameEngine.Instance.GraphicsDevice;

            if (blendMode == BlendState.AlphaBlend)
            {
                device.BlendState = BlendState.AlphaBlend;
            }
            else if (blendMode == BlendState.Additive)
            {
                device.BlendState = BlendState.Additive;
            }
            SamplerState s = new SamplerState();
            s.AddressU = TextureAddressMode.Wrap;
            s.AddressV = TextureAddressMode.Wrap;
            device.SamplerStates[0] = s;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
                //pass.Apply();
            }
        }
Esempio n. 13
0
        public void DrawTerrainAsset(TerrainBlock asset)
        {
            SamplerState s = new SamplerState();
            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;
            s.AddressU = TextureAddressMode.Wrap; s.AddressV = TextureAddressMode.Wrap;
            Game.GraphicsDevice.SamplerStates[0] = s;
            Game.GraphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.None };
            //effect.FogEnabled = true;
            //effect.FogStart = 120f;
            //effect.FogEnd = 150f;
            //effect.FogColor = Color.CornflowerBlue.ToVector3();
            effect.TextureEnabled = true;
            effect.Texture = asset.GetTexture();
            effect.EnableDefaultLighting();
            effect.AmbientLightColor = new Vector3(0.5f, 0.5f, 0.5f);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                game.GraphicsDevice.SetVertexBuffer(asset.GetVertexBuffer());
                game.GraphicsDevice.Indices = asset.GetIndexBuffer();
                game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, asset.GetVerticesLength(), 0, asset.GetIndicesLength() / 3);
            }

            //base.Draw(gameTime);
        }
 /// <summary>
 /// DownSample a Color Texture (using hardware Linear filtering, cant be used on Single/float Textures)
 /// </summary>
 /// <param name="render">The render.</param>
 /// <param name="Texture2D">The texture2 D.</param>
 /// <param name="SamplerState">State of the sampler.</param>
 /// <returns></returns>
 public Texture2D DownColorTexture(RenderHelper render, Texture2D Texture2D, SamplerState SamplerState)
 {
     render.PushRenderTarget(RenderTarget2D);
     render.RenderTextureComplete(Texture2D, Color.White,
         Rectangle, Matrix.Identity, Texture2D.Bounds,
         true, SpriteSortMode.Deferred, SamplerState);
     return render.PopRenderTargetAsSingleRenderTarget2D();
 }
Esempio n. 15
0
 public override void Draw(GraphicsDevice device, Camera camera)
 {
     SamplerState ss = new SamplerState();
     ss.AddressU = TextureAddressMode.Wrap;
     ss.AddressV = TextureAddressMode.Wrap;
     device.SamplerStates[0] = ss;
     base.Draw(device, camera);
 }
Esempio n. 16
0
 public override void Initialize()
 {
     base.Initialize();
     SamplerState customState = new SamplerState();
     customState.Filter = TextureFilter.Linear;
     GraphicsDevice.SamplerStates[0] = customState;
     isInitialized = true;
 }
Esempio n. 17
0
 public void Begin(SpriteSortMode sortMode, BlendState blendState)
 {
     _sortMode = sortMode;
     _blendState = (blendState == null) ? BlendState.AlphaBlend : blendState;
     _depthStencilState = DepthStencilState.None;
     _samplerState = SamplerState.LinearClamp;
     _rasterizerState = RasterizerState.CullCounterClockwise;
     _matrix = Matrix.Identity;
 }
Esempio n. 18
0
 static SamplerState()
 {
     AnisotropicClamp = new SamplerState("SamplerState.AnisotropicClamp", TextureFilter.Anisotropic, TextureAddressMode.Clamp);
     AnisotropicWrap = new SamplerState("SamplerState.AnisotropicWrap", TextureFilter.Anisotropic, TextureAddressMode.Wrap);
     LinearClamp = new SamplerState("SamplerState.LinearClamp", TextureFilter.Linear, TextureAddressMode.Clamp);
     LinearWrap = new SamplerState("SamplerState.LinearWrap", TextureFilter.Linear, TextureAddressMode.Wrap);
     PointClamp = new SamplerState("SamplerState.PointClamp", TextureFilter.Point, TextureAddressMode.Clamp);
     PointWrap = new SamplerState("SamplerState.PointWrap", TextureFilter.Point, TextureAddressMode.Wrap);
 }
Esempio n. 19
0
 public void handleFinalRender( Color letterboxColor, RenderTarget2D source, Rectangle finalRenderDestinationRect, SamplerState samplerState )
 {
     // we can just draw directly to the screen here with our effect
     Core.graphicsDevice.setRenderTarget( null );
     Core.graphicsDevice.Clear( letterboxColor );
     Graphics.instance.batcher.begin( BlendState.Opaque, samplerState, DepthStencilState.None, RasterizerState.CullNone, effect );
     Graphics.instance.batcher.draw( source, finalRenderDestinationRect, Color.White );
     Graphics.instance.batcher.end();
 }
Esempio n. 20
0
 public void Begin()
 {
     _sortMode = SpriteSortMode.Deferred;
     _blendState = BlendState.AlphaBlend;
     _depthStencilState = DepthStencilState.None;
     _samplerState = SamplerState.LinearClamp;
     _rasterizerState = RasterizerState.CullCounterClockwise;
     _matrix = Matrix.Identity;
 }
Esempio n. 21
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                DeleteGLTexture();
                glLastSamplerState = null;
            }

            base.Dispose(disposing);
        }
 /* Constructors */
 public GraphicsObject(ILevel component_owner, PhysicalObject parent)
     : base(component_owner, 0.0f)
 {
     mParent = parent;
     mColour = Color.White;
     mRenderColour = Color.White;
     mScale = Vector2.One;
     mBlendState = BlendState.AlphaBlend;
     mSamplerState = SamplerState.AnisotropicClamp;
 }
Esempio n. 23
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                glTexture = -1;
                glLastSamplerState = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 24
0
 private static void DoAsserts(SamplerState samplerState, Action<TestDelegate> assertMethod)
 {
     assertMethod(() => samplerState.AddressU = TextureAddressMode.Clamp);
     assertMethod(() => samplerState.AddressV = TextureAddressMode.Clamp);
     assertMethod(() => samplerState.AddressW = TextureAddressMode.Clamp);
     assertMethod(() => samplerState.Filter = TextureFilter.Anisotropic);
     assertMethod(() => samplerState.MaxAnisotropy = 0);
     assertMethod(() => samplerState.MaxMipLevel = 0);
     assertMethod(() => samplerState.MipMapLevelOfDetailBias = 0);
 }
Esempio n. 25
0
 /// <summary>
 /// Begin the SpriteBatch
 /// </summary>
 /// <param name="SortMode">Self-explanatory.</param>
 /// <param name="BlendState">Self-explanatory.</param>
 /// <param name="SamplerState">Self-explanatory.</param>
 /// <param name="DepthStencilState">Self-explanatory.</param>
 /// <param name="RasterizerState">Self-explanatory.</param>
 /// <param name="Effect">Self-explanatory.</param>
 /// <param name="Matrix">Self-explanatory.</param>
 public void Begin(SpriteSortMode SortMode = SpriteSortMode.Deferred, BlendState BlendState = null,
     SamplerState SamplerState = null, DepthStencilState DepthStencilState = null,
     RasterizerState RasterizerState = null, Effect Effect = null, Matrix? Matrix = null, bool Backup = false)
 {
     if (Begun) End();
     Begun = true;
     if (Backup)
         this.Backup(SortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix);
     SpriteBatch.Begin(SortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix);
 }
Esempio n. 26
0
 /// <summary>
 /// construct a TTSpriteBatch with custom rendering parameters for the batch
 /// </summary>
 public TTSpriteBatch(GraphicsDevice gfx, SpriteSortMode ssm, BlendState bs, SamplerState ss, DepthStencilState dss, RasterizerState rs, Effect fx)
     : base(gfx)
 {
     spriteSortMode = ssm;
     blendState = bs;
     samplerState = ss;
     depthStencilState = dss;
     rasterizerState = rs;
     effect = fx;
 }
Esempio n. 27
0
 public DrawMode(DrawMode copy)
 {
     sortMode          = copy.sortMode;
     blendState        = copy.blendState;
     samplerState      = copy.samplerState;
     depthStencilState = copy.depthStencilState;
     rasterizerState   = copy.rasterizerState;
     effect            = copy.effect;
     transform         = copy.transform;
 }
Esempio n. 28
0
 // ================== CONSTRUCTORS ================== //
 public DrawMode()
 {
     sortMode          = SpriteSortMode.Immediate;
     blendState        = BlendState.NonPremultiplied;
     samplerState      = SamplerState.LinearClamp;
     depthStencilState = DepthStencilState.None;
     rasterizerState   = RasterizerState.CullNone;
     effect            = null;
     transform         = Matrix.Identity;
 }
Esempio n. 29
0
        public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState)
        {
            _sortMode = sortMode;

            _blendState = (blendState == null) ? BlendState.AlphaBlend : blendState;
            _depthStencilState = (depthStencilState == null) ? DepthStencilState.None : depthStencilState;
            _samplerState = (samplerState == null) ? SamplerState.LinearClamp : samplerState;
            _rasterizerState = (rasterizerState == null) ? RasterizerState.CullCounterClockwise : rasterizerState;

            _matrix = Matrix.Identity;
        }
Esempio n. 30
0
 public void Backup(SpriteSortMode SortMode = SpriteSortMode.Deferred, BlendState BlendState = null,
     SamplerState SamplerState = null, DepthStencilState DepthStencilState = null,
     RasterizerState RasterizerState = null, Effect Effect = null, Matrix? Matrix = null)
 {
     this.SortMode = SortMode;
     this.BlendState = BlendState;
     this.SamplerState = SamplerState;
     this.DepthStencilState = DepthStencilState;
     this.RasterizerState = RasterizerState;
     this.Effect = Effect;
     this.Matrix = Matrix;
 }
 /// <summary>
 /// Binds the implementation. This is called the first time an unbound state is set to the device or manually by the user in order to
 /// create the underlying state ahead of time (best practice). Once called the state properties are read-only.
 /// </summary>
 public override void BindSamplerState()
 {
     if (!base.IsBound)
     {
         _samplerState                         = new XFG.SamplerState();
         _samplerState.AddressU                = XNAHelper.ToXNATextureAddressMode(base.AddressU);
         _samplerState.AddressV                = XNAHelper.ToXNATextureAddressMode(base.AddressV);
         _samplerState.AddressW                = XNAHelper.ToXNATextureAddressMode(base.AddressW);
         _samplerState.Filter                  = XNAHelper.ToXNATextureFilter(base.Filter);
         _samplerState.MaxAnisotropy           = base.MaxAnisotropy;
         _samplerState.MipMapLevelOfDetailBias = base.MipMapLevelOfDetailBias;
         base.IsBound = true;
     }
 }
Esempio n. 32
0
        public void Enable(int index)
        {
            var samplerState = new X.SamplerState()
            {
                Filter        = desc.filter,
                MaxAnisotropy = 1,
                AddressU      = desc.addressU,
                AddressV      = desc.addressV,
                                #if !SILVERLIGHT
                AddressW = desc.addressW
                                #endif
            };

            video.Device.SamplerStates[index] = samplerState;
        }
Esempio n. 33
0
        private void defualtStates()
        {
            var rasterizerState = new Microsoft.Xna.Framework.Graphics.RasterizerState();

            rasterizerState.CullMode             = CullMode.None;
            rasterizerState.FillMode             = FillMode.Solid;
            rasterizerState.MultiSampleAntiAlias = false;
            rasterizerState.ScissorTestEnable    = false;
            Device.RasterizerState = rasterizerState;

            var samplerStates = new Microsoft.Xna.Framework.Graphics.SamplerState();

            samplerStates.Filter    = TextureFilter.Linear;
            Device.SamplerStates[0] = samplerStates;
        }
Esempio n. 34
0
 private void PlatformGraphicsDeviceResetting()
 {
     DeleteGLTexture();
     glLastSamplerState = null;
 }
Esempio n. 35
0
 public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect)
 {
     Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, Matrix.Identity);
 }
Esempio n. 36
0
        public void handleFinalRender(Color letterboxColor, Microsoft.Xna.Framework.Graphics.RenderTarget2D source, Rectangle finalRenderDestinationRect, Microsoft.Xna.Framework.Graphics.SamplerState samplerState)
        {
            Core.graphicsDevice.SetRenderTarget(null);
            Core.graphicsDevice.Clear(letterboxColor);
            Graphics.instance.batcher.begin(BlendState.Opaque, samplerState, DepthStencilState.None, RasterizerState.CullNone, null);
            Graphics.instance.batcher.draw(source, finalRenderDestinationRect, Color.White);
            Graphics.instance.batcher.end();

            _screenSpaceRenderer.render(scene);
        }