コード例 #1
0
ファイル: BasicMaterial.cs プロジェクト: Hengle/Engine-Nine
        public BasicMaterial(GraphicsDevice graphics)
        {
            effect = GraphicsResources <BasicEffect> .GetInstance(graphics, typeof(BasicMaterial));

            pass           = effect.CurrentTechnique.Passes[0];
            GraphicsDevice = graphics;
        }
コード例 #2
0
        public AlphaTestMaterial(GraphicsDevice graphics)
        {
            GraphicsDevice = graphics;
            effect         = GraphicsResources <AlphaTestEffect> .GetInstance(graphics, typeof(AlphaTestMaterial));

            effect.ReferenceAlpha = Constants.ReferenceAlpha;
        }
コード例 #3
0
        public TextureMaterial(GraphicsDevice graphics)
        {
            effect = GraphicsResources <BasicEffect> .GetInstance(graphics, typeof(TextureMaterial));

            effect.LightingEnabled = false;
            pass           = effect.CurrentTechnique.Passes[0];
            GraphicsDevice = graphics;
        }
コード例 #4
0
 /// <summary>
 /// The main constructor for the class.
 /// </summary>
 public FrameRate(GraphicsDevice graphics, SpriteFont font)
 {
     this.Font            = font;
     this.GraphicsDevice  = graphics;
     this.UpdateFrequency = TimeSpan.FromSeconds(1);
     this.Color           = new Color(255, 255, 0, 255);
     this.Visible         = true;
     this.Scale           = 1;
     this.spriteBatch     = GraphicsResources <SpriteBatch> .GetInstance(GraphicsDevice);
 }
コード例 #5
0
ファイル: GameConsole.cs プロジェクト: Hengle/Engine-Nine
        public void Draw(float elapsedTime)
        {
            if (Font == null)
            {
                return;
            }

            SpriteBatch spriteBatch = GraphicsResources <SpriteBatch> .GetInstance(GraphicsDevice);

            spriteBatch.Begin();

            const int Border = 8;

            // Compute number of lines to be rendered
            int height    = (int)(FontSize + LineSpacing);
            int lineCount = messages.Count + 1;

            if (lineCount > MaxLines)
            {
                lineCount = MaxLines;
            }

            // Use Graphics.Clear to draw a background quad
            int y = GraphicsDevice.PresentationParameters.BackBufferHeight - lineCount * height - Border;

            // Draw text
            float fontScale = 1.0f * FontSize / (Font.MeasureString("A").Y - 10);
            int   i         = messages.Count - (lineCount - 1);

            if (i < 0)
            {
                i = 0;
            }

            for (; i < messages.Count; ++i)
            {
                spriteBatch.DrawString(
                    Font, messages[i], new Vector2(Border + 2, y), ForegroundColor, 0,
                    Vector2.Zero, fontScale, SpriteEffects.None, 0);

                y += height;
            }

            // Update text cursor
            currentBlinkTime += elapsedTime;

            if (currentBlinkTime > CursorBlinkInterval)
            {
                currentBlinkTime = -CursorBlinkInterval;
            }

            // Draw last line and text cursor
            // FIXME: Timing not working when game is paused
            if (currentBlinkTime < 0)
            {
                spriteBatch.DrawString(
                    Font, lastLine, new Vector2(Border + 2, y), ForegroundColor, 0,
                    Vector2.Zero, fontScale, SpriteEffects.None, 0);
            }
            else
            {
                spriteBatch.DrawString(
                    Font, lastLine + CursorText, new Vector2(Border + 2, y), ForegroundColor, 0,
                    Vector2.Zero, fontScale, SpriteEffects.None, 0);
            }

            spriteBatch.End();
        }
コード例 #6
0
 public DualTextureMaterial(GraphicsDevice graphics)
 {
     GraphicsDevice = graphics;
     effect         = GraphicsResources <DualTextureEffect> .GetInstance(graphics, typeof(DualTextureMaterial));
 }
コード例 #7
0
ファイル: SkinnedMaterial.cs プロジェクト: Hengle/Engine-Nine
 public SkinnedMaterial(GraphicsDevice graphics)
 {
     GraphicsDevice = graphics;
     effect         = GraphicsResources <SkinnedEffect> .GetInstance(graphics, typeof(SkinnedMaterial));
 }
コード例 #8
0
        private static SpriteBatch PrepareSprite(GraphicsDevice graphics, Effect effect)
        {
            SetViewport(effect as IEffectMatrices, graphics.Viewport.Bounds);

            return(GraphicsResources <SpriteBatch> .GetInstance(graphics));
        }
コード例 #9
0
 public SpriteBatchRenderer(GraphicsDevice graphics)
     : base(graphics)
 {
     spriteBatch = GraphicsResources <SpriteBatch> .GetInstance(graphics);
 }
コード例 #10
0
 public EnvironmentMapMaterial(GraphicsDevice graphics)
 {
     GraphicsDevice = graphics;
     effect         = GraphicsResources <EnvironmentMapEffect> .GetInstance(graphics, typeof(EnvironmentMapMaterial));
 }
コード例 #11
0
        public static void Draw(this SpriteBatch spriteBatch, Rectangle rect, Color color)
        {
            var texture = GraphicsResources <BlankTexture> .GetInstance(spriteBatch.GraphicsDevice);

            spriteBatch.Draw(texture.Texture, rect, color);
        }
コード例 #12
0
        public static void Draw(this SpriteBatch spriteBatch, Vector2 position, Vector2 scale, float rotation, Color color)
        {
            var texture = GraphicsResources <BlankTexture> .GetInstance(spriteBatch.GraphicsDevice);

            spriteBatch.Draw(texture.Texture, position, null, color, rotation, Vector2.Zero, scale, SpriteEffects.None, 0);
        }