public override void Draw(IGraphicsAdapter pSystem) { if (Background != null) { pSystem.DrawRect(Bounds, Background); } }
public static void Main() { ApplicationRuntime.Init(); MessageManager.OnDispatchError = OnDispatchError; MessageManager.OnMessageReceived = MessageReceived; fb = CreateFrameBuffer(); if (fb == null) { Console.WriteLine("No Framebuffer found"); ApplicationRuntime.Exit(0); } sur = new FramebufferSurface(fb); gfx = new GraphicsAdapter(sur); gfx.SetSource(0x00115F9F); gfx.Rectangle(0, 0, sur.Width, sur.Height); gfx.Fill(); SysCalls.RegisterService(SysCallTarget.Tmp_DisplayServer_CreateWindow); SysCalls.RegisterService(SysCallTarget.Tmp_DisplayServer_FlushWindow); SysCalls.SetServiceStatus(ServiceStatus.Ready); Console.WriteLine("DisplayServer ready"); while (true) { SysCalls.ThreadSleep(0); } }
public static unsafe void Main() { ApplicationRuntime.Init(); MessageManager.OnDispatchError = OnDispatchError; MessageManager.OnMessageReceived = MessageReceived; Console.WriteLine("Gui Demo starting"); var targetProcessID = SysCalls.GetProcessIDForCommand(SysCallTarget.Tmp_DisplayServer_CreateWindow); var windowData = (CreateWindowResult *)SysCalls.RequestMessageBuffer((uint)sizeof(CreateWindowResult), targetProcessID).Start; SysCalls.Tmp_DisplayServer_CreateWindow(ApplicationRuntime.CurrentProcessID, windowData, 200, 100); sur = new MemorySurface(windowData->Addr, windowData->Width, windowData->Height, windowData->Pitch, windowData->Depth); gfx = new GraphicsAdapter(sur); gfx.SetSource(0x0000FF00); gfx.Rectangle(0, 0, sur.Width, sur.Height); gfx.Fill(); SysCalls.Tmp_DisplayServer_FlushWindow(); Console.WriteLine("Gui Demo ready"); var direction = 1; var pos = 128; gfx.MoveTo(10, 10); gfx.LineTo(50, 70); while (true) { uint color = 0x0000FF00; uint mask = (uint)pos; uint newColor = color | mask; gfx.SetSource(newColor); gfx.Rectangle(0, 0, sur.Width, sur.Height); gfx.Fill(); gfx.SetSource(0x00FF0000); gfx.Stroke(); pos += direction; if (pos >= 255) { direction = -1; } else { if (pos <= 0) { direction = 1; } } SysCalls.Tmp_DisplayServer_FlushWindow(); //SysCalls.ThreadSleep(0); } }
public FrameBufferTextScreenDevice(IGraphicsAdapter dev) { this.dev = dev; Columns = dev.Target.Width / CharWidth; Rows = dev.Target.Height / CharHeight; SetupColors(); }
private RadialGradientBrush(Vector2 pCenter, Vector2 pDirection, IGraphicsAdapter pAdapter, params GradientColor[] pColor) { if (pAdapter.Method == RenderMethods.DirectX) { var dx = (DirectXAdapter)pAdapter; var prop = new RadialGradientBrushProperties() { Center = pCenter, RadiusX = pDirection.X, RadiusY = pDirection.Y }; GradientStop[] stops = new GradientStop[pColor.Length]; for (int i = 0; i < pColor.Length; i++) { stops[i].Color = pColor[i].Color; stops[i].Position = pColor[i].Position; } var grad = new GradientStopCollection(dx.Context, stops); _brush = new SharpDX.Direct2D1.RadialGradientBrush(dx.Context, ref prop, grad); _brush.Opacity = 1f; } else { throw new NotImplementedException(); } }
public override void Draw(IGraphicsAdapter pSystem) { if (!Enabled) { _brush.Color = DisabledColor; } else { switch (_state) { case ButtonState.Idle: _brush.Color = Color; break; case ButtonState.MouseDown: _brush.Color = MouseDownColor; break; case ButtonState.MouseOver: _brush.Color = MouseOverColor; break; default: throw new UnknownEnumException(typeof(ButtonState), _state); } } pSystem.DrawRect(Bounds, _brush); }
public void Draw(IGraphicsAdapter pSystem, float pDeltaTime) { if (Bitmap != null) { var t = Transform.Create(GameObject); pSystem.SetTransform(t); var position = GameObject.Position; if (_body != null) { position += _body.Velocity * pDeltaTime * GameTime.DeltaTime; //Interpolate position based on the amount of leftover update time } position = Game.ActiveCamera.ToCameraSpace(position); var scale = GameObject.Scale * Game.ActiveCamera.Zoom; if (Effect != null) { Effect.Draw(Bitmap, Opacity, position, scale); } else { pSystem.DrawBitmap(Bitmap, Opacity, position, scale); } } }
public override void Draw(IGraphicsAdapter pSystem) { base.Draw(pSystem); var w = Width * _percent; pSystem.DrawFillRect(new Rectangle(Position.X, Position.Y + 20, Width, 10), _background); pSystem.DrawFillRect(new Rectangle(Position.X + 1, Position.Y + 21, w, 8), _foreground); }
protected override void DoDraw(IGraphicsAdapter pSystem) { pSystem.DrawBitmap(Bitmap, Opacity, GameObject.ScreenPosition, GameObject.Scale * Game.ActiveCamera.Zoom, new Rectangle(_currentFrame * _frameSize.X, AnimationNum * _frameSize.Y, _frameSize.X, _frameSize.Y)); }
public override void Draw(IGraphicsAdapter pSystem) { pSystem.DrawRect(Bounds, _background); if (IsToggled) { pSystem.DrawRectOutline(Bounds, Border); } }
public override void Draw(IGraphicsAdapter pSystem) { base.Draw(pSystem); if (IsSelected) { pSystem.DrawRect(new Rectangle(Position, Width, Height), _highlightBrush, 3); } }
public override void Draw(IGraphicsAdapter pSystem) { pSystem.DrawRect(Bounds, Background); if (IsChecked) { pSystem.DrawLine(new Vector2(Bounds.Left, Bounds.Top), new Vector2(Bounds.Right, Bounds.Bottom), Foreground); pSystem.DrawLine(new Vector2(Bounds.Left, Bounds.Bottom), new Vector2(Bounds.Right, Bounds.Top), Foreground); } }
public override void Draw(IGraphicsAdapter pSystem) { var innerPos = new Vector2(Position.X + BorderThickness.Left, Position.Y + BorderThickness.Top); pSystem.DrawRect(new Rectangle(Position, ActualWidth, ActualHeight), Background); var scalar = Increment ? 1 - Progress : Progress; pSystem.DrawRect(new Rectangle(innerPos, (ActualWidth - BorderThickness.Width) * scalar, ActualHeight - BorderThickness.Height), Foreground); }
internal static void DrawUI(IGraphicsAdapter pAdapter) { for (int i = 0; i < _scenes.Count; i++) { var s = _scenes.PeekAt(i); if (s.Active) { s._ui.Draw(pAdapter); } } }
public override void Draw(IGraphicsAdapter pSystem) { _terrain.BitmapData(ref _image, _resolution); pSystem.DrawBitmap(_image, 1, Position, new Vector2(Width, Height)); var x = Game.ActiveCamera.Position * _ratio; var w = Game.ActiveCamera.Width * _ratio; var h = Game.ActiveCamera.Height * _ratio; pSystem.DrawRect(new Rectangle(Position.X + x.X, Position.Y + x.Y, w, h), _cameraOutline, 1); pSystem.DrawRect(new Rectangle(Position, Width, Height), _cameraOutline, 2); }
public override void Draw(IGraphicsAdapter pSystem) { pSystem.DrawRect(Bounds, Background); pSystem.DrawText(Text, Bounds, Font, true); //TODO clip, DrawTextLayout? if (_showCursor && IsFocused) { var s = Font.MeasureString(Text.Substring(0, _cursorPos), ActualWidth); var x = Bounds.Left + s.Width + 1; pSystem.DrawLine(new Vector2(x, Bounds.Top + 1), new Vector2(x, Bounds.Bottom - 1), Cursor); } }
private SolidColorBrush(Color pColor, IGraphicsAdapter pTarget) { if (pTarget.Method == RenderMethods.DirectX) { var dx = (DirectXAdapter)pTarget; _brush = new SharpDX.Direct2D1.SolidColorBrush(dx.Context, new SharpDX.Color4(pColor.R / 255f, pColor.G / 255f, pColor.B / 255f, pColor.A / 255f)); _brush.Opacity = pColor.A / 255f; } else { throw new NotImplementedException(); } }
private Font(string pFamily, float pSize, Color pColor, IGraphicsAdapter pAdapter) { if (pAdapter.Method == RenderMethods.DirectX) { var dx = (DirectXAdapter)pAdapter; _factory = dx.FactoryDWrite; Format = new TextFormat(dx.FactoryDWrite, pFamily, pSize); Brush = new SharpDX.Direct2D1.SolidColorBrush(dx.Context, pColor); } else { throw new NotImplementedException(); } }
internal void DrawInternal(IGraphicsAdapter pSystem) { if (_disposed) { return; } Draw(pSystem); foreach (var e in _orderedItems) { if (e.Visible == Visibility.Visible) { e.DrawInternal(pSystem); } } }
public override void Draw(IGraphicsAdapter pSystem) { //Draw labels var y = Bounds.Top + ((ActualHeight - BarHeight) / 2); pSystem.DrawText(Min.ToString(), new Rectangle(Position.X, y, _labelWidth, ActualHeight), LabelFont); pSystem.DrawText(Max.ToString(), new Rectangle(_barBounds.Right, y, _labelWidth, ActualHeight), LabelFont); //Draw slider pSystem.DrawRect(_barBounds, Bar); pSystem.DrawElipse(_sliderPosition, _sliderRadius, Grip); //Show value if sliding if (_dragging) { pSystem.DrawText(Value.ToString(), new Rectangle(_sliderPosition, _labelWidth, ActualHeight), LabelFont); } }
internal void Draw(IGraphicsAdapter pSystem) { //We update and draw at the same time because GameObjects will often manipulate UI elements //So if we arrange before those updates can happen it can cause a frame of misplaced items var bounds = new Rectangle(0, 0, Game.Form.Width, Game.Form.Height); pSystem.ResetTransform(); foreach (var e in _elements) { e.Arrange(bounds); if (e.Visible == Visibility.Visible) { e.DrawInternal(pSystem); } } _measureInvalid = false; }
public void Draw(IGraphicsAdapter pSystem) { int x = (int)(Evolusim.ActiveCamera.Position.X / BitmapSize); int y = (int)(Evolusim.ActiveCamera.Position.Y / BitmapSize); float numTilesX = Game.Form.Width / (BitmapSize * Game.ActiveCamera.Zoom); float numTilesY = Game.Form.Height / (BitmapSize * Game.ActiveCamera.Zoom); //Width and height should be the same var startPoint = Evolusim.ActiveCamera.ToCameraSpace(new Vector2(x * BitmapSize, y * BitmapSize)); Vector2 scale = new Vector2(BitmapSize) * Game.ActiveCamera.Zoom; var currentX = startPoint.X; var currentY = startPoint.Y; var maxX = Math.Min(x + numTilesX + 3, Size); var maxY = Math.Min(y + numTilesY + 3, Size); for (int i = x; i < maxX; i++) { for (int j = y; j < maxY; j++) { int tileCount = 0; TerrainType type = GetTerrainType(i, j); var brush = GetBrush(i, j); while (j < maxY && type == GetTerrainType(i, j)) { tileCount++; j++; } var height = scale.Y * tileCount; pSystem.DrawFillRect(new Rectangle(currentX, currentY, scale.X + 1, height + 1), brush); currentY += height; j--; } currentY = startPoint.Y; currentX += scale.X; } }
protected override void DoDraw(IGraphicsAdapter pSystem) { //TODO make a custom component that handles rendering this? var scale = new Vector2(GameObject.Scale.X / 2, GameObject.Scale.Y / 2) * Game.ActiveCamera.Zoom; var pos = GameObject.ScreenPosition + new Vector2(scale.X / 2, -scale.Y / 2); if (_currentStatus.HasFlag(Status.Scared)) { pSystem.DrawBitmap(_scared, 1, pos, scale); } else if (_currentStatus.HasFlag(Status.Sleeping)) { pSystem.DrawBitmap(_sleep, 1, pos, scale); } else if (_currentStatus.HasFlag(Status.Hungry)) { pSystem.DrawBitmap(_hungry, 1, pos, scale); } else if (_currentStatus.HasFlag(Status.Mating)) { pSystem.DrawBitmap(_heart, 1, pos, scale); } }
public override void Draw(IGraphicsAdapter pSystem) { pSystem.DrawText(Text, Bounds, Font); }
protected override void DoDraw(IGraphicsAdapter pSystem, Effect pEffect) { throw new NotImplementedException(); }
public RenderPipelineSystem(World world, IGraphicsAdapter graphics) : base(world) { RenderingPipeline = new ForwardRenderingPipeline(graphics); this.graphics = graphics; }
public OpenGLHost() { this.adapter = new OpenGLGraphicsAdapter(); }
public override void Draw(IGraphicsAdapter pSystem) { pSystem.DrawBitmap(_bitmap, 1, Position, Bounds.Size); }
public RenderSystem(IGraphicsAdapter pAdapter) : base(typeof(RenderComponent)) { _adapter = pAdapter; }
public DebugRenderSystem(IGraphicsAdapter pAdapter) : base(typeof(ColliderComponent)) { _adapter = pAdapter; DebugBoxes = Pen.Create(Color.Aqua, 1); }