Ejemplo n.º 1
0
        private void WriteRasterizerState(String name, RasterizerState value)
        {
            _writer.Write(TAB_BLOCK2);
            _writer.Write("RasterizerState");
            WriteSpace();
            _writer.Write(name);
            RenderStateKey key = value.RenderStateKey;

            if (key.Equals(RasterizerState.CullBackClockwiseFront.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("CullBackClockwiseFront");
                WriteNewLine();
            }
            else if (key.Equals(RasterizerState.CullBackCounterClockwiseFront.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("CullBackCounterClockwiseFront");
                WriteNewLine();
            }
            else if (key.Equals(RasterizerState.CullNone.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("CullNone");
                WriteNewLine();
            }
            else if (key.Equals(RasterizerState.CullNoneWireframe.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("CullNoneWireframe");
                WriteNewLine();
            }
            else
            {
                WriteOpenBrace();

                if (value.Cull != CullMode.Back)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("Cull");
                    WriteSeparator();
                    _writer.Write(value.Cull.ToString());
                    WriteNewLine();
                }

                if (value.VertexWinding != VertexWinding.Clockwise)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("VertexWinding");
                    WriteSeparator();
                    _writer.Write(value.VertexWinding.ToString());
                    WriteNewLine();
                }

                if (value.DepthBias != 0)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("DepthBias");
                    WriteSeparator();
                    _writer.Write(value.DepthBias);
                    WriteNewLine();
                }

                if (value.Fill != FillMode.Solid)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("Fill");
                    WriteSeparator();
                    _writer.Write(value.Fill.ToString());
                    WriteNewLine();
                }

                if (value.EnableMultiSampleAntiAlias == false)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("EnableMultiSampleAntiAlias");
                    WriteSeparator();
                    _writer.Write("false");
                    WriteNewLine();
                }

                if (value.EnableScissorTest == true)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("EnableScissorTest");
                    WriteSeparator();
                    _writer.Write("true");
                    WriteNewLine();
                }

                if (!value.SlopeScaledDepthBias.Equals(0.0f))
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("SlopeScaledDepthBias");
                    WriteSeparator();
                    _writer.Write(value.SlopeScaledDepthBias);
                    WriteNewLine();
                }

                WriteCloseBrace(false, TAB_BLOCK2);
            }
        }
Ejemplo n.º 2
0
        private void WriteSamplerState(bool pixelSampler, int index, SamplerState value)
        {
            _writer.Write(TAB_BLOCK2);
            if (pixelSampler)
            {
                _writer.Write("SamplerState");
            }
            else
            {
                _writer.Write("VertexSamplerState");
            }
            _writer.Write("[");
            _writer.Write(index);
            _writer.Write("]");
            RenderStateKey key = value.RenderStateKey;

            if (key.Equals(SamplerState.AnisotropicClamp.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("AnisotropicClamp");
                WriteNewLine();
            }
            else if (key.Equals(SamplerState.AnisotropicWrap.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("AnisotropicWrap");
                WriteNewLine();
            }
            else if (key.Equals(SamplerState.LinearClamp.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("LinearClamp");
                WriteNewLine();
            }
            else if (key.Equals(SamplerState.LinearWrap.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("LinearWrap");
                WriteNewLine();
            }
            else if (key.Equals(SamplerState.PointClamp.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("PointClamp");
                WriteNewLine();
            }
            else if (key.Equals(SamplerState.PointWrap.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("PointWrap");
                WriteNewLine();
            }
            else
            {
                WriteOpenBrace();

                if (value.AddressU != TextureAddressMode.Clamp)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AddressU");
                    WriteSeparator();
                    _writer.Write(value.AddressU.ToString());
                    WriteNewLine();
                }

                if (value.AddressV != TextureAddressMode.Clamp)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AddressV");
                    WriteSeparator();
                    _writer.Write(value.AddressV.ToString());
                    WriteNewLine();
                }

                if (value.AddressW != TextureAddressMode.Clamp)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AddressW");
                    WriteSeparator();
                    _writer.Write(value.AddressW.ToString());
                    WriteNewLine();
                }

                if (value.Filter != TextureFilter.Point)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("Filter");
                    WriteSeparator();
                    _writer.Write(value.Filter.ToString());
                    WriteNewLine();
                }

                if (value.MaxAnisotropy != 4)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("MaxAnisotropy");
                    WriteSeparator();
                    _writer.Write(value.MaxAnisotropy);
                    WriteNewLine();
                }

                if (!value.MipMapLevelOfDetailBias.Equals(0.0f))
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("MipMapLevelOfDetailBias");
                    WriteSeparator();
                    _writer.Write(value.MipMapLevelOfDetailBias);
                    WriteNewLine();
                }

                WriteCloseBrace(false, TAB_BLOCK2);
            }
        }
Ejemplo n.º 3
0
        private void WriteBlendState(String name, BlendState value)
        {
            _writer.Write(TAB_BLOCK2);
            _writer.Write("BlendState");
            WriteSpace();
            _writer.Write(name);
            RenderStateKey key = value.RenderStateKey;

            if (key.Equals(BlendState.AdditiveBlend.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("AdditiveBlend");
                WriteNewLine();
            }
            else if (key.Equals(BlendState.AlphaBlendNonPremultiplied.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("AlphaBlendNonPremultiplied");
                WriteNewLine();
            }
            else if (key.Equals(BlendState.AlphaBlendPremultiplied.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("AlphaBlendPremultiplied");
                WriteNewLine();
            }
            else if (key.Equals(BlendState.Opaque.RenderStateKey))
            {
                WriteSeparator();
                _writer.Write("Opaque");
                WriteNewLine();
            }
            else
            {
                WriteOpenBrace();

                if (value.AlphaBlendFunction != BlendFunction.Add)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AlphaBlendFunction");
                    WriteSeparator();
                    _writer.Write(value.AlphaBlendFunction.ToString());
                    WriteNewLine();
                }

                if (value.AlphaSourceBlend != Blend.One)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AlphaSourceBlend");
                    WriteSeparator();
                    _writer.Write(value.AlphaSourceBlend.ToString());
                    WriteNewLine();
                }

                if (value.AlphaDestinationBlend != Blend.Zero)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("AlphaDestinationBlend");
                    WriteSeparator();
                    _writer.Write(value.AlphaDestinationBlend.ToString());
                    WriteNewLine();
                }

                if (value.ColorBlendFunction != BlendFunction.Add)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("ColorBlendFunction");
                    WriteSeparator();
                    _writer.Write(value.ColorBlendFunction.ToString());
                    WriteNewLine();
                }

                if (value.ColorSourceBlend != Blend.One)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("ColorSourceBlend");
                    WriteSeparator();
                    _writer.Write(value.ColorSourceBlend.ToString());
                    WriteNewLine();
                }

                if (value.ColorDestinationBlend != Blend.Zero)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("ColorDestinationBlend");
                    WriteSeparator();
                    _writer.Write(value.ColorDestinationBlend.ToString());
                    WriteNewLine();
                }

                if (!value.BlendFactor.Equals(Color.White))
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("BlendFactor");
                    WriteSeparator();
                    Color c = value.BlendFactor;
                    _writer.Write(c.R);
                    WriteSpace();
                    _writer.Write(c.G);
                    WriteSpace();
                    _writer.Write(c.B);
                    WriteSpace();
                    _writer.Write(c.A);
                    WriteNewLine();
                }

                if (value.MultiSampleMask != int.MaxValue)
                {
                    _writer.Write(TAB_BLOCK3);
                    _writer.Write("MultiSampleMask");
                    WriteSeparator();
                    _writer.Write(value.MultiSampleMask);
                    WriteNewLine();
                }

                int beCount = value.BlendEnableCount;
                if (beCount > 0)
                {
                    if (value.GetBlendEnable(0) == false)
                    {
                        _writer.Write(TAB_BLOCK3);
                        _writer.Write("BlendEnable[0]");
                        WriteSeparator();
                        _writer.Write("false");
                        WriteNewLine();
                    }

                    for (int i = 1; i < beCount; i++)
                    {
                        if (value.GetBlendEnable(i) == true)
                        {
                            _writer.Write(TAB_BLOCK3);
                            _writer.Write("BlendEnable[");
                            _writer.Write(i);
                            _writer.Write("]");
                            WriteSeparator();
                            _writer.Write("true");
                            WriteNewLine();
                        }
                    }
                }

                int cwCount = value.ColorWriteChannelsCount;
                if (cwCount > 0)
                {
                    ColorWriteChannels cwc = value.GetWriteChannels(0);
                    if (cwc != ColorWriteChannels.All)
                    {
                        _writer.Write(TAB_BLOCK3);
                        _writer.Write("ColorWriteChannels[0]");
                        WriteSeparator();
                        _writer.Write(cwc.ToString().Replace(",", " |"));
                        WriteNewLine();
                    }

                    for (int i = 1; i < cwCount; i++)
                    {
                        cwc = value.GetWriteChannels(i);
                        if (cwc != ColorWriteChannels.All)
                        {
                            _writer.Write(TAB_BLOCK3);
                            _writer.Write("ColorWriteChannels[");
                            _writer.Write(i);
                            _writer.Write("]");
                            WriteSeparator();
                            _writer.Write(cwc.ToString().Replace(",", " |"));
                            WriteNewLine();
                        }
                    }
                }

                WriteCloseBrace(false, TAB_BLOCK2);
            }
        }