Ejemplo n.º 1
0
 public ChatHandler(DesyncContext context, Character npc, DialogTree pool, PaletteType palette = PaletteType.Glass)
 {
     Context = context;
     Npc     = npc;
     Tree    = pool;
     Palette = GraphicsService.GetPalette(palette);
 }
Ejemplo n.º 2
0
        public async Task GetCardAsync(SocketUser user = null)
        {
            user ??= Context.User;
            if (!Context.Container.TryGetUser(user.Id, out User account))
            {
                await Context.Channel.ThrowAsync("The specified user does not have an existing account.");

                return;
            }

            try
            {
                using var graphics = new GraphicsService();
                var d = new CardDetails(account, user);
                var p = CardProperties.Default;

                p.Palette = PaletteType.Glass;
                p.Trim    = false;
                p.Casing  = Casing.Upper;

                Bitmap card = graphics.DrawCard(d, p);

                await Context.Channel.SendImageAsync(card, $"../tmp/{Context.User.Id}_card.png");
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Ejemplo n.º 3
0
    public void OutputBitmap(string fileName, Bitmap bmp)
    {
        GraphicsService graphicsService = new GraphicsService();

        uint[] uintArray = graphicsService.ConvertBitmapToUintArray(bmp);
        OutputUintArray(fileName, uintArray);
    }
Ejemplo n.º 4
0
        public async Task DrawMaskAsync()
        {
            using (var g = new GraphicsService())
            {
                var d = new CardDetails(Context.Account, Context.User);

                using (Bitmap card = g.DrawCard(d, PaletteType.GammaGreen))
                {
                    using (var factory = new TextFactory())
                    {
                        Grid <float> mask = ImageHelper.GetOpacityMask(card);

                        var pixels = new Grid <Color>(card.Size, new ImmutableColor(0, 0, 0, 255));

                        // TODO: Make ImmutableColor.Empty values
                        pixels.SetEachValue((x, y) =>
                                            ImmutableColor.Blend(new ImmutableColor(0, 0, 0, 255), new ImmutableColor(255, 255, 255, 255),
                                                                 mask.GetValue(x, y)));

                        using (Bitmap masked = ImageHelper.CreateRgbBitmap(pixels.Values))
                            await Context.Channel.SendImageAsync(masked, $"../tmp/{Context.User.Id}_card_mask.png");
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void _ProjectPanel_ProjectLoaded(Project project)
        {
            _project           = project;
            _projectService    = new ProjectService(new ErrorService(), project);
            _graphicsService   = new GraphicsService(_errorService, project);
            _levelService      = new LevelService(_errorService, project);
            _palettesService   = new PalettesService(_errorService, project);
            _worldService      = new WorldService(_errorService, project);
            _tileService       = new TileService(_errorService, project);
            _textService       = new TextService(_errorService, project);
            _clipBoardService  = new ClipBoardService();
            _romService        = new RomService(_errorService, _graphicsService, _palettesService, _tileService, _levelService, _worldService, _textService);
            _gameObjectService = new GameObjectService(_errorService, project);

            _levelService.LevelUpdated += _levelService_LevelUpdated;
            _worldService.WorldUpdated += _worldService_WorldUpdated;


            List <WorldInfo> worldInfos = new List <WorldInfo>();

            worldInfos.AddRange(project.WorldInfo);
            worldInfos.Add(project.EmptyWorld);

            FilePanel.Initialize(_levelService, _worldService);

            SplashText.Visibility   = Visibility.Collapsed;
            _config.LastProjectPath = _project.DirectoryPath + "\\" + _project.Name + ".json";
        }
Ejemplo n.º 6
0
        public async Task SmearAsync(PaletteType a, PaletteType b)
        {
            GammaPalette result = GammaPalette.Smear(GraphicsService.GetPalette(a), GraphicsService.GetPalette(b));

            await Context.Channel.SendImageAsync(ImageHelper.CreateGradient(result, 128, 64, AngleF.Right),
                                                 "../tmp/smear.png");
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DebugGraphicsScreen" /> class.
        /// </summary>
        /// <param name="services">The services.</param>
        public DebugGraphicsScreen(IServiceLocator services)
            : base(services?.GetInstance <IGraphicsService>())
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            Coverage      = GraphicsScreenCoverage.Partial;
            _spriteBatch  = GraphicsService.GetSpriteBatch();
            _whiteTexture = GraphicsService.GetDefaultTexture2DWhite();

            var contentManager = services.GetInstance <ContentManager>();
            var spriteFont     = contentManager.Load <SpriteFont>("DigitalRune.Editor.Game/Fonts/DejaVuSans");

            DebugRenderer          = new DebugRenderer(GraphicsService, spriteFont);
            _internalDebugRenderer = new DebugRenderer(GraphicsService, spriteFont);

            // To count the update frame rate, we handle the GameLogicUpdating event.
            // (We cannot use GraphicsScreen.OnUpdate because it is only called at the same rate if
            // the graphics screen is registered in the graphics service. If it is not registered,
            // then OnUpdate and OnRender are always called together.)
            var editor = services.GetInstance <IEditorService>();

            _gameExtension = editor.Extensions.OfType <GameExtension>().FirstOrDefault();
            if (_gameExtension != null)
            {
                _gameExtension.GameLogicUpdating += OnGameLogicUpdating;
            }
        }
Ejemplo n.º 8
0
        public CustomCommandSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Add a DelegateGraphicsScreen as the first graphics screen to the graphics
            // service. This lets us do the rendering in the Render method of this class.
            var graphicsScreen = new DelegateGraphicsScreen(GraphicsService)
            {
                RenderCallback = Render
            };

            GraphicsService.Screens.Insert(0, graphicsScreen);

            _spriteBatch = GraphicsService.GetSpriteBatch();

            // Load a few SpriteFonts for rendering.
            _textFont   = UIContentManager.Load <SpriteFont>("UI Themes/WindowsPhone7/Segoe15");
            _buttonFont = ContentManager.Load <SpriteFont>("ButtonImages/xboxControllerSpriteFont");

            // Add custom commands to input service.
            _buttonHoldCommand = new ButtonHoldCommand(Buttons.A, 1.0f)
            {
                Name = "Hold A"
            };
            _buttonTapCommand = new ButtonTapCommand(Buttons.A, 0.2f, 1.0f)
            {
                Name = "Tap A"
            };
            _buttonSequenceCommand = new ButtonSequenceCommand(new [] { Buttons.A, Buttons.B, Buttons.A, Buttons.B }, 2.0f)
            {
                Name = "A-B-A-B"
            };
            InputService.Commands.Add(_buttonHoldCommand);
            InputService.Commands.Add(_buttonTapCommand);
            InputService.Commands.Add(_buttonSequenceCommand);
        }
Ejemplo n.º 9
0
        public async Task GetCardAsync(SocketUser user = null)
        {
            user ??= Context.User;
            Context.TryGetUser(user.Id, out ArcadeUser account);

            if (await CatchEmptyAccountAsync(account))
            {
                return;
            }

            try
            {
                using var graphics = new GraphicsService();
                var d = new CardDetails(account, user);
                var p = CardProperties.Default;
                p.Font            = account.Card.Font;
                p.Palette         = account.Card.Palette.Primary;
                p.PaletteOverride = account.Card.Palette.Build();
                p.Trim            = false;
                p.Casing          = Casing.Upper;

                System.Drawing.Bitmap card = graphics.DrawCard(d, p);

                await Context.Channel.SendImageAsync(card, $"../tmp/{Context.User.Id}_card.png");
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Ejemplo n.º 10
0
        public GraphicsWindow(GraphicsService graphicsService, TileService tileService, PalettesService palettesService)
        {
            InitializeComponent();

            _graphicsService = graphicsService;
            _tileService     = tileService;
            _paletteService  = palettesService;

            _graphicsAccessor = new GraphicsAccessor(_graphicsService.GetTilesAtAddress(0));
            _graphicsRenderer = new GraphicsSetRender(_graphicsAccessor);
            _blockRenderer    = new BlockRenderer();


            Dpi dpi = this.GetDpi();

            _graphicsBitmap = new WriteableBitmap(128, 128, dpi.X, dpi.Y, PixelFormats.Bgra32, null);
            _editorBitmap   = new WriteableBitmap(16, 16, dpi.X, dpi.Y, PixelFormats.Bgra32, null);

            PatternTable.Source = _graphicsBitmap;
            EditorImage.Source  = _editorBitmap;

            LoadPalettes();
            GraphicsType.SelectedIndex = LayoutOrder.SelectedIndex = 0;

            _paletteService.PalettesChanged += _paletteService_PalettesChanged;
        }
Ejemplo n.º 11
0
        public GameObjectEditor(ProjectService projectService, PalettesService palettesService, GraphicsService graphicsService, GameObjectService gameObjectService)
        {
            InitializeComponent();

            _projectService    = projectService;
            _gameObjectService = gameObjectService;
            _graphicsService   = graphicsService;
            _palettesService   = palettesService;
            _graphicsAccessor  = new GraphicsAccessor(graphicsService.GetGlobalTiles(), graphicsService.GetExtraTiles());
            viewObjects.Add(viewObject);

            Dpi dpi = this.GetDpi();

            _bitmap              = new WriteableBitmap(256, 256, dpi.X, dpi.Y, PixelFormats.Bgra32, null);
            _renderer            = new GameObjectRenderer(_gameObjectService, _palettesService, _graphicsAccessor);
            _renderer.RenderGrid = true;

            GameObjectRenderer.Source = _bitmap;

            List <Palette> palettes = _palettesService.GetPalettes();

            ObjectSelector.Initialize(_gameObjectService, _palettesService, _graphicsAccessor, palettes[0]);

            PaletteSelector.ItemsSource   = palettes;
            PaletteSelector.SelectedIndex = 0;

            _graphicsService.GraphicsUpdated      += _graphicsService_GraphicsUpdated;
            _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated;
        }
Ejemplo n.º 12
0
 public ShopHandler(DesyncContext context, Market market, PaletteType palette)
 {
     Context = context;
     Market  = market;
     Vendor  = market.GetActive();
     Palette = GraphicsService.GetPalette(palette);
 }
Ejemplo n.º 13
0
 /// <inheritdoc />
 protected override void Dispose(bool isDisposing)
 {
     if (isDisposing)
     {
         _graphicsService.Dispose();
         _graphicsService = null !;
     }
 }
Ejemplo n.º 14
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsService graphics = services.Get <GraphicsService>(ServicesDefinition.Graphics);

            graphics.BeginDraw();
            gameplays.DrawSprites(gameTime, graphics.SpriteBatch);
            graphics.EndDraw();
            base.Draw(gameTime);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// runs on engine start
 /// </summary>
 public override void Init()
 {
     _graphicsService      = new GraphicsService();
     _commandBufferService = new CommandBufferService(_graphicsService.PrimaryDevice);
     _descriptorLayouts    = new Dictionary <string, DescriptorLayout>();
     _renderPasses         = new Dictionary <string, RenderPass>();
     InitDescriptorLayouts();
     InitRenderPasses();
 }
Ejemplo n.º 16
0
 public GraphForm(ParamsModel3D paramsModel3D, DigitalVoltmeterForm parrent)
 {
     InitializeComponent();
     this.parrent    = parrent;
     k               = parrent.K;
     GraphicsService = new GraphicsService();
     ParamsModel     = paramsModel3D;
     InitializeDataGrid();
     trackBarZoom.Value = (int)(level * 1000);
     RefreshGraph();
 }
Ejemplo n.º 17
0
        public void DrawHealth()
        {
            PositionComponent pos = GetComponent <PositionComponent>();
            var       rect        = pos.GetRectangle();
            Character obj         = (Character)GameObject;
            var       health_rect = new Rectangle(rect.Left, rect.Bottom + 5, rect.Width, 5);

            GraphicsService.DrawGame(GameContent.Instance.whitePixel, health_rect, Color.Gray, rotation: pos.WorldPosition.RotationAngle, clamped_origin: Vector2.Zero);
            health_rect.Width = (int)(health_rect.Width * (obj.CurrentHitPoints / obj.MaxHitPoints));
            GraphicsService.DrawGame(GameContent.Instance.whitePixel, health_rect, Color.Red, rotation: pos.WorldPosition.RotationAngle, clamped_origin: Vector2.Zero);
        }
Ejemplo n.º 18
0
        public virtual void DrawStorage()
        {
            var spriteBatch = GraphicsService.Instance;

            spriteBatch.Begin();
            if (MouseStorage != null)
            {
                var mouse_pos = Mouse.GetState().Position;
                GraphicsService.DrawScreen(((RenderComponent)MouseStorage).Texture, new Rectangle(mouse_pos, new Point(60, 60)), Color.White, 0, Vector2.Zero);
            }
            spriteBatch.End();
        }
Ejemplo n.º 19
0
        private void TransformTo2DAndDrawPoints(Graphics g, Pen pen, List <Point3D> points, double size)
        {
            List <Point3D> pointsFor2D = new List <Point3D>();

            for (int i = 0; i < points.Count; i++)
            {
                pointsFor2D.Add(new Point3D((int)((points[i].X * l1() + points[i].Y * l2() + (points[i].Z * l3())) / (size * 0.001)) + movePosition.X,
                                            (int)((points[i].X * m1() + points[i].Y * m2() + (points[i].Z * m3())) / (size * 0.001)) + movePosition.Y,
                                            (int)((points[i].X * n1() + points[i].Y * n2() + (points[i].Z * n3())) / (size * 0.001))));
            }
            GraphicsService.DrawSurface(g, pen, pointsFor2D);
        }
        public override void DrawToLightMask()
        {
            //var projectile = projectiles[i];
            var pos = GetComponent <PositionComponent>();
            // var mask_halfsize = new Vector2(100, 100);
            var mask_halfsize = pos.WorldPosition.halfsize + new Vector2(Radius);
            var rect          = new Rectangle((pos.WorldPosition.Center - mask_halfsize).ToPoint(), (mask_halfsize * 2).ToPoint());
            // spriteBatch.Draw(lightMask, GameToScreen(rect), GetLightColor());
            var lightMask = GameContent.Instance.lightMask;

            // TODO: find a better way to apply glow to stuff
            GraphicsService.DrawGameCentered(lightMask, rect, Scene.RenderSystem.GetLightColor(GlowColor));
        }
Ejemplo n.º 21
0
        public async Task DrawCardMaskAsync()
        {
            using var g = new GraphicsService();
            var d = new CardDetails(Context.Account, Context.User);

            using (Bitmap card = g.DrawCard(d, PaletteType.GammaGreen))
            {
                Grid <float> mask = ImageHelper.GetOpacityMask(card);

                using (Bitmap gradient = ImageHelper.CreateGradient(GammaPalette.GammaGreen, card.Width, card.Height, 0.0f))
                    using (Bitmap result = ImageHelper.SetOpacityMask(gradient, mask))
                        await Context.Channel.SendImageAsync(result, $"../tmp/{Context.User.Id}_gradient_card_mask.png");
            }
        }
Ejemplo n.º 22
0
        public async Task DrawBorderAsync(int width = 32, int height = 32, int thickness = 2, PaletteType palette = PaletteType.GammaGreen, Gamma background = Gamma.StandardDim, Gamma border = Gamma.Max, BorderEdge edge = BorderEdge.Outside, BorderAllow allow = BorderAllow.All)
        {
            /*
             * var width = Context.GetOptionOrDefault("width", 32);
             * var height = Context.GetOptionOrDefault("height", 32);
             * var thickness = Context.GetOptionOrDefault("thickness", 2);
             * var color = Context.GetOptionOrDefault("color", ImmutableColor.GammaGreen);
             * var edge = Context.GetOptionOrDefault("edge", BorderEdge.Outside);
             * var allow = Context.GetOptionOrDefault("allow", BorderAllow.All);
             */

            using (var tmp = ImageHelper.CreateSolid(GraphicsService.GetPalette(palette)[background], width, height))
                using (Bitmap b = ImageHelper.SetBorder(tmp, GraphicsService.GetPalette(palette)[border], thickness, edge, allow))
                    await Context.Channel.SendImageAsync(b, "../tmp/border.png");
        }
Ejemplo n.º 23
0
        private void EndBillboards(RenderContext context)
        {
            if (!_billboardMode)
            {
                return;
            }

            _billboardMode = false;

            // Reset texture to prevent "memory leak".
            SetTexture(null);

#if !WP7
            if (EnableOffscreenRendering)
            {
                // ----- Combine off-screen buffer with scene.
                if (_upsampleFilter == null)
                {
                    _upsampleFilter = GraphicsService.GetUpsampleFilter();
                }

                var graphicsDevice = GraphicsService.GraphicsDevice;
                graphicsDevice.BlendState = BlendState.Opaque;

                // The previous scene render target is bound as texture.
                // --> Switch scene render targets!
                var sceneTexture     = context.RenderTarget;
                var renderTargetPool = GraphicsService.RenderTargetPool;
                var renderTarget     = renderTargetPool.Obtain2D(new RenderTargetFormat(sceneTexture));
                context.SourceTexture = _offscreenBuffer;
                context.SceneTexture  = sceneTexture;
                context.RenderTarget  = renderTarget;

                _upsampleFilter.Mode           = UpsamplingMode;
                _upsampleFilter.DepthThreshold = DepthThreshold;
                _upsampleFilter.RebuildZBuffer = true;

                _upsampleFilter.Process(context);

                context.SourceTexture = null;
                context.SceneTexture  = null;
                renderTargetPool.Recycle(_offscreenBuffer);
                renderTargetPool.Recycle(sceneTexture);
                _depthBufferHalf = null;
                _offscreenBuffer = null;
            }
#endif
        }
Ejemplo n.º 24
0
        public async Task GetCardAsync(bool trim, CardDeny deny, BorderAllow border,
                                       Casing casing, FontType font, PaletteType palette, Gamma usernameGamma = Gamma.Max,
                                       Gamma activityGamma = Gamma.Max, Gamma borderGamma = Gamma.Max, ImageScale scale = ImageScale.Medium, int padding = 2)
        {
            SocketUser user = Context.User;

            if (!Context.Container.TryGetUser(user.Id, out User account))
            {
                await Context.Channel.ThrowAsync("The specified user does not have an existing account.");

                return;
            }

            try
            {
                using var graphics = new GraphicsService();
                var d = new CardDetails(account, user);

                var p = new CardProperties
                {
                    Trim    = trim,
                    Deny    = deny,
                    Border  = border,
                    Casing  = casing,
                    Font    = font,
                    Palette = palette,
                    Gamma   = new Dictionary <CardComponentType, Gamma?>
                    {
                        [CardComponentType.Username]   = usernameGamma,
                        [CardComponentType.Activity]   = activityGamma,
                        [CardComponentType.Border]     = borderGamma,
                        [CardComponentType.Background] = null,
                        [CardComponentType.Avatar]     = Gamma.Max
                    },
                    Padding = new Padding(padding),
                    Scale   = scale
                };

                Bitmap card = graphics.DrawCard(d, p);

                Logger.Debug("Drawing card...");
                await Context.Channel.SendImageAsync(card, $"../tmp/{Context.User.Id}_card.png");
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Ejemplo n.º 25
0
    public void Tick(World model)
    {
        IMDraw.Axis3D(Vector3.zero, Quaternion.identity, 1000f, 0.2f);
        IMDraw.Grid3D(Vector3.zero, Quaternion.identity, 5f, 5f, 10, 10, new Color(1f, 1f, 1f, 0.5f));

        foreach (var p in model.points.Values)
        {
            if (model.debugSettings.isShowingNodes)
            {
                GraphicsService.DrawCube(p.pos.Vector3(), Vector3.one * 0.25f, Config.Colors.Blue);
                GraphicsService.DrawLabel(p.pos.Vector3(), Config.Colors.White, p.id.ToString() + "\n" + p.pos.ToString());
            }

            float y = 0f;
            foreach (var c in p.colors)
            {
                y += 0.2f;
                GraphicsService.DrawCube(
                    p.pos.Vector3() + new Vector3(0.2f, 0f, y - 0.2f),
                    Vector3.one * 0.1f,
                    ColorService.GetUnityColor(c)
                    );
            }
        }

        foreach (var c in model.connections.Values)
        {
            Point fromPoint = PointService.GetPointWithId(model, c.fromPointId);
            Point toPoint   = PointService.GetPointWithId(model, c.toPointId);
            var   color     = ColorService.GetUnityColor(c.color);
            color.a = 0.75f;
            GraphicsService.DrawLine3D(fromPoint.pos.Vector3(), toPoint.pos.Vector3(), 0.1f, color);

            if (model.debugSettings.isShowingConnectionInfo)
            {
                GraphicsService.DrawLabel(
                    Vector.Lerp(fromPoint.pos, toPoint.pos, 0.5f).Vector3(),
                    Config.Colors.White,
                    c.id.ToString()
                    );
            }
        }

        Color trainColor = ColorService.GetUnityColor(model.train.nextColor);

        GraphicsService.DrawCube(model.train.pos.Vector3(), Vector3.one * 0.5f, trainColor);
        GraphicsService.DrawLabel(model.train.pos.Vector3(), trainColor, "TRAIN" + "\n" + model.train.toGridPos);
    }
Ejemplo n.º 26
0
        public async Task GetTimeAsync()
        {
            try
            {
                string       path    = $"../tmp/{Context.User.Id}_time.png";
                GammaPalette palette = TimeCycle.FromUtcNow();

                using var graphics = new GraphicsService();
                Bitmap bmp = graphics.DrawText(DateTime.UtcNow.ToString("hh:mm tt").ToUpper(), Gamma.Max, palette);
                await Context.Channel.SendImageAsync(bmp, path);
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Ejemplo n.º 27
0
        public TileBlockEditor(ProjectService projectService, WorldService worldService, LevelService levelService, GraphicsService graphicsService, PalettesService palettesService, TileService tileService, TextService textService)
        {
            _ignoreChanges = true;
            InitializeComponent();

            _projectService  = projectService;
            _palettesService = palettesService;
            _graphicsService = graphicsService;
            _worldService    = worldService;
            _levelService    = levelService;
            _tileService     = tileService;
            _textService     = textService;

            List <KeyValuePair <string, string> > tileSetText = _textService.GetTable("tile_sets");

            tileSetText.Insert(0, new KeyValuePair <string, string>("0", "Map"));

            TerrainList.ItemsSource        = _localTileTerrain = _tileService.GetTerrainCopy();
            LevelList.ItemsSource          = _levelService.AllWorldsLevels();
            MapInteractionList.ItemsSource = _localMapTileInteraction = _tileService.GetMapTileInteractionCopy();

            _graphicsAccessor = new GraphicsAccessor(_graphicsService.GetTileSection(0), _graphicsService.GetTileSection(0), _graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles());

            _graphicsSetRenderer = new GraphicsSetRender(_graphicsAccessor);
            _tileSetRenderer     = new TileSetRenderer(_graphicsAccessor, _localTileTerrain, _localMapTileInteraction);

            Dpi dpi = this.GetDpi();

            _graphicsSetBitmap = new WriteableBitmap(128, 128, dpi.X, dpi.Y, PixelFormats.Bgra32, null);
            _tileBlockBitmap   = new WriteableBitmap(16, 16, dpi.X, dpi.Y, PixelFormats.Bgra32, null);

            GraphicsSetImage.Source = _graphicsSetBitmap;

            TileBlockImage.Source = _tileBlockBitmap;

            BlockSelector.Initialize(_graphicsAccessor, _tileService, _tileService.GetTileSet(0), _graphicsService.GetPalette(0), _tileSetRenderer);
            BlockSelector.TileBlockSelected += BlockSelector_TileBlockSelected;

            LevelList.SelectedIndex          = 1;
            BlockSelector.SelectedBlockValue = 0;
            _ignoreChanges = false;

            _graphicsService.GraphicsUpdated      += _graphicsService_GraphicsUpdated;
            _graphicsService.ExtraGraphicsUpdated += _graphicsService_GraphicsUpdated;
        }
Ejemplo n.º 28
0
    internal GraphicsAdapter(GraphicsService service, IDXGIAdapter1 *dxgiAdapter) : base(service)
    {
        dxgiAdapter = GetLatestDxgiAdapter(dxgiAdapter, out _dxgiAdapterVersion);
        _dxgiAdapter.Attach(dxgiAdapter);

        DXGI_ADAPTER_DESC1 dxgiAdapterDesc;

        ThrowExternalExceptionIfFailed(dxgiAdapter->GetDesc1(&dxgiAdapterDesc));

        _description = GetUtf16Span(dxgiAdapterDesc.Description, 128).GetString() ?? string.Empty;
        _pciDeviceId = dxgiAdapterDesc.DeviceId;
        _pciVendorId = dxgiAdapterDesc.VendorId;

        SetName(_description);

        _devices      = new ValueList <GraphicsDevice>();
        _devicesMutex = new ValueMutex();
    }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            var logger = LoggerFactory.GetLogger();

            logger.Information("===== Запуск =====");

            using (IGraphicsService graphicsService = new GraphicsService(logger))
            {
                if (graphicsService.TryInitialize())
                {
                    var blockMoveEngine = new GameEntityUpdateEngine();
                    var gameEngine      = new GameEngine(graphicsService, blockMoveEngine, logger);

                    gameEngine.CreateNew();

                    try
                    {
                        var quit = false;

                        while (!quit)
                        {
                            while (SDL2.SDL.SDL_PollEvent(out SDL2.SDL.SDL_Event sdlEvent) != 0)
                            {
                                if (sdlEvent.type == SDL2.SDL.SDL_EventType.SDL_QUIT)
                                {
                                    quit = true;
                                    break;
                                }
                            }

                            gameEngine.Update();
                        }
                    }
                    finally
                    {
                        blockMoveEngine = null;
                    }
                }
            }

            logger.Information("===== Останов =====");
        }
Ejemplo n.º 30
0
        protected AnimationSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Add a DelegateGraphicsScreen and use the OnRender method of this class to
            // do the rendering.
            var graphicsScreen = new DelegateGraphicsScreen(GraphicsService)
            {
                RenderCallback = OnRender,
            };

            // The order of the graphics screens is back-to-front. Add the screen at index 0,
            // i.e. behind all other screens. The screen should be rendered first and all other
            // screens (menu, GUI, help, ...) should be on top.
            GraphicsService.Screens.Insert(0, graphicsScreen);

            // Provide a SpriteBatch, SpriteFont and images for rendering.
            SpriteBatch = GraphicsService.GetSpriteBatch();
            SpriteFont  = UIContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Default");
            Logo        = ContentManager.Load <Texture2D>("Logo");
            Reticle     = ContentManager.Load <Texture2D>("Reticle");
        }