示例#1
0
        public MonoGame(GraphicsDevice graphicsDevice, ContentManager contentManager, Effect effect)
        {
            m_GraphicsDevice = graphicsDevice;
            m_ContentManager = contentManager;
            m_Effect         = new GwenEffect(effect);
            spriteBatch      = new SpriteBatch(graphicsDevice);

            m_VertexArray = new VertexPositionColorTexture[MaxVerts];
            m_IndexArray  = new short[MaxVerts * 3 / 2];

            for (int i = 0; i < MaxVerts / 4; i++)
            {
                /*
                 *   1----2
                 *   |   /|
                 *   |  / |
                 *   | /  |
                 *   |/   |
                 *   0----3
                 */
                // Triangle 1
                m_IndexArray[i * 6 + 0] = (short)(i * 4);
                m_IndexArray[i * 6 + 1] = (short)(i * 4 + 1);
                m_IndexArray[i * 6 + 2] = (short)(i * 4 + 2);
                // Triangle 2
                m_IndexArray[i * 6 + 3] = (short)(i * 4 + 2);
                m_IndexArray[i * 6 + 4] = (short)(i * 4 + 3);
                m_IndexArray[i * 6 + 5] = (short)(i * 4);
            }

            m_VertexBuffer = new VertexBuffer(m_GraphicsDevice, typeof(VertexPositionColorTexture), m_VertexArray.Length, BufferUsage.WriteOnly);

            m_IndexBuffer = new IndexBuffer(m_GraphicsDevice, IndexElementSize.SixteenBits, m_IndexArray.Length, BufferUsage.WriteOnly);
            m_IndexBuffer.SetData <short>(m_IndexArray);

            m_StringCache = new Dictionary <Tuple <String, Font>, Texture>();

            m_DefaultFont = null;
        }
示例#2
0
 protected GwenEffect(GwenEffect clone)
     : base(clone)
 {
     CacheEffectParams();
 }