public void SetupSettings()
        {
            // Setup renderstates
            SetAlphaBlendEnable(false);
            SetAlphaTestEnable(false);
            SetCullMode(Cull.None);
            SetDestinationBlend(Blend.InverseSourceAlpha);
            SetFillMode(FillMode.Solid);
            SetMultisampleAntialias((General.Settings.AntiAliasingSamples > 0));
            SetSourceBlend(Blend.SourceAlpha);
            SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
            SetZEnable(false);
            SetZWriteEnable(false);

            // Texture addressing
            SetSamplerState(TextureAddress.Wrap);

            //mxd. It's still nice to have anisotropic filtering when texture filtering is disabled
            TextureFilter magminfilter = (General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Nearest);

            SetSamplerFilter(
                magminfilter,
                magminfilter,
                General.Settings.VisualBilinear ? MipmapFilter.Linear : MipmapFilter.Nearest,
                General.Settings.FilterAnisotropy);

            // Initialize presentations
            Presentation.Initialize();
        }
Example #2
0
        // This completes initialization after the device has started or has been reset
        public void SetupSettings()
        {
            // Setup renderstates
            device.SetRenderState(RenderState.AlphaBlendEnable, false);
            device.SetRenderState(RenderState.AlphaBlendEnable, false);
            device.SetRenderState(RenderState.AlphaFunc, Compare.GreaterEqual);
            device.SetRenderState(RenderState.AlphaRef, 0x0000007E);
            device.SetRenderState(RenderState.AlphaTestEnable, false);
            device.SetRenderState(RenderState.Ambient, Color.White.ToArgb());
            device.SetRenderState(RenderState.AmbientMaterialSource, ColorSource.Material);
            device.SetRenderState(RenderState.AntialiasedLineEnable, false);
            device.SetRenderState(RenderState.Clipping, true);
            device.SetRenderState(RenderState.ColorVertex, false);
            device.SetRenderState(RenderState.ColorWriteEnable, ColorWriteEnable.Red | ColorWriteEnable.Green | ColorWriteEnable.Blue | ColorWriteEnable.Alpha);
            device.SetRenderState(RenderState.CullMode, Cull.None);
            device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
            device.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Color1);
            device.SetRenderState(RenderState.DitherEnable, true);
            device.SetRenderState(RenderState.FillMode, FillMode.Solid);
            device.SetRenderState(RenderState.FogEnable, false);
            device.SetRenderState(RenderState.FogTableMode, FogMode.Linear);
            device.SetRenderState(RenderState.Lighting, false);
            device.SetRenderState(RenderState.LocalViewer, false);
            device.SetRenderState(RenderState.NormalizeNormals, false);
            device.SetRenderState(RenderState.PointSpriteEnable, false);
            device.SetRenderState(RenderState.RangeFogEnable, false);
            device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
            device.SetRenderState(RenderState.SpecularEnable, false);
            device.SetRenderState(RenderState.StencilEnable, false);
            device.SetRenderState(RenderState.TextureFactor, -1);
            device.SetRenderState(RenderState.ZEnable, false);
            device.SetRenderState(RenderState.ZWriteEnable, false);
            device.PixelShader  = null;
            device.VertexShader = null;

            // Matrices
            device.SetTransform(TransformState.World, Matrix.Identity);
            device.SetTransform(TransformState.View, Matrix.Identity);
            device.SetTransform(TransformState.Projection, Matrix.Identity);

            // Sampler settings
            if (General.Settings.ClassicBilinear)
            {
                device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
                device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
                device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear);
                device.SetSamplerState(0, SamplerState.MipMapLodBias, 0f);
            }
            else
            {
                device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point);
                device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
                device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point);
                device.SetSamplerState(0, SamplerState.MipMapLodBias, 0f);
            }

            // Texture addressing
            device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
            device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
            device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Wrap);

            // First texture stage
            device.SetTextureStageState(0, TextureStage.ColorOperation, TextureOperation.Modulate);
            device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Texture);
            device.SetTextureStageState(0, TextureStage.ColorArg2, TextureArgument.Diffuse);
            device.SetTextureStageState(0, TextureStage.ResultArg, TextureArgument.Current);
            device.SetTextureStageState(0, TextureStage.TexCoordIndex, 0);

            // Second texture stage
            device.SetTextureStageState(1, TextureStage.ColorOperation, TextureOperation.Modulate);
            device.SetTextureStageState(1, TextureStage.ColorArg1, TextureArgument.Current);
            device.SetTextureStageState(1, TextureStage.ColorArg2, TextureArgument.TFactor);
            device.SetTextureStageState(1, TextureStage.ResultArg, TextureArgument.Current);
            device.SetTextureStageState(1, TextureStage.TexCoordIndex, 0);

            // No more further stages
            device.SetTextureStageState(2, TextureStage.ColorOperation, TextureOperation.Disable);

            // First alpha stage
            device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
            device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture);
            device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse);

            // Second alpha stage
            device.SetTextureStageState(1, TextureStage.AlphaOperation, TextureOperation.Modulate);
            device.SetTextureStageState(1, TextureStage.AlphaArg1, TextureArgument.Current);
            device.SetTextureStageState(1, TextureStage.AlphaArg2, TextureArgument.TFactor);

            // No more further stages
            device.SetTextureStageState(2, TextureStage.AlphaOperation, TextureOperation.Disable);

            // Setup material
            Material material = new Material();

            material.Ambient  = new Color4(Color.White);
            material.Diffuse  = new Color4(Color.White);
            material.Specular = new Color4(Color.White);
            device.Material   = material;

            // Shader settings
            shaders.World3D.SetConstants(General.Settings.VisualBilinear, true);

            // Texture filters
            postfilter        = Filter.Point;
            mipgeneratefilter = Filter.Box;

            // Initialize presentations
            Presentation.Initialize();
        }
Example #3
0
        // This completes initialization after the device has started or has been reset
        public void SetupSettings()
        {
            // Setup renderstates
            device.SetRenderState(RenderState.AlphaBlendEnable, false);
            device.SetRenderState(RenderState.AlphaBlendEnable, false);
            device.SetRenderState(RenderState.AlphaFunc, Compare.GreaterEqual);
            device.SetRenderState(RenderState.AlphaRef, 0x0000007E);
            device.SetRenderState(RenderState.AlphaTestEnable, false);
            device.SetRenderState(RenderState.Ambient, Color.White.ToArgb());
            device.SetRenderState(RenderState.AmbientMaterialSource, ColorSource.Material);
            device.SetRenderState(RenderState.AntialiasedLineEnable, false);
            device.SetRenderState(RenderState.Clipping, true);
            device.SetRenderState(RenderState.ColorVertex, false);
            device.SetRenderState(RenderState.ColorWriteEnable, ColorWriteEnable.Red | ColorWriteEnable.Green | ColorWriteEnable.Blue | ColorWriteEnable.Alpha);
            device.SetRenderState(RenderState.CullMode, Cull.None);
            device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
            device.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Color1);
            //device.SetRenderState(RenderState.DitherEnable, true);
            device.SetRenderState(RenderState.FillMode, FillMode.Solid);
            device.SetRenderState(RenderState.FogEnable, false);
            device.SetRenderState(RenderState.FogTableMode, FogMode.Linear);
            device.SetRenderState(RenderState.Lighting, false);
            device.SetRenderState(RenderState.LocalViewer, false);
            device.SetRenderState(RenderState.MultisampleAntialias, (General.Settings.AntiAliasingSamples > 0));             //mxd
            device.SetRenderState(RenderState.NormalizeNormals, false);
            device.SetRenderState(RenderState.PointSpriteEnable, false);
            device.SetRenderState(RenderState.RangeFogEnable, false);
            device.SetRenderState(RenderState.ShadeMode, ShadeMode.Gouraud);
            device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
            device.SetRenderState(RenderState.SpecularEnable, false);
            device.SetRenderState(RenderState.StencilEnable, false);
            device.SetRenderState(RenderState.TextureFactor, -1);
            device.SetRenderState(RenderState.ZEnable, false);
            device.SetRenderState(RenderState.ZWriteEnable, false);
            device.PixelShader  = null;
            device.VertexShader = null;

            // Matrices
            device.SetTransform(TransformState.World, Matrix.Identity);
            device.SetTransform(TransformState.View, Matrix.Identity);
            device.SetTransform(TransformState.Projection, Matrix.Identity);

            // Texture addressing
            device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
            device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
            device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Wrap);

            // Setup material
            device.Material = new Material {
                Ambient  = new Color4(Color.White),
                Diffuse  = new Color4(Color.White),
                Specular = new Color4(Color.White)
            };

            // Shader settings
            shaders.World3D.SetConstants(General.Settings.VisualBilinear, Math.Min(devicecaps.MaxAnisotropy, General.Settings.FilterAnisotropy));

            // Texture filters
            postfilter        = Filter.Point;
            mipgeneratefilter = Filter.Box;

            // Initialize presentations
            Presentation.Initialize();
        }