Example #1
0
        private List <VertexPositionTextureDataColor> GetVLForThisEffectAndTexture(EffectState effect, Texture2D texture)
        {
            Dictionary <Texture2D, List <VertexPositionTextureDataColor> > vls;

            if (m_DrawCommands.ContainsKey(effect))
            {
                vls = m_DrawCommands[effect];
            }
            else
            {
                vls = new Dictionary <Texture2D, List <VertexPositionTextureDataColor> >();
                m_DrawCommands.Add(effect, vls);
            }

            List <VertexPositionTextureDataColor> vl;

            if (vls.ContainsKey(texture))
            {
                vl = vls[texture];
            }
            else
            {
                if (m_QueuedVertexLists.Count > 0)
                {
                    vl = m_QueuedVertexLists.Dequeue();
                    vl.Clear();
                }
                else
                {
                    vl = new List <VertexPositionTextureDataColor>(1024);
                }
                vls.Add(texture, vl);
            }
            return(vl);
        }
Example #2
0
 public bool DrawSprite(EffectState effect, Texture2D texture, Vector3 position, Vector2 area, Vector4 uv, Color hue, Vector4 data)
 {
     List<VertexPositionTextureDataColor> vl = GetVLForThisEffectAndTexture(effect, texture);
     position += Depth.NextZ;
     PreTransformedQuad q = new PreTransformedQuad(position, area, uv, hue, data);
     for (int i = 0; i < q.Vertices.Length; i++)
     {
         vl.Add(q.Vertices[i]);
     }
     return true;
 }
Example #3
0
        public bool DrawSprite(EffectState effect, Texture2D texture, Vector3 position, Vector2 area, Vector4 uv, Color hue, Vector4 data)
        {
            List <VertexPositionTextureDataColor> vl = GetVLForThisEffectAndTexture(effect, texture);

            position += Depth.NextZ;
            PreTransformedQuad q = new PreTransformedQuad(position, area, uv, hue, data);

            for (int i = 0; i < q.Vertices.Length; i++)
            {
                vl.Add(q.Vertices[i]);
            }
            return(true);
        }
Example #4
0
 public void Render(EffectState effect, Matrix projection, Matrix view, Matrix world, Texture2D texture)
 {
     // set up graphics state
     m_Graphics.BlendState = BlendState.AlphaBlend;
     m_Graphics.DepthStencilState = DepthStencilState.Default;
     m_Graphics.SamplerStates[0] = effect.Sampler;
     m_Graphics.RasterizerState = new RasterizerState {
         ScissorTestEnable = true,
         CullMode = CullMode.None
     }; // RasterizerState.CullNone;
     m_Graphics.Textures[0] = texture;
     // set up effect state
     effect.Effect.Parameters["ProjectionMatrix"].SetValue(projection);
     effect.Effect.Parameters["ViewMatrix"].SetValue(view);
     effect.Effect.Parameters["WorldMatrix"].SetValue(world);
     effect.Effect.Parameters["Viewport"].SetValue(new Vector2(m_Graphics.Viewport.Width, m_Graphics.Viewport.Height));
     effect.Effect.CurrentTechnique.Passes[0].Apply();
     if (m_WorldTris.Count <= 0)
         return;
     m_Graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, m_WorldTris.Vertices, 0, m_WorldTris.Index, m_TriIndices, 0, m_WorldTris.Count);
     m_WorldTris.Reset();
 }
Example #5
0
 public void Render(EffectState effect, Matrix projection, Matrix view, Matrix world, Texture2D texture)
 {
     // set up graphics state
     m_Graphics.BlendState        = BlendState.AlphaBlend;
     m_Graphics.DepthStencilState = DepthStencilState.Default;
     m_Graphics.SamplerStates[0]  = effect.Sampler;
     m_Graphics.RasterizerState   = new RasterizerState {
         ScissorTestEnable = true,
         CullMode          = CullMode.None
     }; // RasterizerState.CullNone;
     m_Graphics.Textures[0] = texture;
     // set up effect state
     effect.Effect.Parameters["ProjectionMatrix"].SetValue(projection);
     effect.Effect.Parameters["ViewMatrix"].SetValue(view);
     effect.Effect.Parameters["WorldMatrix"].SetValue(world);
     effect.Effect.Parameters["Viewport"].SetValue(new Vector2(m_Graphics.Viewport.Width, m_Graphics.Viewport.Height));
     effect.Effect.CurrentTechnique.Passes[0].Apply();
     if (m_WorldTris.Count <= 0)
     {
         return;
     }
     m_Graphics.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, m_WorldTris.Vertices, 0, m_WorldTris.Index, m_TriIndices, 0, m_WorldTris.Count);
     m_WorldTris.Reset();
 }
Example #6
0
File: Curses.cs Project: pabru/YCPU
        public void Render(SpriteBatchExtended spriteBatch, EffectState effect, Vector2 offset)
        {
            const float sixteenth   = 1 / 16f;
            float       horizSpacer = m_AdditionalHorizSpacingPixel ? 1f : 0f;

            for (int y = 0; y < CharsHigh; y++)
            {
                for (int x = 0; x < CharsWide; x++)
                {
                    byte ch = m_CharBuffer[x + y * CharsWide];
                    if (ch == 0)
                    {
                        continue;
                    }
                    float u = ch % 16 * sixteenth;
                    float v = ch / 16 * sixteenth;
                    spriteBatch.DrawSprite(effect, m_Texture,
                                           new Vector3(offset.X + x * (OneCharWidth + horizSpacer), offset.Y + y * OneCharHeight, 0),
                                           new Vector2(OneCharWidth, OneCharHeight),
                                           new Vector4(u, v, u + sixteenth, v + sixteenth),
                                           Color.LightGray);
                }
            }
        }
Example #7
0
 public bool DrawSprite(EffectState effect, Texture2D texture, Vector3 position, Vector2 area, Vector4 uv, Color hue)
 {
     return DrawSprite(effect, texture, position, area, uv, hue, Vector4.Zero);
 }
Example #8
0
        private List<VertexPositionTextureDataColor> GetVLForThisEffectAndTexture(EffectState effect, Texture2D texture)
        {
            Dictionary<Texture2D, List<VertexPositionTextureDataColor>> vls;
            if (m_DrawCommands.ContainsKey(effect))
            {
                vls = m_DrawCommands[effect];
            }
            else
            {
                vls = new Dictionary<Texture2D, List<VertexPositionTextureDataColor>>();
                m_DrawCommands.Add(effect, vls);
            }

            List<VertexPositionTextureDataColor> vl;
            if (vls.ContainsKey(texture))
            {
                vl = vls[texture];
            }
            else
            {
                if (m_QueuedVertexLists.Count > 0)
                {
                    vl = m_QueuedVertexLists.Dequeue();
                    vl.Clear();
                }
                else
                {
                    vl = new List<VertexPositionTextureDataColor>(1024);
                }
                vls.Add(texture, vl);
            }
            return vl;
        }
Example #9
0
 public bool DrawSprite(EffectState effect, Texture2D texture, Vector3 position, Vector2 area, Vector4 uv, Color hue)
 {
     return(DrawSprite(effect, texture, position, area, uv, hue, Vector4.Zero));
 }
Example #10
0
        protected override void Initialize()
        {
            Registry = new ServiceRegistry();

            Registry.Register(m_SpriteBatch = new SpriteBatchExtended(this));
            m_SpriteBatch.Initialize();

            Registry.Register(m_InputManager = new InputManager(Window.Handle));

            m_InputProvider = new InputProvider(m_InputManager);
            m_DisplayProvider = new DisplayProvider(m_SpriteBatch);

            m_Emulator = new Emulator();
            m_Emulator.Initialize(m_DisplayProvider, m_InputProvider);
            m_Curses = new Curses(GraphicsDevice, c_ConsoleWidth, c_ConsoleHeight, c_CursesFont, true);
            m_Effect = new EffectState(m_SpriteBatch.LoadEffectContent("BasicEffect"), SamplerState.PointClamp);
            m_EffectCRT = new EffectState(m_SpriteBatch.LoadEffectContent("CRTEffect"), SamplerState.AnisotropicClamp);

            m_Graphics.PreferredBackBufferWidth = c_WindowW * 2;
            m_Graphics.PreferredBackBufferHeight = c_WindowH;
            m_Graphics.IsFullScreen = false;
            m_Graphics.ApplyChanges();
            IsMouseVisible = true;

            base.Initialize();

            SystemFunctions.SetFocus(Window.Handle);
        }
Example #11
0
 public void Render(SpriteBatchExtended spriteBatch, EffectState effect, Vector2 offset)
 {
     const float sixteenth = 1 / 16f;
     float horizSpacer = m_AdditionalHorizSpacingPixel ? 1f : 0f;
     for (int y = 0; y < CharsHigh; y++) {
         for (int x = 0; x < CharsWide; x++) {
             byte ch = m_CharBuffer[x + y * CharsWide];
             if (ch == 0)
                 continue;
             float u = ch % 16 * sixteenth;
             float v = ch / 16 * sixteenth;
             spriteBatch.DrawSprite(effect, m_Texture,
                 new Vector3(offset.X + x * (OneCharWidth + horizSpacer), offset.Y + y * OneCharHeight, 0),
                 new Vector2(OneCharWidth, OneCharHeight),
                 new Vector4(u, v, u + sixteenth, v + sixteenth),
                 Color.LightGray);
         }
     }
 }