static BlendState()
        {
            Additive = new BlendState()
            {
                ColorSourceBlend = Blend.SourceAlpha,
                AlphaSourceBlend = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.One,
                AlphaDestinationBlend = Blend.One
            };

            AlphaBlend = new BlendState()
            {
                ColorSourceBlend = Blend.One,
                AlphaSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaDestinationBlend = Blend.InverseSourceAlpha
            };

            NonPremultiplied = new BlendState()
            {
                ColorSourceBlend = Blend.SourceAlpha,
                AlphaSourceBlend = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaDestinationBlend = Blend.InverseSourceAlpha
            };

            Opaque = new BlendState()
            {
                ColorSourceBlend = Blend.One,
                AlphaSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.Zero,
                AlphaDestinationBlend = Blend.Zero
            };

            EmissiveTexture = new BlendState()
            {
                ColorSourceBlend = Blend.SourceAlpha,
                AlphaSourceBlend = Blend.Zero,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaDestinationBlend = Blend.Zero,
                ColorWriteChannels = ColorWriteEnable.Red | ColorWriteEnable.Green | ColorWriteEnable.Blue,

            };
        }
 internal static void BeginSpriteBatch(BlendState blendState, DepthStencilState depthState, RasterizerState rasterizerState)
 {
     if (m_spriteBatchUsageCount == 0)
     {
         //  Deferred means that draw call will be send to GPU not on every Draw(), but only at the End() or if we change
         //  a texture between Begin/End. It's faster than Immediate mode.
         m_spriteBatch.Begin(SpriteSortMode.Deferred,
                             blendState,
                             VRageRender.Graphics.SamplerState.LinearClamp,
                             depthState,
                             rasterizerState);
     }
     m_spriteBatchUsageCount++;
 }
 public static void BeginSpriteBatch(BlendState blendState)
 {
     BeginSpriteBatch(blendState, MyStateObjects.GuiDefault_DepthStencilState, RasterizerState.CullNone);
 }
Beispiel #4
0
        public static float DrawText(Vector2 screenCoord, StringBuilder text, Color color, float scale, bool depthRead, BlendState blendState, MyGuiDrawAlignEnum align = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
        {
            if (depthRead)
                DepthStencilState.DepthRead.Apply();
            else
                DepthStencilState.None.Apply();

            MyRender.BeginSpriteBatch(blendState);

            Vector2 textSize = MyRender.GetDebugFont().MeasureString(text, scale);
            screenCoord = MyUtils.GetCoordAligned(screenCoord, textSize, align);
            float textLength = MyRender.GetDebugFont().DrawString(screenCoord, color, text, scale);

            MyRender.EndSpriteBatch();

            return textLength;
        }
 /// <summary>
 /// Begins a sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil and rasterizer state objects. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise).
 /// </summary>
 /// <param name="sortMode">Sprite drawing order.</param>
 /// <param name="blendState">Blending options.</param>
 /// <param name="samplerState">Texture sampling options.</param>
 /// <param name="depthStencilState">Depth and stencil options.</param>
 /// <param name="rasterizerState">Rasterization options.</param>
 public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState)
 {
     Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, null, Matrix.Identity);
 }
 /// <summary>
 /// Begins a sprite batch rendering using the specified sorting mode and blend state. Other states are sets to default (DepthStencilState.None, SamplerState.LinearClamp, RasterizerState.CullCounterClockwise). If you pass a null blend state, the default is BlendState.AlphaBlend.
 /// </summary>
 /// <param name="sortMode">Sprite drawing order.</param>
 /// <param name="blendState">Blending options.</param>
 public void Begin(SpriteSortMode sortMode, BlendState blendState)
 {
     Begin(sortMode, blendState, null, null, null, null, Matrix.Identity);
 }