コード例 #1
0
 public override void Draw(IGraphicsAdapter pSystem)
 {
     if (Background != null)
     {
         pSystem.DrawRect(Bounds, Background);
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: abanu-org/app-guidemo
        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);
            }
        }
コード例 #4
0
 public FrameBufferTextScreenDevice(IGraphicsAdapter dev)
 {
     this.dev = dev;
     Columns  = dev.Target.Width / CharWidth;
     Rows     = dev.Target.Height / CharHeight;
     SetupColors();
 }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
                }
            }
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 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));
 }
コード例 #10
0
 public override void Draw(IGraphicsAdapter pSystem)
 {
     pSystem.DrawRect(Bounds, _background);
     if (IsToggled)
     {
         pSystem.DrawRectOutline(Bounds, Border);
     }
 }
コード例 #11
0
 public override void Draw(IGraphicsAdapter pSystem)
 {
     base.Draw(pSystem);
     if (IsSelected)
     {
         pSystem.DrawRect(new Rectangle(Position, Width, Height), _highlightBrush, 3);
     }
 }
コード例 #12
0
 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);
     }
 }
コード例 #13
0
        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);
        }
コード例 #14
0
 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);
         }
     }
 }
コード例 #15
0
        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);
        }
コード例 #16
0
ファイル: Textbox.cs プロジェクト: btbaggin/SmallEngine
        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);
            }
        }
コード例 #17
0
 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();
     }
 }
コード例 #18
0
ファイル: Font.cs プロジェクト: btbaggin/SmallEngine
 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();
     }
 }
コード例 #19
0
ファイル: UIElement.cs プロジェクト: btbaggin/SmallEngine
 internal void DrawInternal(IGraphicsAdapter pSystem)
 {
     if (_disposed)
     {
         return;
     }
     Draw(pSystem);
     foreach (var e in _orderedItems)
     {
         if (e.Visible == Visibility.Visible)
         {
             e.DrawInternal(pSystem);
         }
     }
 }
コード例 #20
0
        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);
            }
        }
コード例 #21
0
ファイル: UIManager.cs プロジェクト: btbaggin/SmallEngine
        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;
        }
コード例 #22
0
        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;
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
 public override void Draw(IGraphicsAdapter pSystem)
 {
     pSystem.DrawText(Text, Bounds, Font);
 }
コード例 #25
0
 protected override void DoDraw(IGraphicsAdapter pSystem, Effect pEffect)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public RenderPipelineSystem(World world, IGraphicsAdapter graphics) : base(world)
 {
     RenderingPipeline = new ForwardRenderingPipeline(graphics);
     this.graphics     = graphics;
 }
コード例 #27
0
ファイル: OpenGLHost.cs プロジェクト: ronbrogan/OpenH2
 public OpenGLHost()
 {
     this.adapter = new OpenGLGraphicsAdapter();
 }
コード例 #28
0
ファイル: Image.cs プロジェクト: btbaggin/SmallEngine
 public override void Draw(IGraphicsAdapter pSystem)
 {
     pSystem.DrawBitmap(_bitmap, 1, Position, Bounds.Size);
 }
コード例 #29
0
 public RenderSystem(IGraphicsAdapter pAdapter) : base(typeof(RenderComponent))
 {
     _adapter = pAdapter;
 }
コード例 #30
0
 public DebugRenderSystem(IGraphicsAdapter pAdapter) : base(typeof(ColliderComponent))
 {
     _adapter   = pAdapter;
     DebugBoxes = Pen.Create(Color.Aqua, 1);
 }