Пример #1
0
 private static void PushAll(bool alphaEnable, bool lineStrip, bool alphaTest, int alpha)
 {
     int index = 0;
     if (alphaTest)
     {
         index |= 1;
     }
     if (lineStrip)
     {
         index |= 2;
     }
     if (alphaEnable)
     {
         index |= 4;
     }
     ArrayList list = m_Lists[index];
     if (((m_Counts[index] != 0) && (list != null)) && (list.Count != 0))
     {
         Device device = Engine.m_Device;
         if (alphaTest != m_CurAlphaTest)
         {
             m_CurAlphaTest = alphaTest;
             device.get_RenderState().set_AlphaTestEnable(alphaTest);
         }
         int num3 = lineStrip ? 2 : 4;
         int num4 = num3 * 0x1c;
         if (m_VertexStream == null)
         {
             m_VertexStream = new BufferedVertexStream(Engine.m_VertexBuffer, 0x8000, 0x1c);
         }
         for (int i = 0; i < list.Count; i++)
         {
             Texture texture = (Texture) list[i];
             TextureVB evb = texture.GetVB(alphaEnable, lineStrip, alphaTest, alpha);
             if ((evb.m_Count > 0) && (evb.m_Frame == m_ActFrames))
             {
                 int num6 = m_VertexStream.Push(evb.m_Stream.GetBuffer(), evb.m_Count * num3, false);
                 if (num6 >= 0)
                 {
                     device.SetTexture(0, texture.Surface);
                     if (lineStrip)
                     {
                         device.DrawPrimitives(2, num6, evb.m_Count);
                     }
                     else
                     {
                         device.DrawIndexedPrimitives(4, num6, 0, evb.m_Count * 4, 0, evb.m_Count * 2);
                     }
                     evb.m_Frame = -1;
                 }
             }
         }
         list.Clear();
         m_Counts[index] = 0;
     }
 }
Пример #2
0
        private static void PushAlphaStates()
        {
            if (m_AlphaStateCount != 0)
            {
                if (m_VertexStream == null)
                {
                    m_VertexStream = new BufferedVertexStream(Engine.m_VertexBuffer, 0x8000, 0x1c);
                }
                Device device = Engine.m_Device;
                device.get_RenderState().set_ZBufferWriteEnable(false);
                device.get_RenderState().set_AlphaBlendEnable(true);
                for (int i = 0; i < m_AlphaStateCount; i++)
                {
                    AlphaState state = (AlphaState) m_AlphaStates[i];
                    Texture texture = state.m_Texture;
                    TextureVB textureVB = state.m_TextureVB;
                    if ((textureVB.m_Count > 0) && (textureVB.m_Frame == m_ActFrames))
                    {
                        if (state.m_AlphaTest != m_CurAlphaTest)
                        {
                            m_CurAlphaTest = state.m_AlphaTest;
                            device.get_RenderState().set_AlphaTestEnable(m_CurAlphaTest);
                        }
                        if (state.m_BlendType != m_CurBlendType)
                        {
                            m_CurBlendType = state.m_BlendType;
                            RenderStates states = device.get_RenderState();
                            switch (m_CurBlendType)
                            {
                                case DrawBlendType.Normal:
                                    states.set_SourceBlend(5);
                                    states.set_DestinationBlend(6);
                                    break;

                                case DrawBlendType.Additive:
                                    states.set_SourceBlend(2);
                                    states.set_DestinationBlend(2);
                                    break;

                                case DrawBlendType.BlackTransparency:
                                    states.set_SourceBlend(1);
                                    states.set_DestinationBlend(3);
                                    states.set_BlendOperation(1);
                                    break;
                            }
                        }
                        int num2 = state.m_LineStrip ? 2 : 4;
                        int num3 = num2 * 0x1c;
                        int vertexCount = textureVB.m_Count * num2;
                        int num5 = m_VertexStream.Push(textureVB.m_Stream.GetBuffer(), vertexCount, false);
                        if (num5 >= 0)
                        {
                            device.SetTexture(0, texture.Surface);
                            if (state.m_LineStrip)
                            {
                                device.DrawPrimitives(2, num5, textureVB.m_Count);
                            }
                            else
                            {
                                device.DrawIndexedPrimitives(4, num5, 0, vertexCount, 0, 2 * textureVB.m_Count);
                            }
                        }
                    }
                }
                device.get_RenderState().set_AlphaBlendEnable(false);
                device.get_RenderState().set_ZBufferWriteEnable(true);
                m_AlphaStateCount = 0;
            }
        }
Пример #3
0
 public static void Init(Caps Caps)
 {
     if (m_VertexStream != null)
     {
         m_VertexStream.Unlock();
     }
     m_VertexStream = null;
     m_CanAAEdges = false;
     m_CanAADependent = false;
     m_CanAAIndependent = false;
     m_CanCullNone = Caps.get_PrimitiveMiscCaps().get_SupportsCullNone();
     m_CanCullCW = Caps.get_PrimitiveMiscCaps().get_SupportsCullClockwise();
     m_CanAntiAlias = m_CanAADependent || m_CanAAIndependent;
     m_AAEnable = false;
     m_EdgeAAEnable = false;
     m_AlphaTestEnable = false;
     m_CullEnable = true;
     m_AlphaEnable = false;
     Engine.m_Device.set_VertexFormat(0x144);
     Sampler sampler = Engine.m_Device.get_SamplerState().get_SamplerState(0);
     sampler.set_AddressU(3);
     sampler.set_AddressV(3);
     sampler.set_MinFilter(1);
     sampler.set_MagFilter(1);
     Engine.m_Device.get_RenderState().set_ZBufferEnable(true);
     Engine.m_Device.get_RenderState().set_ZBufferWriteEnable(true);
 }