Example #1
0
 public void Init(CFontProvider fontProvider)
 {
     m_fontProvider = fontProvider;
 }
        internal void Init(Device device, CFontProvider fontProvider)
        {
            m_textRenderer.Init(fontProvider);
            m_primitiveShader.Init(device);
            m_primitiveMap.Init(device);
            m_lineShader.Init(device);

            for (int i = 0; i < m_lineCommandLists.Length; i++)
            {
                CDebugLineCommandList lineCommandList = new CDebugLineCommandList();
                lineCommandList.Init(device);
                m_lineCommandLists[i] = lineCommandList;
            }

            RasterizerStateDescription wireframeDescription = new RasterizerStateDescription()
            {
                CullMode         = CullMode.Back,
                DepthBias        = 0,
                FillMode         = FillMode.Wireframe,
                IsScissorEnabled = false
            };

            m_wireframeState = new RasterizerState(device, wireframeDescription);

            RasterizerStateDescription solidDescription = new RasterizerStateDescription()
            {
                CullMode         = CullMode.Back,
                DepthBias        = 0,
                FillMode         = FillMode.Solid,
                IsScissorEnabled = false
            };

            m_solidState = new RasterizerState(device, solidDescription);

            DepthStencilStateDescription depthEnabledDescription;

            depthEnabledDescription.IsDepthEnabled  = true;
            depthEnabledDescription.DepthWriteMask  = DepthWriteMask.All;
            depthEnabledDescription.DepthComparison = Comparison.Less;

            depthEnabledDescription.IsStencilEnabled = true;
            depthEnabledDescription.StencilReadMask  = 0xFF;
            depthEnabledDescription.StencilWriteMask = 0xFF;

            depthEnabledDescription.FrontFace.FailOperation      = StencilOperation.Keep;
            depthEnabledDescription.FrontFace.DepthFailOperation = StencilOperation.Keep;
            depthEnabledDescription.FrontFace.PassOperation      = StencilOperation.Keep;
            depthEnabledDescription.FrontFace.Comparison         = Comparison.Always;

            depthEnabledDescription.BackFace.FailOperation      = StencilOperation.Keep;
            depthEnabledDescription.BackFace.DepthFailOperation = StencilOperation.Decrement;
            depthEnabledDescription.BackFace.PassOperation      = StencilOperation.Keep;
            depthEnabledDescription.BackFace.Comparison         = Comparison.Always;

            m_depthEnabledState = new DepthStencilState(device, depthEnabledDescription);

            DepthStencilStateDescription depthDisabledDescription = new DepthStencilStateDescription();

            depthDisabledDescription.IsDepthEnabled   = false;
            depthDisabledDescription.IsStencilEnabled = false;

            m_depthDisabledState = new DepthStencilState(device, depthDisabledDescription);
        }