Define the states used for drawing to a RenderTarget
Exemplo n.º 1
0
 public void Draw(Sfg.RenderTarget target, Sfg.RenderStates states)
 {
     foreach (var view in _views)
     {
         target.Draw(view, states);
     }
 }
Exemplo n.º 2
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="copy">States to copy</param>
 ////////////////////////////////////////////////////////////
 public RenderStates(RenderStates copy)
 {
     BlendMode = copy.BlendMode;
     Transform = copy.Transform;
     Texture = copy.Texture;
     Shader = copy.Shader;
 }
        public void Initialize()
        {
            SelectedShader = new Shader(null, "Shader/SelectedShader.frag");
            SelectedState = new RenderStates(SelectedShader);

            AddControls();
        }
Exemplo n.º 4
0
        public RenderTarget(SFML.Graphics.RenderTarget renderTarget)
        {
            this.renderTarget = renderTarget;
            m_VertexCache = new Vertex[CacheSize];

            m_RenderState = RenderStates.Default;
        }
Exemplo n.º 5
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            body.FillColor = data.FillColor;

            target.Draw(body);
            target.Draw(text);
        }
Exemplo n.º 6
0
        public override void Draw(RenderTarget target, RenderStates states)
        {
            states.Transform *= Transform;
            graphic.Draw(target, states);

            base.Draw(target, states);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SFML"/> class.
 /// </summary>
 /// <param name="target">SFML render target.</param>
 public SFML(RenderTarget target)
 {
     m_Target = target;
     m_VertexCache = new Vertex[CacheSize];
     m_RenderState = new RenderStates(BlendMode.Alpha);
         // somehow worked without this in previous SFML version (May 9th 2010)
 }
Exemplo n.º 8
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     var sprite = sprites[type];
     sprite.Position = new Vector2f(x, y);
     sprite.Rotation = rotation;
     target.Draw(sprite);
 }
Exemplo n.º 9
0
Arquivo: Map.cs Projeto: remy22/game-1
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(background, states);
     foreach (Layer l in layers) {
         target.Draw(l, states);
     }
 }
Exemplo n.º 10
0
        public void Draw(VertexArray vertices, RenderStates states) {
            if (!drawing) return;

            // Render states have changed, so flush and clear.
            if (!CompareStates(renderStates, states)) {
                Flush();
                vertexArray.Clear();
                renderStates = states;
            }

            // Exceeding maximum sprites, so flush and clear.
            if (DrawCount >= MaxSprites) {
                Flush();
                DrawCount = 0;
                vertexArray.Clear();
            }

            // Apply the transform to the four points
            var transform = states.Transform;
            
            // Append the vertices
            for (uint i = 0; i < vertices.VertexCount; i++) {
                var vertex = vertices[i];
                var pos = transform.TransformPoint(vertex.Position.X, vertex.Position.Y);
                vertex.Position.X = pos.X;
                vertex.Position.Y = pos.Y;
                vertexArray.Append(vertex);
            }

            DrawCount++;
            // I think that's it?
        }
Exemplo n.º 11
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            states.Transform.Combine(Transform);

            target.Draw(m_QuadArray, states);
            target.Draw(m_LineArray, states);
        }
Exemplo n.º 12
0
        public Menu()
            : base()
        {
            hoverCursor = Content.GetTexture("cursorHover.png");
            defaultCursor = Content.GetTexture("cursorPointer.png");
            currentCursor = defaultCursor;
            char1 = new Animation(Content.GetTexture("idle.png"), 4, 0, 0, true);
            char2 = new Animation(Content.GetTexture("char2_idle.png"), 4, 0, 0, true);
            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));

            rectConnect = new RectangleShape()
            {
                Size = new Vector2f(150, 30),
                Position = new Vector2f(-25, 70)
            };
            rectIP = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 40)
            };
            rectUsername = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 10)
            };

            MainGame.window.TextEntered += TextEnteredEvent;
        }
Exemplo n.º 13
0
        public Deathmatch()
            : base()
        {
            Projectiles = new List<Projectile>();
            BackgroundImages = new List<Sprite>();
            BackgroundImagesFar = new List<Sprite>();
            BackgroundTracks = new List<Sprite>();
            BackgroundGameObjects = new List<GameObject>();
            Players = new List<Actor>();
            Mailman = new ClientMailman(this);

            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));
            Image mapImg = new Image("Content/mapCol.png");
            mapBytes = mapImg.Pixels;
            mapSprite = new Sprite(new Texture(mapImg));
            mapWidth = (int)mapImg.Size.X;
            mapHeight = (int)mapImg.Size.Y;

            player = new ClientPlayer(this);
            player.Pos = new Vector2f(46, 62);
            Players.Add(player);

            trainSoundExterior = new SoundInstance(Content.GetSound("trainSpeed2.wav"), 1f, 0, 15, true);
            trainSoundInterior = new SoundInstance(Content.GetSound("trainSpeed0.wav"), 1, 0, 15, true);
            trainSound = trainSoundExterior;

            MainGame.Camera.Center = player.Pos - new Vector2f(0, 90);
        }
Exemplo n.º 14
0
 public void Draw(Sfg.RenderTarget target, Sfg.RenderStates states)
 {
     _score.DisplayedString = $"Score: {_gameplayState.Score}";
     target.Draw(_background);
     target.Draw(new WorldView(_gameplayState.World));
     target.Draw(new TerminoView(_gameplayState.World.CurrentPiece));
     target.Draw(_score);
 }
Exemplo n.º 15
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            if (_dirty)
                Rebuild();

            states.Transform *= Transform;
            target.Draw(_vertices, states);
        }
Exemplo n.º 16
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(rectangleShape);
     target.Draw(unitPictureBoxRenderer);
     target.Draw(healthBarRenderer);
     target.Draw(MoveButtonRenderer);
     target.Draw(AttackButtonRenderer);
 }
Exemplo n.º 17
0
 public ShieldGenerator(Vector2f position)
 {
     tex = Content.GetTexture("generatorStand.png");
     col = Content.GetTexture("genBlue.png");
     shader = new RenderStates(new Shader(null, "Content/shield.frag"));
     whenPlaced = DateTime.Now;
     Pos = position;
 }
Exemplo n.º 18
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            if (data.PictureSprite != null)
                curentPicture = data.PictureSprite;

            target.Draw(frame);
            target.Draw(curentPicture);
        }
Exemplo n.º 19
0
 private void DrawBackground(RenderTarget target, Texture background, Vector2f cameraPosition)
 {
     var renderState = new RenderStates(BlendMode.Add);
     var offset = new Vector2f(0.12f * cameraPosition.X % background.Size.X, 0.12f * cameraPosition.Y % background.Size.Y);
     renderState.Transform.Translate(-offset);
     var bgSprite = new Sprite(background, new IntRect(0, 0, (int)target.Size.X * 2, (int)target.Size.Y * 2));
     target.Draw(bgSprite, renderState);
 }
Exemplo n.º 20
0
   bool CompareStates(RenderStates a, RenderStates b) {
       if (a.Texture != b.Texture) return false;
       if (a.Shader != b.Shader) return false;
       if (a.BlendMode != b.BlendMode) return false;
       // Dont care about transform right now.
 
       return true;
   }
Exemplo n.º 21
0
 public FastTextureAtlas(TextureAtlas atlas)
 {
     TextureAtlas = atlas;
     _atlas = new Sprite(TextureAtlas.Texture);
     RenderTexture = new RenderTexture(atlas.Size, atlas.Size);
     RenderTexture.Draw(_atlas);
     RenderTexture.Display();
     _replace = new RenderStates(BlendMode.None, Transform.Identity, null, null);
 }
Exemplo n.º 22
0
 public void Draw(RenderTarget Target, RenderStates states)
 {
     states.Transform *= Transform;
     for (DrawListIndex = 0; DrawListIndex < Children.Count; DrawListIndex++)
     {
         if (!(Children[DrawListIndex] is DisplayObject) || Children[DrawListIndex].Visible)
             Children[DrawListIndex].Draw(Target, states);
     }
 }
Exemplo n.º 23
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            var bounds = Program.Camera.Bounds;
            var pos = Program.Camera.Position;

            _sprite.Position = pos - new Vector2f(bounds.Width / 2, bounds.Height / 2);
            _sprite.TextureRect = new IntRect((int)(pos.X % _texture.Size.X), (int)(pos.Y % _texture.Size.Y), (int)bounds.Width, (int)bounds.Height);
            target.Draw(_sprite);
        }
Exemplo n.º 24
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     target.Clear(Color.Black);
     target.Draw(_backgroundSprite);
     foreach (var w in Widgets)
     {
         target.Draw(w);
     }
 }
Exemplo n.º 25
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     if (vertices != null)
     {
         states.Transform *= Transform;
         states.Texture = texture;
         target.Draw(vertices, primitiveType, states);
     }
 }
Exemplo n.º 26
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(mapRenderer);
     for (int i = 0; i < UnitRenderers.Length; i++)
     {
         target.Draw(UnitRenderers[i]);
     }
     target.Draw(interfaceBarRenderer);
 }
Exemplo n.º 27
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            foreach (MenuItem item in menuItems)
            {
                target.Draw(item);
            }

            target.Draw(selectionPointer);
        }
Exemplo n.º 28
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     // Each tileset texture has a unique vertex array
     foreach (var v in verts) {
         Tileset tileset = Map.GetOwningTileset(v.Key);
         states.Texture = tileset.Texture;
         states.Transform = Map.Transform;
         target.Draw(v.Value, states);
     }
 }
Exemplo n.º 29
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            _paletteTexture.Update(_palette);
            _dataTexture.Update(_data);

            states.Transform *= Transform;
            states.Shader = _renderer;

            target.Draw(_display, states);
        }
Exemplo n.º 30
0
        public static RenderStates UsePhosphorGlow(Texture TexA, Texture TexB, float Sub)
        {
            if (PhosphorGlowStates.Shader == null)
                PhosphorGlowStates = new RenderStates(PhosphorGlow);

            PhosphorGlowStates.Shader.SetParameter("tex_a", TexA);
            PhosphorGlowStates.Shader.SetParameter("tex_b", TexB);
            PhosphorGlowStates.Shader.SetParameter("sub", Sub);
            return PhosphorGlowStates;
        }
Exemplo n.º 31
0
        public virtual void Draw(RenderTarget target, RenderStates states)
        {
            states.Transform *= this.Transform;
            DrawCurrent(target, states);

            foreach (SceneNode itr in mChildren)
            {
                itr.Draw(target, states);
            }
        }
Exemplo n.º 32
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            var worldStates = states;

            worldStates.Transform *= worldTransform;
            currentMap.Draw(target, worldStates);

            foreach (var actor in actors)
                actor.Draw(target, states);
        }
Exemplo n.º 33
0
        public SfmlRenderer(RenderWindow window, CommonResource resource, bool highResolution)
        {
            sfmlWindow = window;
            palette    = resource.Palette;

            colors = InitColors(palette);

            sfmlWindowWidth  = (int)window.Size.X;
            sfmlWindowHeight = (int)window.Size.Y;

            if (highResolution)
            {
                screen            = new DrawScreen(resource.Wad, 640, 400);
                sfmlTextureWidth  = 512;
                sfmlTextureHeight = 1024;
            }
            else
            {
                screen            = new DrawScreen(resource.Wad, 320, 200);
                sfmlTextureWidth  = 256;
                sfmlTextureHeight = 512;
            }

            sfmlTextureData = new byte[4 * screen.Width * screen.Height];

            try
            {
                sfmlTexture = new SFML.Graphics.Texture((uint)sfmlTextureWidth, (uint)sfmlTextureHeight);
                sfmlSprite  = new SFML.Graphics.Sprite(sfmlTexture);
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Capture(e).Throw();
            }

            sfmlSprite.Position = new Vector2f(0, 0);
            sfmlSprite.Rotation = 90;
            var scaleX = (float)sfmlWindowWidth / screen.Width;
            var scaleY = (float)sfmlWindowHeight / screen.Height;

            sfmlSprite.Scale = new Vector2f(scaleY, -scaleX);

            sfmlStates = new RenderStates(BlendMode.None);

            menu            = new MenuRenderer(resource.Wad, screen);
            threeD          = new ThreeDRenderer(resource, screen);
            statusBar       = new StatusBarRenderer(resource.Wad, screen);
            intermission    = new IntermissionRenderer(resource.Wad, screen);
            openingSequence = new OpeningSequenceRenderer(resource.Wad, screen, this);
            autoMap         = new AutoMapRenderer(screen);
        }
Exemplo n.º 34
0
        public Renderer()
        {
            blitState           = new SFML.Graphics.RenderStates();
            blitState.Transform = Transform.Identity;
            blitState.Shader    = null;
            blitState.BlendMode = BlendMode.Add;

            if (UsePlaceholderSprite)
            {
                placeholderSprite = new SFML.Graphics.Sprite();
            }
            rectSprite = new SFML.Graphics.Sprite();
        }
Exemplo n.º 35
0
        public void Draw(RenderTarget target, SRenderStates Renderstates)
        {
            if (Drawing)
            {
                throw new InvalidOperationException("Call End first.");
            }

            foreach (var item in QueuedTextures)
            {
                Renderstates.Texture   = item.Texture.SFMLTexture;
                Renderstates.BlendMode = (SBlendMode)BlendingSettings;

                item.Verticies.Draw(target, Renderstates);
            }
        }
Exemplo n.º 36
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Draw a drawable object to the render-target
 /// </summary>
 /// <param name="drawable">Object to draw</param>
 /// <param name="states">Render states to use for drawing</param>
 ////////////////////////////////////////////////////////////
 public void Draw(Drawable drawable, RenderStates states)
 {
     drawable.Draw(this, states);
 }
Exemplo n.º 37
0
        ////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw primitives defined by a sub-array of vertices
        /// </summary>
        /// <param name="vertices">Pointer to the vertices</param>
        /// <param name="start">Index of the first vertex to use in the array</param>
        /// <param name="count">Number of vertices to draw</param>
        /// <param name="type">Type of primitives to draw</param>
        /// <param name="states">Render states to use for drawing</param>
        ////////////////////////////////////////////////////////////
        public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type, RenderStates states)
        {
            RenderStates.MarshalData marshaledStates = states.Marshal();

            unsafe
            {
                fixed(Vertex *vertexPtr = vertices)
                {
                    sfRenderWindow_drawPrimitives(CPointer, vertexPtr + start, count, type, ref marshaledStates);
                }
            }
        }
Exemplo n.º 38
0
        public SfmlRenderer(Config config, RenderWindow window, CommonResource resource)
        {
            try
            {
                Console.Write("Initialize renderer: ");

                this.config = config;

                config.video_gamescreensize  = Math.Clamp(config.video_gamescreensize, 0, MaxWindowSize);
                config.video_gammacorrection = Math.Clamp(config.video_gammacorrection, 0, MaxGammaCorrectionLevel);

                sfmlWindow = window;
                palette    = resource.Palette;

                sfmlWindowWidth  = (int)window.Size.X;
                sfmlWindowHeight = (int)window.Size.Y;

                if (config.video_highresolution)
                {
                    screen            = new DrawScreen(resource.Wad, 640, 400);
                    sfmlTextureWidth  = 512;
                    sfmlTextureHeight = 1024;
                }
                else
                {
                    screen            = new DrawScreen(resource.Wad, 320, 200);
                    sfmlTextureWidth  = 320;
                    sfmlTextureHeight = 200;
                }

                sfmlTextureData = new byte[4 * screen.Width * screen.Height];

                sfmlTexture = new SFML.Graphics.Texture((uint)sfmlTextureWidth, (uint)sfmlTextureHeight);
                sfmlSprite  = new SFML.Graphics.Sprite(sfmlTexture);

                sfmlSprite.Position = new Vector2f(0, 0);
                sfmlSprite.Rotation = 90;
                var scaleX = (float)sfmlWindowWidth / screen.Width;
                var scaleY = (float)sfmlWindowHeight / screen.Height;
                sfmlSprite.Scale = new Vector2f(scaleY, -scaleX);

                sfmlStates = new RenderStates(BlendMode.None);

                menu            = new MenuRenderer(resource.Wad, screen);
                threeD          = new ThreeDRenderer(resource, screen, config.video_gamescreensize);
                statusBar       = new StatusBarRenderer(resource.Wad, screen);
                intermission    = new IntermissionRenderer(resource.Wad, screen);
                openingSequence = new OpeningSequenceRenderer(resource.Wad, screen, this);
                autoMap         = new AutoMapRenderer(resource.Wad, screen);
                finale          = new FinaleRenderer(resource, screen);

                pause = Patch.FromWad(resource.Wad, "M_PAUSE");

                var scale = screen.Width / 320;
                wipeBandWidth = 2 * scale;
                wipeBandCount = screen.Width / wipeBandWidth + 1;
                wipeHeight    = screen.Height / scale;
                wipeBuffer    = new byte[screen.Data.Length];

                palette.ResetColors(gammaCorrectionParameters[config.video_gammacorrection]);

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Exemplo n.º 39
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Draws the widget on the render target
 /// </summary>
 ///
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public override void Draw(SFML.Graphics.RenderTarget target, SFML.Graphics.RenderStates states)
 {
 }
Exemplo n.º 40
0
 public void Draw(Sfg.RenderTarget target, Sfg.RenderStates states)
 {
     target.Draw(_score, states);
 }
Exemplo n.º 41
0
 public void Draw(RenderTarget target, SRenderStates states)
 {
     Parent.Draw(target, states);
 }
Exemplo n.º 42
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Draw primitives defined by an array of vertices
 /// </summary>
 /// <param name="vertices">Pointer to the vertices</param>
 /// <param name="type">Type of primitives to draw</param>
 /// <param name="states">Render states to use for drawing</param>
 ////////////////////////////////////////////////////////////
 public void Draw(Vertex[] vertices, PrimitiveType type, RenderStates states)
 {
     Draw(vertices, 0, (uint)vertices.Length, type, states);
 }