public Edge() : base("edge post-effect") { // Create the off-screen surface mySurface = new RenderTexture(800, 600); mySurface.Smooth = true; // Load the textures myBackgroundTexture = new Texture("resources/sfml.png"); myBackgroundTexture.Smooth = true; myEntityTexture = new Texture("resources/devices.png"); myEntityTexture.Smooth = true; // Initialize the background sprite myBackgroundSprite = new Sprite(myBackgroundTexture); myBackgroundSprite.Position = new Vector2f(135, 100); // Load the moving entities myEntities = new Sprite[6]; for (int i = 0; i < myEntities.Length; ++i) { myEntities[i] = new Sprite(myEntityTexture, new IntRect(96 * i, 0, 96, 96)); } // Load the shader myShader = new Shader(null, "resources/edge.frag"); myShader.SetParameter("texture", Shader.CurrentTexture); }
public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { base.Draw(tex, scroll, shadow); if (active) { text.Font = TextureMan.Font; text.CharacterSize = 8; text.Position = new Vector2f(320 / 2.0f, 20); FloatRect textRect = text.GetLocalBounds(); text.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); text.DisplayedString = InfoString; if (shadow) { text.Color = new Color(20, 20, 20, 40); text.Position = new Vector2f(text.Position.X - 1, text.Position.Y - 1); } else { int d; if (c * 10 > 255) d = 255; else d = c * 10; text.Color = new Color(255, 255, 255, (byte)(d)); } tex.Draw(text); } }
public static bool CreateShadows() { Image img = spriteSheet.Texture.CopyToImage(); for (uint k = 0; k < img.Size.X; k++) for (uint j = 0; j < img.Size.Y; j++) { Color c = img.GetPixel(k, j); if (c.A == 255) { Color d = new Color(); d.A = 40; d.R = d.G = d.B = 0; img.SetPixel(k, j, d); } } Texture tex = new Texture(img); Sprite tempsprite = new Sprite(); tempsprite.Texture = tex; shadowSpriteSheet = new RenderTexture(textureSize, textureSize); shadowSpriteSheet.Draw(tempsprite); shadowSpriteSheet.Display(); shadowSprite.Texture = shadowSpriteSheet.Texture; img.Dispose(); tempsprite.Dispose(); tex.Dispose(); return true; }
public Map(string name, Vector2i size, int cellSize = 32) { Name = name; Size = size; CellSize = cellSize; Center = new Vector2f(); Layer0Cells = new MapCell[size.X, size.Y]; Layer1Cells = new MapCell[size.X, size.Y]; Layer2Cells = new MapCell[size.X, size.Y]; for (var x = 0; x < Size.X; x++) { for (var y = 0; y < Size.Y; y++) { Layer0Cells[x, y] = new MapCell(); Layer1Cells[x, y] = new MapCell(); Layer2Cells[x, y] = new MapCell(); } } _entities = new List<Entity>(); _lights = new List<PointLight>(); AmbientLightColor = Color.White; _lightTexture = new RenderTexture((uint) (size.X * cellSize), (uint) (size.Y * cellSize)); _lightSprite = new Sprite(_lightTexture.Texture); }
public BloomTest(RenderTexture target_tex, RenderTarget target) { _target = target; _bloom = new Shader(null, "bloom.glsl"); _texture = new RenderTexture((uint)GlobalProps.Width, (uint)GlobalProps.Height); _states.BlendMode = BlendMode.Alpha; _states.Shader = _bloom; _states.Transform = Transform.Identity; _states.Texture = target_tex.Texture; _bloom.SetParameter("referenceTex", Shader.CurrentTexture); _bloom.SetParameter("pixelWidth", 4); _bloom.SetParameter("pixelHeight", 4); int w = GlobalProps.Width, h = GlobalProps.Height; Vector2f v0 = new Vector2f(0, 0); Vector2f v1 = new Vector2f(w, 0); Vector2f v2 = new Vector2f(w, h); Vector2f v3 = new Vector2f(0, h); _verts = new Vertex[4]; _verts[0] = new Vertex(v0, Color.White, v0); _verts[1] = new Vertex(v1, Color.White, v1); _verts[2] = new Vertex(v2, Color.White, v2); _verts[3] = new Vertex(v3, Color.White, v3); }
public FboTest() { Text = new Text("", new Font("lekton.ttf"), 20) { Color = Color.White, Position = new Vector2f(10, 10), }; textureOne = new SFML.Graphics.RenderTexture(32, 32); textureTwo = new SFML.Graphics.RenderTexture(640, 480); textureThree = new SFML.Graphics.RenderTexture(640, 480); shapeTwo = new RectangleShape(new Vector2f(20, 20)) { FillColor = Color.Red, }; shapeThree = new RectangleShape(new Vector2f(40, 40)) { FillColor = new Color(0, 0, 0, 30), Origin = new Vector2f(20, 20) }; window = new RenderWindow(new VideoMode(640, 480), "SFML.Net RenderTexture FBO bug spike", Styles.Default, new ContextSettings { DepthBits = 32 }); window.SetActive(); window.Closed += OnClosed; window.KeyPressed += OnKeyPressed; }
public static void Main(String[] args) { RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title"); RenderTexture tex = new RenderTexture(1000, 700); Sprite texSprite = new Sprite(tex.Texture); Fractal fractal = new Fractal(); fractal.CreateTreeFractal(500, 700, 3, 100, 0); Console.WriteLine(fractal.Nodes.Count); while (window.IsOpen()) { window.Clear(); tex.Clear(new Color(0, 0, 0, 200 )); foreach (Shape s in fractal.Nodes) { window.Draw(s); } tex.Display(); window.Draw(texSprite); window.Display(); Image img = window.Capture(); img.SaveToFile("C:/i.png"); Console.ReadLine(); } }
static HWSurfaceInstance() { _atlas = new RenderTexture(_aw, _ah); _atlastex = _atlas.Texture; _batch = new SpriteBatch(_atlas); _batch.SetBlendMode(BlendMode.None); }
public void Draw(RenderTexture texture) { Vertex[] lines = new Vertex[(endAngle - startAngle) * 2]; for(int i = startAngle; i < endAngle; i+=2) { Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i)); lines[i] = new Vertex(position, new Color(color.R, color.G, color.B, 255)); lines[i+1] = new Vertex(position + (heading * radius), new Color(color.R, color.G, color.B, 0)); } texture.Draw(lines, 0, (uint)(endAngle - startAngle) * 2, PrimitiveType.Lines, new RenderStates(BlendMode.Multiply)); /* VertexArray shape = new VertexArray(PrimitiveType.Points, (uint)(endAngle - startAngle) * 2); shape.Append(new Vertex(position)); for(int i = startAngle; i < endAngle; i++) { Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i)); heading = Util.Vector.norm(heading); shape.Append(new Vertex(position + (heading * radius))); } shape.Append(new Vertex(position)); texture.Draw(shape, new RenderStates(BlendMode.None));*/ }
public MapGraphicsComponent(TmxMap Map) { var tileWidth = Map.Tilesets.Single().TileWidth; var tileHeight = Map.Tilesets.Single().TileHeight; var tileSpacing = Map.Tilesets.Single().Spacing; var tileMargins = Map.Tilesets.Single().Margin; texture = new RenderTexture((uint)(Map.Width * tileWidth), (uint)(Map.Height * tileHeight)); foreach (var layer in Map.Layers) { foreach (var tile in layer.Tiles) { var columns = (int)tileset.Texture.Size.X / (tileWidth + tileSpacing); int x = (tile.Gid - 1) % columns, y = (tile.Gid - 1) / columns; tileset.TextureRect = new IntRect(x * (tileWidth + tileSpacing) + tileMargins, y * (tileHeight + tileSpacing) + tileMargins, tileWidth, tileHeight); tileset.Position = new Vector2f(tile.X * tileWidth, tile.Y * tileHeight); texture.Draw(tileset); } } texture.Display(); Sprite = new Sprite(texture.Texture); }
private void SetupGrid(Vector2u mapSize) { const int gridSize = 16; _gridTexture = new RenderTexture(2000, 2000); var col = new Color(120, 120, 120); var verticies = new List<Vertex>(); for (int x = 0; x < mapSize.X; x += gridSize) { verticies.Add(new Vertex(new Vector2f(x, 0), col)); verticies.Add(new Vertex(new Vector2f(x, mapSize.Y), col)); } for (int y = 0; y < mapSize.Y; y += gridSize) { verticies.Add(new Vertex(new Vector2f(0, y), col)); verticies.Add(new Vertex(new Vector2f(mapSize.X, y), col)); } _gridlines = verticies.ToArray(); _gridTexture.Clear(new Color(190, 190, 190)); //_view = new View(new FloatRect(0,0,displaySize.X, displaySize.Y)); _view = new View(new FloatRect(0, 0, DisplayView.Size.X, DisplayView.Size.Y)); DisplayView = _view; //_gridTexture.SetView(_view); _gridTexture.Draw(_gridlines, PrimitiveType.Lines); _gridTexture.Display(); _grid = new Sprite(_gridTexture.Texture); AddItemToDraw(_grid, 0); }
public GameManager(RenderWindow window, Display startingDisplay) { this.window = window; ActiveDisplay = startingDisplay; tex = new RenderTexture(window.Size.X, window.Size.Y); }
private void GenerateSprite() { texture = new RenderTexture((uint)box.Width, (uint)box.Height); drawText = new Text(text, font); drawText.Color = foreground; texture.Draw(drawText); sprite = new Sprite(texture.Texture); }
public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { base.Draw(tex, scroll, shadow); if (shadow) { line.Size = new Vector2f(2, hookPosY); line.Position = new Vector2f(hookPosX + 31 + Position.X - 2, Position.Y - 72 - 2); line.Position -= scroll; line.FillColor = new Color(0, 0, 0, 40); line.OutlineColor = new Color(20, 20, 20); tex.Draw(line); } for (int i = 0; i < 5; i++) { DrawSegment("cranesegment", new Vector2f(Position.X, Position.Y - i * 16 - 16), scroll, tex, shadow); } for (int i = 0; i < 7; i++) { DrawSegment("cranesegment", new Vector2f(Position.X + i * 16 + 16, Position.Y - (16 * 5)), scroll, tex, shadow); } DrawSegment("cranehook", new Vector2f(Position.X + 32 + hookPosX, Position.Y - 64 + hookPosY), scroll, tex, shadow); if (!shadow) { line.Size = new Vector2f(2, hookPosY); line.Position = new Vector2f(hookPosX + 31 + Position.X, Position.Y - 72); line.Position -= scroll; line.FillColor = new Color(20, 20, 20); line.OutlineColor = new Color(20, 20, 20); tex.Draw(line); } }
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); }
public TDCommon(GameWindow mGameWindow) { _gameWindow = mGameWindow; _floorSprite = new Sprite(Assets.GetTexture(@"environment\floor\gray")) {Texture = {Repeated = true}}; GUI = new TDGUI(mGameWindow.RenderWindow); SelectionSprite = new Sprite(Assets.GetTexture(@"selection")); GameTexture = new RenderTexture(1024, 768) {Smooth = true}; GameSprite = new Sprite(GameTexture.Texture); }
public GameManager(RenderWindow window) { _window = window; // blank display ActiveDisplay = new Display(new Vector2u(window.Size.X, window.Size.Y)); tex = new RenderTexture(window.Size.X, window.Size.Y); }
/// <summary> /// .ctor /// </summary> public ScreenSaverEngine(ScreenSaverSettings settings) { _viewPorts = new ViewPortCollection(settings.IsFullscreen, settings.IsMultiMonitorEnabled); _canvas = new RenderTexture((uint) _viewPorts.WorkingArea.Width, (uint) _viewPorts.WorkingArea.Height, false); _canvas.Clear(Color.Black); _canvas.Display(); // Needed due to FBO causing inverted co-ords otherwise _chrono = new Chrono(); _fpsLimiter = new FpsLimiter(settings.MaxFps); }
public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { if (!activated) DrawSegment("detonatorhandle", new Vector2f(Position.X, Position.Y - 2), scroll, tex, shadow); else DrawSegment("detonatorhandle", new Vector2f(Position.X, Position.Y), scroll, tex, shadow); base.Draw(tex, scroll, shadow); }
public Lighting(Game game) { this.game = game; lights = new List<Light>(); lightTexture = new RenderTexture(game.Window.Size.X, game.Window.Size.Y); lightStates = new RenderStates(RenderStates.Default); //lightStates.BlendMode = BlendMode.None; }
public MainMenuView() { scene = new Scene(ScrollInputs.None); (playButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png") { Position = new Vector2f(500, 200), Size = new Vector2f(280, 49), Text = "Play", Anchor = AnchorPoints.Left | AnchorPoints.Top }).OnClick += PlayButton_OnClick; (settingsButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png") { Position = new Vector2f(500, 260), Size = new Vector2f(280, 49), Text = "Settings", Anchor = AnchorPoints.Left | AnchorPoints.Top }).OnClick += SettingsButton_OnClick; (quitButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png") { Position = new Vector2f(500, 320), Size = new Vector2f(280, 49), Text = "Quit", Anchor = AnchorPoints.Left | AnchorPoints.Top }).OnClick += QuitButton_OnClick; scene.AddComponent(playButton); scene.AddComponent(settingsButton); scene.AddComponent(quitButton); particles = new IndexedParticleSystem(); particle = new Sprite(new Texture("Content/particle.png")); particle.Origin = new Vector2f(32, 32); particleEmitter = new Emitter(); particleEmitter.Position = new Vector2f(50, 50); particleEmitter.ParticlesSpawnRate = 200; particleEmitter.Spread = 30; particleEmitter.Color = Color.Blue; particles.AddEmitter(particleEmitter); greenEmitter = new Emitter(); greenEmitter.Position = new Vector2f(50, 50); greenEmitter.ParticlesSpawnRate = 150; greenEmitter.Spread = 30; greenEmitter.Color = Colors.Lime; particles.AddEmitter(greenEmitter); bg = new Sprite(); particleTexture = new RenderTexture(1280, 720); particleTexture.Clear(Color.Blue); }
public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { base.Draw(tex, scroll, shadow); for (int i = 0; i < 3; i++) { DrawSegment("laddersegment", new Vector2f(Position.X, Position.Y - 16 - i * 16), scroll, tex, shadow); } }
public MiniMap(Level.TileMap tileMap, FogOfWar fog, Dictionary<ushort, Entities.EntityBase> entities ) { Team = 0; Entities = entities; TileMap = tileMap; Fog = fog; CameraPosition = new Vector2f(0, 0); renderTexture = new RenderTexture(SIZEX, SIZEY); MapSprite = new Sprite(renderTexture.Texture); }
protected void DrawSegment(string name, Vector2f pos, Vector2f scroll, RenderTexture tex, bool shadow) { Spr = TextureMan.GetSprite(name, shadow); Spr.Position = pos; if (shadow) Spr.Position = new Vector2f(pos.X - 2, pos.Y - 2); Spr.Position -= scroll; Spr.Origin = new Vector2f(8, 8); Spr.Scale = new Vector2f(1 * scaleX, 1 * scaleY); tex.Draw(Spr); }
public DrawableBase(Vector2u displaySize) { toUpdate = new List<IUpdatable>(); toDraw = new Dictionary<uint, List<Drawable>>(); _targetSpr = new Sprite(); BackgroundColor = Color.Transparent; Target = new RenderTexture(displaySize.X, displaySize.Y) { Smooth = true }; }
public FastText(Font font, uint size) { textObject = new Text("Set Text Property", font, size); renderSprite = new Sprite(); TextSize = size; TextAlignment = Alignment.TopLeft; Size = new Vector2f(50, 50); Anchor = AnchorPoints.None; Padding = new FloatRect(3, 3, 3, 3); BackgroundColor = Color.Transparent; renderContainer = new RenderTexture((uint)Size.X, (uint)Size.Y); }
/// <summary> /// Funkcja generuje teksture przycisku. /// </summary> /// <param name="width">Dlugosc przycisku</param> /// <param name="height">Wysokosc przycisku</param> /// <param name="color">Color przycisku</param> /// <returns>Wygenerowana tekstura</returns> public static Texture ButtonTexture(uint width, uint height, Color color) { RenderTexture renderTexture = new RenderTexture(height, width); renderTexture.Clear(Color.Transparent); RectangleShape fill = new RectangleShape(new Vector2f(height-4, width-4)) { FillColor = color, Position = new Vector2f(2, 2), OutlineThickness = 2, OutlineColor = Color.Black, }; renderTexture.Draw(fill); return new Texture(renderTexture.Texture) { Smooth = true }; }
public GlyphStreamManager(GlyphStreamManagerConfig settings, Vector2u workingArea) { _workingArea = workingArea.ToRectangle(); streams = new List<GlyphStream>(); _settings = settings; if (!string.IsNullOrEmpty(settings.ShaderType)) // TODO: configurable shader { shader = ShaderWrapper.Get(settings.ShaderType); tempCanvas = new RenderTexture(workingArea.X, workingArea.Y, true); tempCanvas.Display(); } _maximumStreams = settings.MaximumGlyphStreams; _chanceOfNewStream = settings.ChanceOfNewGlyphStream; }
public HWSurfaceInstance(ScriptEngine parent, string filename) : base(parent.Object.InstancePrototype) { using (Texture tex = new Texture(filename)) { _width = tex.Size.X; _height = tex.Size.Y; _tex = new RenderTexture(_width, _height); _myBatch = new SpriteBatch(_tex); _myBatch.SetBlendMode(BlendMode.None); _myBatch.Add(tex, 0, 0); _myBatch.Flush(); Update(); } Init(); }
public SpaceInvadersScreen(string title, Game parent) : base(title, parent) { backgroundMusic.Play(); SetupHUD(); laneWidth = parent.Size.X / numberOfLanes; player = new Player(new Vector2f(Parent.Size.X * 0.5f, parent.Size.Y - 20), AssetsManager.Textures["ship"]); player.Scale *= 0.5f; playerHitSound.SoundBuffer = AssetsManager.Sounds["playerHit"]; explosionSound.SoundBuffer = AssetsManager.Sounds["explosion"]; spriteBatchTexture = new RenderTexture((uint)(parent.Size.X), (uint)(parent.Size.Y)); spriteBatch = new Sprite(spriteBatchTexture.Texture); }
public HWSurfaceInstance(ScriptEngine parent, int width, int height, Color bg_color) : base(parent.Object.InstancePrototype) { Console.WriteLine("Create surf: {0}x{1} {2}", width, height, bg_color); if (width <= 0) throw new ArgumentOutOfRangeException("width", "Width must be > 0."); _width = (uint)width; if (height <= 0) throw new ArgumentOutOfRangeException("height", "Height must be > 0."); _height = (uint)height; _tex = new RenderTexture(_width, _height); _tex.Clear(bg_color); Init(); }