public void Draw(Renderer2D renderer, Matrix cam) { hope.CalculateLightmap(renderer, cam, PixelSize, new Color(51, 51, 51)); for (int i = 0; i < Layers.Length; i++) { Layers[i].Draw(renderer); } renderer.End(); renderer.Begin(LightHelper.Multiply, cam); hope.Draw(renderer); renderer.End(); renderer.Begin(cam); }
public override void Draw(Renderer2D renderer, GameTime time) { renderer.Begin(cam.Transform); TimeWatcher.Start("Map.Draw"); w.map.Draw(renderer, cam.Transform); TimeWatcher.End(); renderer.End(); if (debug) { renderer.Begin(cam.Transform); DebugRenderer.DrawWorld(renderer, time); renderer.End(); renderer.Begin(); DebugRenderer.DrawScreen(renderer, time); renderer.End(); } }
protected override void OnRender(GameTime gameTime) { var transform = Matrix4x4.CreateOrthographicOffCenter(0, App.Window.Width, App.Window.Height, 0, -1, 1); _renderer.ProjectionMatrix = transform; _renderer.Begin(); _renderer.DrawString(_font, _fps, Vector2.Zero, Color.White); _renderer.End(); }
public void OnRender() { m_Renderer2D.Begin(); m_RenderSystem.Update(m_EntityManager); OnRender(m_Renderer2D); m_Renderer2D.End(); m_Renderer2D.Present(); }
protected override void OnRender(GameTime gameTime) { // TODO: word-wrap var text = _text; var measure = _font.MeasureString(text); var rect = new Rectangle(0, App.Window.Height - measure.Y, App.Window.Width, measure.Y); _renderer.ProjectionMatrix = Matrix4x4.CreateOrthographicOffCenter(0, App.Window.Width, App.Window.Height, 0, -1, 1); _renderer.Begin(); _renderer.FillRectangle(rect, Color.Gray); _renderer.DrawString(_font, text, rect.Location, Color.White); _renderer.End(); }
public CharlieWindow(int width, int height, Action <Window, Renderer2D> onDraw) { _onDrawAction = onDraw; Panel = new Panel(); Panel.Width = width; Panel.Height = height; Panel.Dock = DockStyle.Fill; Panel.BackColor = System.Drawing.Color.Black; Panel.Location = new System.Drawing.Point(0, 0); Panel.Click += (object o, EventArgs e) => { Panel.Parent.Select(); }; var screenDimensions = Screen.FromControl(Panel).Bounds; WindowConfig config = new WindowConfig(screenDimensions.Width, screenDimensions.Height, "", WindowFlags.Borderless | WindowFlags.PositionOrigin); NativeWindow = new Window(config); NativeWindow.SetClearColor(0.1f, 0.2f, 0.3f, 1.0f); Timer timer = new Timer(); timer.Interval = 1000 / 120; _renderer = new Renderer2D(); _renderer.Initalize(Matrix4.Orthographic(screenDimensions.Width, 0, 0, screenDimensions.Height, 1, -1)); Font font = new Font("Assets/WendyOne-Regular.ttf", 38); timer.Tick += (object o, EventArgs e) => { NativeWindow.PollEvents(); NativeWindow.Clear(); _renderer.Begin(); _onDrawAction(NativeWindow, _renderer); _renderer.End(); _renderer.Present(); NativeWindow.SwapBuffers(); }; Panel.Disposed += (object o, EventArgs e) => { _renderer.Dispose(); }; timer.Start(); Win32.SetWindowPos(NativeWindow.GetHWND(), IntPtr.Zero, 0, 0, 0, 0, Win32.SWP_NOSIZE); Win32.SetParent(NativeWindow.GetHWND(), Panel.Handle); Win32.SetWindowLong(NativeWindow.GetHWND(), Win32.GWL_STYLE, (uint)Win32.WS_CHILD); }
public void Draw(Renderer2D renderer, Matrix cam, Rectangle areaOfInfluence) { renderTarget?.Dispose(); renderTarget = new RenderTarget2D(renderer.GraphicsDevice, areaOfInfluence.Width, areaOfInfluence.Height); oldRenderTargets = renderer.GraphicsDevice.GetRenderTargets(); renderer.GraphicsDevice.SetRenderTarget(null); renderer.GraphicsDevice.SetRenderTarget(renderTarget); renderer.GraphicsDevice.Clear(Color.TransparentBlack); renderer.End(); renderer.Begin(); int x; int y; int[] data; TileSet tileSet; int actualData; Rectangle sourceRectangle; foreach (var layer in map.Layers) { data = layer.GetRawData(); for (int i = 0; i < data.Length; i++) { if (data[i] == 0) { continue; } x = 16 * (i % map.TileSize.X); y = 16 * (i / map.TileSize.X); if (x + 16 < areaOfInfluence.X || y + 16 < areaOfInfluence.Y || x - 16 > areaOfInfluence.Right || y - 16 > areaOfInfluence.Bottom) { continue; } tileSet = tileSetsShadow.TileSets.FirstOrDefault(t => t.Name == tileSetsMap.IndexToTileSet(data[i]).Name + "_shadow"); if (tileSet == null) { continue; } actualData = tileSetsMap.ShortenIndex(data[i]) + 1; if (tileSetsMap.IsAnimation(data[i])) { var tile = animatedTileLightings.FirstOrDefault(t => t.Index == new DataTypes.Index2((i % map.TileSize.X), (i / map.TileSize.X))); renderer.Draw(tile.Current(), new Rectangle(x - areaOfInfluence.X, y - areaOfInfluence.Y, 16, 16), Color.White); continue; } sourceRectangle = tileSetsShadow.GetSourceRectangle(actualData); renderer.Draw(tileSet.Texture, new Rectangle(x - areaOfInfluence.X, y - areaOfInfluence.Y, 16, 16), sourceRectangle, Color.White); //16 // } } renderer.End(); renderer.GraphicsDevice.SetRenderTarget(null); renderer.GraphicsDevice.SetRenderTargets(oldRenderTargets); renderer.Begin(cam); using (FileStream fs = new FileStream("obstacles.png", FileMode.Create)) renderTarget.SaveAsPng(fs, renderTarget.Width, renderTarget.Height); }